Skip to content

Latest commit

 

History

History

kogito-usertasks-with-security-springboot

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Kogito user task orchestration

Description

A quickstart project shows very typical user task orchestration. It comes with two tasks assigned to human actors via groups assignments - managers. So essentially anyone who is a member of that group can act on the tasks. Though this example applies four eye principle which essentially means that user who approved first task cannot approve second one. So there must be always at least two distinct manager involved.

This example shows

  • working with user tasks
  • four eye principle with user tasks

Build and run

Prerequisites

You will need:

  • Java 1.8.0+ installed
  • Environment variable JAVA_HOME set accordingly
  • Maven 3.5.4+ installed

Compile and Run in Local Dev Mode

mvn clean package spring-boot:run    

Compile and Run using uberjar

mvn clean package 

To run the generated native executable, generated in target/, execute

java -jar target/kogito-usertasks-sprintboot-{version}.jar

Use the application

Submit a request to start new approval

To make use of this application it is as simple as putting a sending request to http://localhost:8080/approvals with following content

{
"traveller" : { 
  "firstName" : "John", 
  "lastName" : "Doe", 
  "email" : "jon.doe@example.com", 
  "nationality" : "American",
  "address" : { 
  	"street" : "main street", 
  	"city" : "Boston", 
  	"zipCode" : "10005", 
  	"country" : "US" }
  }
}

Complete curl command can be found below:

curl -u john:john -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"traveller" : { "firstName" : "John", "lastName" : "Doe", "email" : "jon.doe@example.com", "nationality" : "American","address" : { "street" : "main street", "city" : "Boston", "zipCode" : "10005", "country" : "US" }}}' http://localhost:8080/approvals

Show active approvals

curl -u john:john -H 'Content-Type:application/json' -H 'Accept:application/json' http://localhost:8080/approvals

Show tasks

curl -u john:john -H 'Content-Type:application/json' -H 'Accept:application/json' 'http://localhost:8080/approvals/{uuid}/tasks?user=admin&group=managers'

where {uuid} is the id of the given approval instance

Complete first line approval task

curl -X POST -d '{"approved" : true}' -H 'Content-Type:application/json' -H 'Accept:application/json' http://localhost:8080/approvals/{uuid}/firstLineApproval/{tuuid}?user=admin&group=managers'

where {uuid} is the id of the given approval instance and {tuuid} is the id of the task instance

Show tasks

curl -u john:john -H 'Content-Type:application/json' -H 'Accept:application/json' 'http://localhost:8080/approvals/{uuid}/tasks?user=admin&group=managers'

where {uuid} is the id of the given approval instance

This should return empty response as the admin user was the first approver and by that can't be assigned to another one.

Repeating the request with another user will return task

curl -H 'Content-Type:application/json' -H 'Accept:application/json' 'http://localhost:8080/approvals/{uuid}/tasks?john=admin&group=managers'

Complete second line approval task

curl -X POST -d '{"approved" : true}' -H 'Content-Type:application/json' -H 'Accept:application/json' 'http://localhost:8080/approvals/{uuid}/secondLineApproval/{tuuid}?john=admin&group=managers'

where {uuid} is the id of the given approval instance and {tuuid} is the id of the task instance

This completes the approval and returns approvals model where both approvals of first and second line can be found, plus the approver who made the first one.

{
	"approver":"admin",
	"firstLineApproval":true,
	"id":"2eeafa82-d631-4554-8d8e-46614cbe3bdf",
	"secondLineApproval":true,
	"traveller":{
		"address":{
			"city":"Boston",
			"country":"US",
			"street":"main street",
			"zipCode":"10005"},
		"email":"jon.doe@example.com",
		"firstName":"John",
		"lastName":"Doe",
		"nationality":"American"
	}
}