camunda-workflow 0.1.5 → 0.3.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 +62 -1
- data/CONTRIBUTING.md +2 -2
- data/README.md +107 -119
- data/lib/camunda.rb +7 -4
- data/lib/camunda/bpmn_xml.rb +7 -2
- data/lib/camunda/deployment.rb +1 -1
- data/lib/camunda/external_task.rb +35 -2
- data/lib/camunda/external_task_job.rb +1 -2
- data/lib/camunda/model.rb +8 -1
- data/lib/camunda/poller.rb +10 -9
- data/lib/camunda/process_definition.rb +11 -6
- data/lib/camunda/railtie.rb +6 -0
- data/lib/camunda/task.rb +18 -0
- data/lib/camunda/variable_serialization.rb +3 -2
- data/lib/camunda/workflow.rb +9 -2
- data/lib/camunda/workflow/version.rb +1 -1
- data/lib/generators/camunda/spring_boot/USAGE +1 -1
- data/lib/generators/camunda/spring_boot/spring_boot_generator.rb +30 -49
- data/lib/generators/camunda/spring_boot/templates/pom.xml +2 -2
- data/lib/{generators/camunda/spring_boot/templates → tasks}/camunda.rake +1 -6
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59fd3142d352f68570b4fc0ad558e0853035f733127e11fd384e3b1749103423
|
4
|
+
data.tar.gz: 20d53613e7b3d4d81cc3221d9f4bfce1cec3f80d017448cf05bc29e19f26297a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cf2d0f7ac7bb1ced5bf8d8f840fecf238d9202788c283da01794c1857926a4882fa60a065c3ca2cda094c0eed81afff09592202aeaf84ee28d298e67c2169c9
|
7
|
+
data.tar.gz: 81f51922568cda9e16826715f8fd209859a2a3ab14bf74c3767eeb2b1e60655830e301e795478f76fe9d45af22c3b1650d4a7afd3e37a89629946b6c478d7890
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,66 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.2.2](https://github.com/amalagaura/camunda-workflow/tree/v0.2.2) (2020-01-08)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/amalagaura/camunda-workflow/compare/v0.2.1...v0.2.2)
|
6
|
+
|
7
|
+
**Closed issues:**
|
8
|
+
|
9
|
+
- The task for Message End Events is on the parent node of camunda:type="external" [\#34](https://github.com/amalagaura/camunda-workflow/issues/34)
|
10
|
+
- Error in documentation regarding deployment of BPMN files. [\#32](https://github.com/amalagaura/camunda-workflow/issues/32)
|
11
|
+
|
12
|
+
**Merged pull requests:**
|
13
|
+
|
14
|
+
- Camunda calls the external task from bpmn:endEvent [\#35](https://github.com/amalagaura/camunda-workflow/pull/35) ([amalagaura](https://github.com/amalagaura))
|
15
|
+
- fixed documentation on README [\#33](https://github.com/amalagaura/camunda-workflow/pull/33) ([curatingbits](https://github.com/curatingbits))
|
16
|
+
|
17
|
+
## [v0.2.1](https://github.com/amalagaura/camunda-workflow/tree/v0.2.1) (2019-12-28)
|
18
|
+
|
19
|
+
[Full Changelog](https://github.com/amalagaura/camunda-workflow/compare/v0.2.0...v0.2.1)
|
20
|
+
|
21
|
+
**Closed issues:**
|
22
|
+
|
23
|
+
- Include gems via Railtie instead of by copying the .rake file [\#29](https://github.com/amalagaura/camunda-workflow/issues/29)
|
24
|
+
- Remove check for what bpmn\_perform returns. Ignore if not a hash. [\#27](https://github.com/amalagaura/camunda-workflow/issues/27)
|
25
|
+
|
26
|
+
**Merged pull requests:**
|
27
|
+
|
28
|
+
- Remove startup error instructions [\#31](https://github.com/amalagaura/camunda-workflow/pull/31) ([amalagaura](https://github.com/amalagaura))
|
29
|
+
- create railtie to include rake tasks [\#30](https://github.com/amalagaura/camunda-workflow/pull/30) ([curatingbits](https://github.com/curatingbits))
|
30
|
+
|
31
|
+
## [v0.2.0](https://github.com/amalagaura/camunda-workflow/tree/v0.2.0) (2019-12-20)
|
32
|
+
|
33
|
+
[Full Changelog](https://github.com/amalagaura/camunda-workflow/compare/v0.1.5...v0.2.0)
|
34
|
+
|
35
|
+
**Closed issues:**
|
36
|
+
|
37
|
+
- Change the diagrams symlink to resources and change the symlink structure [\#25](https://github.com/amalagaura/camunda-workflow/issues/25)
|
38
|
+
- remove listen note since it seems to have gone away [\#23](https://github.com/amalagaura/camunda-workflow/issues/23)
|
39
|
+
- Rename fetch\_and\_execute to fetch\_and\_queue [\#22](https://github.com/amalagaura/camunda-workflow/issues/22)
|
40
|
+
- Add a backtrace silencer to remove extra backtrace information from exceptions reported to Camunda [\#18](https://github.com/amalagaura/camunda-workflow/issues/18)
|
41
|
+
|
42
|
+
**Merged pull requests:**
|
43
|
+
|
44
|
+
- Ignore if a Hash is not returned from bpmn\_perform [\#28](https://github.com/amalagaura/camunda-workflow/pull/28) ([amalagaura](https://github.com/amalagaura))
|
45
|
+
- Change symlink structure and change bpmn/diagrams to bpmn/resources [\#26](https://github.com/amalagaura/camunda-workflow/pull/26) ([amalagaura](https://github.com/amalagaura))
|
46
|
+
- Change fetch\_and\_execute to fetch\_and\_queue [\#24](https://github.com/amalagaura/camunda-workflow/pull/24) ([amalagaura](https://github.com/amalagaura))
|
47
|
+
- Add backtrace cleaner to only relevant lines for error incidents [\#21](https://github.com/amalagaura/camunda-workflow/pull/21) ([amalagaura](https://github.com/amalagaura))
|
48
|
+
|
49
|
+
## [v0.1.5](https://github.com/amalagaura/camunda-workflow/tree/v0.1.5) (2019-12-19)
|
50
|
+
|
51
|
+
[Full Changelog](https://github.com/amalagaura/camunda-workflow/compare/v0.1.4...v0.1.5)
|
52
|
+
|
53
|
+
**Closed issues:**
|
54
|
+
|
55
|
+
- Add some more screenshots [\#16](https://github.com/amalagaura/camunda-workflow/issues/16)
|
56
|
+
|
57
|
+
**Merged pull requests:**
|
58
|
+
|
59
|
+
- Upgrading gems and changing bpmn error message [\#20](https://github.com/amalagaura/camunda-workflow/pull/20) ([amalagaura](https://github.com/amalagaura))
|
60
|
+
- Rake feature [\#19](https://github.com/amalagaura/camunda-workflow/pull/19) ([curatingbits](https://github.com/curatingbits))
|
61
|
+
- Update readme with screenshots [\#17](https://github.com/amalagaura/camunda-workflow/pull/17) ([amalagaura](https://github.com/amalagaura))
|
62
|
+
- Add assert scenario test for sample.bpmn [\#15](https://github.com/amalagaura/camunda-workflow/pull/15) ([curatingbits](https://github.com/curatingbits))
|
63
|
+
|
3
64
|
## [v0.1.4](https://github.com/amalagaura/camunda-workflow/tree/v0.1.4) (2019-12-11)
|
4
65
|
|
5
66
|
[Full Changelog](https://github.com/amalagaura/camunda-workflow/compare/v0.1.3...v0.1.4)
|
@@ -26,6 +87,7 @@
|
|
26
87
|
|
27
88
|
- Raise Submission errors if Camunda does not accept completion [\#11](https://github.com/amalagaura/camunda-workflow/pull/11) ([amalagaura](https://github.com/amalagaura))
|
28
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))
|
29
91
|
|
30
92
|
## [v0.1.2](https://github.com/amalagaura/camunda-workflow/tree/v0.1.2) (2019-11-27)
|
31
93
|
|
@@ -33,7 +95,6 @@
|
|
33
95
|
|
34
96
|
**Merged pull requests:**
|
35
97
|
|
36
|
-
- Add rubocop rspec [\#6](https://github.com/amalagaura/camunda-workflow/pull/6) ([amalagaura](https://github.com/amalagaura))
|
37
98
|
- Correct find\_by\_business\_key\_and\_task\_definition\_key! [\#5](https://github.com/amalagaura/camunda-workflow/pull/5) ([amalagaura](https://github.com/amalagaura))
|
38
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))
|
39
100
|
- Refactor to return proper Her models after responses [\#3](https://github.com/amalagaura/camunda-workflow/pull/3) ([amalagaura](https://github.com/amalagaura))
|
data/CONTRIBUTING.md
CHANGED
@@ -7,7 +7,7 @@ Make sure whatever you are adding has specs. We should be able to maintain 100%
|
|
7
7
|
|
8
8
|
### Camunda interactions
|
9
9
|
|
10
|
-
We are using VCR to record interactions with a local Camunda engine.
|
10
|
+
We are using VCR to record interactions with a local Camunda engine.
|
11
11
|
|
12
12
|
You can for instance upgrade the Camunda version, delete the `spec/vcr` folder and then re-run the specs with `bundle exec rspec`
|
13
13
|
|
@@ -17,4 +17,4 @@ This project is in the worldwide [public domain](LICENSE.md). As stated in [CONT
|
|
17
17
|
|
18
18
|
> This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/).
|
19
19
|
>
|
20
|
-
> All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.
|
20
|
+
> All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.
|
data/README.md
CHANGED
@@ -1,136 +1,142 @@
|
|
1
|
-
[![Build Status](https://travis-ci.com/amalagaura/camunda-workflow.svg?branch=master)](https://travis-ci.com/amalagaura/camunda-workflow)
|
1
|
+
[![Build Status](https://travis-ci.com/amalagaura/camunda-workflow.svg?branch=master)](https://travis-ci.com/amalagaura/camunda-workflow)
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/camunda-workflow.svg)](https://badge.fury.io/rb/camunda-workflow)
|
3
3
|
[![Inline docs](http://inch-ci.org/github/amalagaura/camunda-workflow.svg?branch=master)](http://inch-ci.org/github/amalagaura/camunda-workflow)
|
4
4
|
# Camunda Workflow
|
5
5
|
|
6
6
|
## An opinionated interface to Camunda for Ruby/Rails apps
|
7
7
|
|
8
|
-
[Her](https://github.com/remiprev/her)
|
8
|
+
Camunda Workflow uses [Her](https://github.com/remiprev/her) 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
|
-
### Add to your Gemfile
|
11
|
-
```ruby
|
12
|
-
gem 'camunda-workflow'
|
13
|
-
```
|
14
10
|
|
15
11
|
## Camunda Integration with Ruby
|
16
|
-
The process definitions key becomes the module name of your implementation classes and must be set to the name of a ruby style constant.
|
17
|
-
|
18
|
-
![image](https://user-images.githubusercontent.com/498234/70742441-899ecf00-1ceb-11ea-9eb8-42dbb08dbd2d.png)
|
19
12
|
|
13
|
+
The Camunda model process definition key is the module name of your implementation classes.
|
20
14
|
|
21
|
-
|
15
|
+
![image](https://user-images.githubusercontent.com/498234/71268690-82934480-231b-11ea-9c58-0500b7ace028.png)
|
22
16
|
|
23
|
-
|
17
|
+
An external task is created with a Ruby class name for the id. And the process definition key should be set as the topic name.
|
24
18
|
|
25
|
-
|
19
|
+
![image](https://user-images.githubusercontent.com/498234/71268753-af475c00-231b-11ea-8b39-89d2f306539b.png)
|
20
|
+
|
21
|
+
Tasks are fetched, locked and then queued. We expect classes (ActiveJob) to implement each external task. So, according to the above screenshots, the poller and queuer will expect a class called `SomeProcess::SomeTask` to be implemented in your app.
|
26
22
|
|
27
23
|
### Integration with your worker classes
|
28
24
|
|
29
|
-
|
25
|
+
Worker classes should inherit from `CamundaJob`. It is generated with `rails g camunda:install`.
|
30
26
|
|
31
|
-
|
27
|
+
`perform` is implemented on `Camunda::ExternalTaskJob`. It calls `bpmn_perform` with variables from Camunda and returns the results back to Camunda.
|
28
|
+
```
|
29
|
+
class CamundaJob < ApplicationJob
|
30
|
+
# If using Sidekiq, change to include Sidekiq::Worker instead of inheriting from ApplicationJob
|
31
|
+
include Camunda::ExternalTaskJob
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
+
class SomeProcess::SomeTask < CamundaJob
|
35
|
+
def bpmn_perform(variables)
|
36
|
+
do_something(variables[:foo])
|
34
37
|
|
35
|
-
|
38
|
+
# A hash returned will become variables in the Camunda BPMN process instance
|
39
|
+
{ foo: 'bar', foo2: { json: "str" }, array_var: ["str"] }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
```
|
36
43
|
|
44
|
+
### Exceptions create Camunda incidents
|
45
|
+
If your implementation throws an exception, it is caught and then sent to Camunda with a stack trace.
|
46
|
+
![image](https://user-images.githubusercontent.com/498234/71266361-35f93a80-2316-11ea-96ed-6501ef68f849.png)
|
47
|
+
|
48
|
+
![image](https://user-images.githubusercontent.com/498234/71269561-a22b6c80-231d-11ea-80af-b748ba7eb09a.png)
|
37
49
|
### Supporting bpmn exceptions
|
38
50
|
|
39
|
-
Camunda supports throwing bpmn exceptions on a service task to communicate logic errors and not underlying code errors. These expected errors are thrown with
|
51
|
+
Camunda supports throwing bpmn exceptions on a service task to communicate logic errors and not underlying code errors. These expected errors are thrown with
|
40
52
|
```ruby
|
41
|
-
|
53
|
+
class SomeProcess::SomeTask < CamundaJob
|
54
|
+
def bpmn_perform(variables)
|
55
|
+
result = do_something(variables[:foo])
|
56
|
+
|
57
|
+
if result == :expected
|
58
|
+
{ foo: 'bar', foo2: { json: "str" }, array_var: ["str"] }
|
59
|
+
else
|
60
|
+
raise Camunda::BpmnError.new error_code: 'bpmn-error', message: "Special BPMN error", variables: { bpmn: 'error' }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
42
64
|
```
|
43
65
|
|
44
66
|
## Generators
|
45
67
|
|
46
|
-
###
|
68
|
+
### Java Spring Boot App install
|
47
69
|
```bash
|
48
|
-
rails generate camunda:
|
70
|
+
rails generate camunda:spring_boot
|
49
71
|
```
|
72
|
+
Creates a skeleton Java Spring Boot app, which also contains the minimal files to run unit tests on a BPMN file. The Spring boot app can be used to
|
73
|
+
start a Camunda instance with a REST api and also be deployed to PCF by generating a Spring Boot jar and pushing it.
|
50
74
|
|
51
|
-
|
52
|
-
Sidekiq::Worker instead.
|
53
|
-
|
54
|
-
All of the BPMN worker classes will inherit from this class
|
55
|
-
|
56
|
-
### Java Spring Boot App install
|
75
|
+
### BPMN ActiveJob install
|
57
76
|
```bash
|
58
|
-
rails generate camunda:
|
77
|
+
rails generate camunda:install
|
59
78
|
```
|
60
|
-
Creates
|
61
|
-
|
79
|
+
Creates `app/jobs/camunda_job.rb`. A class that inherits from ApplicationJob and includes `ExternalTaskJob`. It can be changed to include `Sidekiq::Worker` instead.
|
80
|
+
|
81
|
+
All of the BPMN worker classes will inherit from this class
|
62
82
|
|
63
83
|
### BPMN Classes
|
64
84
|
```bash
|
65
85
|
rails generate camunda:bpmn_classes
|
66
86
|
```
|
67
|
-
|
68
|
-
Parses the BPMN file and creates task classes according to the ID of the process file and the ID of
|
69
|
-
each task. It checks each task and only creates it if the topic name is the same as the process ID. This
|
70
|
-
allows one to have some tasks be handled outside the Rails app. It confirms that the ID's are valid Ruby constant names.
|
87
|
+
Parses the BPMN file and creates task classes according to the ID of the process file and the ID of each task. It checks each task and only creates it if the topic name is the same as the process ID. This allows one to have some tasks be handled outside the Rails app. It confirms that the ID's are valid Ruby constant names.
|
71
88
|
|
72
89
|
#### Starting the Camunda server for development
|
73
90
|
|
74
|
-
[Java 7](https://www.java.com/en/) and [Apache Maven](https://maven.apache.org/install.html) are requirements to run
|
75
|
-
[Spring](https://docs.spring.io/spring-boot/docs/1.5.21.RELEASE/reference/html/getting-started-system-requirements.html).
|
76
|
-
Make sure all requirements for Spring are satisfied before starting Camunda engine via spring boot.
|
91
|
+
[Java 7](https://www.java.com/en/) and [Apache Maven](https://maven.apache.org/install.html) are requirements to run the Camunda server. We are using the [Spring](https://docs.spring.io/spring-boot/docs/1.5.21.RELEASE/reference/html/getting-started-system-requirements.html) distribution. The Camunda application has a `pom.xml`, which Maven uses to install the required dependencies.
|
77
92
|
|
78
|
-
Start the application:
|
93
|
+
Start the application:
|
79
94
|
```bash
|
80
|
-
|
81
|
-
```
|
82
|
-
```bash
|
95
|
+
cd bpmn/java_app
|
83
96
|
mvn spring-boot:run
|
84
|
-
```
|
85
|
-
The following Rake commands are available to maintain the spring boot server.
|
86
|
-
|
87
|
-
```Bash
|
88
|
-
# Install the spring-boot app dependencies.
|
89
|
-
rake camunda:install
|
90
|
-
```
|
91
|
-
We suggest (not required) running the install command before running the spring boot server for the first time or if the pom.xml file is updated. The
|
92
|
-
install cleans up artifacts created by prior builds and installs the package dependencies into the local repository.
|
93
97
|
|
94
|
-
|
95
|
-
# Start the Camunda spring boot app
|
98
|
+
# Or use the included rake task:
|
99
|
+
# Start the Camunda spring boot app with `mvn spring-boot:run`
|
96
100
|
rake camunda:run
|
97
101
|
```
|
98
102
|
|
103
|
+
If you create Java based unit tests for your bpmn file they can be run with an included rake task as well.
|
104
|
+
|
105
|
+
|
106
|
+
#### Running java unit tests
|
99
107
|
```bash
|
100
|
-
|
108
|
+
cd bpmn/java_app
|
109
|
+
mvn clean test
|
110
|
+
|
111
|
+
# Or use the included rake task:
|
112
|
+
# Runs spring boot test suite with `mvn clean test`
|
101
113
|
rake camunda:test
|
102
114
|
```
|
103
|
-
|
104
|
-
|
105
|
-
Camunda-workflow defaults to an in-memory, h2 database engine. If you rather use a Postgres database engine, comment out the
|
106
|
-
h2 database engine settings in the `pom.xml` file located in `bpmn/java_app`. Default settings for using Postgres are available in the `pom.xml` file.
|
107
|
-
You will need to create a Postgres database on localhost called `camunda`.
|
108
115
|
|
109
|
-
|
110
|
-
|
111
|
-
the engine prefix is `rest-engine`. Camunda-workflow is configured to use `rest-engine`.
|
116
|
+
Camunda-workflow defaults to an in-memory, h2 database engine. If you rather use a Postgres database engine, comment out the h2 database engine settings in the `pom.xml` file located in `bpmn/java_app`. Default settings for using Postgres are available in the `pom.xml` file.
|
117
|
+
You will need to create a Postgres database on localhost called `camunda`.
|
112
118
|
|
113
|
-
|
114
|
-
|
119
|
+
### Configuration
|
120
|
+
#### Engine Route Prefix of the Java Spring Boot app
|
121
|
+
The default engine route prefix for the provided Java Spring Boot app is `rest`. If you choose to download and use the Camunda distribution, the engine prefix is `rest-engine`. Camunda-workflow is configured to use `rest` by default.
|
115
122
|
|
123
|
+
To override the default engine route prefix, you need to add an initializer file in your rails app.
|
116
124
|
|
117
125
|
```ruby
|
118
126
|
# filename initializers/camunda.rb
|
119
127
|
Camunda::Workflow.configure do |config|
|
120
|
-
config.engine_route_prefix = 'rest'
|
128
|
+
config.engine_route_prefix = 'rest-engine'
|
121
129
|
end
|
122
130
|
```
|
123
131
|
#### Enable HTTP Basic Auth for Java Spring Boot app
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
Otherwise, the request will return as `401 unauthorized`. Users are set up within the admin dashboard of Camunda and used to authenticate by passing an Authorization header during requests to the REST API. Below is how to configure
|
128
|
-
the `camunda_user` and `camunda_password` to be used in the header request to authenticate using HTTP Basic Auth.
|
132
|
+
|
133
|
+
Authentication can be enabled in the Camunda Java Spring Boot app by setting an environment variable `CAMUNDA_AUTH` to `true` or `false` or by setting the `camunda.authentication` variable located in the `application.properties` (bpmn/java_app/src/main/resources) file to `true`.
|
134
|
+
|
135
|
+
When HTTP Basic Auth is enabled, it's required that a user with the appropriate permissions is setup in Camunda. Otherwise, the request will return as `401 unauthorized`. Users are set up within the admin dashboard of Camunda and used to authenticate by passing an Authorization header during requests to the REST API. Below is how to configure the `camunda_user` and `camunda_password` to be used in the header request to authenticate using HTTP Basic Auth.
|
129
136
|
|
130
137
|
```ruby
|
131
138
|
# filename initializers/camunda.rb
|
132
139
|
Camunda::Workflow.configure do |config|
|
133
|
-
config.engine_route_prefix = 'rest'
|
134
140
|
config.camunda_user = ENV['CAMUNDA_USER']
|
135
141
|
config.camunda_password = ENV['CAMUNDA_PASSWORD']
|
136
142
|
end
|
@@ -145,19 +151,18 @@ The jar is in `target/camunda-bpm-springboot.jar`
|
|
145
151
|
|
146
152
|
It will fail to start. Create a postgres database as a service in PCF and bind it to the application. The Springboot application is configured for Postgres and will then be able to start.
|
147
153
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
154
|
+
## Usage
|
155
|
+
|
156
|
+
### Add to your Gemfile
|
157
|
+
```ruby
|
158
|
+
gem 'camunda-workflow'
|
152
159
|
```
|
153
160
|
|
154
|
-
## Usage
|
155
161
|
### Deploying a model
|
156
|
-
Uses a default name, etc. Below outlines how to deploy a process using the included sample.bpmn
|
157
|
-
file created by the generator. Alternatively you can deploy using Camunda Modeler
|
162
|
+
Uses a default name, etc. Below outlines how to deploy a process using the included sample.bpmn file created by the generator. Alternatively you can deploy using Camunda Modeler
|
158
163
|
|
159
164
|
```ruby
|
160
|
-
|
165
|
+
Camunda::Deployment.create file_names: ['bpmn/diagrams/sample.bpmn']
|
161
166
|
```
|
162
167
|
### Processes
|
163
168
|
|
@@ -176,47 +181,54 @@ will be converted to:
|
|
176
181
|
|
177
182
|
#### Destroy a process
|
178
183
|
```ruby
|
179
|
-
|
180
|
-
```
|
184
|
+
Camunda::ProcessInstance.destroy_existing start_response.id
|
185
|
+
```
|
181
186
|
|
182
187
|
### Tasks
|
183
188
|
|
184
189
|
#### Fetch tasks and queue with ActiveJob
|
185
190
|
|
186
|
-
The poller
|
187
|
-
|
191
|
+
The poller runs an infinite loop with long polling to fetch tasks, queue, and run them. The topic is the process definition key, as shown in the screenshot example from the Camunda Modeler.
|
192
|
+
|
193
|
+
Below will run the poller to fetch, lock, and run a task for the example process definition located in the `starting a process` detailed above.
|
188
194
|
|
189
|
-
|
190
|
-
the `starting a process` detailed above.
|
195
|
+
Poller will need to run in a separate process or thread and needs to be running constantly in order to poll Camunda and queue jobs.
|
191
196
|
|
192
197
|
```ruby
|
193
|
-
|
198
|
+
Camunda::Poller.fetch_and_queue %w[CamundaWorkflow]
|
199
|
+
```
|
200
|
+
|
201
|
+
#### Running the poller in a separate thread
|
202
|
+
We have had success with running a long running thread in a Rails app using [Rufus Scheduler](https://github.com/jmettraux/rufus-scheduler). Something like:
|
203
|
+
|
204
|
+
```
|
205
|
+
rufus_scheduler.in('10.seconds') do
|
206
|
+
Camunda::Poller.fetch_and_queue %w[Topics]
|
207
|
+
end
|
194
208
|
```
|
195
209
|
|
196
|
-
#### Fetch tasks
|
197
|
-
For testing from the console
|
198
210
|
|
199
|
-
|
200
|
-
tasks = Camunda::ExternalTask.fetch_and_lock %w[CamundaWorkflow]
|
201
|
-
```
|
211
|
+
#### Fetch tasks For testing from the console
|
202
212
|
|
213
|
+
```ruby
|
214
|
+
tasks = Camunda::ExternalTask.fetch_and_lock %w[CamundaWorkflow]
|
215
|
+
```
|
203
216
|
#### Run a task
|
204
217
|
|
205
218
|
```ruby
|
206
|
-
|
207
|
-
```
|
219
|
+
tasks.each(&:run_now)
|
220
|
+
```
|
208
221
|
|
209
222
|
|
210
223
|
### User Tasks
|
211
224
|
#### Mark a user task complete
|
212
225
|
```ruby
|
213
|
-
|
214
|
-
|
215
|
-
task.complete!(var1: 'value')
|
226
|
+
# Or you can query Camunda::Task with other parameters like assignee task.complete!(var1: 'value')
|
227
|
+
Camunda::Task.find_by_business_key_and_task_definition_key!(instance_business_key, task_key).complete!
|
216
228
|
```
|
217
229
|
|
218
230
|
### Rspec Helpers
|
219
|
-
RSpec helpers
|
231
|
+
RSpec helpers validate your application to make sure it has a class for every External task in a given BPMN file.
|
220
232
|
```ruby
|
221
233
|
require 'camunda/matchers'
|
222
234
|
|
@@ -228,30 +240,6 @@ RSpec.describe "BPMN Diagrams" do
|
|
228
240
|
end
|
229
241
|
end
|
230
242
|
```
|
231
|
-
#### Note:
|
232
|
-
|
233
|
-
If you get an error
|
234
|
-
|
235
|
-
** ERROR: directory is already being watched! **
|
236
|
-
|
237
|
-
Directory: bpmn/java_app/src/main/resources
|
238
|
-
is already being watched through: bpmn/diagrams
|
239
|
-
|
240
|
-
MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
|
241
|
-
|
242
|
-
It is because ActionMailer preview causes test/mailers/previews to get added to the Rails EventedFileChecker
|
243
|
-
by default. RSpec is supposed to override it, but it is not
|
244
|
-
appropriately overridden for EventedFileChecker and/or you don't have spec/mailers/preview existing. If that
|
245
|
-
directory does not exist, it goes to the first common directory that exists, which is your Rails root folder.
|
246
|
-
So EventedFileChecker is listening to your entire Rails folder. Not a big problem, but it causes a problem
|
247
|
-
for our created symlink.
|
248
|
-
|
249
|
-
So add:
|
250
|
-
|
251
|
-
config.action_mailer.show_previews = false
|
252
|
-
|
253
|
-
to your `development.rb` file to solve listen errors about a symlink. Unless you are using ActionMailer
|
254
|
-
previews, in which case you should have the directory created already.
|
255
243
|
|
256
244
|
## Contributing
|
257
245
|
|
data/lib/camunda.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
|
-
require 'active_support/core_ext/string/inflections
|
2
|
-
require 'active_support/core_ext/object/blank
|
1
|
+
require 'active_support/core_ext/string/inflections'
|
2
|
+
require 'active_support/core_ext/object/blank'
|
3
3
|
require 'her'
|
4
4
|
require 'faraday'
|
5
5
|
require 'faraday_middleware'
|
6
|
+
require 'camunda/railtie' if defined?(Rails)
|
6
7
|
# Top level module for camunda-workflow.
|
7
8
|
module Camunda
|
8
9
|
# Camunda class
|
9
10
|
class << self
|
10
11
|
# Allows setting the logger to a custom logger
|
11
12
|
attr_writer :logger
|
13
|
+
|
12
14
|
# Default is output to the standard output stream.
|
13
15
|
# @return [Object] instance which is used for logging
|
14
16
|
def logger
|
@@ -26,9 +28,10 @@ module Camunda
|
|
26
28
|
return if env[:body].blank?
|
27
29
|
|
28
30
|
json = JSON.parse(env[:body])
|
29
|
-
|
31
|
+
case json
|
32
|
+
when Array
|
30
33
|
json.map { |hash| transform_hash!(hash) }
|
31
|
-
|
34
|
+
when Hash
|
32
35
|
transform_hash!(json)
|
33
36
|
end
|
34
37
|
env[:body] = JSON.generate(json)
|
data/lib/camunda/bpmn_xml.rb
CHANGED
@@ -20,9 +20,14 @@ class Camunda::BpmnXML
|
|
20
20
|
|
21
21
|
# creates a new instance of Camunda::BpmnXML::Task
|
22
22
|
def external_tasks
|
23
|
-
@doc.xpath('
|
23
|
+
@doc.xpath('(//bpmn:serviceTask[@camunda:type="external"]|//bpmn:sendTask[@camunda:type="external"])').map do |task|
|
24
24
|
Task.new(task)
|
25
|
-
end
|
25
|
+
end +
|
26
|
+
@doc.xpath('//bpmn:endEvent/bpmn:messageEventDefinition[@camunda:type="external"]').map do |child_node|
|
27
|
+
task = child_node.parent.dup
|
28
|
+
task["topic"] = child_node["topic"]
|
29
|
+
Task.new(task)
|
30
|
+
end
|
26
31
|
end
|
27
32
|
|
28
33
|
# We may have tasks with different topics. Returns classes with topics which are the same as the BPMN process id
|
data/lib/camunda/deployment.rb
CHANGED
@@ -10,7 +10,7 @@ class Camunda::Deployment < Camunda::Model
|
|
10
10
|
# Deploys a new process definition to Camunda and returns an instance of Camunda::ProcessDefinition.
|
11
11
|
# @note Only supporting .create which uses a POST on deployment/create.
|
12
12
|
# @example
|
13
|
-
# pd = Camunda::Deployment.create(file_names: ['bpmn/
|
13
|
+
# pd = Camunda::Deployment.create(file_names: ['bpmn/resources/sample.bpmn']).first
|
14
14
|
# @param files_names [Array<String>] file paths of the bpmn file for deployment
|
15
15
|
# @param tenant_id [String] supplied when a single Camunda installation should serve more than one tenant
|
16
16
|
# @param deployment_source [String] the source of where the deployment occurred.
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require 'active_support/core_ext/string/inflections
|
1
|
+
require 'active_support/core_ext/string/inflections'
|
2
|
+
require 'active_support/backtrace_cleaner'
|
2
3
|
# External Tasks are the task entity for camunda. We can query the topic and lock the task. After the task
|
3
4
|
# is locked, the external task of the process instance can be worked and completed. Below is an excerpt from the Camunda
|
4
5
|
# documentation regarding the ExternalTask process.
|
@@ -41,7 +42,9 @@ class Camunda::ExternalTask < Camunda::Model
|
|
41
42
|
variables_information = "Input variables are #{input_variables.inspect}\n\n" if input_variables.present?
|
42
43
|
self.class.post_raw("#{collection_path}/#{id}/failure",
|
43
44
|
workerId: worker_id, errorMessage: exception.message,
|
44
|
-
errorDetails:
|
45
|
+
errorDetails:
|
46
|
+
variables_information.to_s + exception.message +
|
47
|
+
backtrace_cleaner.clean(exception.backtrace).join("\n"))[:response]
|
45
48
|
end
|
46
49
|
|
47
50
|
# Reports the error to Camunda and creates an incident for the process instance.
|
@@ -130,6 +133,25 @@ class Camunda::ExternalTask < Camunda::Model
|
|
130
133
|
topics: topic_details
|
131
134
|
end
|
132
135
|
|
136
|
+
# Locking means that the task is reserved for this worker for a certain duration beginning with the time of fetching and
|
137
|
+
# prevents that another worker can fetch the same task while the lock is valid. Locking duration is set in the the
|
138
|
+
# Camunda::Workflow configuration. Before an external task can be completed, it must be locked.
|
139
|
+
#
|
140
|
+
# This method calls fetch_and_lock and then queues the jobs that were retrieved
|
141
|
+
# @example
|
142
|
+
# task = Camunda::ExternalTask.fetch_and_queue("CamundaWorkflow")
|
143
|
+
# @param topics [Array<String>] definition keys
|
144
|
+
# @param lock_duration [Integer]
|
145
|
+
# @param long_polling_duration [Integer]
|
146
|
+
# @return [Camunda::ExternalTask]
|
147
|
+
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).each do |task|
|
149
|
+
task.queue_task
|
150
|
+
rescue Camunda::MissingImplementationClass => e
|
151
|
+
task.failure(e)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
133
155
|
# Returns the class name which is supposed to implement this task
|
134
156
|
# @return [String] modularized class name of bpmn task implementation
|
135
157
|
def task_class_name
|
@@ -144,6 +166,17 @@ class Camunda::ExternalTask < Camunda::Model
|
|
144
166
|
raise Camunda::MissingImplementationClass, task_class_name unless klass
|
145
167
|
end
|
146
168
|
end
|
169
|
+
|
170
|
+
private
|
171
|
+
|
172
|
+
def backtrace_cleaner
|
173
|
+
@backtrace_cleaner ||= ActiveSupport::BacktraceCleaner.new.tap do |bc|
|
174
|
+
Camunda::Workflow.configuration.backtrace_silencer_lines.each do |line|
|
175
|
+
bc.add_silencer { |exception_line| exception_line =~ /#{line}/ }
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
147
180
|
# If the BPMN file expects a variable and the variable isn't supplied with an SubmissionError will be raised
|
148
181
|
# indicating that the variable does not exist.
|
149
182
|
class SubmissionError < StandardError
|
@@ -13,8 +13,7 @@ module Camunda::ExternalTaskJob
|
|
13
13
|
# @raise [Camunda::ExternalTask::SubmissionError] if Camunda does not accept the submission of the task
|
14
14
|
def perform(id, input_variables)
|
15
15
|
output_variables = bpmn_perform(input_variables)
|
16
|
-
output_variables = {}
|
17
|
-
raise ArgumentError, "Expected a hash, got #{output_variables}" unless output_variables.is_a?(Hash)
|
16
|
+
output_variables = {} unless output_variables.is_a?(Hash)
|
18
17
|
|
19
18
|
report_completion id, output_variables
|
20
19
|
rescue Camunda::BpmnError => e
|
data/lib/camunda/model.rb
CHANGED
@@ -3,6 +3,10 @@ require 'her/model'
|
|
3
3
|
class Camunda::Model
|
4
4
|
include Her::Model
|
5
5
|
|
6
|
+
def self.log_details?
|
7
|
+
defined?(Rails) && Rails.env.development?
|
8
|
+
end
|
9
|
+
|
6
10
|
# We use a lambda so that this is evaluated after Camunda::Workflow.configuration is set
|
7
11
|
api = lambda do
|
8
12
|
# Configuration for Her and Faraday requests and responses
|
@@ -14,12 +18,15 @@ class Camunda::Model
|
|
14
18
|
c.use Faraday::Request::BasicAuthentication, Camunda::Workflow.configuration.camunda_user,
|
15
19
|
Camunda::Workflow.configuration.camunda_password
|
16
20
|
# Response
|
17
|
-
c.use Faraday::Response::Logger, ActiveSupport::Logger.new(
|
21
|
+
c.use Faraday::Response::Logger, ActiveSupport::Logger.new($stdout), bodies: true if log_details?
|
18
22
|
c.use Her::Middleware::FirstLevelParseJSON
|
19
23
|
|
20
24
|
c.use Her::Middleware::SnakeCase
|
21
25
|
# Adapter
|
22
26
|
c.adapter :net_http
|
27
|
+
|
28
|
+
# HTTP proxy
|
29
|
+
c.proxy = Camunda::Workflow.configuration.http_proxy if Camunda::Workflow.configuration.http_proxy
|
23
30
|
end
|
24
31
|
end
|
25
32
|
|
data/lib/camunda/poller.rb
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
# The poller will run as an infinite loop with long polling to fetch tasks, queue, and run them.
|
2
|
-
# Topic is the process definition key. Below will run the poller to fetch, lock, and
|
2
|
+
# Topic is the process definition key. Below will run the poller to fetch, lock, and queue a task for the
|
3
3
|
# example process definition with an id of CamundaWorkflow.
|
4
4
|
# @example
|
5
|
-
# Camunda::Poller.
|
5
|
+
# Camunda::Poller.fetch_and_queue %w[CamundaWorkflow]
|
6
6
|
class Camunda::Poller
|
7
|
+
# @deprecated Please use {#fetch_and_queue} instead
|
8
|
+
def self.fetch_and_execute(topics, lock_duration: nil, long_polling_duration: nil)
|
9
|
+
warn "[DEPRECATION] `fetch_and_execute` is deprecated. Please use `fetch_and_queue` instead."
|
10
|
+
fetch_and_queue(topics, lock_duration: lock_duration, long_polling_duration: long_polling_duration)
|
11
|
+
end
|
12
|
+
|
7
13
|
# @param topics [Array] process definition keys
|
8
14
|
# @param lock_duration [Integer] lock duration time, default time is set in Camunda::Workflow.configuration
|
9
15
|
# @param long_polling_duration [Integer] long polling time, default is set to Camunda::Workflow.configuration
|
10
|
-
def self.
|
16
|
+
def self.fetch_and_queue(topics, lock_duration: nil, long_polling_duration: nil)
|
11
17
|
loop do
|
12
|
-
Camunda::ExternalTask
|
13
|
-
.fetch_and_lock(topics, lock_duration: lock_duration, long_polling_duration: long_polling_duration).each do |task|
|
14
|
-
task.queue_task
|
15
|
-
rescue Camunda::MissingImplementationClass => e
|
16
|
-
task.failure(e)
|
17
|
-
end
|
18
|
+
Camunda::ExternalTask.fetch_and_queue(topics, lock_duration: lock_duration, long_polling_duration: long_polling_duration)
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
@@ -23,9 +23,7 @@ class Camunda::ProcessDefinition < Camunda::Model
|
|
23
23
|
tenant_id ||= Camunda::Workflow.configuration.tenant_id
|
24
24
|
|
25
25
|
response = post_raw start_path_for_key(key, tenant_id), hash
|
26
|
-
|
27
|
-
|
28
|
-
Camunda::ProcessInstance.new response[:parsed_data][:data]
|
26
|
+
process_instance_result(response)
|
29
27
|
end
|
30
28
|
|
31
29
|
# Starts an individual process instance for a process definition. The below example shows how to start a process
|
@@ -40,9 +38,7 @@ class Camunda::ProcessDefinition < Camunda::Model
|
|
40
38
|
def start(hash={})
|
41
39
|
hash[:variables] = serialize_variables(hash[:variables]) if hash[:variables]
|
42
40
|
response = self.class.post_raw "process-definition/#{id}/start", hash
|
43
|
-
|
44
|
-
|
45
|
-
Camunda::ProcessInstance.new response[:parsed_data][:data]
|
41
|
+
self.class.process_instance_result(response)
|
46
42
|
end
|
47
43
|
|
48
44
|
# Sets path to include tenant_id if a tenant_id is provided with a process definition on deployment.
|
@@ -51,4 +47,13 @@ class Camunda::ProcessDefinition < Camunda::Model
|
|
51
47
|
path << "/tenant-id/#{tenant_id}" if tenant_id
|
52
48
|
"#{path}/start"
|
53
49
|
end
|
50
|
+
|
51
|
+
def self.process_instance_result(response)
|
52
|
+
unless response[:response].status == 200
|
53
|
+
raise Camunda::ProcessEngineException,
|
54
|
+
"#{response[:parsed_data][:data][:message]} HTTP Status: #{response[:response].status}"
|
55
|
+
end
|
56
|
+
|
57
|
+
Camunda::ProcessInstance.new response[:parsed_data][:data]
|
58
|
+
end
|
54
59
|
end
|
data/lib/camunda/task.rb
CHANGED
@@ -35,6 +35,24 @@ class Camunda::Task < Camunda::Model
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
def bpmn_error!(error_code, error_message, vars={})
|
39
|
+
self.class
|
40
|
+
.post_raw("#{self.class.collection_path}/#{id}/bpmnError", errorCode: error_code, errorMessage: error_message,
|
41
|
+
variables: serialize_variables(vars))[:response]
|
42
|
+
.tap do |response|
|
43
|
+
raise SubmissionError, response.body[:data][:message] unless response.success?
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def bpmn_escalation!(escalation_code, vars={})
|
48
|
+
self.class
|
49
|
+
.post_raw("#{self.class.collection_path}/#{id}/bpmnEscalation", escalationCode: escalation_code,
|
50
|
+
variables: serialize_variables(vars))[:response]
|
51
|
+
.tap do |response|
|
52
|
+
raise SubmissionError, response.body[:data][:message] unless response.success?
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
38
56
|
# Error class when the task cannot be submitted. For instance if the bpmn process expects a variable and the variable
|
39
57
|
# isn't supplied, Camunda will not accept the task
|
40
58
|
class SubmissionError < StandardError
|
@@ -41,9 +41,10 @@ module Camunda
|
|
41
41
|
# @param json [Array,Hash]
|
42
42
|
# @return [Hash] returns hash with camelCase keys
|
43
43
|
def transform_json(json)
|
44
|
-
|
44
|
+
case json
|
45
|
+
when Array
|
45
46
|
json.map { |element| transform_json(element) }
|
46
|
-
|
47
|
+
when Hash
|
47
48
|
camelcase_keys(json)
|
48
49
|
else
|
49
50
|
json
|
data/lib/camunda/workflow.rb
CHANGED
@@ -11,7 +11,7 @@ module Camunda
|
|
11
11
|
# Implements Configuration class and sets default instance variables. The default variables can be overridden by creating an
|
12
12
|
# initializer file within your rails application and setting the variables like in the example below.
|
13
13
|
# @note if HTTP Basic Auth is used with the Camunda engine, this is where you would set a camunda_user and camunda_password
|
14
|
-
# using the
|
14
|
+
# using the credentials from a user setup in Camunda Admin.
|
15
15
|
# @example
|
16
16
|
# 'Camunda::Workflow.configure do |config|
|
17
17
|
# config.engine_url = 'http://localhost:8080'
|
@@ -61,16 +61,23 @@ module Camunda
|
|
61
61
|
# Camunda password is supplied with the Camunda user to authenticate using HTTP Basic Auth.
|
62
62
|
# @return [String] Camunda password for HTTP Basic Auth
|
63
63
|
attr_accessor :camunda_password
|
64
|
+
# Can configure the backtrace silencer
|
65
|
+
# @return [Array<String>] List of backtrace silencer strings which are used to clean incident backtraces
|
66
|
+
attr_accessor :backtrace_silencer_lines
|
67
|
+
# Configure an HTTP proxy for all requests to use
|
68
|
+
# @return [String] The defined HTTP proxy
|
69
|
+
attr_accessor :http_proxy
|
64
70
|
|
65
71
|
def initialize
|
66
72
|
@engine_url = 'http://localhost:8080'
|
67
|
-
@engine_route_prefix = 'rest
|
73
|
+
@engine_route_prefix = 'rest'
|
68
74
|
@camunda_user = ''
|
69
75
|
@camunda_password = ''
|
70
76
|
@worker_id = '0'
|
71
77
|
@lock_duration = 14.days
|
72
78
|
@max_polling_tasks = 2
|
73
79
|
@long_polling_duration = 30.seconds
|
80
|
+
@backtrace_silencer_lines = %w[gems/activesupport gems/sidekiq gems/activejob gems/i18n gems/actionpack]
|
74
81
|
@tenant_id = if defined?(Rails)
|
75
82
|
Rails.env.test? ? 'test-environment' : nil
|
76
83
|
end
|
@@ -9,4 +9,4 @@ Example:
|
|
9
9
|
|
10
10
|
with a sample BPMN file and Unit Test.
|
11
11
|
|
12
|
-
The suggested location for your BPMN file is in `bpmn/
|
12
|
+
The suggested location for your BPMN file is in `bpmn/resources` which symlinks to `bpmn/java_app/src/main/resources`.
|
@@ -5,28 +5,28 @@ module Camunda
|
|
5
5
|
# Spring Boot jar and pushing it.
|
6
6
|
class SpringBootGenerator < Rails::Generators::Base
|
7
7
|
source_root File.expand_path('templates', __dir__)
|
8
|
-
class_option :
|
9
|
-
class_option :
|
8
|
+
class_option :bpmn_folder_name, type: :string, default: 'bpmn'
|
9
|
+
class_option :java_app_folder_name, type: :string, default: 'java_app'
|
10
|
+
class_option :resources_folder_name, type: :string, default: 'resources'
|
10
11
|
|
11
|
-
# Links resources to
|
12
|
+
# Links resources to the java app resources folder
|
12
13
|
def link_resources_folder
|
13
|
-
create_link File.join(
|
14
|
-
end
|
15
|
-
|
16
|
-
# Copies a sample bpmn file to help demonstrate the usage for camunda-workflow
|
17
|
-
def copy_sample_bpmn
|
18
|
-
copy_file 'sample.bpmn', File.join(diagram_path, 'sample.bpmn'), ''
|
19
|
-
copy_file 'ProcessScenarioTest.java', File.join(bpmn_app_path, 'src/test/java/unittest/ProcessScenarioTest.java')
|
14
|
+
create_link resources_path, File.join(java_app_folder_name, 'src/main/resources/')
|
20
15
|
end
|
21
16
|
|
22
17
|
# Copies all spring boot files into a rails application and provides a Camunda engine for testing.
|
23
18
|
def copy_java_app_files
|
24
|
-
copy_file 'pom.xml', File.join(
|
25
|
-
copy_file 'camunda.cfg.xml', File.join(
|
26
|
-
copy_file 'logback.xml', File.join(
|
27
|
-
copy_file 'application.properties', File.join(
|
28
|
-
copy_file 'Camunda.java', File.join(
|
29
|
-
|
19
|
+
copy_file 'pom.xml', File.join(java_app_path, 'pom.xml')
|
20
|
+
copy_file 'camunda.cfg.xml', File.join(java_app_path, 'src/test/resources/camunda.cfg.xml')
|
21
|
+
copy_file 'logback.xml', File.join(java_app_path, 'src/main/resources/logback.xml')
|
22
|
+
copy_file 'application.properties', File.join(java_app_path, 'src/main/resources/application.properties')
|
23
|
+
copy_file 'Camunda.java', File.join(java_app_path, 'src/main/java/camunda/Camunda.java')
|
24
|
+
end
|
25
|
+
|
26
|
+
# Copies a sample bpmn file to help demonstrate the usage for camunda-workflow
|
27
|
+
def copy_sample_bpmn
|
28
|
+
copy_file 'sample.bpmn', File.join(resources_path, 'sample.bpmn')
|
29
|
+
copy_file 'ProcessScenarioTest.java', File.join(java_app_path, 'src/test/java/unittest/ProcessScenarioTest.java')
|
30
30
|
end
|
31
31
|
|
32
32
|
# Add spring boot files to .gitignore
|
@@ -35,50 +35,31 @@ module Camunda
|
|
35
35
|
ignores << '.cfignore' if File.exist?('.cfignore')
|
36
36
|
ignores.each do |file|
|
37
37
|
append_to_file file do
|
38
|
-
"\n# BPMN Java app\n"
|
39
|
-
File.join(bpmn_app_path, 'target') +
|
40
|
-
"\n"
|
38
|
+
"\n# BPMN Java app\n#{File.join(java_app_path, 'target')}\n"
|
41
39
|
end
|
42
40
|
end
|
43
41
|
end
|
44
42
|
|
45
|
-
|
46
|
-
def output_error_instructions
|
47
|
-
puts <<~DOC
|
48
|
-
If you get an error when starting your Rails app
|
49
|
-
|
50
|
-
** ERROR: directory is already being watched! **
|
51
|
-
|
52
|
-
Directory: bpmn/java_app/src/main/resources
|
53
|
-
is already being watched through: bpmn/diagrams
|
54
|
-
|
55
|
-
MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
|
56
|
-
|
57
|
-
It is because ActionMailer preview causes test/mailers/previews to get added to the Rails EventedFileChecker
|
58
|
-
by default. RSpec is supposed to override it, but it is not overridden properly for EventedFileChecker and/or
|
59
|
-
you don't have spec/mailers/preview existing. If that directory does not exist it goes to the first common
|
60
|
-
directory that exists which is your Rails root folder.
|
61
|
-
|
62
|
-
So EventedFileChecker is listening to your entire Rails folder. Not a big problem, but it causes a problem
|
63
|
-
for our created symlink.
|
64
|
-
|
65
|
-
So add:
|
43
|
+
private
|
66
44
|
|
67
|
-
|
45
|
+
def bpmn_folder_name
|
46
|
+
options['bpmn_folder_name']
|
47
|
+
end
|
68
48
|
|
69
|
-
|
70
|
-
|
71
|
-
DOC
|
49
|
+
def java_app_folder_name
|
50
|
+
options['java_app_folder_name']
|
72
51
|
end
|
73
52
|
|
74
|
-
|
53
|
+
def resources_folder_name
|
54
|
+
options['resources_folder_name']
|
55
|
+
end
|
75
56
|
|
76
|
-
def
|
77
|
-
|
57
|
+
def resources_path
|
58
|
+
File.join(bpmn_folder_name, resources_folder_name)
|
78
59
|
end
|
79
60
|
|
80
|
-
def
|
81
|
-
|
61
|
+
def java_app_path
|
62
|
+
File.join(bpmn_folder_name, java_app_folder_name)
|
82
63
|
end
|
83
64
|
end
|
84
65
|
end
|
@@ -12,10 +12,10 @@
|
|
12
12
|
<description>A Process Application for [Camunda BPM](http://docs.camunda.org).</description>
|
13
13
|
|
14
14
|
<properties>
|
15
|
-
<camunda.version>7.12.0
|
15
|
+
<camunda.version>7.12.0</camunda.version>
|
16
16
|
<!--
|
17
17
|
Adjust if you want to use Camunda Enterprise Edition (EE):
|
18
|
-
<camunda.version>7.
|
18
|
+
<camunda.version>7.12.0-ee</camunda.version>
|
19
19
|
Make sure you also switch to the ee webapp dependency
|
20
20
|
and EE repository below
|
21
21
|
-->
|
@@ -15,11 +15,6 @@ namespace :camunda do
|
|
15
15
|
# Runs spring boot test suite e.g. mvn test.
|
16
16
|
desc 'Runs test suite for Camunda spring-boot application'
|
17
17
|
task :test do
|
18
|
-
system('mvn test', chdir: mvn_path)
|
19
|
-
end
|
20
|
-
# Installs the spring-boot app dependencies mvn clean install.
|
21
|
-
desc 'Installs spring-boot dependencies for Camunda spring-boot app.'
|
22
|
-
task :install do
|
23
|
-
system('mvn clean install -DskipTests=true', chdir: mvn_path)
|
18
|
+
system('mvn clean test', chdir: mvn_path)
|
24
19
|
end
|
25
20
|
end
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: camunda-workflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ankur Sethi
|
8
8
|
- Duggan Roberts
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
date: 2019-11-22 00:00:00.000000000 Z
|
@@ -215,6 +215,7 @@ files:
|
|
215
215
|
- lib/camunda/poller.rb
|
216
216
|
- lib/camunda/process_definition.rb
|
217
217
|
- lib/camunda/process_instance.rb
|
218
|
+
- lib/camunda/railtie.rb
|
218
219
|
- lib/camunda/signal.rb
|
219
220
|
- lib/camunda/task.rb
|
220
221
|
- lib/camunda/variable_serialization.rb
|
@@ -233,15 +234,15 @@ files:
|
|
233
234
|
- lib/generators/camunda/spring_boot/templates/ProcessScenarioTest.java
|
234
235
|
- lib/generators/camunda/spring_boot/templates/application.properties
|
235
236
|
- lib/generators/camunda/spring_boot/templates/camunda.cfg.xml
|
236
|
-
- lib/generators/camunda/spring_boot/templates/camunda.rake
|
237
237
|
- lib/generators/camunda/spring_boot/templates/logback.xml
|
238
238
|
- lib/generators/camunda/spring_boot/templates/pom.xml
|
239
239
|
- lib/generators/camunda/spring_boot/templates/sample.bpmn
|
240
|
+
- lib/tasks/camunda.rake
|
240
241
|
homepage: https://github.com/amalagaura/camunda-workflow
|
241
242
|
licenses:
|
242
243
|
- MIT
|
243
244
|
metadata: {}
|
244
|
-
post_install_message:
|
245
|
+
post_install_message:
|
245
246
|
rdoc_options: []
|
246
247
|
require_paths:
|
247
248
|
- lib
|
@@ -257,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
257
258
|
version: '0'
|
258
259
|
requirements: []
|
259
260
|
rubygems_version: 3.0.6
|
260
|
-
signing_key:
|
261
|
+
signing_key:
|
261
262
|
specification_version: 4
|
262
263
|
summary: Opinionated Ruby integration with Camunda
|
263
264
|
test_files: []
|