Module: BpmManager::RedHat
- Defined in:
- lib/bpm_manager/red_hat.rb
Class Method Summary collapse
-
.assign_task(task_id, user_id) ⇒ Object
Assigns a Task for an User.
-
.clear_all_history ⇒ Object
Clears all the History –WARNING: Destructive action!–.
-
.complete_task(task_id, opts = {}) ⇒ Object
Completes a Task.
-
.complete_task_as_admin(task_id, opts = {}) ⇒ Object
Completes a Task as Administrator.
-
.create_process(deployment_id, process_definition_id, opts = {}) ⇒ Object
Creates a new Process.
-
.deployments ⇒ Object
Gets all server deployments.
-
.exit_task(task_id) ⇒ Object
Exits a Task.
-
.fail_task(task_id) ⇒ Object
Fails a Task.
-
.get_history(process_definition_id = "") ⇒ Object
Gets the Process History.
-
.get_task_sla(task_instance_id, process_sla_hours = 0, task_sla_hours = 0, warning_offset_percent = 20) ⇒ Object
Gets the SLA for a Process Instance.
-
.process_instance(process_instance_id) ⇒ Object
Gets a Process Instance.
-
.process_instance_variables(process_instance_id) ⇒ Object
Gets a Process Instance Variables.
-
.process_instances ⇒ Object
Gets all Process Instances.
-
.release_task(task_id) ⇒ Object
Releases a Task.
-
.resume_task(task_id) ⇒ Object
Resumes a Task.
-
.skip_task(task_id) ⇒ Object
Skips a Task.
-
.start_task(task_id) ⇒ Object
Starts a Task.
-
.stop_task(task_id) ⇒ Object
Stops a Task.
-
.suspend_task(task_id) ⇒ Object
Suspends a Task.
-
.task_query(task_id) ⇒ Object
Gets all the information for a Task ID.
-
.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
50 51 52 |
# File 'lib/bpm_manager/red_hat.rb', line 50 def self.assign_task(task_id, user_id) BpmManager.server['/task/' + task_id.to_s + '/delegate'].post(:targetEntityId => user_id.to_s) end |
.clear_all_history ⇒ Object
Clears all the History –WARNING: Destructive action!–
121 122 123 |
# File 'lib/bpm_manager/red_hat.rb', line 121 def self.clear_all_history() BpmManager.server['/history/clear'].post({}) end |
.complete_task(task_id, opts = {}) ⇒ Object
Completes a Task
90 91 92 |
# File 'lib/bpm_manager/red_hat.rb', line 90 def self.complete_task(task_id, opts = {}) BpmManager.server['/task/' + task_id.to_s + '/complete'].post(opts) end |
.complete_task_as_admin(task_id, opts = {}) ⇒ Object
Completes a Task as Administrator
95 96 97 98 99 |
# File 'lib/bpm_manager/red_hat.rb', line 95 def self.complete_task_as_admin(task_id, opts = {}) self.release_task(task_id) self.start_task(task_id) BpmManager.server['/task/' + task_id.to_s + '/complete'].post(opts) end |
.create_process(deployment_id, process_definition_id, opts = {}) ⇒ Object
Creates a new Process
13 14 15 |
# File 'lib/bpm_manager/red_hat.rb', line 13 def self.create_process(deployment_id, process_definition_id, opts = {}) BpmManager.server['/runtime/' + deployment_id.to_s + '/process/' + process_definition_id.to_s + '/start'].post(opts) end |
.deployments ⇒ Object
Gets all server deployments
8 9 10 |
# File 'lib/bpm_manager/red_hat.rb', line 8 def self.deployments() return JSON.parse(BpmManager.server['/deployment'].get) end |
.exit_task(task_id) ⇒ Object
Exits a Task
107 108 109 |
# File 'lib/bpm_manager/red_hat.rb', line 107 def self.exit_task(task_id) BpmManager.server['/task/' + task_id.to_s + '/exit'].post({}) end |
.fail_task(task_id) ⇒ Object
Fails a Task
102 103 104 |
# File 'lib/bpm_manager/red_hat.rb', line 102 def self.fail_task(task_id) BpmManager.server['/task/' + task_id.to_s + '/fail'].post({}) end |
.get_history(process_definition_id = "") ⇒ Object
Gets the Process History
112 113 114 115 116 117 118 |
# File 'lib/bpm_manager/red_hat.rb', line 112 def self.get_history(process_definition_id = "") if process_definition_id.empty? JSON.parse(BpmManager.server['/history/instances'].get) else JSON.parse(BpmManager.server['/history/process/' + process_definition_id.to_s].get) end end |
.get_task_sla(task_instance_id, process_sla_hours = 0, task_sla_hours = 0, warning_offset_percent = 20) ⇒ Object
Gets the SLA for a Process Instance
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/bpm_manager/red_hat.rb', line 126 def self.get_task_sla(task_instance_id, process_sla_hours = 0, task_sla_hours = 0, warning_offset_percent = 20) my_task = self.tasks_with_opts('taskId' => task_instance_id).first unless my_task.nil? sla = OpenStruct.new(:task => OpenStruct.new, :process => OpenStruct.new) # Calculates the process sla sla.process.status = calculate_sla(my_task.process.start_on, process_sla_hours, warning_offset_percent) sla.process.status_name = (calculate_sla(my_task.process.start_on, process_sla_hours, warning_offset_percent) == 0) ? 'ok' : (calculate_sla(my_task.process.start_on, process_sla_hours, warning_offset_percent) == 1 ? 'warning' : 'due') sla.process.percentages = calculate_sla_percent(my_task.process.start_on, process_sla_hours, warning_offset_percent) # Calculates the task sla sla.task.status = calculate_sla(my_task.created_on, task_sla_hours, warning_offset_percent) sla.task.status_name = (calculate_sla(my_task.created_on, task_sla_hours, warning_offset_percent) == 0) ? 'ok' : (calculate_sla(my_task.created_on, task_sla_hours, warning_offset_percent) == 1 ? 'warning' : 'due') sla.task.percentages = calculate_sla_percent(my_task.created_on, task_sla_hours, warning_offset_percent) else sla = nil end return sla end |
.process_instance(process_instance_id) ⇒ Object
Gets a Process Instance
23 24 25 |
# File 'lib/bpm_manager/red_hat.rb', line 23 def self.process_instance(process_instance_id) JSON.parse(BpmManager.server['/history/instance/' + process_instance_id.to_s].get) end |
.process_instance_variables(process_instance_id) ⇒ Object
Gets a Process Instance Variables
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bpm_manager/red_hat.rb', line 28 def self.process_instance_variables(process_instance_id) begin result = Hash.new JSON.parse(BpmManager.server['/history/instance/' + process_instance_id.to_s + '/variable'].get)['historyLogList'].each{|e| result[e.first.second['variable-id']] = e.first.second['value']} return result rescue return {} # same result as not found record in jbpm end end |
.process_instances ⇒ Object
Gets all Process Instances
18 19 20 |
# File 'lib/bpm_manager/red_hat.rb', line 18 def self.process_instances JSON.parse(BpmManager.server['/history/instances'].get) end |
.release_task(task_id) ⇒ Object
Releases a Task
65 66 67 |
# File 'lib/bpm_manager/red_hat.rb', line 65 def self.release_task(task_id) BpmManager.server['/task/' + task_id.to_s + '/release'].post({}) end |
.resume_task(task_id) ⇒ Object
Resumes a Task
80 81 82 |
# File 'lib/bpm_manager/red_hat.rb', line 80 def self.resume_task(task_id) BpmManager.server['/task/' + task_id.to_s + '/resumes'].post({}) end |
.skip_task(task_id) ⇒ Object
Skips a Task
85 86 87 |
# File 'lib/bpm_manager/red_hat.rb', line 85 def self.skip_task(task_id) BpmManager.server['/task/' + task_id.to_s + '/skip'].post({}) end |
.start_task(task_id) ⇒ Object
Starts a Task
60 61 62 |
# File 'lib/bpm_manager/red_hat.rb', line 60 def self.start_task(task_id) BpmManager.server['/task/' + task_id.to_s + '/start'].post({}) end |
.stop_task(task_id) ⇒ Object
Stops a Task
70 71 72 |
# File 'lib/bpm_manager/red_hat.rb', line 70 def self.stop_task(task_id) BpmManager.server['/task/' + task_id.to_s + '/stop'].post({}) end |
.suspend_task(task_id) ⇒ Object
Suspends a Task
75 76 77 |
# File 'lib/bpm_manager/red_hat.rb', line 75 def self.suspend_task(task_id) BpmManager.server['/task/' + task_id.to_s + '/suspend'].post({}) end |
.task_query(task_id) ⇒ Object
Gets all the information for a Task ID
55 56 57 |
# File 'lib/bpm_manager/red_hat.rb', line 55 def self.task_query(task_id) JSON.parse(BpmManager.server['/task/' + task_id.to_s].get) end |
.tasks(user_id = '') ⇒ Object
Gets all tasks, optionally you could specify an user id
40 41 42 |
# File 'lib/bpm_manager/red_hat.rb', line 40 def self.tasks(user_id = '') self.structure_task_data(JSON.parse(BpmManager.server['/task/query?taskOwner=' + user_id].get)) end |
.tasks_with_opts(opts = {}) ⇒ Object
Gets all tasks with options
45 46 47 |
# File 'lib/bpm_manager/red_hat.rb', line 45 def self.tasks_with_opts(opts = {}) self.structure_task_data(JSON.parse(BpmManager.server['/task/query' + (opts.empty? ? '' : '?' + opts.map{|k,v| k.to_s + '=' + v.to_s}.join('&'))].get)) end |