Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 2.59 KB

task_execution_sample.adoc

File metadata and controls

46 lines (31 loc) · 2.59 KB

Task Execution Sample

This sample demonstrates the following:

  • How to programmatically create process actors on process start using the ProcActionsFragment;

  • How to pass process variables to the process instance using the ProcActionsFragment;

  • How to get and modify standard process actions created by the ProcActionsFragment (e.g. change "Start process" button caption);

  • How to start a process programmatically without the ProcActionsFragment;

  • How to automatically update the processState field each time the process moves further using the ActivitiEventListener.

The sample uses the Task execution – 1 process model:

TaskExecution1Model
Figure 1. Task Execution Model

In this example, we don’t use the StandardProcForm to assign process actors. We do it with the help of the before start process predicate of the ProcActionsFragment. See the setBeforeStartProcessPredicate() method.

TaskEdit.java
link:../../../source/examples/TaskEdit.java[role=include]

See the setStartProcessActionProcessVariablesSupplier() usage in the TaskEdit.java as an example of how to pass process variables at process start using the ProcActionsFragment. The acceptanceRequired process variable will be used by one of the process gateways to decide whether the task must be accepted by the initiator or the process must be completed.

The changeStartProcessBtnCaption() demonstrates that you can get and modify process actions generated by the ProcActionsFragment. In this method, the standard button caption "Start process" is replaced by the custom one.

The onStartProcessProgrammaticallyBtnClick() method demonstrates how to start a new process instance without the ProcActionsFragment.

The UpdateProcessStateListener.java is an implementation of the org.activiti.engine.delegate.event.ActivitiEventListener. This listener is registered as a process-level listener. It does the following: each time a new process step is reached, the processState field of the related com.company.bpmsamples.entity.Task entity is updated with the current process step name.

UpdateProcessStateListener.java
link:../../../source/examples/UpdateProcessStateListener.java[role=include]

That’s how process-level event listeners configuration looks in the process model.

TaskExecution1UpdateProcessStateListener
Figure 2. Process State Listener

To open this window click somewhere in the modeler, click the Show advanced properties link and then go with the Event listeners property.