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
-
.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
Class Method Details
.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 28 29 |
# 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 raise Camunda::ProcessEngineException, response[:parsed_data][:data][:message] unless response[:response].status == 200 Camunda::ProcessInstance.new response[:parsed_data][:data] 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.
49 50 51 52 53 |
# File 'lib/camunda/process_definition.rb', line 49 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
40 41 42 43 44 45 46 |
# File 'lib/camunda/process_definition.rb', line 40 def start(hash={}) hash[:variables] = serialize_variables(hash[:variables]) if hash[:variables] response = self.class.post_raw "process-definition/#{id}/start", hash raise Camunda::ProcessEngineException, response[:parsed_data][:data][:message] unless response[:response].status == 200 Camunda::ProcessInstance.new response[:parsed_data][:data] end |