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
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
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]
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
Is there any special Doc where i can find this ?
Only the source code.
Greg
Link to the source code
Thanks
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.