Search in sources :

Example 6 with ParallelGateway

use of org.activiti.bpmn.model.ParallelGateway in project Activiti by Activiti.

the class FlowNodeMultipleOutgoingFlowsConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("parallel1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof ParallelGateway);
    ParallelGateway gateway = (ParallelGateway) flowElement;
    List<SequenceFlow> sequenceFlows = gateway.getOutgoingFlows();
    assertTrue(sequenceFlows.size() == 3);
    assertTrue(sequenceFlows.get(0).getId().equals("sid-B9EE4ECE-BF72-4C25-B768-8295906E5CF8") || sequenceFlows.get(0).getId().equals("sid-D2491B73-0382-4EC2-AAAC-C8FD129E4CBE") || sequenceFlows.get(0).getId().equals("sid-7036D56C-E8EF-493B-ADEC-57EED4C6CE1F"));
    assertTrue(sequenceFlows.get(1).getId().equals("sid-B9EE4ECE-BF72-4C25-B768-8295906E5CF8") || sequenceFlows.get(1).getId().equals("sid-D2491B73-0382-4EC2-AAAC-C8FD129E4CBE") || sequenceFlows.get(1).getId().equals("sid-7036D56C-E8EF-493B-ADEC-57EED4C6CE1F"));
    assertTrue(sequenceFlows.get(2).getId().equals("sid-B9EE4ECE-BF72-4C25-B768-8295906E5CF8") || sequenceFlows.get(2).getId().equals("sid-D2491B73-0382-4EC2-AAAC-C8FD129E4CBE") || sequenceFlows.get(2).getId().equals("sid-7036D56C-E8EF-493B-ADEC-57EED4C6CE1F"));
    assertTrue(sequenceFlows.get(0).getSourceRef().equals("parallel1"));
    assertTrue(sequenceFlows.get(1).getSourceRef().equals("parallel1"));
    assertTrue(sequenceFlows.get(2).getSourceRef().equals("parallel1"));
    flowElement = model.getMainProcess().getFlowElement("parallel2");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof ParallelGateway);
    gateway = (ParallelGateway) flowElement;
    sequenceFlows = gateway.getIncomingFlows();
    assertTrue(sequenceFlows.size() == 3);
    assertTrue(sequenceFlows.get(0).getId().equals("sid-4C19E041-42FA-485D-9D09-D47CCD9DB270") || sequenceFlows.get(0).getId().equals("sid-05A991A6-0296-4867-ACBA-EF9EEC68FB8A") || sequenceFlows.get(0).getId().equals("sid-C546AC84-379D-4094-9DC3-548593F2EA0D"));
    assertTrue(sequenceFlows.get(1).getId().equals("sid-4C19E041-42FA-485D-9D09-D47CCD9DB270") || sequenceFlows.get(1).getId().equals("sid-05A991A6-0296-4867-ACBA-EF9EEC68FB8A") || sequenceFlows.get(1).getId().equals("sid-C546AC84-379D-4094-9DC3-548593F2EA0D"));
    assertTrue(sequenceFlows.get(2).getId().equals("sid-4C19E041-42FA-485D-9D09-D47CCD9DB270") || sequenceFlows.get(2).getId().equals("sid-05A991A6-0296-4867-ACBA-EF9EEC68FB8A") || sequenceFlows.get(2).getId().equals("sid-C546AC84-379D-4094-9DC3-548593F2EA0D"));
    assertTrue(sequenceFlows.get(0).getTargetRef().equals("parallel2"));
    assertTrue(sequenceFlows.get(1).getTargetRef().equals("parallel2"));
    assertTrue(sequenceFlows.get(2).getTargetRef().equals("parallel2"));
}
Also used : FlowElement(org.activiti.bpmn.model.FlowElement) ParallelGateway(org.activiti.bpmn.model.ParallelGateway) SequenceFlow(org.activiti.bpmn.model.SequenceFlow)

Example 7 with ParallelGateway

use of org.activiti.bpmn.model.ParallelGateway in project Activiti by Activiti.

the class ParallelGatewayXMLConverter method convertXMLToElement.

@Override
protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
    ParallelGateway gateway = new ParallelGateway();
    BpmnXMLUtil.addXMLLocation(gateway, xtr);
    parseChildElements(getXMLElementName(), gateway, model, xtr);
    return gateway;
}
Also used : ParallelGateway(org.activiti.bpmn.model.ParallelGateway)

Example 8 with ParallelGateway

use of org.activiti.bpmn.model.ParallelGateway in project Activiti by Activiti.

the class ParallelStepsDefinitionConverter method createProcessArtifact.

protected ParallelGateway createProcessArtifact(ParallelStepsDefinition parallelStepsDefinition, WorkflowDefinitionConversion conversion) {
    // First parallel gateway
    ParallelGateway forkGateway = createParallelGateway(conversion);
    // Sequence flow from last activity to first gateway
    addSequenceFlow(conversion, conversion.getLastActivityId(), forkGateway.getId());
    conversion.setLastActivityId(forkGateway.getId());
    // Convert all other steps, disabling activity id updates which makes all 
    // generated steps have a sequence flow to the first gateway
    WorkflowDefinitionConversionFactory conversionFactory = conversion.getConversionFactory();
    List<FlowElement> endElements = new ArrayList<FlowElement>();
    for (ListStepDefinition<ParallelStepsDefinition> stepListDefinition : parallelStepsDefinition.getStepList()) {
        for (int i = 0; i < stepListDefinition.getSteps().size(); i++) {
            if (i == 0) {
                conversion.setSequenceflowGenerationEnabled(false);
            } else {
                conversion.setSequenceflowGenerationEnabled(true);
            }
            StepDefinition step = stepListDefinition.getSteps().get(i);
            FlowElement flowElement = (FlowElement) conversionFactory.getStepConverterFor(step).convertStepDefinition(step, conversion);
            if (i == 0) {
                addSequenceFlow(conversion, forkGateway.getId(), flowElement.getId());
            }
            if ((i + 1) == stepListDefinition.getSteps().size()) {
                endElements.add(flowElement);
            }
        }
    }
    conversion.setSequenceflowGenerationEnabled(false);
    // Second parallel gateway
    ParallelGateway joinGateway = createParallelGateway(conversion);
    conversion.setLastActivityId(joinGateway.getId());
    conversion.setSequenceflowGenerationEnabled(true);
    // Create sequence flow from all generated steps to the second gateway
    for (FlowElement endElement : endElements) {
        addSequenceFlow(conversion, endElement.getId(), joinGateway.getId());
    }
    return forkGateway;
}
Also used : ParallelGateway(org.activiti.bpmn.model.ParallelGateway) WorkflowDefinitionConversionFactory(org.activiti.workflow.simple.converter.WorkflowDefinitionConversionFactory) FlowElement(org.activiti.bpmn.model.FlowElement) ArrayList(java.util.ArrayList) ParallelStepsDefinition(org.activiti.workflow.simple.definition.ParallelStepsDefinition) ListStepDefinition(org.activiti.workflow.simple.definition.ListStepDefinition) StepDefinition(org.activiti.workflow.simple.definition.StepDefinition)

Example 9 with ParallelGateway

use of org.activiti.bpmn.model.ParallelGateway in project Activiti by Activiti.

the class FeedbackStepDefinitionConverter method createForkParallelGateway.

protected ParallelGateway createForkParallelGateway(WorkflowDefinitionConversion conversion, Map<String, BaseElement> processElements) {
    ParallelGateway fork = new ParallelGateway();
    fork.setId(conversion.getUniqueNumberedId(ConversionConstants.GATEWAY_ID_PREFIX));
    addFlowElement(conversion, fork);
    processElements.put(FEEDBACK_FORK, fork);
    return fork;
}
Also used : ParallelGateway(org.activiti.bpmn.model.ParallelGateway)

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