Search in sources :

Example 1 with BoundaryEvent

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);
    }
}
Also used : BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) com.mxgraph.model.mxGeometry(com.mxgraph.model.mxGeometry) com.mxgraph.model.mxCell(com.mxgraph.model.mxCell) DataObject(org.activiti.bpmn.model.DataObject) com.mxgraph.util.mxPoint(com.mxgraph.util.mxPoint)

Example 2 with BoundaryEvent

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();
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) Task(org.activiti.bpmn.model.Task) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) com.mxgraph.view.mxGraph(com.mxgraph.view.mxGraph) CallActivity(org.activiti.bpmn.model.CallActivity) Artifact(org.activiti.bpmn.model.Artifact) Association(org.activiti.bpmn.model.Association) FlowElement(org.activiti.bpmn.model.FlowElement) Gateway(org.activiti.bpmn.model.Gateway) Event(org.activiti.bpmn.model.Event) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) DataObject(org.activiti.bpmn.model.DataObject) TextAnnotation(org.activiti.bpmn.model.TextAnnotation)

Example 3 with BoundaryEvent

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);
    }
}
Also used : BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) FlowElement(org.activiti.bpmn.model.FlowElement) ArrayList(java.util.ArrayList) Event(org.activiti.bpmn.model.Event) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent)

Example 4 with BoundaryEvent

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));
    }
}
Also used : TimerDeclarationImpl(org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent) TimerStartEventJobHandler(org.activiti.engine.impl.jobexecutor.TimerStartEventJobHandler) TimerCatchIntermediateEventJobHandler(org.activiti.engine.impl.jobexecutor.TimerCatchIntermediateEventJobHandler) TimerExecuteNestedActivityJobHandler(org.activiti.engine.impl.jobexecutor.TimerExecuteNestedActivityJobHandler) JobHandler(org.activiti.engine.impl.jobexecutor.JobHandler) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) StartEvent(org.activiti.bpmn.model.StartEvent) ArrayList(java.util.ArrayList) List(java.util.List) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 5 with BoundaryEvent

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);
        }
    }
}
Also used : ThrowEvent(org.activiti.bpmn.model.ThrowEvent) Signal(org.activiti.bpmn.model.Signal) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent) StartEvent(org.activiti.bpmn.model.StartEvent) EventSubscriptionDeclaration(org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration)

Aggregations

BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)31 FlowElement (org.activiti.bpmn.model.FlowElement)11 SubProcess (org.activiti.bpmn.model.SubProcess)8 StartEvent (org.activiti.bpmn.model.StartEvent)7 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)7 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)6 SignalEventDefinition (org.activiti.bpmn.model.SignalEventDefinition)6 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)6 UserTask (org.activiti.bpmn.model.UserTask)6 ErrorEventDefinition (org.activiti.bpmn.model.ErrorEventDefinition)5 CompensateEventDefinition (org.activiti.bpmn.model.CompensateEventDefinition)4 DataObject (org.activiti.bpmn.model.DataObject)4 EventDefinition (org.activiti.bpmn.model.EventDefinition)4 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)4 MessageEventDefinition (org.activiti.bpmn.model.MessageEventDefinition)4 Activity (org.activiti.bpmn.model.Activity)3 Association (org.activiti.bpmn.model.Association)3 CancelEventDefinition (org.activiti.bpmn.model.CancelEventDefinition)3 Event (org.activiti.bpmn.model.Event)3 FlowNode (org.activiti.bpmn.model.FlowNode)3