Rest Api Context

This REST API can access in **one call** all your **Process variables** , **BDM variables** (with all the hierarchies), **Local variable** , from a **taskId** or from a **caseId** .

What is the usage?

You can design one form per process: Look at https://youtu.be/M9Y8xaHZFRo

or definitively, simplify your life https://youtu.be/ZY3OgD27DJg, you will see the improvement.

You want to implement a Controller in your form? then this video is for you: https://youtu.be/1-smrL8pprw

Short cut link

------ Case (overview) ------ Use http://../API/extension/context?caseId={{caseId}},

------ Task ------ http://../API/extension/context?taskId={{taskId}},

------ Process instantiation ------ http://../API/extension/context?processId={{processId}}

------ Storage Id (access to document) ------ http://../API/extension/context?contentStorageId={{contentStorageId}}

-------------------------------- Complete access: -------------------------------- UI Designer gives you an ID, then you want to build a form valid for all situation? Create one variable JAVASCRIPT, then the formInput is

Variable: **Url** Type: **JavaScript** Value: **return window.location.href**

Variable: **formInput** Type: **External API** Value: **http://../API/extension/context?processId={{Id}}&taskId={{Id}}&caseId={{Id}}&url={{url}}**

The RestApiContext is delivered too with a PermissionRule to check the document download: if a teacher uploads a document in the student case, maybe you don't want the student access it?

See the tutorial for a step by step information

-------------------------------- Difference : --------------------------------

The difference with the standard REST API to access variable and BDM are this one: 1/ Perimeter: using http://../API/bpm/activityVariable/[activity_id]/[variable_name] or http://../API/bpm/caseVariable/[caseId]/[variableName], you need to know where is the variable (process, activity) 2/ theses REST API can't handle HashMap, List or Datatype, only basic type 3/ one variable at a call 4/ not way to control security 5/ one call per BDM 6/ if the BDM has a children "load when needed", the basic RestAPI does not include it, and you have to deal with Javascript / RestAPI to get the first level of child, and there are no simple way to get a grandchild 7/ no way to protect the header.CommentOfTheManagerEmployeeMustNotAccess in anyway 8/ case is archive ? REST API to call are different ( ! ) . So, building an overview is 10 rest API ? You have to call 10 more REST API, different REST API, to get the result.

-------------------------------- Installation guide --------------------------------

Run the BonitaPortal, and connect as a Administrator. 1. Then, the profile Administrator should be accessible. 2. In the profile Administrator, select "Resources". 3. Click on the button ADD, and give the file ContextAccess-x.y.zip" 4. that's it : the RestContextExtention is installed and deployed

-------------------------------- Data managed -------------------------------- These type of variable are managed * Simple variable : STRING, Example on the returned JSON: "message": "Hello the word"

* Numerical value INTEGER, FLOAT Example on the returned JSON: "numberOfLines": 54 * Boolean value

Example on the returned JSON: "allowNegativeAmount" : true

* Date A date is returned in the JSON format to be used on the browser Example on the returned JSON: "dateOfRegistration": "2016-05-23T14:24:16.683Z"

* Map of object The Java class Map is managed, and return a JSON set of data "address": { "country": "USA", "city" : "San Francisco", "zipcode" : 94702 "validfrom" : "2016-05-23T14:24:16.683Z" } * List of object (list of String, list of Integer...) The list is a JSON list, each content can be whatever is manage as a value (String, Integer, Date, Bdm...)

Example on the returned JSON: "listOfMessage": [ "Hello", "the", "world" ], * Java Enumerate. If the data is an Java Enumerate (nota : the ListOfOption in Bonita is not an Enumerate, it's a String in fact) The value is return as a String and a new value, same name but finish by "_list" return the list of possible value. "aPetsAnimalEnum" : "TURTLE", "aPetsAnimalEnum_list" : [ "CAT", "DOG", "CROCODILE", "TURTLE", "FROGGY" ] * Data Type Any data type generated by the studio, or Serializable, can be handle. The return is a map of information, where all attributes are recursively exploited

Example on the returned JSON:

"invoice": { "lines": [ { "product": "BPAD", "lineNumber": "100" }, { "product": "AI", "lineNumber": "200" } ], "details": { "address": "44 Tahoha St", "country": "USA", "city": "San Francisco" }, "headerNumber": 0, "name": "TheDatatype Name" } * Business Data Model The business Data Model (Multiple or not) are displayed, and are recursively exploited (list of line of an invoice for example). if you BDM has some aggregation (the Invoice reference a Customer), then the information on the customer can be returned : you have to use the Pilot for that.

Example on the returned JSON: "summerOrder": { "aFloat": 6.334, "multInteger": [ 553, 54, null, 56 ], "aBoolean": false, "multDate": [ "2016-08-17T19:25:32+0000", "2016-08-17T19:25:32+0000", null, "2016-08-17T19:25:32+0000" ], "aInteger": 444, "numheader": "1471461932737", "aLong": 45334545, "persistenceId": 24, "ticket": { "persistenceId": 57, "solicitante": "Name of the Solicitante", "idTicket": 12 } }; -------------------------------- first step --------------------------------

When you use some processes variables (process, or local variable), use this REST Api to access all the variable in one call. All variables are delivered on a Json format (even HashMap and List, and Datatype) and you don't need to care if the variable is a process variable or a local variable.

So, you can use ../API/extension/context?caseId={{caseId}} or ../API/extension/context?taskId={{taskId}}

-------------------------------- How to pilot the result ? --------------------------------

To pilot which variable has to be retrieved and return, you can defined

* a local variable "context",

* or a process variable "globalcontext"

* or a parameter "paramcontext"

which contains some JSON information. For example, set as localvariable "context" the following information: { "aBoolean":"data", "aDate":"data", "aHashMap":"data", "aInteger":"data", "aList":"data", "aLong":"data", "aString":"data", "aLocalVariable":"data", "aDataType":"datatype" }

then you get as a result : { "aBoolean":true, "aLocalVariable":"yes, Local variable too", "aHashMap":{"age":34,"lastname":"Bates","firstname":"Walter"}, "aString":"Hello the word", "aInteger":54, "aList":["Hello","the","world"], "aDataType":{ "lines": [ {"product":"BPAD","lineNumber":"100"}, {"product":"AI","lineNumber":"200"} ], "details": {"address":"44 Tahoha St","country":"USA","city":"San Francisco"}, "headerNumber":0, "name":"TheDatatype Name" }, "aLong":12, "aDate":"2016-04-27T22:39:32+0000" }

-------------------------------- access the BDM--------------------------------

When you have a BDM variable like "summerOrder", ask in the pilot : "summerOrder" : { "name": "data", "ticket": "", "lines" : { "linename" : "data", "ticket" : { "solicitante" : "data" }, "price":"data" } } Saying that, you will get the variable, and the children "ticket" and all fields in tickets (if ticket is a MULTIPLE, then you get a LIST of RECORD). Then you ask to get lines, and in lines, subchild "linename" and "price". Then, if the BDM has more attributes (like in the lines an attribute "for_the_manager_only", then this information is not part of the result (except if you ask "")

-------------------------------- all variables --------------------------------

Get it simple, get all ! And in fact, if you don't specify a pilot, that what you have. if you want all variables (process, activity, BDM) : { "*":"all" } Nota : if you ask with a parameters "taskId" you get all the LOCAL variable, the PROCESS variables and the BDM variables. With a parameter caseId, you get only the process variable and the BDM variables.

-------------------------------- case is archived ? --------------------------------

If the case 9002 is now archived, just continue to ask the case 9002 : the REST API get all the information even if the case is archived. Enjoy a simple way to build the Overview page !

-------------------------------- log --------------------------------

in the URL, ask "&log=true" and then you get additional result in the JSON : source of data, performance to fetch the result. And on the server too, you will have more information in the log

--------------------------------------- Security --------------------------------

All the REST API activityVariable/ and caseVariable are based on the permission access task_visualization. So, if your process contains a sensitive information like "managerComment", at any moment, the employe can access this information via one of this API. To avoid that: * change the permission access of this two REST API to "onlyadministratorway" * in each activity, define a local variable "context" where you define what the user can see. Doing that, the REST API will deliver only what it's define in the local variable. And because the variable is on the server, user has no way to change it.

-------------------------------- Tutorial --------------------------------

To demonstrate the usage, install the RestApiContext (see the Installation part).

* load the BOS file "DemontrasteRestApiContext",

* access the Business Data Model (Development / Business Data Model / Manage) and click on Finish to deploy the data model

*Use ContextCall: Select the Context Call process, and click on Run to deploy it Click on Start to create a case. On the portal, you should see three different tasks : ContextUse, allContext,GlobalContext.

Click on the task ContextUseand look the URL:

http://localhost:8080/bonita/portal/homepage#?_p=tasklistinguser&_pf=1&_f=available&_id=100003

the taskId is under "id" : is this URL, taskId is 100003. To get the caseId, on the portal, the id is visible after the "Case: xxxx" (example : 5004) Run a Firefox Browser. Connect as Walter.Bates. BY A REST CLIENT On Firefox, run the Rest Client Extension (a Rest Client module on Firefox).

The browser share the cookie, so now your rest client is connected

* * * Set the REST URL :

Method : POST

URL : http://localhost:8080/bonita/API/extension/context?caseId=5004

Click on SEND, result is Status : 200

Response Body:

{ "aBoolean": true, "globalcontext": "{ \"*\":\"all\" }", "aHashMap": { "age": 34, "lastname": "Bates", "firstname": "Walter" }, "aString": "Hello the word", "aInteger": 54, "aList": [ "Hello", "the", "world" ], "aDataType": { "lines": [ { "product": "BPAD", "lineNumber": "100" }, { "product": "AI", "lineNumber": "200" } ], "details": { "address": "44 Tahoha St", "country": "USA", "city": "San Francisco" }, "headerNumber": 0, "name": "TheDatatype Name" }, "aLong": 12, "aDate": "2016-05-23T14:24:16.683Z" }

* * * Set the REST URL TASK (the answer will contain the 'aLocalVariable') :

Method : POST

URL : http://localhost:8080/bonita/API/extension/context?taskId=100003

Click on SEND, result is Status : 200 Response Body:

{ "aBoolean": true, "aLocalVariable": 43, "globalcontext": "{ \"*\":\"all\" }", "aHashMap": { "age": 34, "lastname": "Bates", "firstname": "Walter" }, "aString": "Hello the word", "aInteger": 54, "aList": [ "Hello", "the", "world" ], "aDataType": { "lines": [ { "product": "BPAD", "lineNumber": "100" }, { "product": "AI", "lineNumber": "200" } ], "details": { "address": "44 Tahoha St", "country": "USA", "city": "San Francisco" }, "headerNumber": 0, "name": "TheDatatype Name" }, "aLong": 12, "aDate": "2016-05-23T14:24:16.683Z" }

BY THE UIDESIGNER click on the different task, and then the REST API is called and get the information. Access the task definition with the UIDesigner to see how to use it.

Licence: 
LGPL v3

Downloads

Total downloads: 27 106
Version BonitaBPM Version Post date Download Link to content
2.13.3 7.11.x, 7.10.x, 7.9.x, 7.8.x 2021-Jan-21 Download
845 downloads
Release note
2.13.2 7.10.x 2020-May-27 Download
814 downloads
Release note
2.13.1 7.10.x, 7.9.x, 7.8.x 2020-May-02 Download
569 downloads
Release note
2.13 7.10.x, 7.9.x, 7.8.x, 7.7.x 2020-Mar-10 Download
665 downloads
Release note
2.12 7.8.x 2019-Mar-20 Download
1122 downloads
Release note
2.11 7.7.x, 7.6.x, 7.5.x 2018-Nov-14 Download
1029 downloads
Release note
2.10 7.5.x, 7.4.x, 7.3.x, 7.2.x 2017-Oct-31 Download
1717 downloads
Release note
2.9 AccessRight and Explicit variable 7.5.x, 7.4.x, 7.3.x, 7.2.x 2017-Jul-14 Download
1495 downloads
Release note
2.8 - 7.5 Ready 7.5.x, 7.4.x, 7.3.x, 7.2.x 2017-Jun-09 Download
1583 downloads
Release note
2.7 Permission access 7.4.x, 7.3.x, 7.2.x 2017-May-08 Download
1688 downloads
Release note
2.6 7.4.x, 7.3.x, 7.2.x 2017-Feb-16 Download
1826 downloads
Release note
2.5 7.x 2016-Dec-31 Download
1785 downloads
Release note
2.4 7.x 2016-Sep-10 Download
1901 downloads
Release note
2.3 7.x 2016-Aug-18 Download
1800 downloads
Release note
2.2 7.x 2016-Jul-06 Download
1882 downloads
Release note
2.1 7.x 2016-May-24 Download
2193 downloads
Release note
2.0 7.x 2016-May-12 Download
2048 downloads
Release note
1.0 7.x 2016-Apr-28 Download
2144 downloads
Release note
Notifications