how to integrate ExclusiveGateway , EndEvent and other workflow objects using java to create own Model

cancel
Showing results for 
Search instead for 
Did you mean: 
ilyass_act
Active Member

how to integrate ExclusiveGateway , EndEvent and other workflow objects using java to create own Model

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

8 Replies
jearles
Established Member II

Re: how to create object such as ExclusiveGateway , EndEvent ... using java

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

ilyass_act
Active Member

Re:  how to create object such as ExclusiveGateway , EndEvent  ... using java

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]

gdharley
Intermediate

Re: how to integrate ExclusiveGateway , EndEvent and other workflow objects using java to create own Model

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

ilyass_act
Active Member

Re:  how to  integrate ExclusiveGateway , EndEvent and other workflow objects using java to create own Model

Is there any special Doc where i can find this ?

gdharley
Intermediate

Re: how to integrate ExclusiveGateway , EndEvent and other workflow objects using java to create own Model

Only the source code.

Greg

ilyass_act
Active Member

Re: how to integrate ExclusiveGateway , EndEvent and other workflow objects using java to create own Model

Link to the source code

gdharley
Intermediate

Re: how to integrate ExclusiveGateway , EndEvent and other workflow objects using java to create own Model

ilyass_act
Active Member

Re:  how to  integrate ExclusiveGateway , EndEvent and other workflow objects using java to create own Model

Thanks