camunda-workflow 0.6.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +55 -13
- data/README.md +1 -1
- data/lib/camunda/deployment.rb +9 -5
- data/lib/camunda/external_task.rb +19 -22
- data/lib/camunda/incident.rb +1 -1
- data/lib/camunda/model.rb +8 -35
- data/lib/camunda/process_definition.rb +5 -8
- data/lib/camunda/process_instance.rb +3 -3
- data/lib/camunda/signal.rb +2 -2
- data/lib/camunda/task.rb +14 -16
- data/lib/camunda/workflow/version.rb +1 -1
- data/lib/camunda/workflow.rb +24 -1
- data/lib/camunda.rb +70 -20
- metadata +27 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9401504309d2afda4ebc29413c718c1c2ccaba1a560a21300688239e518be1b8
|
4
|
+
data.tar.gz: fdfeccc97db56ce156a8edb7adee0792d877c3badfe429a650c6f75f551720b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 060af24f736f97e3b7652a3f2c58b53dd2f10f1655179d801de85525b2b0b8455f99783ea824faf8234e1549a59476cbcbd09784a51d5c1a63f3995ff089456a
|
7
|
+
data.tar.gz: '098a818250200d5bbb79289a6b89f1c591fac90b0e4b502d883d9af37443a69a715d75403aa0f1afc11ef7838d6cff31b74051afed1acd8ec5774fb856ac6021'
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,52 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.6.0](https://github.com/amalagaura/camunda-workflow/tree/v0.6.0) (2023-07-19)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/amalagaura/camunda-workflow/compare/v0.3.0...v0.6.0)
|
6
|
+
|
7
|
+
**Closed issues:**
|
8
|
+
|
9
|
+
- Upgrade rails development dependency [\#63](https://github.com/amalagaura/camunda-workflow/issues/63)
|
10
|
+
- Not able to use it with Sidekiq [\#52](https://github.com/amalagaura/camunda-workflow/issues/52)
|
11
|
+
- Migrate project to the Camunda Community Hub? [\#50](https://github.com/amalagaura/camunda-workflow/issues/50)
|
12
|
+
|
13
|
+
**Merged pull requests:**
|
14
|
+
|
15
|
+
- Bump camunda-workflow to 0.6.0 [\#73](https://github.com/amalagaura/camunda-workflow/pull/73) ([amalagaura](https://github.com/amalagaura))
|
16
|
+
- Yashupadhyay16 upgrade rails version [\#71](https://github.com/amalagaura/camunda-workflow/pull/71) ([amalagaura](https://github.com/amalagaura))
|
17
|
+
- Remove Gemfile.lock [\#70](https://github.com/amalagaura/camunda-workflow/pull/70) ([amalagaura](https://github.com/amalagaura))
|
18
|
+
- Update Nokogiri [\#69](https://github.com/amalagaura/camunda-workflow/pull/69) ([amalagaura](https://github.com/amalagaura))
|
19
|
+
- Github actions for CI [\#67](https://github.com/amalagaura/camunda-workflow/pull/67) ([amalagaura](https://github.com/amalagaura))
|
20
|
+
- Bump rack from 2.2.4 to 2.2.6.3 [\#65](https://github.com/amalagaura/camunda-workflow/pull/65) ([dependabot[bot]](https://github.com/apps/dependabot))
|
21
|
+
- Bump postgresql from 42.2.25 to 42.3.8 in /lib/generators/camunda/spring\_boot/templates [\#60](https://github.com/amalagaura/camunda-workflow/pull/60) ([dependabot[bot]](https://github.com/apps/dependabot))
|
22
|
+
- Bump postgresql from 42.2.7 to 42.2.25 in /lib/generators/camunda/spring\_boot/templates [\#53](https://github.com/amalagaura/camunda-workflow/pull/53) ([dependabot[bot]](https://github.com/apps/dependabot))
|
23
|
+
- Bump nokogiri from 1.11.2 to 1.12.5 [\#51](https://github.com/amalagaura/camunda-workflow/pull/51) ([dependabot[bot]](https://github.com/apps/dependabot))
|
24
|
+
- Bump rexml from 3.2.4 to 3.2.5 [\#48](https://github.com/amalagaura/camunda-workflow/pull/48) ([dependabot[bot]](https://github.com/apps/dependabot))
|
25
|
+
|
26
|
+
## [v0.3.0](https://github.com/amalagaura/camunda-workflow/tree/v0.3.0) (2021-04-07)
|
27
|
+
|
28
|
+
[Full Changelog](https://github.com/amalagaura/camunda-workflow/compare/v0.2.3...v0.3.0)
|
29
|
+
|
30
|
+
**Merged pull requests:**
|
31
|
+
|
32
|
+
- Bump nokogiri from 1.10.10 to 1.11.2 [\#47](https://github.com/amalagaura/camunda-workflow/pull/47) ([dependabot[bot]](https://github.com/apps/dependabot))
|
33
|
+
- Update gems [\#45](https://github.com/amalagaura/camunda-workflow/pull/45) ([amalagaura](https://github.com/amalagaura))
|
34
|
+
- Bump rack from 2.1.1 to 2.2.3 [\#44](https://github.com/amalagaura/camunda-workflow/pull/44) ([dependabot[bot]](https://github.com/apps/dependabot))
|
35
|
+
- Bump nokogiri from 1.10.7 to 1.10.9 [\#43](https://github.com/amalagaura/camunda-workflow/pull/43) ([dependabot[bot]](https://github.com/apps/dependabot))
|
36
|
+
- Bump websocket-extensions from 0.1.4 to 0.1.5 [\#42](https://github.com/amalagaura/camunda-workflow/pull/42) ([dependabot[bot]](https://github.com/apps/dependabot))
|
37
|
+
- Add HTTP status code for process definition start errors [\#41](https://github.com/amalagaura/camunda-workflow/pull/41) ([amalagaura](https://github.com/amalagaura))
|
38
|
+
- Adding the ability to set an HTTP proxy for API calls [\#40](https://github.com/amalagaura/camunda-workflow/pull/40) ([dannykopping](https://github.com/dannykopping))
|
39
|
+
- Checking if Rails is defined before calling it [\#38](https://github.com/amalagaura/camunda-workflow/pull/38) ([dannykopping](https://github.com/dannykopping))
|
40
|
+
- Add ability to escalate user tasks and submit bpmn errors for user tasks [\#37](https://github.com/amalagaura/camunda-workflow/pull/37) ([amalagaura](https://github.com/amalagaura))
|
41
|
+
|
42
|
+
## [v0.2.3](https://github.com/amalagaura/camunda-workflow/tree/v0.2.3) (2020-01-14)
|
43
|
+
|
44
|
+
[Full Changelog](https://github.com/amalagaura/camunda-workflow/compare/v0.2.2...v0.2.3)
|
45
|
+
|
46
|
+
**Closed issues:**
|
47
|
+
|
48
|
+
- Handle BPMN errors of user tasks [\#36](https://github.com/amalagaura/camunda-workflow/issues/36)
|
49
|
+
|
3
50
|
## [v0.2.2](https://github.com/amalagaura/camunda-workflow/tree/v0.2.2) (2020-01-08)
|
4
51
|
|
5
52
|
[Full Changelog](https://github.com/amalagaura/camunda-workflow/compare/v0.2.1...v0.2.2)
|
@@ -73,6 +120,13 @@
|
|
73
120
|
|
74
121
|
- Add find\_by! to all Camunda Her models [\#14](https://github.com/amalagaura/camunda-workflow/pull/14) ([amalagaura](https://github.com/amalagaura))
|
75
122
|
- Yarddoc documentation [\#12](https://github.com/amalagaura/camunda-workflow/pull/12) ([curatingbits](https://github.com/curatingbits))
|
123
|
+
- Raise Submission errors if Camunda does not accept completion [\#11](https://github.com/amalagaura/camunda-workflow/pull/11) ([amalagaura](https://github.com/amalagaura))
|
124
|
+
- Allow Poller to not exit its loop when there is a missing class and report error [\#8](https://github.com/amalagaura/camunda-workflow/pull/8) ([amalagaura](https://github.com/amalagaura))
|
125
|
+
- Add rubocop rspec [\#6](https://github.com/amalagaura/camunda-workflow/pull/6) ([amalagaura](https://github.com/amalagaura))
|
126
|
+
- Correct find\_by\_business\_key\_and\_task\_definition\_key! [\#5](https://github.com/amalagaura/camunda-workflow/pull/5) ([amalagaura](https://github.com/amalagaura))
|
127
|
+
- added authentication via templates for spring\\_boot generator and Her [\#4](https://github.com/amalagaura/camunda-workflow/pull/4) ([curatingbits](https://github.com/curatingbits))
|
128
|
+
- Refactor to return proper Her models after responses [\#3](https://github.com/amalagaura/camunda-workflow/pull/3) ([amalagaura](https://github.com/amalagaura))
|
129
|
+
- Added tests for Camunda workflow [\#2](https://github.com/amalagaura/camunda-workflow/pull/2) ([curatingbits](https://github.com/curatingbits))
|
76
130
|
|
77
131
|
## [v0.1.3](https://github.com/amalagaura/camunda-workflow/tree/v0.1.3) (2019-12-06)
|
78
132
|
|
@@ -83,23 +137,11 @@
|
|
83
137
|
- When there is a logic error in submitting a user task we are getting a MissingTask error instead [\#9](https://github.com/amalagaura/camunda-workflow/issues/9)
|
84
138
|
- If a class does not exist, the Poller loop crashes [\#7](https://github.com/amalagaura/camunda-workflow/issues/7)
|
85
139
|
|
86
|
-
**Merged pull requests:**
|
87
|
-
|
88
|
-
- Raise Submission errors if Camunda does not accept completion [\#11](https://github.com/amalagaura/camunda-workflow/pull/11) ([amalagaura](https://github.com/amalagaura))
|
89
|
-
- Allow Poller to not exit its loop when there is a missing class and report error [\#8](https://github.com/amalagaura/camunda-workflow/pull/8) ([amalagaura](https://github.com/amalagaura))
|
90
|
-
- Add rubocop rspec [\#6](https://github.com/amalagaura/camunda-workflow/pull/6) ([amalagaura](https://github.com/amalagaura))
|
91
|
-
|
92
140
|
## [v0.1.2](https://github.com/amalagaura/camunda-workflow/tree/v0.1.2) (2019-11-27)
|
93
141
|
|
94
142
|
[Full Changelog](https://github.com/amalagaura/camunda-workflow/compare/fc9ab266909628118a892082abdff953f3bc7eca...v0.1.2)
|
95
143
|
|
96
|
-
**Merged pull requests:**
|
97
|
-
|
98
|
-
- Correct find\_by\_business\_key\_and\_task\_definition\_key! [\#5](https://github.com/amalagaura/camunda-workflow/pull/5) ([amalagaura](https://github.com/amalagaura))
|
99
|
-
- added authentication via templates for spring\\_boot generator and Her [\#4](https://github.com/amalagaura/camunda-workflow/pull/4) ([curatingbits](https://github.com/curatingbits))
|
100
|
-
- Refactor to return proper Her models after responses [\#3](https://github.com/amalagaura/camunda-workflow/pull/3) ([amalagaura](https://github.com/amalagaura))
|
101
|
-
- Added tests for Camunda workflow [\#2](https://github.com/amalagaura/camunda-workflow/pull/2) ([curatingbits](https://github.com/curatingbits))
|
102
|
-
|
103
144
|
|
104
145
|
|
105
146
|
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
147
|
+
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
## An opinionated interface to Camunda for Ruby/Rails apps
|
7
7
|
|
8
|
-
Camunda Workflow uses [
|
8
|
+
Camunda Workflow uses [Spyke](https://github.com/balvig/spyke) to communicate with the [Camunda REST API](https://docs.camunda.org/manual/latest/reference/rest/). It executes [External Service Tasks](https://docs.camunda.org/manual/latest/user-guide/process-engine/external-tasks/) using a Ruby class corresponding to each Camunda external task.
|
9
9
|
|
10
10
|
|
11
11
|
## Camunda Integration with Ruby
|
data/lib/camunda/deployment.rb
CHANGED
@@ -6,7 +6,8 @@
|
|
6
6
|
# @note You must supply the paths of the BPMN files as a param titled file_names to deploy the BPMN file
|
7
7
|
# and deploy BPMN, DMN, CMMN definitions in the Camunda engine.
|
8
8
|
class Camunda::Deployment < Camunda::Model
|
9
|
-
|
9
|
+
uri 'deployment/(:id)'
|
10
|
+
|
10
11
|
# Deploys a new process definition to Camunda and returns an instance of Camunda::ProcessDefinition.
|
11
12
|
# @note Only supporting .create which uses a POST on deployment/create.
|
12
13
|
# @example
|
@@ -20,10 +21,9 @@ class Camunda::Deployment < Camunda::Model
|
|
20
21
|
deployment_name ||= file_names.map { |file_name| File.basename(file_name) }.join(", ")
|
21
22
|
tenant_id ||= Camunda::Workflow.configuration.tenant_id
|
22
23
|
args = file_data(file_names).merge('deployment-name' => deployment_name, 'deployment-source' => deployment_source)
|
23
|
-
args.merge!(
|
24
|
-
response =
|
25
|
-
|
26
|
-
deployed_process_definitions(response[:parsed_data][:data][:deployed_process_definitions])
|
24
|
+
args.merge!('tenant-id': tenant_id) if tenant_id
|
25
|
+
response = request(:post, "deployment/create", args)
|
26
|
+
deployed_process_definitions(response.body[:data][:deployed_process_definitions])
|
27
27
|
end
|
28
28
|
|
29
29
|
# Convenience method for dealing with files and IO that are to be uploaded
|
@@ -47,4 +47,8 @@ class Camunda::Deployment < Camunda::Model
|
|
47
47
|
|
48
48
|
definitions_hash.values.map { |process_definition| Camunda::ProcessDefinition.new process_definition }
|
49
49
|
end
|
50
|
+
|
51
|
+
def destroy(params={})
|
52
|
+
self.attributes = delete(params)
|
53
|
+
end
|
50
54
|
end
|
@@ -14,9 +14,13 @@ require 'active_support/backtrace_cleaner'
|
|
14
14
|
class Camunda::ExternalTask < Camunda::Model
|
15
15
|
# Camunda engine doesn't searching on snake_case variables.
|
16
16
|
include Camunda::VariableSerialization
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
uri 'external-task/(:id)'
|
18
|
+
|
19
|
+
%i[fetchAndLock unlock].each do |name|
|
20
|
+
define_singleton_method(name) do |hash|
|
21
|
+
with("external-task/#{name}").where(hash).post
|
22
|
+
end
|
23
|
+
end
|
20
24
|
|
21
25
|
# @note long_polling_duration is defaulted to 30 seconds in Camunda::Workflow.configuration.
|
22
26
|
# @return [Integer] default polling duration from Camunda::Workflow configuration
|
@@ -40,29 +44,27 @@ class Camunda::ExternalTask < Camunda::Model
|
|
40
44
|
# @param input_variables [Hash] process variables
|
41
45
|
def failure(exception, input_variables={})
|
42
46
|
variables_information = "Input variables are #{input_variables.inspect}\n\n" if input_variables.present?
|
43
|
-
self.class.
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
backtrace_cleaner.clean(exception.backtrace).join("\n"))[:response]
|
47
|
+
self.class.request(:post, "external-task/#{id}/failure", workerId: worker_id, errorMessage: exception.message,
|
48
|
+
errorDetails:
|
49
|
+
variables_information.to_s + exception.message +
|
50
|
+
backtrace_cleaner.clean(exception.backtrace).join("\n"))
|
48
51
|
end
|
49
52
|
|
50
53
|
# Reports the error to Camunda and creates an incident for the process instance.
|
51
54
|
# @param bpmn_exception [Camunda::BpmnError]
|
52
55
|
def bpmn_error(bpmn_exception)
|
53
|
-
self.class.
|
54
|
-
|
55
|
-
|
56
|
+
self.class.request(:post, "external-task/#{id}/bpmnError",
|
57
|
+
workerId: worker_id, variables: serialize_variables(bpmn_exception.variables),
|
58
|
+
errorCode: bpmn_exception.error_code, errorMessage: bpmn_exception.message)
|
56
59
|
end
|
57
60
|
|
58
61
|
# Completes the process instance of a fetched task
|
59
62
|
# @param variables [Hash] submitted when starting the process definition
|
60
63
|
# @raise [Camunda::ExternalTask::SubmissionError] if Camunda does not accept the task submission
|
61
64
|
def complete(variables={})
|
62
|
-
self.class.
|
63
|
-
|
64
|
-
|
65
|
-
raise SubmissionError, response.body[:data][:message] unless response.success?
|
65
|
+
self.class.request(:post, "external-task/#{id}/complete", workerId: worker_id,
|
66
|
+
variables: serialize_variables(variables)).tap do |response|
|
67
|
+
raise SubmissionError, response.errors["message"] unless response.errors.blank?
|
66
68
|
end
|
67
69
|
end
|
68
70
|
|
@@ -73,12 +75,6 @@ class Camunda::ExternalTask < Camunda::Model
|
|
73
75
|
self.class.worker_id
|
74
76
|
end
|
75
77
|
|
76
|
-
# Helper method for instances since collection_path is a class method
|
77
|
-
# @return [String]
|
78
|
-
def collection_path
|
79
|
-
self.class.collection_path
|
80
|
-
end
|
81
|
-
|
82
78
|
# deserializes JSON attributes from variables returned by Camunda API
|
83
79
|
def variables
|
84
80
|
super.transform_values do |details|
|
@@ -145,7 +141,8 @@ class Camunda::ExternalTask < Camunda::Model
|
|
145
141
|
# @param long_polling_duration [Integer]
|
146
142
|
# @return [Camunda::ExternalTask]
|
147
143
|
def self.fetch_and_queue(topics, lock_duration: nil, long_polling_duration: nil)
|
148
|
-
fetch_and_lock(topics, lock_duration: lock_duration, long_polling_duration: long_polling_duration)
|
144
|
+
response = fetch_and_lock(topics, lock_duration: lock_duration, long_polling_duration: long_polling_duration)
|
145
|
+
response.each do |task|
|
149
146
|
task.queue_task
|
150
147
|
rescue Camunda::MissingImplementationClass => e
|
151
148
|
task.failure(e)
|
data/lib/camunda/incident.rb
CHANGED
@@ -2,5 +2,5 @@
|
|
2
2
|
# that happen in the process engine. Such incidents usually indicate some kind of problem
|
3
3
|
# related to process execution. Incidents are reported on failures that occur.
|
4
4
|
class Camunda::Incident < Camunda::Model
|
5
|
-
|
5
|
+
uri 'incident/(:id)'
|
6
6
|
end
|
data/lib/camunda/model.rb
CHANGED
@@ -1,43 +1,12 @@
|
|
1
|
-
require '
|
2
|
-
# This class in the main element of
|
3
|
-
class Camunda::Model
|
4
|
-
include Her::Model
|
5
|
-
|
6
|
-
def self.log_details?
|
7
|
-
defined?(Rails) && Rails.env.development?
|
8
|
-
end
|
9
|
-
|
10
|
-
# We use a lambda so that this is evaluated after Camunda::Workflow.configuration is set
|
11
|
-
api = lambda do
|
12
|
-
# Configuration for Her and Faraday requests and responses
|
13
|
-
Her::API.new(url: File.join(Camunda::Workflow.configuration.engine_url)) do |c|
|
14
|
-
c.path_prefix = Camunda::Workflow.configuration.engine_route_prefix
|
15
|
-
# Request
|
16
|
-
c.use Faraday::Request::Multipart
|
17
|
-
c.use FaradayMiddleware::EncodeJson
|
18
|
-
c.use Faraday::Request::BasicAuthentication, Camunda::Workflow.configuration.camunda_user,
|
19
|
-
Camunda::Workflow.configuration.camunda_password
|
20
|
-
# Response
|
21
|
-
c.use Faraday::Response::Logger, ActiveSupport::Logger.new($stdout), bodies: true if log_details?
|
22
|
-
c.use Her::Middleware::FirstLevelParseJSON
|
23
|
-
|
24
|
-
c.use Her::Middleware::SnakeCase
|
25
|
-
# Adapter
|
26
|
-
c.adapter :net_http
|
27
|
-
|
28
|
-
# HTTP proxy
|
29
|
-
c.proxy = Camunda::Workflow.configuration.http_proxy if Camunda::Workflow.configuration.http_proxy
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
use_api api
|
34
|
-
|
1
|
+
require 'spyke/base'
|
2
|
+
# This class in the main element of Spyke. It defines which API models will be bound to.
|
3
|
+
class Camunda::Model < Spyke::Base
|
35
4
|
# Returns result of find_by but raises an exception instead of returning nil
|
36
5
|
# @param params [Hash] query parameters
|
37
6
|
# @return [Camunda::Model]
|
38
7
|
# @raise [Camunda::Model::RecordNotFound] if query returns no results
|
39
8
|
def self.find_by!(params)
|
40
|
-
|
9
|
+
with(base_path).where(params).first.tap do |result|
|
41
10
|
raise Camunda::Model::RecordNotFound unless result
|
42
11
|
end
|
43
12
|
end
|
@@ -49,6 +18,10 @@ class Camunda::Model
|
|
49
18
|
Camunda::Workflow.configuration.worker_id
|
50
19
|
end
|
51
20
|
|
21
|
+
def self.base_path
|
22
|
+
uri.sub("(:id)", '')
|
23
|
+
end
|
24
|
+
|
52
25
|
class RecordNotFound < StandardError
|
53
26
|
end
|
54
27
|
end
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# @see Camunda::ProcessInstance
|
7
7
|
class Camunda::ProcessDefinition < Camunda::Model
|
8
8
|
include Camunda::VariableSerialization
|
9
|
-
|
9
|
+
uri 'process-definition/(:id)'
|
10
10
|
# Starts an individual process instance by key and supplies process variables to be included in the process instance. In
|
11
11
|
# the example below a business key is provided. A business key is a domain-specific identifier of a process instance,
|
12
12
|
# it makes querying for task more efficient. The business key is displayed prominently in applications like Camunda Cockpit.
|
@@ -22,7 +22,7 @@ class Camunda::ProcessDefinition < Camunda::Model
|
|
22
22
|
tenant_id = hash.delete(:tenant_id)
|
23
23
|
tenant_id ||= Camunda::Workflow.configuration.tenant_id
|
24
24
|
|
25
|
-
response =
|
25
|
+
response = request(:post, start_path_for_key(key, tenant_id), hash)
|
26
26
|
process_instance_result(response)
|
27
27
|
end
|
28
28
|
|
@@ -37,7 +37,7 @@ class Camunda::ProcessDefinition < Camunda::Model
|
|
37
37
|
# @raise [Camunda::ProcessEngineException] if submission was unsuccessful
|
38
38
|
def start(hash={})
|
39
39
|
hash[:variables] = serialize_variables(hash[:variables]) if hash[:variables]
|
40
|
-
response = self.class.
|
40
|
+
response = self.class.request(:post, "process-definition/#{id}/start", hash)
|
41
41
|
self.class.process_instance_result(response)
|
42
42
|
end
|
43
43
|
|
@@ -49,11 +49,8 @@ class Camunda::ProcessDefinition < Camunda::Model
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def self.process_instance_result(response)
|
52
|
-
|
53
|
-
raise Camunda::ProcessEngineException,
|
54
|
-
"#{response[:parsed_data][:data][:message]} HTTP Status: #{response[:response].status}"
|
55
|
-
end
|
52
|
+
raise Camunda::ProcessEngineException, response.errors["message"] unless response.errors.blank?
|
56
53
|
|
57
|
-
Camunda::ProcessInstance.new response[
|
54
|
+
Camunda::ProcessInstance.new response.body["data"]
|
58
55
|
end
|
59
56
|
end
|
@@ -4,11 +4,11 @@
|
|
4
4
|
# @see https://docs.camunda.org/manual/7.4/user-guide/process-engine/process-engine-concepts/
|
5
5
|
# @see Camunda::ProcessDefinition
|
6
6
|
class Camunda::ProcessInstance < Camunda::Model
|
7
|
-
|
7
|
+
uri 'process-instance/(:id)'
|
8
8
|
# GETs the process instance and deserializes the variables
|
9
9
|
def variables
|
10
|
-
response = self.class.
|
11
|
-
deserialize_variables response[:
|
10
|
+
response = self.class.request(:get, "process-instance/#{id}/variables")
|
11
|
+
deserialize_variables response.body[:data]
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
data/lib/camunda/signal.rb
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
# `Camunda::Signal.create name: 'Signal Name', variables: {foo: "bar"}`
|
6
6
|
class Camunda::Signal < Camunda::Model
|
7
7
|
include Camunda::VariableSerialization
|
8
|
-
|
8
|
+
uri 'signal/(:id)'
|
9
9
|
# Creates a signal within the process definition on the Camunda engine
|
10
10
|
# @param hash [Hash] variables that are sent to Camunda engine
|
11
11
|
# @return [{Symbol => Hash,Faraday::Response}]
|
12
12
|
def self.create(hash={})
|
13
13
|
hash[:variables] = serialize_variables(hash[:variables]) if hash[:variables]
|
14
|
-
|
14
|
+
request :post, 'signal', hash
|
15
15
|
end
|
16
16
|
end
|
data/lib/camunda/task.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# Finds tasks by business key and task definition and allows you to report a task complete and update process variables.
|
2
2
|
# If a business key isn't supplied when creating a process definition, you can still retrieve UserTasks by using
|
3
|
-
# the `.find_by` helper
|
3
|
+
# the `.find_by` helper.
|
4
4
|
# @see Camunda::ProcessDefinition
|
5
5
|
# @see https://github.com/remi/her
|
6
6
|
# @example
|
7
|
-
# Camunda::Task.find_by(taskDefinitionKey:
|
7
|
+
# Camunda::Task.find_by(taskDefinitionKey: "UserTask")
|
8
8
|
# @example
|
9
9
|
# # You can get all tasks with the `.all.each` helper
|
10
10
|
# tasks = Camunda::Task.all.each
|
@@ -12,10 +12,10 @@
|
|
12
12
|
# tasks.each(&:complete!)
|
13
13
|
class Camunda::Task < Camunda::Model
|
14
14
|
include Camunda::VariableSerialization
|
15
|
-
|
15
|
+
uri "task/(:id)"
|
16
16
|
|
17
17
|
# @example
|
18
|
-
# user_task = Camunda::Task.find_by_business_key_and_task_definition_key!(
|
18
|
+
# user_task = Camunda::Task.find_by_business_key_and_task_definition_key!("WorkflowBusinessKey","UserTask")
|
19
19
|
# @param instance_business_key [String] the process instance business key
|
20
20
|
# @param task_key [String] id/key of the user task
|
21
21
|
# @return [Camunda::Task]
|
@@ -25,36 +25,34 @@ class Camunda::Task < Camunda::Model
|
|
25
25
|
|
26
26
|
# Complete a task and updates process variables.
|
27
27
|
# @example
|
28
|
-
# user_task = Camunda::Task.find_by_business_key_and_task_definition_key!(
|
28
|
+
# user_task = Camunda::Task.find_by_business_key_and_task_definition_key!("WorkflowBusinessKey","UserTask")
|
29
29
|
# user_task.complete!
|
30
30
|
# @param vars [Hash] variables to be submitted as part of task completion
|
31
31
|
def complete!(vars={})
|
32
|
-
self.class.
|
32
|
+
self.class.request(:post, "task/#{id}/complete", variables: serialize_variables(vars))
|
33
33
|
.tap do |response|
|
34
|
-
raise SubmissionError, response.
|
34
|
+
raise SubmissionError, response.errors["message"] unless response.errors.blank?
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
def bpmn_error!(error_code, error_message, vars={})
|
39
|
-
self.class
|
40
|
-
|
41
|
-
variables: serialize_variables(vars))[:response]
|
39
|
+
self.class.request(:post, "task/#{id}/bpmnError", errorCode: error_code, errorMessage: error_message,
|
40
|
+
variables: serialize_variables(vars))
|
42
41
|
.tap do |response|
|
43
|
-
raise SubmissionError, response.
|
42
|
+
raise SubmissionError, response.errors["message"] unless response.errors.blank?
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
47
46
|
def bpmn_escalation!(escalation_code, vars={})
|
48
|
-
self.class
|
49
|
-
|
50
|
-
variables: serialize_variables(vars))[:response]
|
47
|
+
self.class.request(:post, "task/#{id}/bpmnEscalation", escalationCode: escalation_code,
|
48
|
+
variables: serialize_variables(vars))
|
51
49
|
.tap do |response|
|
52
|
-
raise SubmissionError, response.
|
50
|
+
raise SubmissionError, response.errors["message"] unless response.errors.blank?
|
53
51
|
end
|
54
52
|
end
|
55
53
|
|
56
54
|
# Error class when the task cannot be submitted. For instance if the bpmn process expects a variable and the variable
|
57
|
-
# isn
|
55
|
+
# isn"t supplied, Camunda will not accept the task
|
58
56
|
class SubmissionError < StandardError
|
59
57
|
end
|
60
58
|
end
|
data/lib/camunda/workflow.rb
CHANGED
@@ -20,6 +20,7 @@ module Camunda
|
|
20
20
|
# end'
|
21
21
|
def self.configure
|
22
22
|
yield(configuration)
|
23
|
+
initialize_connection
|
23
24
|
end
|
24
25
|
|
25
26
|
# Access the Configuration class
|
@@ -27,7 +28,8 @@ module Camunda
|
|
27
28
|
def self.configuration
|
28
29
|
@configuration ||= Configuration.new
|
29
30
|
end
|
30
|
-
|
31
|
+
|
32
|
+
# Default instance variables configurations for Spyke and camunda-workflow
|
31
33
|
class Configuration
|
32
34
|
# Sets the deult engine url for Camunda REST Api
|
33
35
|
# @return [String] the url for Camunda deployment
|
@@ -84,6 +86,27 @@ module Camunda
|
|
84
86
|
end
|
85
87
|
end
|
86
88
|
end
|
89
|
+
|
90
|
+
def self.log_details?
|
91
|
+
defined?(Rails) && Rails.env.development?
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.initialize_connection
|
95
|
+
Spyke::Base.connection = Faraday.new(url: File.join(configuration.engine_url, configuration.engine_route_prefix)) do |c|
|
96
|
+
c.request :multipart
|
97
|
+
c.request :json
|
98
|
+
c.request :authorization, :basic, Camunda::Workflow.configuration.camunda_user,
|
99
|
+
Camunda::Workflow.configuration.camunda_password
|
100
|
+
|
101
|
+
c.use Faraday::Response::Logger, ActiveSupport::Logger.new($stdout), bodies: true if log_details?
|
102
|
+
c.use Camunda::FirstLevelParseJSON
|
103
|
+
c.use Camunda::Middleware::SnakeCase
|
104
|
+
|
105
|
+
c.adapter Faraday.default_adapter
|
106
|
+
# HTTP proxy
|
107
|
+
c.proxy = Camunda::Workflow.configuration.http_proxy if Camunda::Workflow.configuration.http_proxy
|
108
|
+
end
|
109
|
+
end
|
87
110
|
end
|
88
111
|
end
|
89
112
|
|
data/lib/camunda.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'active_support/core_ext/string/inflections'
|
2
2
|
require 'active_support/core_ext/object/blank'
|
3
|
-
require '
|
3
|
+
require 'spyke'
|
4
4
|
require 'faraday'
|
5
|
-
require 'faraday_middleware'
|
6
5
|
require 'camunda/railtie' if defined?(Rails)
|
7
6
|
# Top level module for camunda-workflow.
|
8
7
|
module Camunda
|
@@ -19,31 +18,80 @@ module Camunda
|
|
19
18
|
end
|
20
19
|
end
|
21
20
|
end
|
22
|
-
##
|
23
|
-
# Responsible for handling deserialization of variables.
|
24
|
-
class Her::Middleware::SnakeCase < Faraday::Response::Middleware
|
25
|
-
# Check if variables are an Array or JSON and ensure variable names are transformed back from camelCase to snake_case.
|
26
|
-
# @param env [Array,Hash]
|
27
|
-
def on_complete(env)
|
28
|
-
return if env[:body].blank?
|
29
21
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
22
|
+
module Middleware
|
23
|
+
class Camunda::FirstLevelParseJSON < Faraday::Middleware
|
24
|
+
# Taken from Her::Middleware::FirstLevelParseJSON
|
25
|
+
# Parse the response body
|
26
|
+
#
|
27
|
+
# @param [String] body The response body
|
28
|
+
# @return [Mixed] the parsed response
|
29
|
+
# @private
|
30
|
+
def parse(body)
|
31
|
+
json = JSON.parse body
|
32
|
+
if json.respond_to?(:keys)
|
33
|
+
errors = json.delete(:errors)
|
34
|
+
metadata = json.delete(:metadata)
|
35
|
+
end
|
36
|
+
errors ||= {}
|
37
|
+
metadata ||= {}
|
38
|
+
{
|
39
|
+
data: json,
|
40
|
+
errors: errors,
|
41
|
+
metadata: metadata
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
# This method is triggered when the response has been received. It modifies
|
46
|
+
# the value of `env[:body]`.
|
47
|
+
#
|
48
|
+
# @param [Hash] env The response environment
|
49
|
+
# @private
|
50
|
+
def on_complete(env)
|
51
|
+
str = case env[:status]
|
52
|
+
when 204
|
53
|
+
'{}'
|
54
|
+
when 200
|
55
|
+
env[:body]
|
56
|
+
when 400..599
|
57
|
+
env[:body] == '' ? '{}' : env[:body]
|
58
|
+
end
|
59
|
+
|
60
|
+
env[:body] = case env[:status]
|
61
|
+
when 400..599
|
62
|
+
{ data: nil, metadata: {}, errors: JSON.parse(str) }
|
63
|
+
else
|
64
|
+
parse str
|
65
|
+
end
|
36
66
|
end
|
37
|
-
env[:body] = JSON.generate(json)
|
38
67
|
end
|
39
68
|
|
40
|
-
|
69
|
+
# Responsible for handling deserialization of variables.
|
70
|
+
class Camunda::Middleware::SnakeCase < Faraday::Middleware
|
71
|
+
# Check if variables are an Array or JSON and ensure variable names are transformed back from camelCase to snake_case.
|
72
|
+
# @param env [Array,Hash]
|
73
|
+
def on_complete(env)
|
74
|
+
return if env[:body].blank?
|
75
|
+
|
76
|
+
json = JSON.parse(env[:body])
|
77
|
+
case json
|
78
|
+
when Array
|
79
|
+
json.map { |hash| transform_hash!(hash) }
|
80
|
+
when Hash
|
81
|
+
transform_hash!(json)
|
82
|
+
end
|
83
|
+
env[:body] = JSON.generate(json)
|
84
|
+
end
|
85
|
+
|
86
|
+
private
|
41
87
|
|
42
|
-
|
43
|
-
|
44
|
-
|
88
|
+
# Return a new hash with all keys converted by the block operation.
|
89
|
+
def transform_hash!(hash)
|
90
|
+
hash.deep_transform_keys!(&:underscore)
|
91
|
+
end
|
45
92
|
end
|
46
93
|
end
|
94
|
+
|
47
95
|
# Error when class corresponding to Camunda bpmn task does not exist.
|
48
96
|
class MissingImplementationClass < StandardError
|
49
97
|
# Initializes message for MissingImplementationClass
|
@@ -51,9 +99,11 @@ module Camunda
|
|
51
99
|
super "Class to run a Camunda activity does not exist. Ensure there is a class with name: #{class_name} available."
|
52
100
|
end
|
53
101
|
end
|
102
|
+
|
54
103
|
# Error when deployment of process definition fails.
|
55
104
|
class ProcessEngineException < StandardError
|
56
105
|
end
|
106
|
+
|
57
107
|
# Error when BPMN process cannot be deployed.
|
58
108
|
class BpmnError < StandardError
|
59
109
|
# Camunda BPMN error code
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: camunda-workflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ankur Sethi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-08-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -17,42 +17,28 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: '2.7'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: '2.7'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: spyke
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 1.
|
34
|
+
version: 7.1.1
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 1.
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: her
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - "~>"
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: 1.1.1
|
49
|
-
type: :runtime
|
50
|
-
prerelease: false
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - "~>"
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: 1.1.1
|
41
|
+
version: 7.1.1
|
56
42
|
- !ruby/object:Gem::Dependency
|
57
43
|
name: activesupport
|
58
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,61 +54,61 @@ dependencies:
|
|
68
54
|
- !ruby/object:Gem::Version
|
69
55
|
version: 3.2.0
|
70
56
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
57
|
+
name: debug
|
72
58
|
requirement: !ruby/object:Gem::Requirement
|
73
59
|
requirements:
|
74
|
-
- - "
|
60
|
+
- - ">="
|
75
61
|
- !ruby/object:Gem::Version
|
76
|
-
version: 1.
|
62
|
+
version: 1.0.0
|
77
63
|
type: :development
|
78
64
|
prerelease: false
|
79
65
|
version_requirements: !ruby/object:Gem::Requirement
|
80
66
|
requirements:
|
81
|
-
- - "
|
67
|
+
- - ">="
|
82
68
|
- !ruby/object:Gem::Version
|
83
|
-
version: 1.
|
69
|
+
version: 1.0.0
|
84
70
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
71
|
+
name: rails
|
86
72
|
requirement: !ruby/object:Gem::Requirement
|
87
73
|
requirements:
|
88
74
|
- - "~>"
|
89
75
|
- !ruby/object:Gem::Version
|
90
|
-
version: 0
|
76
|
+
version: '7.0'
|
91
77
|
type: :development
|
92
78
|
prerelease: false
|
93
79
|
version_requirements: !ruby/object:Gem::Requirement
|
94
80
|
requirements:
|
95
81
|
- - "~>"
|
96
82
|
- !ruby/object:Gem::Version
|
97
|
-
version: 0
|
83
|
+
version: '7.0'
|
98
84
|
- !ruby/object:Gem::Dependency
|
99
|
-
name:
|
85
|
+
name: rspec
|
100
86
|
requirement: !ruby/object:Gem::Requirement
|
101
87
|
requirements:
|
102
|
-
- - "
|
88
|
+
- - "~>"
|
103
89
|
- !ruby/object:Gem::Version
|
104
|
-
version:
|
90
|
+
version: 3.12.0
|
105
91
|
type: :development
|
106
92
|
prerelease: false
|
107
93
|
version_requirements: !ruby/object:Gem::Requirement
|
108
94
|
requirements:
|
109
|
-
- - "
|
95
|
+
- - "~>"
|
110
96
|
- !ruby/object:Gem::Version
|
111
|
-
version:
|
97
|
+
version: 3.12.0
|
112
98
|
- !ruby/object:Gem::Dependency
|
113
|
-
name: rspec
|
99
|
+
name: rspec-debug
|
114
100
|
requirement: !ruby/object:Gem::Requirement
|
115
101
|
requirements:
|
116
|
-
- - "
|
102
|
+
- - ">="
|
117
103
|
- !ruby/object:Gem::Version
|
118
|
-
version:
|
104
|
+
version: 0.2.0
|
119
105
|
type: :development
|
120
106
|
prerelease: false
|
121
107
|
version_requirements: !ruby/object:Gem::Requirement
|
122
108
|
requirements:
|
123
|
-
- - "
|
109
|
+
- - ">="
|
124
110
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
111
|
+
version: 0.2.0
|
126
112
|
- !ruby/object:Gem::Dependency
|
127
113
|
name: rubocop
|
128
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -241,7 +227,8 @@ files:
|
|
241
227
|
homepage: https://github.com/amalagaura/camunda-workflow
|
242
228
|
licenses:
|
243
229
|
- MIT
|
244
|
-
metadata:
|
230
|
+
metadata:
|
231
|
+
rubygems_mfa_required: 'true'
|
245
232
|
post_install_message:
|
246
233
|
rdoc_options: []
|
247
234
|
require_paths:
|