use of org.activiti.bpmn.model.BoundaryEvent in project Activiti by Activiti.
the class BpmnAutoLayout method handleBoundaryEvents.
protected void handleBoundaryEvents() {
for (BoundaryEvent boundaryEvent : boundaryEvents) {
mxGeometry geometry = new mxGeometry(0.8, 1.0, eventSize, eventSize);
geometry.setOffset(new mxPoint(-(eventSize / 2), -(eventSize / 2)));
geometry.setRelative(true);
mxCell boundaryPort = new mxCell(null, geometry, "shape=ellipse;perimter=ellipsePerimeter");
boundaryPort.setId("boundary-event-" + boundaryEvent.getId());
boundaryPort.setVertex(true);
Object portParent = null;
if (boundaryEvent.getAttachedToRefId() != null) {
portParent = generatedVertices.get(boundaryEvent.getAttachedToRefId());
} else if (boundaryEvent.getAttachedToRef() != null) {
portParent = generatedVertices.get(boundaryEvent.getAttachedToRef().getId());
} else {
throw new RuntimeException("Could not generate DI: boundaryEvent '" + boundaryEvent.getId() + "' has no attachedToRef");
}
graph.addCell(boundaryPort, portParent);
generatedVertices.put(boundaryEvent.getId(), boundaryPort);
}
}
use of org.activiti.bpmn.model.BoundaryEvent in project Activiti by Activiti.
the class BpmnAutoLayout method layout.
protected void layout(FlowElementsContainer flowElementsContainer) {
graph = new mxGraph();
cellParent = graph.getDefaultParent();
graph.getModel().beginUpdate();
// Subprocesses are handled in a new instance of BpmnAutoLayout, hence they instantiations of new maps here.
handledFlowElements = new HashMap<String, FlowElement>();
handledArtifacts = new HashMap<String, Artifact>();
generatedVertices = new HashMap<String, Object>();
generatedSequenceFlowEdges = new HashMap<String, Object>();
generatedAssociationEdges = new HashMap<String, Object>();
//Associations are gathered and processed afterwards, because we must be sure we alreadydiv found source and target
associations = new HashMap<String, Association>();
// Text Annotations are gathered and processed afterwards, because we must be sure we already found the parent.
textAnnotations = new HashMap<String, TextAnnotation>();
// Sequence flow are gathered and processed afterwards, because we must be sure we alreadt found source and target
sequenceFlows = new HashMap<String, SequenceFlow>();
// Boundary events are gathered and processed afterwards, because we must be sure we have its parent
boundaryEvents = new ArrayList<BoundaryEvent>();
// Process all elements
for (FlowElement flowElement : flowElementsContainer.getFlowElements()) {
if (flowElement instanceof SequenceFlow) {
handleSequenceFlow((SequenceFlow) flowElement);
} else if (flowElement instanceof Event) {
handleEvent(flowElement);
} else if (flowElement instanceof Gateway) {
createGatewayVertex(flowElement);
} else if (flowElement instanceof Task || flowElement instanceof CallActivity) {
handleActivity(flowElement);
} else if (flowElement instanceof SubProcess) {
handleSubProcess(flowElement);
}
handledFlowElements.put(flowElement.getId(), flowElement);
}
// process artifacts
for (Artifact artifact : flowElementsContainer.getArtifacts()) {
if (artifact instanceof Association) {
handleAssociation((Association) artifact);
} else if (artifact instanceof TextAnnotation) {
handleTextAnnotation((TextAnnotation) artifact);
}
handledArtifacts.put(artifact.getId(), artifact);
}
// Process gathered elements
handleBoundaryEvents();
handleSequenceFlow();
handleAssociations();
// All elements are now put in the graph. Let's layout them!
CustomLayout layout = new CustomLayout(graph, SwingConstants.WEST);
layout.setIntraCellSpacing(100.0);
layout.setResizeParent(true);
layout.setFineTuning(true);
layout.setParentBorder(20);
layout.setMoveParent(true);
layout.setDisableEdgeStyle(false);
layout.setUseBoundingBox(true);
layout.execute(graph.getDefaultParent());
graph.getModel().endUpdate();
generateDiagramInterchangeElements();
}
use of org.activiti.bpmn.model.BoundaryEvent in project Activiti by Activiti.
the class BpmnParse method processFlowElements.
public void processFlowElements(Collection<FlowElement> flowElements) {
// Parsing the elements is done in a strict order of types,
// as otherwise certain information might not be available when parsing a
// certain type.
// Using lists as we want to keep the order in which they are defined
List<SequenceFlow> sequenceFlowToParse = new ArrayList<SequenceFlow>();
List<BoundaryEvent> boundaryEventsToParse = new ArrayList<BoundaryEvent>();
// Flow elements that depend on other elements are parse after the first run-through
List<FlowElement> defferedFlowElementsToParse = new ArrayList<FlowElement>();
// Activities are parsed first
for (FlowElement flowElement : flowElements) {
// Sequence flow are also flow elements, but are only parsed once everyactivity is found
if (flowElement instanceof SequenceFlow) {
sequenceFlowToParse.add((SequenceFlow) flowElement);
} else if (flowElement instanceof BoundaryEvent) {
boundaryEventsToParse.add((BoundaryEvent) flowElement);
} else if (flowElement instanceof Event) {
defferedFlowElementsToParse.add(flowElement);
} else {
bpmnParserHandlers.parseElement(this, flowElement);
}
}
// Deferred elements
for (FlowElement flowElement : defferedFlowElementsToParse) {
bpmnParserHandlers.parseElement(this, flowElement);
}
// Boundary events are parsed after all the regular activities are parsed
for (BoundaryEvent boundaryEvent : boundaryEventsToParse) {
bpmnParserHandlers.parseElement(this, boundaryEvent);
}
// sequence flows
for (SequenceFlow sequenceFlow : sequenceFlowToParse) {
bpmnParserHandlers.parseElement(this, sequenceFlow);
}
}
use of org.activiti.bpmn.model.BoundaryEvent in project Activiti by Activiti.
the class TimerEventDefinitionParseHandler method executeParse.
protected void executeParse(BpmnParse bpmnParse, TimerEventDefinition timerEventDefinition) {
ActivityImpl timerActivity = bpmnParse.getCurrentActivity();
if (bpmnParse.getCurrentFlowElement() instanceof StartEvent) {
ProcessDefinitionEntity processDefinition = bpmnParse.getCurrentProcessDefinition();
timerActivity.setProperty("type", "startTimerEvent");
TimerDeclarationImpl timerDeclaration = createTimer(bpmnParse, timerEventDefinition, timerActivity, TimerStartEventJobHandler.TYPE);
String jobHandlerConfiguration = timerDeclaration.getJobHandlerConfiguration();
Map<String, JobHandler> jobHandlers = Context.getProcessEngineConfiguration().getJobHandlers();
JobHandler jobHandler = jobHandlers.get(TimerStartEventJobHandler.TYPE);
jobHandlerConfiguration = ((TimerEventHandler) jobHandler).setProcessDefinitionKeyToConfiguration(jobHandlerConfiguration, processDefinition.getKey());
jobHandlerConfiguration = ((TimerEventHandler) jobHandler).setActivityIdToConfiguration(jobHandlerConfiguration, timerActivity.getId());
timerDeclaration.setJobHandlerConfiguration(jobHandlerConfiguration);
List<TimerDeclarationImpl> timerDeclarations = (List<TimerDeclarationImpl>) processDefinition.getProperty(PROPERTYNAME_START_TIMER);
if (timerDeclarations == null) {
timerDeclarations = new ArrayList<TimerDeclarationImpl>();
processDefinition.setProperty(PROPERTYNAME_START_TIMER, timerDeclarations);
}
timerDeclarations.add(timerDeclaration);
} else if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) {
timerActivity.setProperty("type", "intermediateTimer");
TimerDeclarationImpl timerDeclaration = createTimer(bpmnParse, timerEventDefinition, timerActivity, TimerCatchIntermediateEventJobHandler.TYPE);
if (getPrecedingEventBasedGateway(bpmnParse, (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement()) != null) {
addTimerDeclaration(timerActivity.getParent(), timerDeclaration);
} else {
addTimerDeclaration(timerActivity, timerDeclaration);
timerActivity.setScope(true);
}
} else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
timerActivity.setProperty("type", "boundaryTimer");
TimerDeclarationImpl timerDeclaration = createTimer(bpmnParse, timerEventDefinition, timerActivity, TimerExecuteNestedActivityJobHandler.TYPE);
// ACT-1427
BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
boolean interrupting = boundaryEvent.isCancelActivity();
if (interrupting) {
timerDeclaration.setInterruptingTimer(true);
}
addTimerDeclaration(timerActivity.getParent(), timerDeclaration);
if (timerActivity.getParent() instanceof ActivityImpl) {
((ActivityImpl) timerActivity.getParent()).setScope(true);
}
timerActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior((BoundaryEvent) bpmnParse.getCurrentFlowElement(), interrupting, timerActivity));
}
}
use of org.activiti.bpmn.model.BoundaryEvent in project Activiti by Activiti.
the class SignalEventDefinitionParseHandler method executeParse.
protected void executeParse(BpmnParse bpmnParse, SignalEventDefinition signalDefinition) {
Signal signal = null;
if (bpmnParse.getBpmnModel().containsSignalId(signalDefinition.getSignalRef())) {
signal = bpmnParse.getBpmnModel().getSignal(signalDefinition.getSignalRef());
String signalName = signal.getName();
signalDefinition.setSignalRef(signalName);
}
if (signal == null) {
return;
}
ActivityImpl activity = bpmnParse.getCurrentActivity();
if (bpmnParse.getCurrentFlowElement() instanceof StartEvent) {
activity.setProperty("type", "signalStartEvent");
EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(signalDefinition.getSignalRef(), "signal");
eventSubscriptionDeclaration.setActivityId(activity.getId());
eventSubscriptionDeclaration.setStartEvent(true);
addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, signalDefinition, bpmnParse.getCurrentScope());
} else if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) {
activity.setProperty("type", "intermediateSignalCatch");
EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(signalDefinition.getSignalRef(), "signal");
if (signal.getScope() != null) {
eventSubscriptionDeclaration.setConfiguration(signal.getScope());
}
if (getPrecedingEventBasedGateway(bpmnParse, (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement()) != null) {
eventSubscriptionDeclaration.setActivityId(activity.getId());
addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, signalDefinition, activity.getParent());
} else {
activity.setScope(true);
addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, signalDefinition, activity);
}
} else if (bpmnParse.getCurrentFlowElement() instanceof ThrowEvent) {
ThrowEvent throwEvent = (ThrowEvent) bpmnParse.getCurrentFlowElement();
activity.setProperty("type", "intermediateSignalThrow");
EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(signalDefinition.getSignalRef(), "signal");
eventSubscriptionDeclaration.setAsync(signalDefinition.isAsync());
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowSignalEventActivityBehavior(throwEvent, signal, eventSubscriptionDeclaration));
} else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
boolean interrupting = boundaryEvent.isCancelActivity();
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity));
activity.setProperty("type", "boundarySignal");
EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(signalDefinition.getSignalRef(), "signal");
eventSubscriptionDeclaration.setActivityId(activity.getId());
if (signal.getScope() != null) {
eventSubscriptionDeclaration.setConfiguration(signal.getScope());
}
addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, signalDefinition, activity.getParent());
if (activity.getParent() instanceof ActivityImpl) {
((ActivityImpl) activity.getParent()).setScope(true);
}
}
}
Aggregations