Search in sources :

Example 1 with ParallelGateway

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());
}
Also used : ParallelGateway(org.activiti.bpmn.model.ParallelGateway) StartEvent(org.activiti.bpmn.model.StartEvent) UserTask(org.activiti.bpmn.model.UserTask) EndEvent(org.activiti.bpmn.model.EndEvent) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) BpmnModel(org.activiti.bpmn.model.BpmnModel) Deployment(org.activiti.engine.test.Deployment)

Example 2 with ParallelGateway

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;
}
Also used : ThrowEvent(org.activiti.bpmn.model.ThrowEvent) BaseElement(org.activiti.bpmn.model.BaseElement) ExclusiveGateway(org.activiti.bpmn.model.ExclusiveGateway) Signal(org.activiti.bpmn.model.Signal) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) HashMap(java.util.HashMap) ParallelGateway(org.activiti.bpmn.model.ParallelGateway) UserTask(org.activiti.bpmn.model.UserTask)

Example 3 with ParallelGateway

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;
}
Also used : ParallelGateway(org.activiti.bpmn.model.ParallelGateway)

Example 4 with ParallelGateway

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;
}
Also used : ParallelGateway(org.activiti.bpmn.model.ParallelGateway)

Example 5 with 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"));
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) FlowElement(org.activiti.bpmn.model.FlowElement) ParallelGateway(org.activiti.bpmn.model.ParallelGateway) SequenceFlow(org.activiti.bpmn.model.SequenceFlow)

Aggregations

ParallelGateway (org.activiti.bpmn.model.ParallelGateway)9 FlowElement (org.activiti.bpmn.model.FlowElement)3 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)2 UserTask (org.activiti.bpmn.model.UserTask)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 BaseElement (org.activiti.bpmn.model.BaseElement)1 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)1 BpmnModel (org.activiti.bpmn.model.BpmnModel)1 EndEvent (org.activiti.bpmn.model.EndEvent)1 ExclusiveGateway (org.activiti.bpmn.model.ExclusiveGateway)1 Signal (org.activiti.bpmn.model.Signal)1 StartEvent (org.activiti.bpmn.model.StartEvent)1 SubProcess (org.activiti.bpmn.model.SubProcess)1 ThrowEvent (org.activiti.bpmn.model.ThrowEvent)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1 Deployment (org.activiti.engine.test.Deployment)1 WorkflowDefinitionConversionFactory (org.activiti.workflow.simple.converter.WorkflowDefinitionConversionFactory)1 ListStepDefinition (org.activiti.workflow.simple.definition.ListStepDefinition)1 ParallelStepsDefinition (org.activiti.workflow.simple.definition.ParallelStepsDefinition)1