Flowable Notes for Beginners

Flowable Notes for Beginners

 

 

1. Flowable is a set of process and tasks inside it.

Example snippet (as per bpmn20.xml):

Below snippet is only for understanding on how the process and tasks will be created in flowable for any bpmn process.

Explanation:

  • couponupload is process id/key created to upload the coupons for a particular shop.
  • This process will have set of tasks in order to complete the whole process, here totally 2 process, one is store already partnered or not and whether the category already available or not.

<process id="couponupload" name="Coupon Upload BPMN Process" isExecutable="true">
<userTask id="store-already-partnered" name="Check whether the store is already partnered or not" flowable:assignee="${ storeName }" flowable:candidateGroups="InternalMaintenanceTeam" flowable:dueDate="${ storeCreationDueDate }">
<extensionElements>
<modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
</extensionElements>
</userTask>

<userTask id="category-already-available" name="Check whether the particular shops category is available or not" flowable:assignee="${ categoryName }" flowable:candidateGroups="InternalMaintenanceTeam">
<extensionElements>
<modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
</extensionElements>
</userTask>

</process>

 

2. Installing Flowable and configuring with Apache Tomcat

You have to download flowable-6.4.0(latest while writing this article) and download the apache tomcat, then move all the below five war files to webapps then do tomcat restart for the deployments.

  1. flowable-admin.war
  2. flowable-idm.war
  3. flowable-modeler.war
  4. flowable-rest.war
  5. flowable-task.war

Then you will be able to see the list of flowable wars deployed in the manager of apache tomcat in this url
http://localhost:8080

Url to access:
http://localhost:8080/flowable-admin/#/engine

Default username and password:
username: admin
password: test

Upload your bpmn20.xml file in flowable-modeler, probably in this page http://localhost:8080/flowable-modeler

 

3. RuntimeService is a class available to start bpmn process.


@Autowired
private RuntimeService runtimeService;

 

Here RuntimeService is autowired and started the flowable process using startProcessInstanceByKey method,


runtimeService.startProcessInstanceByKey("couponupload",processMeta);

Note: couponupload is the process id mentioned in the xml above(or the Model key as per the flowable diagram created, which looks similar to the below popup), processMeta can be passed to process as maps.

 

 

4. TaskService is also a class available in flowable to initiate / play / work around with the flowable tasks.


@Autowired
private TaskService taskService;

 

 

Fetching the list of tasks for a particular assignee:


// this just fetches the list of tasks by the assignee name.

List<Task> tasks = taskService.createTaskQuery().taskAssignee(assignee).orderByDueDateNullsLast().desc().list();

 

 

5. Deleting a process with process_id

Process_id can be taken from the “act_ru_task” table “PROC_INST_ID_” column


@Autowired
private RuntimeService runtimeService;

runtimeService.deleteProcessInstance(processInstanceId, "test");

 

@DeleteMapping(value = "/process/{processInstanceId}")
public boolean deleteLmImplementationByProcess(@PathVariable("processInstanceId") String processInstanceId) {

runtimeService.deleteProcessInstance(processInstanceId, "test");

return true;
}

 

 

 

6. How to get the process varialbles saved back from flowable tables

//Here executionid, is the task key id.


Map<String, Object> processVariables = runtimeService.getVariables(task.getExecutionId());

String taskDefKey = StringUtils.trimToEmpty(task.getTaskDefinitionKey());

// this returns the coupons process variables saved.

processVariables.get("coupons");

 

 

7. How to create a diagram in flowable ?

Flowable Modeler can be used to create any new BPMN process flowable diagrams. Please make sure flowable installation is completed properly before trying to open the below link,

http://localhost:8080/flowable-modeler/#/editor/

Process -> Create Process

 

We have different flows like manual task, end event, choice gateway, timer trigger, intermediate events etc.

Along with that you will also find a different tasks like user task/Script task/Business rule task/Receive task/Manual task/Mail task/Camel task/Http task/Mule task/Send task/Shell task/Decision task.

Mainly we need to fill the fields for every tasks like id(unique to identity and process the task), assignee to take the flow properly with respect to the allowed flowable users, Delegate expression like sending/notifying some updates to involved groups and category(this one can be reused to identify if different flows are using the same functionality).

 

186 total views, 6 views today

About: Mirthbees

Blogger, Innovator, Developer and Enterpreneur. Founder of GuruRecharge, Readymade online recharge script. Lead Developer in Bookrate.in