Blog Posts BPMN DMN

Kogito Task Management API

Blog: Drools & jBPM Blog

Kogito Task management API

In a previous post we discussed the task process API, which dealt with tasks from a process perspective. As explained in there, the task model depends on data defined by users. But, regardless of the task related information provided by users through BPMN processes, every existing task in Kogito has some predefined fields, mainly related to security policies, which are handled by Tasks Management API.

Since Task Management API is a security-sensitive API, it is often referred as Admin API, but that name might cause confusion and should be avoided. Reason is that  this API is not intended for an administrator to change all task parameters arbitrarily, but for any user with enough privileges (in future, when Kogito defines a global authentication policy, API endpoint will be available only to users with certain privileges, administrators will be of course included among them)  to modify those task parameters not exposed by  Task Process API. 

One important implication of this line of thought is that users with administrative privileges must use Task process API, as any other regular user, to perform phase transitions, change output parameters or add comments and attachments.

Task management information

The information that can be consulted or modified by Task Management API consist of:

Some readers might be wondering, what about the current task owner? Following the rationale previously exposed, since the current task owner is expected to be established by using Claim o Release transitions, it was decided to not include it in the list of parameters that can be modified by Task Management API. Again, the administrative user can use the regular Task Process API to do so.

Task management operations

Task management API consists of just one resource, which, in an outburst of originality, is called task.

Endpoint URI match this template

http://<host>:<port>/management/processes/<process id>/instances/<process instance id>/tasks/<task Id>

Task management endpoint supports following HTTP methods: 

Retrieving task information

We will illustrate management API usage by employing the same approval example from previous post 

Since you already have the proper process instance Id and task Id, invoking

GET http://localhost:8080/management/processes/approvals/instances/<process instance id>/tasks/<task Id>

will return as response a JSON similar to this one

{
   "description": null,
   "priority": null,
   "potentialUsers": [
       "manager"
   ],
   "potentialGroups": [
       "managers"
   ],
   "excludedUsers": [],
   "adminUsers": [],
   "adminGroups": [],
   "inputParams": {
       "TaskName": "firstLineApproval",
       "NodeName": "First Line Approval",
       "Skippable": "true",
       "ActorId": "manager",
       "traveller": {
           "firstName": "John",
           "lastName": "Doe",
           "email": "jon.doe@example.com",
           "nationality": "American",
           "address": {
               "street": "main street",
               "city": "Boston",
               "zipCode": "10005",
               "country": "US"
           }
       },
       "GroupId": "managers"
   }
}

Note that inputParams field contains a traveller instance, which is the model defined for firstLineApproval task, but also includes NodeName, Skippable and ActorId, which are not part of it.  

Updating task information

Let’s assume you want to add a description, change skippable input parameter to false and add user menganito to the list of potential users for that task instance, you should invoke 

PATCH http://localhost:8080/management/processes/approvals/instances/<process instance id>/tasks/<task Id>

providing as body

{
    "inputParams" : {"Skippable":false}, 
    "description" : " Real Betis Balompie is the best soccer team in the world",
    "potentialUsers":["manager","meganito"]
}

Please note that when using PATCH you only need to specify those fields that you want to modify, but if the field data type is a JSON collection, you need to specify all the items in the collection. That’s why we only provide skippable as inputParams value (because input parameters are merged) but the complete list for potentialUsers fields (because collections are not merged). 

The response of previous invocation will consist on the whole resource properly modified

{
   "description": " Real Betis Balompie is the best soccer team in the world",
   "priority": null,
   "potentialUsers": [
       "manager", “menganito”
   ],
   "potentialGroups": [
       "managers"
   ],
   "excludedUsers": [],
   "adminUsers": [],
   "adminGroups": [],
   "inputParams": {
       "TaskName": "firstLineApproval",
       "NodeName": "First Line Approval",
       "Skippable": false,
       "ActorId": "manager",
       "traveller": {
           "firstName": "John",
           "lastName": "Doe",
           "email": "jon.doe@example.com",
           "nationality": "American",
           "address": {
               "street": "main street",
               "city": "Boston",
               "zipCode": "10005",
               "country": "US"
           }
       },
       "GroupId": "managers",

   }
}

Conclusion 

In this post we discussed the Task Management API, a brief (just one resource) but powerful one, which is intended to interact with task information that is not part of the process model. Next post, the last of this series, will describe how to establish task deadlines, whose main purpose is to make sure that a task does not fall into oblivion. 

The post Kogito Task Management API appeared first on KIE Community.

Leave a Comment

Get the BPI Web Feed

Using the HTML code below, you can display this Business Process Incubator page content with the current filter and sorting inside your web site for FREE.

Copy/Paste this code in your website html code:

<iframe src="https://www.businessprocessincubator.com/content/kogito-task-management-api/?feed=html" frameborder="0" scrolling="auto" width="100%" height="700">

Customizing your BPI Web Feed

You can click on the Get the BPI Web Feed link on any of our page to create the best possible feed for your site. Here are a few tips to customize your BPI Web Feed.

Customizing the Content Filter
On any page, you can add filter criteria using the MORE FILTERS interface:

Customizing the Content Filter

Customizing the Content Sorting
Clicking on the sorting options will also change the way your BPI Web Feed will be ordered on your site:

Get the BPI Web Feed

Some integration examples

BPMN.org

XPDL.org

×