use of org.activiti.bpmn.model.ParallelGateway in project Activiti by Activiti.
the class RepositoryServiceTest method testGetBpmnModel.
@Deployment
public void testGetBpmnModel() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
// Some basic assertions
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
assertNotNull(bpmnModel);
assertEquals(1, bpmnModel.getProcesses().size());
assertTrue(!bpmnModel.getLocationMap().isEmpty());
assertTrue(!bpmnModel.getFlowLocationMap().isEmpty());
// Test the flow
org.activiti.bpmn.model.Process process = bpmnModel.getProcesses().get(0);
List<StartEvent> startEvents = process.findFlowElementsOfType(StartEvent.class);
assertEquals(1, startEvents.size());
StartEvent startEvent = startEvents.get(0);
assertEquals(1, startEvent.getOutgoingFlows().size());
assertEquals(0, startEvent.getIncomingFlows().size());
String nextElementId = startEvent.getOutgoingFlows().get(0).getTargetRef();
UserTask userTask = (UserTask) process.getFlowElement(nextElementId);
assertEquals("First Task", userTask.getName());
assertEquals(1, userTask.getOutgoingFlows().size());
assertEquals(1, userTask.getIncomingFlows().size());
nextElementId = userTask.getOutgoingFlows().get(0).getTargetRef();
ParallelGateway parallelGateway = (ParallelGateway) process.getFlowElement(nextElementId);
assertEquals(2, parallelGateway.getOutgoingFlows().size());
nextElementId = parallelGateway.getOutgoingFlows().get(0).getTargetRef();
assertEquals(1, parallelGateway.getIncomingFlows().size());
userTask = (UserTask) process.getFlowElement(nextElementId);
assertEquals(1, userTask.getOutgoingFlows().size());
nextElementId = userTask.getOutgoingFlows().get(0).getTargetRef();
parallelGateway = (ParallelGateway) process.getFlowElement(nextElementId);
assertEquals(1, parallelGateway.getOutgoingFlows().size());
assertEquals(2, parallelGateway.getIncomingFlows().size());
nextElementId = parallelGateway.getOutgoingFlows().get(0).getTargetRef();
EndEvent endEvent = (EndEvent) process.getFlowElement(nextElementId);
assertEquals(0, endEvent.getOutgoingFlows().size());
assertEquals(1, endEvent.getIncomingFlows().size());
}
use of org.activiti.bpmn.model.ParallelGateway in project Activiti by Activiti.
the class FeedbackStepDefinitionConverter method createProcessArtifact.
@Override
protected Map<String, BaseElement> createProcessArtifact(FeedbackStepDefinition feedbackStepDefinition, WorkflowDefinitionConversion conversion) {
// See feedback-step.png in the resource folder to get a graphical understanding of the conversion below
Map<String, BaseElement> processElements = new HashMap<String, BaseElement>();
// The first user task, responsible for configuring the feedback
UserTask selectPeopleUserTask = createSelectPeopleUserTask(feedbackStepDefinition, conversion, processElements);
// Parallel gateways (forking/joining)
ParallelGateway fork = createForkParallelGateway(conversion, processElements);
addSequenceFlow(conversion, selectPeopleUserTask, fork);
// Gather feedback user task for the initiator of the feedback step
UserTask gatherFeedbackUserTask = createGatherFeedbackUserTask(feedbackStepDefinition, conversion, processElements);
addSequenceFlow(conversion, fork, gatherFeedbackUserTask);
// Global signal event
Signal signal = createSignalDeclaration(conversion);
// Signal throw event after the gather feedback task
ThrowEvent signalThrowEvent = createSignalThrow(conversion, signal);
addSequenceFlow(conversion, gatherFeedbackUserTask, signalThrowEvent);
// Povide feedback step
UserTask feedbackTask = createFeedbackUserTask(feedbackStepDefinition, conversion, processElements);
addSequenceFlow(conversion, fork, feedbackTask);
// Boundary signal catch to shut down all tasks if the 'gather feedback' task is completed
BoundaryEvent boundarySignalCatch = createBoundarySignalCatch(conversion, signal, feedbackTask);
// Exclusive gateway after the feedback task, needed to correctly merge the sequence flow
// such that the joining parallel gateway has exactly two incoming sequence flow
ExclusiveGateway mergingExclusiveGateway = createMergingExclusiveGateway(conversion);
addSequenceFlow(conversion, feedbackTask, mergingExclusiveGateway);
addSequenceFlow(conversion, boundarySignalCatch, mergingExclusiveGateway);
// Parallel gateway that will join it all together
ParallelGateway join = createJoinParallelGateway(conversion, processElements);
addSequenceFlow(conversion, signalThrowEvent, join);
addSequenceFlow(conversion, mergingExclusiveGateway, join);
// Set the last activity id, such that next steps can connect correctly
conversion.setLastActivityId(join.getId());
return processElements;
}
use of org.activiti.bpmn.model.ParallelGateway in project Activiti by Activiti.
the class FeedbackStepDefinitionConverter method createJoinParallelGateway.
protected ParallelGateway createJoinParallelGateway(WorkflowDefinitionConversion conversion, Map<String, BaseElement> processElements) {
ParallelGateway join = new ParallelGateway();
join.setId(conversion.getUniqueNumberedId(ConversionConstants.GATEWAY_ID_PREFIX));
addFlowElement(conversion, join);
processElements.put(FEEDBACK_JOIN, join);
return join;
}
use of org.activiti.bpmn.model.ParallelGateway in project Activiti by Activiti.
the class ParallelStepsDefinitionConverter method createParallelGateway.
protected ParallelGateway createParallelGateway(WorkflowDefinitionConversion conversion) {
ParallelGateway parallelGateway = new ParallelGateway();
parallelGateway.setId(conversion.getUniqueNumberedId(PARALLEL_GATEWAY_PREFIX));
conversion.getProcess().addFlowElement(parallelGateway);
return parallelGateway;
}
use of org.activiti.bpmn.model.ParallelGateway in project Activiti by Activiti.
the class FlowNodeInSubProcessConverterTest method validateModel.
private void validateModel(BpmnModel model) {
FlowElement flowElement = model.getMainProcess().getFlowElement("subprocess1");
assertNotNull(flowElement);
assertTrue(flowElement instanceof SubProcess);
SubProcess subProcess = (SubProcess) flowElement;
ParallelGateway gateway = (ParallelGateway) subProcess.getFlowElement("sid-A0E0B174-36DF-4C4F-A952-311CC3C031FC");
assertNotNull(gateway);
List<SequenceFlow> sequenceFlows = gateway.getOutgoingFlows();
assertTrue(sequenceFlows.size() == 2);
assertTrue(sequenceFlows.get(0).getId().equals("sid-9C669980-C274-4A48-BF7F-B9C5CA577DD2") || sequenceFlows.get(0).getId().equals("sid-A299B987-396F-46CA-8D63-85991FBFCE6E"));
assertTrue(sequenceFlows.get(1).getId().equals("sid-9C669980-C274-4A48-BF7F-B9C5CA577DD2") || sequenceFlows.get(1).getId().equals("sid-A299B987-396F-46CA-8D63-85991FBFCE6E"));
assertTrue(sequenceFlows.get(0).getSourceRef().equals("sid-A0E0B174-36DF-4C4F-A952-311CC3C031FC"));
assertTrue(sequenceFlows.get(1).getSourceRef().equals("sid-A0E0B174-36DF-4C4F-A952-311CC3C031FC"));
}
Aggregations