summaryrefslogtreecommitdiff
path: root/_posts/2015-03-09-edit-task-object-while-task-is-running.md
blob: b176b822f8eb4ecb9f3ecf3f13c73022aa94b6e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
layout: post
title: "Edit Task object while Task is running"
description: "HowTo edit a Task object inside a Task block."
category: Usage
tags: [Metadata, Object, RDF, Tutorials]
---
{% include JB/setup %}
**This post explains how to edit a Task object with percentageCompleted value.**

_Example:_

```ruby    
    # generate a Task uri
    task_uri = OpenTox::Task.task_uri
    
    # pass 'task_uri' to become new Task uri
    task = OpenTox::Task.run("Message", "Creator", task_uri) do |t|
      
      # get Task object and fill with metadata
      t = OpenTox::Task.find task_uri
      t.metadata
      
      run partial code
      
      # edit progress
      t[RDF::OT.percentageCompleted] = "25"
      t.put
      
      run partial code

      # edit progress
      t[RDF::OT.percentageCompleted] = "50"
      t.put

      run partial code
      "Result URI"
    end
    # wait to complete
    task.wait
```

**If task status is completed task.percentageCompleted == 100%**