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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations