Module: BpmManager::Oracle
- Defined in:
- lib/bpm_manager/oracle.rb
Class Method Summary collapse
-
.assign_task(task_id, user_id) ⇒ Object
Assigns a Task for an User.
-
.fail_task(task_id) ⇒ Object
Fails a Task.
-
.process_instance(process_instance_id) ⇒ Object
Gets a Process Instance.
-
.process_instances ⇒ Object
Gets all Process Instances.
-
.release_task(task_id) ⇒ Object
Releases a Task.
-
.resume_task(task_id) ⇒ Object
Resumes a Task.
- .structure_task_data(input) ⇒ Object
-
.suspend_task(task_id) ⇒ Object
Suspends a Task.
-
.tasks(user_id = "") ⇒ Object
Gets all tasks, optionally you could specify an user id.
-
.tasks_with_opts(opts = {}) ⇒ Object
Gets all tasks with options.
Class Method Details
.assign_task(task_id, user_id) ⇒ Object
Assigns a Task for an User
28 29 30 |
# File 'lib/bpm_manager/oracle.rb', line 28 def self.assign_task(task_id, user_id) RestClient.post(URI.encode(BpmManager.uri('/task/assign/' + task_id.to_s + '/' + user_id.to_s)), :headers => {:content_type => :json, :accept => :json}) end |
.fail_task(task_id) ⇒ Object
Fails a Task
68 69 70 |
# File 'lib/bpm_manager/oracle.rb', line 68 def self.fail_task(task_id) RestClient.post(URI.encode(BpmManager.uri('/task/action/' + task_id.to_s + '/SYS_ERROR')), :headers => {:content_type => :json, :accept => :json}) end |
.process_instance(process_instance_id) ⇒ Object
Gets a Process Instance
23 24 25 |
# File 'lib/bpm_manager/oracle.rb', line 23 def self.process_instance(process_instance_id) JSON.parse(RestClient.get(BpmManager.uri('/process/' + process_instance_id.to_s), :accept => :json)) end |
.process_instances ⇒ Object
Gets all Process Instances
18 19 20 |
# File 'lib/bpm_manager/oracle.rb', line 18 def self.process_instances JSON.parse(RestClient.get(BpmManager.uri('/processes'), :accept => :json)) end |
.release_task(task_id) ⇒ Object
Releases a Task
33 34 35 |
# File 'lib/bpm_manager/oracle.rb', line 33 def self.release_task(task_id) RestClient.post(URI.encode(BpmManager.uri('/task/release/' + task_id.to_s)), :headers => {:content_type => :json, :accept => :json}) end |
.resume_task(task_id) ⇒ Object
Resumes a Task
53 54 55 |
# File 'lib/bpm_manager/oracle.rb', line 53 def self.resume_task(task_id) RestClient.post(URI.encode(BpmManager.uri('/task/action' + task_id.to_s + '/SYS_RESUME')), :headers => {:content_type => :json, :accept => :json}) end |
.structure_task_data(input) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/bpm_manager/oracle.rb', line 78 def self.structure_task_data(input) tasks = [] unless input.nil? input.each do |task| my_task = OpenStruct.new my_task.process = OpenStruct.new process_info = (task['processInfo'].nil? || task['processInfo'].empty?) ? '' : JSON.parse(task['processInfo']).first my_task.id = task['number'] my_task.process_instance_id = task['processInstanceId'] my_task.parent_id = '' my_task.created_on = Time.parse(task['created_on']) my_task.active_on = Time.parse(task['created_on']) my_task.name = task['title'] my_task.owner = task['assigned'] my_task.status = task['status'] my_task.subject = '' my_task.description = '' my_task.data = '' my_task.process.data = process_info my_task.process.deployment_id = '' my_task.process.id = (process_info.nil? || process_info.empty?) ? '' : process_info['processId'] my_task.process.instance_id = task['processInstanceId'] my_task.process.start_on = Time.parse(task['created_on']) my_task.process.name = task['processName'] my_task.process.version = (process_info.nil? || process_info.empty?) ? '' : process_info['revision'] my_task.process.creator = 'Not defined' my_task.process.variables = nil # self.process_instance_variables(my_task.process.deployment_id, my_task.process.instance_id) tasks << my_task end end return tasks end |
.suspend_task(task_id) ⇒ Object
Suspends a Task
48 49 50 |
# File 'lib/bpm_manager/oracle.rb', line 48 def self.suspend_task(task_id) RestClient.post(URI.encode(BpmManager.uri('/task/action/' + task_id.to_s + '/SYS_SUSPEND')), :headers => {:content_type => :json, :accept => :json}) end |
.tasks(user_id = "") ⇒ Object
Gets all tasks, optionally you could specify an user id
8 9 10 |
# File 'lib/bpm_manager/oracle.rb', line 8 def self.tasks(user_id = "") self.structure_task_data(JSON.parse(RestClient.get(BpmManager.uri('/tasks' + (user_id.empty? ? '' : '/' + user_id)), :accept => :json))) end |
.tasks_with_opts(opts = {}) ⇒ Object
Gets all tasks with options
13 14 15 |
# File 'lib/bpm_manager/oracle.rb', line 13 def self.tasks_with_opts(opts = {}) self.structure_task_data(JSON.parse(RestClient.get(BpmManager.uri('/tasks' + (opts.empty? ? '' : '?' + opts.map{|k,v| k.to_s + '=' + v.to_s}.join('&'))), :accept => :json))) end |