Business Process Model and Notation(BPMN ) is a standard for business process modelling. SAP commerce has the business process like order process, consignment process etc, and as of today SAP commerce does not use BPMN notation but use its own process engine for modelling business process. The documentation here explains how we can model the process in BPMN and transform it to SAP Commerce process model.
BPMN to Hybris Process Transformation:
Hybris uses process with hybris specific process xml format rather than BPMN xml format.
The BPMN to Hybris Process transformation API would Help converting the BPMN xml format to Hybris specific process XML and vice versa.
This transformation Utility would help business users to create, view or modify the hybris specific process in bmpn GUI. This would increase the visual representation of any process on hybris over any external bpmn GUI.
Core Process Transformation service:
Core transformation service is provided as jar containing the transformation logic. You can convert any process (can be bpmn process xml or hybris process xml) by passing the xml string to convertProcess method ofDefaultBpmnProcessConversionService.java
The service returns the data object that contains the hybris specific process xml , bpmn specific process xml, process code and list of process tasks (for bpmn to hybris conversion).
Note :
-
- Since the features of hybris process is subset of bpmn process features, The service may not convert each and everything of bpmn features to hybris process xml.
-
- Currently bpmn2 format is supported for the transformation.
How to build the package:
Download the Zip file from https://www.sap.com/developer/trials-downloads/additional-downloads/business-process-transformation-… and extract it. This is a maven project and you need to build it before you can use it. This project depends on one of the jar files (processingserver.jar) from the hybris commerce. So before building the project, open the “pom.xml” file and edit it and provide the path to the processingserver.jar .
<dependency>
<groupId>de.hybris.platform</groupId>
<artifactId>processengine</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>
PATH_TO_HYBRIS_PLATFORM_DIR/ext/processing/bin/processingserver.jar
</systemPath>
</dependency>
Replace the PATH_TO_HYBRIS_PLATFORM_DIR to the actual file path where your hybris commerce is installed.
Go ahead and do a maven clean install, this would create the jar file in target and now you can use this jar file and use it in any java application.
Using Transformation API as a Restful service:
Now we are ready to use the core service for transformation and can be provided as the restful service.
Here are the simple steps to create a restful service.
1 . Create a new Spring MVC web application.
-
- Provide the dependency to the jar file/bpmntransformer extension we built earlier.
-
- define the spring beans as below.
|
After defining the spring bean , you can use the bean “bpmnservice” for bpmn process transformation.
-
- Create the rest controller
import org.springframework.http.HttpEntity; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import de.hybris.platform.processengine.transformer.bpmnhybris.data.BpmnProcessData; import de.hybris.platform.processengine.transformer.bpmnhybris.service.BpmnProcessConversionService; @org.springframework.web.bind.annotation.RestController @RequestMapping(“/restapi”) public class BPMNHybrisTransform { private BpmnProcessConversionService bpmnservice; @RequestMapping(value = “/bpmnhybristransformJSON”, method = RequestMethod.POST, consumes = MediaType.APPLICATION_XML_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public BpmnProcessData processTransformationJSON(HttpEntity<String> httpEntity) { String processxml = httpEntity.getBody(); return bpmnservice.convertProcess(processxml); } @RequestMapping(value = “/bpmnhybristransformation”, method = RequestMethod.POST, consumes = MediaType.APPLICATION_XML_VALUE, produces = MediaType.APPLICATION_XML_VALUE) @ResponseBody public String processTransformationXML(HttpEntity<String> httpEntity) { String processxml = httpEntity.getBody(); BpmnProcessData bpmnProcessData = bpmnservice.convertProcess(processxml); return (BpmnProcessData.ProcessType.HYBRIS.equals(bpmnProcessData.getProcessType())?bpmnProcessData.getProcessContent():bpmnProcessData.getBpmnContent()); } public BpmnProcessConversionService getBpmnservice() { return bpmnservice; } public void setBpmnservice(BpmnProcessConversionService bpmnservice) { this.bpmnservice = bpmnservice; } } |
-
- Define the spring bean passing reference to bpmnservice
<bean id=“bpmnhybristransform”class=“com.hybris.transformer.BPMNHybrisTransform”> <property name=“bpmnservice”ref=“bpmnservice” /> </bean> |
-
- deploy the spring MVC application.
-
- Use postman to verify the process transformation as below.
-
- Set the header with the “Content-Type” as “Application/xml”
-
- Pass the bpmn xml as body part
-
- The output once you post would be the transformed process xml.
Another API /restapi/bpmnhybristransformJSON will provide the output on JSON format with both bpmn and hybris process format with the details on tasks identified in a bpmn text.
Note : Due to some specific syntax on hybris process, we need to add one xml snippet in bpmn xml so that the process xml would be complete.
Let us say , if we want to define the process for Order creation then we need to specify the process model (OrderProcessModel) and this can be done by adding the below code on the bpmn xml file.
<bpmn2:dataObject id=”DataObject_2″ name=”de.hybris.platform.orderprocessing.model.OrderProcessModel as processClass”> <bpmn2:dataState id=”DataState_1″ name=”Data State 1″ /> </bpmn2:dataObject> |
Sample bpmn2 process creation and transforming it to hybris process xml :
Take this sample bmpn2 file content and load it to any BPMN editor (bpmn.io or eclipse bpmn editor or any bpmn editor of your choice). Ignore any warning or error as it is a very basic template in which you would start building the process.
<?xml version=”1.0″ encoding=”UTF-8″?> <!– origin at X=0.0 Y=0.0 –> <bpmn2:definitions xmlns:bpmn2=”http://www.omg.org/spec/BPMN/20100524/MODEL” xmlns:bpmndi=”http://www.omg.org/spec/BPMN/20100524/DI” xmlns:dc=”http://www.omg.org/spec/DD/20100524/DC” xmlns:ns=”http://www.w3.org/2001/XMLSchema” id=”_ESxmkE7AEeibvZO4ZeVwrQ” exporter=”org.eclipse.bpmn2.modeler.core” exporterVersion=”1.4.2.Final-v20171109-1930-B1″> <bpmn2:process id=”demo-order-process” name=”demo-order-process” isExecutable=”false”> <bpmn2:dataObject id=”DataObject_2″ name=”de.hybris.platform.orderprocessing.model.OrderProcessModel as processClass”> <bpmn2:dataState id=”DataState_1″ name=”Data State 1″/> </bpmn2:dataObject> </bpmn2:process> <bpmndi:BPMNDiagram id=”BPMNDiagram_1″> <bpmndi:BPMNPlane id=”BPMNPlane_1″> <bpmndi:BPMNShape id=”BPMNShape_DataObject_1″ bpmnElement=”DataObject_2″> <dc:Bounds height=”50.0″ width=”36.0″ x=”160.0″ y=”380.0″/> <bpmndi:BPMNLabel id=”BPMNLabel_1″ labelStyle=”BPMNLabelStyle_1″> <dc:Bounds height=”66.0″ width=”79.0″ x=”139.0″ y=”430.0″/> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> <bpmndi:BPMNLabelStyle id=”BPMNLabelStyle_1″> <dc:Font name=”arial” size=”9.0″/> </bpmndi:BPMNLabelStyle> </bpmndi:BPMNDiagram> </bpmn2:definitions> |
-
- After loading the template in Visual BPMN editor, add few steps to the process as below.
View the BPMN xml and it would appear as below.
<?xml version=”1.0″ encoding=”UTF-8″?> <bpmn2:definitions xmlns:bpmn2=”http://www.omg.org/spec/BPMN/20100524/MODEL” xmlns:bpmndi=”http://www.omg.org/spec/BPMN/20100524/DI” xmlns:dc=”http://www.omg.org/spec/DD/20100524/DC” xmlns:di=”http://www.omg.org/spec/DD/20100524/DI” xmlns:ns=”http://www.w3.org/2001/XMLSchema” id=”_ESxmkE7AEeibvZO4ZeVwrQ” exporter=”org.eclipse.bpmn2.modeler.core” exporterVersion=”1.4.2.Final-v20171109-1930-B1″> <bpmn2:process id=”demo-order-process” name=”demo-order-process” isExecutable=”false”> <bpmn2:dataObject id=”DataObject_2″ name=”de.hybris.platform.orderprocessing.model.OrderProcessModel as processClass”> <bpmn2:dataState id=”DataState_1″ name=”Data State 1″ /> </bpmn2:dataObject> <bpmn2:startEvent id=”StartEvent_0vtbr1u” name=”Start”> <bpmn2:outgoing>SequenceFlow_1wylk4m</bpmn2:outgoing> </bpmn2:startEvent> <bpmn2:task id=”Task_05i4bfq” name=”checkOrder”> <bpmn2:incoming>SequenceFlow_1wylk4m</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0rgp3tu</bpmn2:outgoing> </bpmn2:task> <bpmn2:sequenceFlow id=”SequenceFlow_1wylk4m” sourceRef=”StartEvent_0vtbr1u” targetRef=”Task_05i4bfq” /> <bpmn2:endEvent id=”EndEvent_12n08mi” name=”End”> <bpmn2:incoming>SequenceFlow_0rgp3tu</bpmn2:incoming> </bpmn2:endEvent> <bpmn2:sequenceFlow id=”SequenceFlow_0rgp3tu” name=”OK” sourceRef=”Task_05i4bfq” targetRef=”EndEvent_12n08mi” /> </bpmn2:process> <bpmndi:BPMNDiagram id=”BPMNDiagram_1″> <bpmndi:BPMNPlane id=”BPMNPlane_1″ bpmnElement=”demo-order-process”> <bpmndi:BPMNShape id=”BPMNShape_DataObject_1″ bpmnElement=”DataObject_2″> <dc:Bounds x=”160″ y=”380″ width=”36″ height=”50″ /> <bpmndi:BPMNLabel id=”BPMNLabel_1″ labelStyle=”BPMNLabelStyle_1″> <dc:Bounds x=”139″ y=”430″ width=”79″ height=”66″ /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id=”StartEvent_0vtbr1u_di” bpmnElement=”StartEvent_0vtbr1u”> <dc:Bounds x=”171″ y=”283″ width=”36″ height=”36″ /> <bpmndi:BPMNLabel> <dc:Bounds x=”177″ y=”326″ width=”24″ height=”13″ /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id=”Task_05i4bfq_di” bpmnElement=”Task_05i4bfq”> <dc:Bounds x=”257″ y=”261″ width=”100″ height=”80″ /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id=”SequenceFlow_1wylk4m_di” bpmnElement=”SequenceFlow_1wylk4m”> <di:waypoint x=”207″ y=”301″ /> <di:waypoint x=”257″ y=”301″ /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id=”EndEvent_12n08mi_di” bpmnElement=”EndEvent_12n08mi”> <dc:Bounds x=”407″ y=”283″ width=”36″ height=”36″ /> <bpmndi:BPMNLabel> <dc:Bounds x=”415″ y=”326″ width=”20″ height=”13″ /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id=”SequenceFlow_0rgp3tu_di” bpmnElement=”SequenceFlow_0rgp3tu”> <di:waypoint x=”357″ y=”301″ /> <di:waypoint x=”407″ y=”301″ /> <bpmndi:BPMNLabel> <dc:Bounds x=”374″ y=”283″ width=”16″ height=”13″ /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> <bpmndi:BPMNLabelStyle id=”BPMNLabelStyle_1″> <dc:Font name=”arial” size=”9″ /> </bpmndi:BPMNLabelStyle> </bpmndi:BPMNDiagram> </bpmn2:definitions>
|
-
- send the BPMN xml to the restful service and you would see the converted hybris process XML.
-
- You can further enhance the model by adding some more tasks and conditions as below and transform it to hybris process xml
With the Utility provided in https://www.sap.com/developer/trials-downloads/additional-downloads/business-process-transformation-for-hybris-commerce-15505.html , you can easily transform the BPMN process into SAP commerce process.