Search in sources :

Example 1 with ExclusiveGateway

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

the class ChoiceStepsDefinitionConverter method createExclusiveGateway.

protected ExclusiveGateway createExclusiveGateway(WorkflowDefinitionConversion conversion) {
    ExclusiveGateway exclusiveGateway = new ExclusiveGateway();
    exclusiveGateway.setId(conversion.getUniqueNumberedId(EXLCUSIVE_GATEWAY_PREFIX));
    conversion.getProcess().addFlowElement(exclusiveGateway);
    return exclusiveGateway;
}
Also used : ExclusiveGateway(org.activiti.bpmn.model.ExclusiveGateway)

Example 2 with ExclusiveGateway

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

the class ChoiceStepsDefinitionConverter method createProcessArtifact.

protected ExclusiveGateway createProcessArtifact(ChoiceStepsDefinition choiceStepsDefinition, WorkflowDefinitionConversion conversion) {
    // First choice gateway
    ExclusiveGateway forkGateway = createExclusiveGateway(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>();
    List<SequenceFlow> bypassingFlows = new ArrayList<SequenceFlow>();
    for (ListConditionStepDefinition<ChoiceStepsDefinition> stepListDefinition : choiceStepsDefinition.getStepList()) {
        StringBuilder conditionBuilder = new StringBuilder();
        for (ConditionDefinition conditionDefintion : stepListDefinition.getConditions()) {
            if (conditionBuilder.length() > 0) {
                conditionBuilder.append(" && ");
            } else {
                conditionBuilder.append("${");
            }
            conditionBuilder.append(conditionDefintion.getLeftOperand());
            conditionBuilder.append(" ");
            conditionBuilder.append(conditionDefintion.getOperator());
            conditionBuilder.append(" ");
            conditionBuilder.append(conditionDefintion.getRightOperand());
        }
        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) {
                if (conditionBuilder.length() > 0) {
                    conditionBuilder.append("}");
                    SequenceFlow mainFlow = addSequenceFlow(conversion, forkGateway.getId(), flowElement.getId(), conditionBuilder.toString());
                    if (stepListDefinition.getName() != null) {
                        mainFlow.setName(stepListDefinition.getName());
                    }
                } else {
                    addSequenceFlow(conversion, forkGateway.getId(), flowElement.getId());
                }
            }
            if ((i + 1) == stepListDefinition.getSteps().size()) {
                endElements.add(flowElement);
            }
        }
        if (stepListDefinition.getSteps().isEmpty()) {
            // Special case for a "stepless" stepListDefinition, which should just create a sequence-flow from the fork to the join
            SequenceFlow created = null;
            if (conditionBuilder.length() > 0) {
                conditionBuilder.append("}");
                created = addSequenceFlow(conversion, forkGateway.getId(), null, conditionBuilder.toString());
            } else {
                created = addSequenceFlow(conversion, forkGateway.getId(), null);
            }
            if (stepListDefinition.getName() != null) {
                created.setName(stepListDefinition.getName());
            }
            bypassingFlows.add(created);
        }
    }
    conversion.setSequenceflowGenerationEnabled(false);
    // Second choice gateway
    ExclusiveGateway joinGateway = createExclusiveGateway(conversion);
    conversion.setLastActivityId(joinGateway.getId());
    conversion.setSequenceflowGenerationEnabled(true);
    // Create sequenceflow from all generated steps to the second gateway
    for (FlowElement endElement : endElements) {
        if (!(endElement instanceof EndEvent)) {
            addSequenceFlow(conversion, endElement.getId(), joinGateway.getId());
        }
    }
    for (SequenceFlow bypassingFlow : bypassingFlows) {
        bypassingFlow.setTargetRef(joinGateway.getId());
    }
    return forkGateway;
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow) ChoiceStepsDefinition(org.activiti.workflow.simple.definition.ChoiceStepsDefinition) ArrayList(java.util.ArrayList) ExclusiveGateway(org.activiti.bpmn.model.ExclusiveGateway) WorkflowDefinitionConversionFactory(org.activiti.workflow.simple.converter.WorkflowDefinitionConversionFactory) FlowElement(org.activiti.bpmn.model.FlowElement) StepDefinition(org.activiti.workflow.simple.definition.StepDefinition) ListConditionStepDefinition(org.activiti.workflow.simple.definition.ListConditionStepDefinition) EndEvent(org.activiti.bpmn.model.EndEvent) ConditionDefinition(org.activiti.workflow.simple.definition.ConditionDefinition)

Example 3 with ExclusiveGateway

use of org.activiti.bpmn.model.ExclusiveGateway 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 4 with ExclusiveGateway

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

the class ComplexGatewayXMLConverter method convertXMLToElement.

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

Example 5 with ExclusiveGateway

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

the class ExclusiveGatewayXMLConverter method convertXMLToElement.

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

Aggregations

ExclusiveGateway (org.activiti.bpmn.model.ExclusiveGateway)9 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)4 FlowElement (org.activiti.bpmn.model.FlowElement)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Activity (org.activiti.bpmn.model.Activity)1 BaseElement (org.activiti.bpmn.model.BaseElement)1 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)1 EndEvent (org.activiti.bpmn.model.EndEvent)1 GraphicInfo (org.activiti.bpmn.model.GraphicInfo)1 ParallelGateway (org.activiti.bpmn.model.ParallelGateway)1 Signal (org.activiti.bpmn.model.Signal)1 ThrowEvent (org.activiti.bpmn.model.ThrowEvent)1 UserTask (org.activiti.bpmn.model.UserTask)1 ActivitiException (org.activiti.engine.ActivitiException)1 WorkflowDefinitionConversionFactory (org.activiti.workflow.simple.converter.WorkflowDefinitionConversionFactory)1 ChoiceStepsDefinition (org.activiti.workflow.simple.definition.ChoiceStepsDefinition)1 ConditionDefinition (org.activiti.workflow.simple.definition.ConditionDefinition)1