Class: Camunda::ProcessDefinition
- Includes:
- VariableSerialization
- Defined in:
- lib/camunda/process_definition.rb
Overview
A process definition defines the structure of a process. The ‘key` of a process definition is the logical identifier of the process. It is used throughout the API, most prominently for starting a process instances. The key of a process definition is defined using the `id` property of the corresponding process element in the BPMN XML file.
Class Method Summary collapse
- .process_instance_result(response) ⇒ Object
-
.start_by_key(key, hash = {}) ⇒ Camunda::ProcessInstance
Starts an individual process instance by key and supplies process variables to be included in the process instance.
-
.start_path_for_key(key, tenant_id) ⇒ Object
Sets path to include tenant_id if a tenant_id is provided with a process definition on deployment.
Instance Method Summary collapse
-
#start(hash = {}) ⇒ Camunda::ProcessInstance
Starts an individual process instance for a process definition.
Methods included from VariableSerialization
Methods inherited from Model
find_by!, log_details?, worker_id
Class Method Details
.process_instance_result(response) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/camunda/process_definition.rb', line 51 def self.process_instance_result(response) unless response[:response].status == 200 raise Camunda::ProcessEngineException, "#{response[:parsed_data][:data][:message]} HTTP Status: #{response[:response].status}" end Camunda::ProcessInstance.new response[:parsed_data][:data] end |
.start_by_key(key, hash = {}) ⇒ Camunda::ProcessInstance
Starts an individual process instance by key and supplies process variables to be included in the process instance. In the example below a business key is provided. A business key is a domain-specific identifier of a process instance, it makes querying for task more efficient. The business key is displayed prominently in applications like Camunda Cockpit.
20 21 22 23 24 25 26 27 |
# File 'lib/camunda/process_definition.rb', line 20 def self.start_by_key(key, hash={}) hash[:variables] = serialize_variables(hash[:variables]) if hash[:variables] tenant_id = hash.delete(:tenant_id) tenant_id ||= Camunda::Workflow.configuration.tenant_id response = post_raw start_path_for_key(key, tenant_id), hash process_instance_result(response) end |
.start_path_for_key(key, tenant_id) ⇒ Object
Sets path to include tenant_id if a tenant_id is provided with a process definition on deployment.
45 46 47 48 49 |
# File 'lib/camunda/process_definition.rb', line 45 def self.start_path_for_key(key, tenant_id) path = "process-definition/key/#{key}" path << "/tenant-id/#{tenant_id}" if tenant_id "#{path}/start" end |
Instance Method Details
#start(hash = {}) ⇒ Camunda::ProcessInstance
Starts an individual process instance for a process definition. The below example shows how to start a process definition after deployment. Starts the process instance by sending a request to the Camunda engine
38 39 40 41 42 |
# File 'lib/camunda/process_definition.rb', line 38 def start(hash={}) hash[:variables] = serialize_variables(hash[:variables]) if hash[:variables] response = self.class.post_raw "process-definition/#{id}/start", hash self.class.process_instance_result(response) end |