Hi Milinda,

JSON support in the REST API has to cover JSON arrays as well. For example,
if a POST is done with a json array, each element/json object in the array
can be added to a java collection with the given variable name. Therefore,
data given as json arrays can be easily referred within bpmn and can be
used in multi-instance activities.

Regards,
Chathura

On Mon, May 16, 2016 at 12:44 PM, Milinda Perera <[email protected]> wrote:

> Hi,
>
>
> We are planning to introduce/enhance XML and JSON variable (ATM JSON
> support is available partially) support for BPMN in WSO2 BPS.
>
> Case 01 : JSON Support
>
> ATM Activiti provides JSON as a data type. Hence, I did some investigation
> on how extend JSON support is provided. The following table depicts results
> summary.
>
> Access From
>
> Read
>
> Create/Update
>
> Java Service Task
>
> ✓
>
> ✓
>
> Condition Expressions
>
> ✓
>
> -
>
> Script Task
>
> ✓
>
> ✗
>
> BPMN REST API
>
> ✗
>
> ✗
>
> We are planning to enhance JSON support by introducing following in WSO2
> BPS BPMN support:
>
>    1.
>
>    Create/Update JSON variables from Script Task.
>    2.
>
>    Create/Update and Read JSON variables from BPMN REST API.
>
>
> For more information how JSON variables can be used within BPMN processes
> ATM (with WSO2 BPS 3.5.1), refer [1].
>
>
>
> Case 02 : XML Support
>
> XML support is not provided in Activiti BPMN engine. So we are going to
> provide it from ground up.
>
> With XML support users can create variables in “xml” as the data type and
> able to extract or set XML content with the help of simple Java API that
> will provided in BPS.
>
> Consider there is an XML variable with name “userInfo” for example with
> the content:
>
> <User>
>
>     <Name>Mark</Name>
>
>     <Country>SL</Country>
>
>     <Address>
>
>        <State>Western</State>
>
>        <City>Colombo<City>
>
>        <Street>ABC Street</Street>
>
> </Address>
>
> </User>
>
> To provide XML support, we have to provide XML manipulation
> (Create/Update/Read) support in Java Service Task, Condition Expressions,
> Script Task and BPMN REST API
>
>
>    1.
>
>    Java Service Task
>
> Within Java service task users can use XML Java api that will provided
> within BPS to create, update, and read/query xml.
>
>
>    1.
>
>    Create
>
> When creating new XML variable and setting it process variable
>
> XML VARIABLE = XML.createInstance(“[XML String]”);
>
> execution.setVariable(“[Variable_name]”, VARIABLE);
>
>
>    1.
>
>    Read/Query
>
> When querying, user should be able to access element contents as follows:
>
> [VARIABLE NAME].XPath(“[XPATH EXPRESSION]”)
>
> Eg: To retrieve City : userInfo.XPath(“/User/Address/City”)
>
>
>    1.
>
>    Update
>
> To update an element in a XML variable
>
> VARIABLE.set(“[XPATH EXPRESSION]”, [String Value])
>
> Eg: To update City : userInfo.set(“/User/Address/City”, “Kandy”)
>
>
>    1.
>
>    Condition Expressions
>
> Within condition expression users can use the same methods provided from
> the Java API to query xml element contents
>
> <conditionExpression xsi:type="tFormalExpression">
>
>      <![CDATA[${xmlVar.XPath("[XPATH EXPRESSION]").asInt() > 10}]]>
>
> </conditionExpression>
>
>
>    1.
>
>    Script Task
>
> Within script task users will be able to use XML DOM (which is standard
> way of manipulating XML in javascript) for manipulating xml within the
> script (ATM we are focusing in JavaScript)
>
>
>
>    1.
>
>    BPMN REST API
>
> Same as for JSON,  need to introduce way to create, update and read xml
> variables.
>
> REST API Improvements
>
> Create/Update xml and json variables over REST API
>
> POST runtime/process-instances/{processInstanceId}/variables
>
> PUT runtime/process-instances/{processInstanceId}/variables
>
> Suggested payload for JSON:
>
> [
>
>     {
>
>      "name":"VariableName",
>
>      "type":"json",
>
>      "value":"{\"id\":1,\"name\":{\"first\":\"Yong\",\"last\":\"Mook
> Kim\"},\"priority\":5}"
>
>     }
>
> ]
>
> Suggested payload for XML:
>
> [
>
>   {
>
> "name":"VariableName",
>
> "Type":"xml",
>
>
> "value":"<root><id>1</id><name><first>fname</first><last>lname</last></name><priority>5</priority></root>"
>
>   }
>
> ]
>
> Get xml and json variables over REST API
>
> GET runtime/process-instances/{processInstanceId}/variables/{variableName}
>
> Response will be (for JSON):
>
> {
>      "name":"variableName",
>      "type":"json",
>      "value":"{\"id\":1,\"name\":{\"first\":\"Yong\",\"last\":\"Mook
> Kim\"},\"priority\":5}",
>      "scope":"local"
>   }
>
> XML variable response will be similar.
>
> The details mentioned above are to share the rough idea about XML/JSON
> enhancements that we planned to do. Appreciate for your suggestion and
> feedbacks on this.
>
> [1]
> http://milindaperera.blogspot.com/2016/05/json-variable-ussage-within-bpmn.html
>
> Thanks,
> Milinda
>
> --
> Milinda Perera
> Software Engineer;
> WSO2 Inc. http://wso2.com ,
> Mobile: (+94) 714 115 032
>
>
> _______________________________________________
> Architecture mailing list
> [email protected]
> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>
>
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to