jBPM5 Draw & Validate a Workflow - jBPM

How to draw and validate a workflow in jBPM5?

Workflow can be drawn by using any of the components available in the palette as explained in above article. All the workflow will have one start but it can have multiple end.

With the help of screenshots, we will explain how to create a workflow.

In the below screenshot, a blank rf or bpmn file is opened

create_workflow

To add any event, select an event from Components Palette and drag and drop to right hand side. For example, we have selected the start event and dragged it to right hand side and also a diverge gateway.

diverge_gateway1

Now, two components have to be connected. Select the Sequence flow and connect the two components.

sequence_flow

sequence_flow1

In this way, you can drag the components to the editor and use the sequence flow for joining different components. Remember that few components will have one incoming and one outgoing connection only. Therefore, you should set the sequence flow accordingly for creating a meaningful flow.

You should set some properties while drawing the workflow and post all the properties to set here. We just created a flow but it will not be very meaningful to look at it at first instant as we have not set any properties in the workflow created.

created_workflow

If you observe the above image, it is a blank workflow without any description as such and user cannot make out anything from the workflow created.

However, to explain further, we have a start component and then a diverge gateway. Depending on the condition of the diverge gateway, we will select one way and execute some code in the script task and then end the workflow. Therefore, we should set properties for the diverge gateway, then the script task and the converge gateway.

At this stage workflow will have some errors and later these will be displayed. When the properties are set there will not be any errors in the workflow. Therefore, we are displaying how to VALIDATE the workflow created.

Tip − Remember that validators are on under Windows → Preferences → Validation

Below screenshot shows the settings in eclipse.

preferences

validation

Based on the screenshot, you can see that there are 4 errors. First error says that the script has no action and then another error is that the type is not defined in the gateway's. Therefore, we should remove these errors to run the workflow.

Now let’s set properties one by one and see the errors disappearing.

Select the first gateway(diverge) and click on properties, then click on type and select the gate based on your requirement.

no_action

Once you have selected the gateway, select a constraint.

gateway

Click on the circle marked red, then you will see below screenshot

errors_fading

Click on edit and fill the details based on the screenshot

errors_fading1

errors_fading2

Click on Import and import the class on which we perform any operation. In the screenshot, we have imported passenger POJO which we will be using in our example.

import_editor

Similarly, fill the details for another constraint

constraint_editor

Now, click the OK button.

editor_constraint

Again, click OK. Now, select the script task and repeat the same process as you did for diverge gateway.

We have just added a SOP (print statement) to display the flow. Any java or mvel code can be written in the script task.

textual_editor

Similarly add the code for second constraint

second_constraint

Finally, you should add the gateway type for the diverge gateway.

diverge_gateway

Now, save the workflow file and go to problems view to resolve all the problems.

workflow_file

None of the errors in the problem view suggests that there is no error in the created workflow. This is the for creating a workflow and validating in jBPM.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

jBPM Topics