Draw & Validate a Workflow


jBPM5 – Draw & Validate a Workflow


”;


To draw a workflow, you can use any of the components available in the palette as described in above article. All the workflow will have one start but it can have multiple end.

With the help of screenshots, I will depict you how to create a workflow.

Here, I’ve opened the blank rf or bpmn file

Create Workflow

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

Diverge Gateway

Now, one needs to connect the two components. Select the Sequence flow and connect the two components.

Sequence Flow
Sequence Flow1

This way you can drag the components to the editor and use the sequence flow to join the different components. One just needs to take care that some components will have one incoming and one outgoing connection only and needs to set the sequence flow accordingly to create a meaningful flow.

One needs to set some properties as well while we draw the workflow. Will post all the properties to set here. I have just created a flow but it won”t be very meaningful to look at it at first instant as I haven”t set any properties in the workflow created.

Created Workflow

As you can see above, it”s a blank workflow without any description as such and one cannot make out anything from the workflow created.

However, to explain further, I have a start component and then a diverge gateway and depending on the condition of the diverge gateway, I will choose one way and execute some code in the script task and then end the workflow. So I need to set properties for the diverge gateway, then the script task and the converge gateway.

At this stage i will also show you that my workflow has some errors and later will show you once I set the properties there would be no errors in my workflow, Hence showing you how to VALIDATE the workflow created.

Tip − Remember that validator”s are on under Windows → Preferences → Validation

Below screenshot shows the settings in eclipse.

Preferences
Validation

As per the screenshot, you can see that there are 4 errors. The first error says script has no action and then another error is the gateway”s defined have no type defined. Hence, we need to remove these errors to be able to run the workflow.

We will now set properties one by one and see the errors fading away.

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

No Action

Once you have selected the gateway then you need to select a constraint.

Gateway

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

Errors Fading

Click on edit and fill the details as per the screenshot −

Errors Fading
Errors Fading

Click on Import and import the class on which we would be performing 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 do the same process as you did for diverge gateway.

We have just added a SOP (print statement) to show 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 need to add the gateway type for the diverge gateway.

Diverge Gateway

Now, save the workflow file and go to problems view. All the problems will be resolved.

Workflow File

No errors in the problem view suggests that, there is no error in the workflow created. This is how a workflow is created as well as validated in jBPM.

Advertisements

”;

Leave a Reply

Your email address will not be published. Required fields are marked *