04-19-2017 08:45 AM
I'm working on a workflow project using Activiti and i'm wondering if there is any helpful doc where i can find how to create object such as ExclusiveGateway , EndEvent ... using java not the XML representation
04-19-2017 12:10 PM
Hi Ilyasse,
What is the particular use case that you're looking to solve doing this? Generally speaking within BPMN, the process is intended to be pretty structured from the get-go, meaning that the gateways and end events are already created prior to running any Java code along side the process instance.
-JEarles
04-19-2017 12:23 PM
ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration()
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
.setJdbcUrl("jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000")
.buildProcessEngine();
RuntimeService runtimeService = processEngine.getRuntimeService();
RepositoryService repositoryService = processEngine.getRepositoryService();
TaskService taskService = processEngine.getTaskService();
// 1. Build up the model from scratch
BpmnModel model = new BpmnModel();
org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process();
model.addProcess(process);
process.setId("my-process");
process.addFlowElement(createStartEvent());
....
process.addFlowElement(createUserTask("task3", "Thirds task","ilyass" ));
new BpmnAutoLayout(model).execute();
Deployment deployment = repositoryService.createDeployment()
.addBpmnModel("dynamic-model.bpmn", model).name("Dynamic process deployment").deploy();
ProcessInstance processInstance =runtimeService
.startProcessInstanceByKey("my-process");
===> create StartEvent :
public static StartEvent createStartEvent(){
StartEvent startEvent = new StartEvent();
startEvent.setId("start");
return startEvent;
}
what i want to do is to create other Workflow component like ExclusiveGateway , and then Bind my process to my JSF pages [if you have any idea how to do that Please help]
04-19-2017 04:03 PM
I think what you are asking for is how to actually create a flow rather than just a bunch of flow elements.
First, create a set of flow elements in the same way you create a start event and user task.
Once you have the flow elements, you "wire" them together using something like:
protected SequenceFlow createSequenceFlow(String from, String to) {
SequenceFlow flow = new SequenceFlow();
flow.setSourceRef(from);
flow.setTargetRef(to);
return flow;
}
...
...
process.addFlowElement(createSequenceFlow("start", "task3"));
Now, the create an exclusive gateway, it is the same process:
ExclusiveGateway gw = new ExclusiveGateway();
gw.setDefaultFlow("aSequenceFlowName");
gw.setId("ExGW");
Now, when the "leave" method is called, the exclusive gateway behavior will be inherited.
You will need to add conditions to the outgoing transitions (sequence flows).
Hope this is what you were after.
Greg
04-20-2017 03:47 AM
Is there any special Doc where i can find this ?
04-20-2017 07:37 AM
Only the source code.
Greg
04-20-2017 08:39 AM
Link to the source code
04-20-2017 08:42 AM
04-20-2017 08:53 AM
Thanks
Explore our Alfresco products with the links below. Use labels to filter content by product module.