A quickstart project that shows the use of business rules and processes
This example shows
You will need:
mvn clean compile spring-boot:run
mvn clean package
To run the generated native executable, generated in target/
, execute
java -jar target/process-business-rules-springboot.jar
You can take a look at the OpenAPI definition - automatically generated and included in this service - to determine all available operations exposed by this service. For easy readability you can visualize the OpenAPI definition file using a UI tool like for example available Swagger UI.
In addition, various clients to interact with this service can be easily generated using this OpenAPI definition.
Once the service is up and running we can invoke the REST endpoints and examine the logic.
To make use of this application it is as simple as putting a sending request to http://localhost:8080/persons
with appropriate contents. See the following two cases:
Given data:
{ "person" : { "name" : "john", "age" : 20 } }
Submit the JSON object from above:
curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"person" : {"name" : "john", "age" : 20}}' http://localhost:8080/persons
After the Curl command you should see a similar console log
{ "id":"fd4f629d-6822-4ca2-a8a6-a74f5f81e83d", "person":{ "name":"john", "age":20, "adult":true } }
Because the person is evaluated as an adult, no outstanding tasks should be here for given person.
We can verify there is no task running for Children Handling using following command:
curl http://localhost:8080/usertasks/instance?user=jdoe
where uuid is the id returned in the previous step.
Given data:
{ "person" : { "name" : "john", "age" : 5 } }
Submit the JSON object from above:
curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"person" : {"name" : "john", "age" : 5}}' http://localhost:8080/persons
After the Curl command you should see a similar console log
{ "id":"c59054b9-aa1d-4771-bc5e-40f8b32d3ff5", "person":{ "name":"john", "age":5, "adult":false } }
Because the person is not evaluated as an adult, there should be outstanding tasks for given person.
To verify there is a running user task for Children
curl http://localhost:8080/usertasks/instance?user=jdoe
Should return something like
[{"id":"1676f775-0759-4579-9676-f5c433689c2a","userTaskId":"_D9CFCEE9-BCDF-48D0-8CB4-A55584DF0D9D",...}]
Then we can complete the user task and validate child with
curl -X POST "http://localhost:8080/usertasks/instance/{userTaskId}/transition?user=jdoe" -H "content-type: application/json" -d '{"transitionId": "complete","data": {"approve": true}}'
Where userTaskId is id returned from the previous query
Should return something similar to
{ "id": "1676f775-0759-4579-9676-f5c433689c2a", "userTaskId": "_D9CFCEE9-BCDF-48D0-8CB4-A55584DF0D9D", "status": { "terminate": "COMPLETED", "name": "Completed" }, "taskName": "ChildrenHandling", ... }
and there should be no outstanding task for the person anymore.