flowable 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +83 -0
- data/LICENSE +21 -0
- data/README.md +872 -0
- data/bin/flowable +510 -0
- data/lib/flowable/flowable.rb +273 -0
- data/lib/flowable/resources/base.rb +44 -0
- data/lib/flowable/resources/bpmn_deployments.rb +90 -0
- data/lib/flowable/resources/bpmn_history.rb +228 -0
- data/lib/flowable/resources/case_definitions.rb +115 -0
- data/lib/flowable/resources/case_instances.rb +188 -0
- data/lib/flowable/resources/deployments.rb +87 -0
- data/lib/flowable/resources/executions.rb +134 -0
- data/lib/flowable/resources/history.rb +264 -0
- data/lib/flowable/resources/plan_item_instances.rb +131 -0
- data/lib/flowable/resources/process_definitions.rb +142 -0
- data/lib/flowable/resources/process_instances.rb +200 -0
- data/lib/flowable/resources/tasks.rb +281 -0
- data/lib/flowable/version.rb +37 -0
- data/lib/flowable/workflow.rb +444 -0
- data/lib/flowable.rb +9 -0
- data/lib/flowable_client/resources/bpmn_history.rb +228 -0
- data/lib/flowable_client/resources/process_definitions.rb +142 -0
- data/lib/flowable_client/resources/process_instances.rb +200 -0
- metadata +104 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Flowable
|
|
4
|
+
module Resources
|
|
5
|
+
class CaseDefinitions < Base
|
|
6
|
+
BASE_PATH = 'cmmn-repository/case-definitions'
|
|
7
|
+
|
|
8
|
+
# List all case definitions
|
|
9
|
+
# @param options [Hash] Query parameters
|
|
10
|
+
# @option options [String] :key Filter by key
|
|
11
|
+
# @option options [String] :keyLike Filter by key pattern
|
|
12
|
+
# @option options [String] :name Filter by name
|
|
13
|
+
# @option options [String] :nameLike Filter by name pattern
|
|
14
|
+
# @option options [Integer] :version Filter by version
|
|
15
|
+
# @option options [String] :deploymentId Filter by deployment
|
|
16
|
+
# @option options [Boolean] :latest Only return latest versions
|
|
17
|
+
# @option options [String] :tenantId Filter by tenant
|
|
18
|
+
# @return [Hash] Paginated list of case definitions
|
|
19
|
+
def list(**options)
|
|
20
|
+
params = paginate_params(options)
|
|
21
|
+
%i[key keyLike name nameLike resourceName resourceNameLike
|
|
22
|
+
category categoryLike categoryNotEquals deploymentId
|
|
23
|
+
startableByUser tenantId].each do |key|
|
|
24
|
+
params[key] = options[key] if options[key]
|
|
25
|
+
end
|
|
26
|
+
params[:version] = options[:version] if options[:version]
|
|
27
|
+
params[:latest] = options[:latest] if options.key?(:latest)
|
|
28
|
+
params[:suspended] = options[:suspended] if options.key?(:suspended)
|
|
29
|
+
|
|
30
|
+
client.get(BASE_PATH, params)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Get a specific case definition
|
|
34
|
+
# @param case_definition_id [String] The case definition ID
|
|
35
|
+
# @return [Hash] Case definition details
|
|
36
|
+
def get(case_definition_id)
|
|
37
|
+
client.get("#{BASE_PATH}/#{case_definition_id}")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Get case definition by key (returns latest version)
|
|
41
|
+
# @param key [String] The case definition key
|
|
42
|
+
# @param tenant_id [String] Optional tenant ID
|
|
43
|
+
# @return [Hash] Case definition details
|
|
44
|
+
def get_by_key(key, tenant_id: nil)
|
|
45
|
+
params = { key: key, latest: true }
|
|
46
|
+
params[:tenantId] = tenant_id if tenant_id
|
|
47
|
+
|
|
48
|
+
result = client.get(BASE_PATH, params)
|
|
49
|
+
result['data']&.first
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Update the category of a case definition
|
|
53
|
+
# @param case_definition_id [String] The case definition ID
|
|
54
|
+
# @param category [String] The new category
|
|
55
|
+
# @return [Hash] Updated case definition
|
|
56
|
+
def update_category(case_definition_id, category)
|
|
57
|
+
client.put("#{BASE_PATH}/#{case_definition_id}", { category: category })
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Get the CMMN XML content of a case definition
|
|
61
|
+
# @param case_definition_id [String] The case definition ID
|
|
62
|
+
# @return [String] CMMN XML content
|
|
63
|
+
def resource_data(case_definition_id)
|
|
64
|
+
client.get("#{BASE_PATH}/#{case_definition_id}/resourcedata")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
alias resource_content resource_data
|
|
68
|
+
|
|
69
|
+
# Get the CMMN model as JSON
|
|
70
|
+
# @param case_definition_id [String] The case definition ID
|
|
71
|
+
# @return [Hash] CMMN model structure
|
|
72
|
+
def model(case_definition_id)
|
|
73
|
+
client.get("#{BASE_PATH}/#{case_definition_id}/model")
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Get all candidate starters for a case definition
|
|
77
|
+
# @param case_definition_id [String] The case definition ID
|
|
78
|
+
# @return [Array<Hash>] List of identity links
|
|
79
|
+
def identity_links(case_definition_id)
|
|
80
|
+
client.get("#{BASE_PATH}/#{case_definition_id}/identitylinks")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Add a candidate starter (user) to a case definition
|
|
84
|
+
# @param case_definition_id [String] The case definition ID
|
|
85
|
+
# @param user_id [String] The user ID
|
|
86
|
+
# @return [Hash] Created identity link
|
|
87
|
+
def add_candidate_user(case_definition_id, user_id)
|
|
88
|
+
client.post(
|
|
89
|
+
"#{BASE_PATH}/#{case_definition_id}/identitylinks",
|
|
90
|
+
{ user: user_id }
|
|
91
|
+
)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Add a candidate starter (group) to a case definition
|
|
95
|
+
# @param case_definition_id [String] The case definition ID
|
|
96
|
+
# @param group_id [String] The group ID
|
|
97
|
+
# @return [Hash] Created identity link
|
|
98
|
+
def add_candidate_group(case_definition_id, group_id)
|
|
99
|
+
client.post(
|
|
100
|
+
"#{BASE_PATH}/#{case_definition_id}/identitylinks",
|
|
101
|
+
{ groupId: group_id }
|
|
102
|
+
)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Remove a candidate starter from a case definition
|
|
106
|
+
# @param case_definition_id [String] The case definition ID
|
|
107
|
+
# @param family [String] 'users' or 'groups'
|
|
108
|
+
# @param identity_id [String] The user or group ID
|
|
109
|
+
# @return [Boolean] true if successful
|
|
110
|
+
def remove_candidate(case_definition_id, family, identity_id)
|
|
111
|
+
client.delete("#{BASE_PATH}/#{case_definition_id}/identitylinks/#{family}/#{identity_id}")
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Flowable
|
|
4
|
+
module Resources
|
|
5
|
+
class CaseInstances < Base
|
|
6
|
+
BASE_PATH = 'cmmn-runtime/case-instances'
|
|
7
|
+
|
|
8
|
+
# List all case instances
|
|
9
|
+
# @param options [Hash] Query parameters
|
|
10
|
+
# @option options [String] :id Filter by instance ID
|
|
11
|
+
# @option options [String] :caseDefinitionKey Filter by definition key
|
|
12
|
+
# @option options [String] :caseDefinitionId Filter by definition ID
|
|
13
|
+
# @option options [String] :businessKey Filter by business key
|
|
14
|
+
# @option options [String] :involvedUser Filter by involved user
|
|
15
|
+
# @option options [Boolean] :includeCaseVariables Include variables in response
|
|
16
|
+
# @option options [String] :tenantId Filter by tenant
|
|
17
|
+
# @return [Hash] Paginated list of case instances
|
|
18
|
+
def list(**options)
|
|
19
|
+
params = paginate_params(options)
|
|
20
|
+
%i[id caseDefinitionKey caseDefinitionId businessKey
|
|
21
|
+
involvedUser tenantId tenantIdLike].each do |key|
|
|
22
|
+
params[key] = options[key] if options[key]
|
|
23
|
+
end
|
|
24
|
+
params[:includeCaseVariables] = options[:includeCaseVariables] if options.key?(:includeCaseVariables)
|
|
25
|
+
params[:withoutTenantId] = options[:withoutTenantId] if options.key?(:withoutTenantId)
|
|
26
|
+
|
|
27
|
+
client.get(BASE_PATH, params)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Get a specific case instance
|
|
31
|
+
# @param case_instance_id [String] The case instance ID
|
|
32
|
+
# @return [Hash] Case instance details
|
|
33
|
+
def get(case_instance_id)
|
|
34
|
+
client.get("#{BASE_PATH}/#{case_instance_id}")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Start a new case instance by case definition ID
|
|
38
|
+
# @param case_definition_id [String] The case definition ID
|
|
39
|
+
# @param variables [Hash] Optional variables (name => value)
|
|
40
|
+
# @param business_key [String] Optional business key
|
|
41
|
+
# @param return_variables [Boolean] Return variables in response
|
|
42
|
+
# @return [Hash] Created case instance
|
|
43
|
+
def start_by_id(case_definition_id, variables: {}, business_key: nil, return_variables: false)
|
|
44
|
+
body = { caseDefinitionId: case_definition_id }
|
|
45
|
+
body[:businessKey] = business_key if business_key
|
|
46
|
+
body[:variables] = build_variables_array(variables) unless variables.empty?
|
|
47
|
+
body[:returnVariables] = return_variables if return_variables
|
|
48
|
+
|
|
49
|
+
client.post(BASE_PATH, body)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Start a new case instance by case definition key
|
|
53
|
+
# @param case_definition_key [String] The case definition key
|
|
54
|
+
# @param variables [Hash] Optional variables (name => value)
|
|
55
|
+
# @param business_key [String] Optional business key
|
|
56
|
+
# @param tenant_id [String] Optional tenant ID
|
|
57
|
+
# @param return_variables [Boolean] Return variables in response
|
|
58
|
+
# @return [Hash] Created case instance
|
|
59
|
+
def start_by_key(case_definition_key, variables: {}, business_key: nil, tenant_id: nil, return_variables: false)
|
|
60
|
+
body = { caseDefinitionKey: case_definition_key }
|
|
61
|
+
body[:businessKey] = business_key if business_key
|
|
62
|
+
body[:tenantId] = tenant_id if tenant_id
|
|
63
|
+
body[:variables] = build_variables_array(variables) unless variables.empty?
|
|
64
|
+
body[:returnVariables] = return_variables if return_variables
|
|
65
|
+
|
|
66
|
+
client.post(BASE_PATH, body)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Delete a case instance
|
|
70
|
+
# @param case_instance_id [String] The case instance ID
|
|
71
|
+
# @return [Boolean] true if successful
|
|
72
|
+
def delete(case_instance_id)
|
|
73
|
+
client.delete("#{BASE_PATH}/#{case_instance_id}")
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Query case instances with complex filters
|
|
77
|
+
# @param query [Hash] Query body with filters and variable conditions
|
|
78
|
+
# @return [Hash] Paginated list of case instances
|
|
79
|
+
def query(query)
|
|
80
|
+
client.post('query/case-instances', query)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Get the diagram/image for a case instance
|
|
84
|
+
# @param case_instance_id [String] The case instance ID
|
|
85
|
+
# @return [String] Binary image data
|
|
86
|
+
def diagram(case_instance_id)
|
|
87
|
+
client.get("#{BASE_PATH}/#{case_instance_id}/diagram")
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Get the stage overview for a case instance
|
|
91
|
+
# @param case_instance_id [String] The case instance ID
|
|
92
|
+
# @return [Array<Hash>] List of stages with their status
|
|
93
|
+
def stage_overview(case_instance_id)
|
|
94
|
+
client.get("#{BASE_PATH}/#{case_instance_id}/stage-overview")
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# --- Identity Links ---
|
|
98
|
+
|
|
99
|
+
# Get involved people for a case instance
|
|
100
|
+
# @param case_instance_id [String] The case instance ID
|
|
101
|
+
# @return [Array<Hash>] List of identity links
|
|
102
|
+
def identity_links(case_instance_id)
|
|
103
|
+
client.get("#{BASE_PATH}/#{case_instance_id}/identitylinks")
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Add an involved user to a case instance
|
|
107
|
+
# @param case_instance_id [String] The case instance ID
|
|
108
|
+
# @param user_id [String] The user ID
|
|
109
|
+
# @param type [String] Type of involvement (e.g., 'participant')
|
|
110
|
+
# @return [Hash] Created identity link
|
|
111
|
+
def add_involved_user(case_instance_id, user_id, type: 'participant')
|
|
112
|
+
client.post(
|
|
113
|
+
"#{BASE_PATH}/#{case_instance_id}/identitylinks",
|
|
114
|
+
{ userId: user_id, type: type }
|
|
115
|
+
)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Remove an involved user from a case instance
|
|
119
|
+
# @param case_instance_id [String] The case instance ID
|
|
120
|
+
# @param user_id [String] The user ID
|
|
121
|
+
# @param type [String] Type of involvement
|
|
122
|
+
# @return [Boolean] true if successful
|
|
123
|
+
def remove_involved_user(case_instance_id, user_id, type)
|
|
124
|
+
client.delete("#{BASE_PATH}/#{case_instance_id}/identitylinks/users/#{user_id}/#{type}")
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# --- Variables ---
|
|
128
|
+
|
|
129
|
+
# Get all variables for a case instance
|
|
130
|
+
# @param case_instance_id [String] The case instance ID
|
|
131
|
+
# @return [Array<Hash>] List of variables
|
|
132
|
+
def variables(case_instance_id)
|
|
133
|
+
client.get("#{BASE_PATH}/#{case_instance_id}/variables")
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# Get a specific variable from a case instance
|
|
137
|
+
# @param case_instance_id [String] The case instance ID
|
|
138
|
+
# @param variable_name [String] The variable name
|
|
139
|
+
# @return [Hash] Variable details
|
|
140
|
+
def variable(case_instance_id, variable_name)
|
|
141
|
+
client.get("#{BASE_PATH}/#{case_instance_id}/variables/#{variable_name}")
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Create variables on a case instance (fails if exists)
|
|
145
|
+
# @param case_instance_id [String] The case instance ID
|
|
146
|
+
# @param variables [Hash] Variables to create (name => value)
|
|
147
|
+
# @return [Array<Hash>] Created variables
|
|
148
|
+
def create_variables(case_instance_id, variables)
|
|
149
|
+
client.post(
|
|
150
|
+
"#{BASE_PATH}/#{case_instance_id}/variables",
|
|
151
|
+
build_variables_array(variables)
|
|
152
|
+
)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# Create or update variables on a case instance
|
|
156
|
+
# @param case_instance_id [String] The case instance ID
|
|
157
|
+
# @param variables [Hash] Variables to set (name => value)
|
|
158
|
+
# @return [Array<Hash>] Updated variables
|
|
159
|
+
def set_variables(case_instance_id, variables)
|
|
160
|
+
client.put(
|
|
161
|
+
"#{BASE_PATH}/#{case_instance_id}/variables",
|
|
162
|
+
build_variables_array(variables)
|
|
163
|
+
)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Update a single variable on a case instance
|
|
167
|
+
# @param case_instance_id [String] The case instance ID
|
|
168
|
+
# @param name [String] Variable name
|
|
169
|
+
# @param value [Object] Variable value
|
|
170
|
+
# @param type [String] Optional explicit type
|
|
171
|
+
# @return [Hash] Updated variable
|
|
172
|
+
def update_variable(case_instance_id, name, value, type: nil)
|
|
173
|
+
body = { name: name, value: value }
|
|
174
|
+
body[:type] = type || infer_type(value)
|
|
175
|
+
|
|
176
|
+
client.put("#{BASE_PATH}/#{case_instance_id}/variables/#{name}", body)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# Delete a variable from a case instance
|
|
180
|
+
# @param case_instance_id [String] The case instance ID
|
|
181
|
+
# @param variable_name [String] The variable name
|
|
182
|
+
# @return [Boolean] true if successful
|
|
183
|
+
def delete_variable(case_instance_id, variable_name)
|
|
184
|
+
client.delete("#{BASE_PATH}/#{case_instance_id}/variables/#{variable_name}")
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Flowable
|
|
4
|
+
module Resources
|
|
5
|
+
class Deployments < Base
|
|
6
|
+
BASE_PATH = 'cmmn-repository/deployments'
|
|
7
|
+
|
|
8
|
+
# List all deployments
|
|
9
|
+
# @param options [Hash] Query parameters
|
|
10
|
+
# @option options [String] :name Filter by exact name
|
|
11
|
+
# @option options [String] :nameLike Filter by name pattern (use % wildcard)
|
|
12
|
+
# @option options [String] :category Filter by category
|
|
13
|
+
# @option options [String] :tenantId Filter by tenant
|
|
14
|
+
# @option options [Integer] :start Pagination start (default: 0)
|
|
15
|
+
# @option options [Integer] :size Page size (default: 10)
|
|
16
|
+
# @option options [String] :sort Sort field (id/name/deployTime/tenantId)
|
|
17
|
+
# @option options [String] :order Sort order (asc/desc)
|
|
18
|
+
# @return [Hash] Paginated list of deployments
|
|
19
|
+
def list(**options)
|
|
20
|
+
params = paginate_params(options)
|
|
21
|
+
params[:name] = options[:name] if options[:name]
|
|
22
|
+
params[:nameLike] = options[:nameLike] if options[:nameLike]
|
|
23
|
+
params[:category] = options[:category] if options[:category]
|
|
24
|
+
params[:tenantId] = options[:tenantId] if options[:tenantId]
|
|
25
|
+
params[:withoutTenantId] = options[:withoutTenantId] if options[:withoutTenantId]
|
|
26
|
+
|
|
27
|
+
client.get(BASE_PATH, params)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Get a specific deployment
|
|
31
|
+
# @param deployment_id [String] The deployment ID
|
|
32
|
+
# @return [Hash] Deployment details
|
|
33
|
+
def get(deployment_id)
|
|
34
|
+
client.get("#{BASE_PATH}/#{deployment_id}")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Create a new deployment from a file
|
|
38
|
+
# @param file_path [String] Path to CMMN file (.cmmn.xml, .bar, .zip)
|
|
39
|
+
# @param name [String] Optional deployment name
|
|
40
|
+
# @param tenant_id [String] Optional tenant ID
|
|
41
|
+
# @param category [String] Optional category
|
|
42
|
+
# @return [Hash] Created deployment
|
|
43
|
+
def create(file_path, name: nil, tenant_id: nil, category: nil)
|
|
44
|
+
additional_fields = {}
|
|
45
|
+
additional_fields[:deploymentName] = name if name
|
|
46
|
+
additional_fields[:tenantId] = tenant_id if tenant_id
|
|
47
|
+
additional_fields[:category] = category if category
|
|
48
|
+
|
|
49
|
+
client.post_multipart(BASE_PATH, file_path, additional_fields)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Delete a deployment
|
|
53
|
+
# @param deployment_id [String] The deployment ID
|
|
54
|
+
# @param cascade [Boolean] Also delete related case/process instances (default: false)
|
|
55
|
+
# @return [Boolean] true if successful
|
|
56
|
+
def delete(deployment_id, cascade: false)
|
|
57
|
+
params = cascade ? { cascade: true } : {}
|
|
58
|
+
client.delete("#{BASE_PATH}/#{deployment_id}", params)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# List resources in a deployment
|
|
62
|
+
# @param deployment_id [String] The deployment ID
|
|
63
|
+
# @return [Array<Hash>] List of resources
|
|
64
|
+
def resources(deployment_id)
|
|
65
|
+
client.get("#{BASE_PATH}/#{deployment_id}/resources")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Get a specific resource from a deployment
|
|
69
|
+
# @param deployment_id [String] The deployment ID
|
|
70
|
+
# @param resource_id [String] The resource ID (URL-encoded if contains /)
|
|
71
|
+
# @return [Hash] Resource details
|
|
72
|
+
def resource(deployment_id, resource_id)
|
|
73
|
+
encoded_resource_id = URI.encode_www_form_component(resource_id)
|
|
74
|
+
client.get("#{BASE_PATH}/#{deployment_id}/resources/#{encoded_resource_id}")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Get the content of a deployment resource
|
|
78
|
+
# @param deployment_id [String] The deployment ID
|
|
79
|
+
# @param resource_id [String] The resource ID
|
|
80
|
+
# @return [String] Raw resource content
|
|
81
|
+
def resource_data(deployment_id, resource_id)
|
|
82
|
+
encoded_resource_id = URI.encode_www_form_component(resource_id)
|
|
83
|
+
client.get("#{BASE_PATH}/#{deployment_id}/resourcedata/#{encoded_resource_id}")
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Flowable
|
|
4
|
+
module Resources
|
|
5
|
+
class Executions < Base
|
|
6
|
+
BASE_PATH = 'service/runtime/executions'
|
|
7
|
+
|
|
8
|
+
# List all executions
|
|
9
|
+
# @param options [Hash] Query parameters
|
|
10
|
+
# @option options [String] :id Filter by execution ID
|
|
11
|
+
# @option options [String] :processDefinitionKey Filter by process definition key
|
|
12
|
+
# @option options [String] :processDefinitionId Filter by process definition ID
|
|
13
|
+
# @option options [String] :processInstanceId Filter by process instance ID
|
|
14
|
+
# @option options [String] :activityId Filter by activity ID
|
|
15
|
+
# @option options [String] :parentId Filter by parent execution ID
|
|
16
|
+
# @option options [String] :tenantId Filter by tenant
|
|
17
|
+
# @return [Hash] Paginated list of executions
|
|
18
|
+
def list(**options)
|
|
19
|
+
params = paginate_params(options)
|
|
20
|
+
%i[id processDefinitionKey processDefinitionId processInstanceId
|
|
21
|
+
activityId parentId signalEventSubscriptionName
|
|
22
|
+
messageEventSubscriptionName tenantId tenantIdLike].each do |key|
|
|
23
|
+
params[key] = options[key] if options[key]
|
|
24
|
+
end
|
|
25
|
+
params[:withoutTenantId] = options[:withoutTenantId] if options.key?(:withoutTenantId)
|
|
26
|
+
|
|
27
|
+
client.get(BASE_PATH, params)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Get a specific execution
|
|
31
|
+
# @param execution_id [String] The execution ID
|
|
32
|
+
# @return [Hash] Execution details
|
|
33
|
+
def get(execution_id)
|
|
34
|
+
client.get("#{BASE_PATH}/#{execution_id}")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Execute an action on an execution
|
|
38
|
+
# @param execution_id [String] The execution ID
|
|
39
|
+
# @param action [String] Action type
|
|
40
|
+
# @param options [Hash] Additional action parameters
|
|
41
|
+
# @return [Hash] Response
|
|
42
|
+
def execute_action(execution_id, action, **options)
|
|
43
|
+
body = { action: action }
|
|
44
|
+
body.merge!(options)
|
|
45
|
+
client.put("#{BASE_PATH}/#{execution_id}", body)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Signal an execution
|
|
49
|
+
# @param execution_id [String] The execution ID
|
|
50
|
+
# @param variables [Hash] Optional variables
|
|
51
|
+
# @return [Hash] Response
|
|
52
|
+
def signal(execution_id, variables: {})
|
|
53
|
+
body = { action: 'signal' }
|
|
54
|
+
body[:variables] = build_variables_array(variables) unless variables.empty?
|
|
55
|
+
client.put("#{BASE_PATH}/#{execution_id}", body)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Trigger a message event
|
|
59
|
+
# @param execution_id [String] The execution ID
|
|
60
|
+
# @param message_name [String] The message name
|
|
61
|
+
# @param variables [Hash] Optional variables
|
|
62
|
+
# @return [Hash] Response
|
|
63
|
+
def message_event(execution_id, message_name, variables: {})
|
|
64
|
+
body = { action: 'messageEventReceived', messageName: message_name }
|
|
65
|
+
body[:variables] = build_variables_array(variables) unless variables.empty?
|
|
66
|
+
client.put("#{BASE_PATH}/#{execution_id}", body)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Trigger a signal event
|
|
70
|
+
# @param execution_id [String] The execution ID
|
|
71
|
+
# @param signal_name [String] The signal name
|
|
72
|
+
# @param variables [Hash] Optional variables
|
|
73
|
+
# @return [Hash] Response
|
|
74
|
+
def signal_event(execution_id, signal_name, variables: {})
|
|
75
|
+
body = { action: 'signalEventReceived', signalName: signal_name }
|
|
76
|
+
body[:variables] = build_variables_array(variables) unless variables.empty?
|
|
77
|
+
client.put("#{BASE_PATH}/#{execution_id}", body)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# --- Variables ---
|
|
81
|
+
|
|
82
|
+
# Get all variables for an execution
|
|
83
|
+
# @param execution_id [String] The execution ID
|
|
84
|
+
# @param scope [String] 'local' or 'global'
|
|
85
|
+
# @return [Array<Hash>] List of variables
|
|
86
|
+
def variables(execution_id, scope: nil)
|
|
87
|
+
params = {}
|
|
88
|
+
params[:scope] = scope if scope
|
|
89
|
+
client.get("#{BASE_PATH}/#{execution_id}/variables", params)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Get a specific variable from an execution
|
|
93
|
+
# @param execution_id [String] The execution ID
|
|
94
|
+
# @param variable_name [String] The variable name
|
|
95
|
+
# @param scope [String] 'local' or 'global'
|
|
96
|
+
# @return [Hash] Variable details
|
|
97
|
+
def variable(execution_id, variable_name, scope: nil)
|
|
98
|
+
params = {}
|
|
99
|
+
params[:scope] = scope if scope
|
|
100
|
+
client.get("#{BASE_PATH}/#{execution_id}/variables/#{variable_name}", params)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Create variables on an execution
|
|
104
|
+
# @param execution_id [String] The execution ID
|
|
105
|
+
# @param variables [Hash] Variables to create (name => value)
|
|
106
|
+
# @return [Array<Hash>] Created variables
|
|
107
|
+
def create_variables(execution_id, variables)
|
|
108
|
+
client.post("#{BASE_PATH}/#{execution_id}/variables", build_variables_array(variables))
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Update variables on an execution
|
|
112
|
+
# @param execution_id [String] The execution ID
|
|
113
|
+
# @param variables [Hash] Variables to update (name => value)
|
|
114
|
+
# @return [Array<Hash>] Updated variables
|
|
115
|
+
def update_variables(execution_id, variables)
|
|
116
|
+
client.put("#{BASE_PATH}/#{execution_id}/variables", build_variables_array(variables))
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Query executions with complex filters
|
|
120
|
+
# @param query [Hash] Query body
|
|
121
|
+
# @return [Hash] Paginated list of executions
|
|
122
|
+
def query(query)
|
|
123
|
+
client.post('service/query/executions', query)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Get active activities in an execution
|
|
127
|
+
# @param execution_id [String] The execution ID
|
|
128
|
+
# @return [Array<Hash>] List of activities
|
|
129
|
+
def activities(execution_id)
|
|
130
|
+
client.get("#{BASE_PATH}/#{execution_id}/activities")
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|