Search in sources :

Example 1 with Event

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

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

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

the class CompensateEventDefinitionParser method parseChildElement.

public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
    if (parentElement instanceof Event == false)
        return;
    CompensateEventDefinition eventDefinition = new CompensateEventDefinition();
    BpmnXMLUtil.addXMLLocation(eventDefinition, xtr);
    eventDefinition.setActivityRef(xtr.getAttributeValue(null, ATTRIBUTE_COMPENSATE_ACTIVITYREF));
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_COMPENSATE_WAITFORCOMPLETION))) {
        eventDefinition.setWaitForCompletion(Boolean.parseBoolean(xtr.getAttributeValue(null, ATTRIBUTE_COMPENSATE_WAITFORCOMPLETION)));
    }
    BpmnXMLUtil.parseChildElements(ELEMENT_EVENT_COMPENSATEDEFINITION, eventDefinition, xtr, model);
    ((Event) parentElement).getEventDefinitions().add(eventDefinition);
}
Also used : Event(org.activiti.bpmn.model.Event) CompensateEventDefinition(org.activiti.bpmn.model.CompensateEventDefinition)

Example 4 with Event

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

the class ErrorEventDefinitionParser method parseChildElement.

public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
    if (parentElement instanceof Event == false)
        return;
    ErrorEventDefinition eventDefinition = new ErrorEventDefinition();
    BpmnXMLUtil.addXMLLocation(eventDefinition, xtr);
    eventDefinition.setErrorCode(xtr.getAttributeValue(null, "errorRef"));
    BpmnXMLUtil.parseChildElements(ELEMENT_EVENT_ERRORDEFINITION, eventDefinition, xtr, model);
    ((Event) parentElement).getEventDefinitions().add(eventDefinition);
}
Also used : ErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition) Event(org.activiti.bpmn.model.Event)

Example 5 with Event

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

the class TimerEventDefinitionParser method parseChildElement.

public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
    if (parentElement instanceof Event == false)
        return;
    TimerEventDefinition eventDefinition = new TimerEventDefinition();
    String calendarName = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_CALENDAR_NAME);
    if (StringUtils.isNotEmpty(calendarName)) {
        eventDefinition.setCalendarName(calendarName);
    }
    BpmnXMLUtil.addXMLLocation(eventDefinition, xtr);
    BpmnXMLUtil.parseChildElements(ELEMENT_EVENT_TIMERDEFINITION, eventDefinition, xtr, model);
    ((Event) parentElement).getEventDefinitions().add(eventDefinition);
}
Also used : Event(org.activiti.bpmn.model.Event) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Aggregations

Event (org.activiti.bpmn.model.Event)11 FlowElement (org.activiti.bpmn.model.FlowElement)4 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)3 MessageEventDefinition (org.activiti.bpmn.model.MessageEventDefinition)3 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)3 SignalEventDefinition (org.activiti.bpmn.model.SignalEventDefinition)3 EventDefinition (org.activiti.bpmn.model.EventDefinition)2 Gateway (org.activiti.bpmn.model.Gateway)2 Message (org.activiti.bpmn.model.Message)2 Signal (org.activiti.bpmn.model.Signal)2 SubProcess (org.activiti.bpmn.model.SubProcess)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 com.mxgraph.view.mxGraph (com.mxgraph.view.mxGraph)1 ArrayList (java.util.ArrayList)1 Activity (org.activiti.bpmn.model.Activity)1 Artifact (org.activiti.bpmn.model.Artifact)1 Association (org.activiti.bpmn.model.Association)1 CallActivity (org.activiti.bpmn.model.CallActivity)1 CancelEventDefinition (org.activiti.bpmn.model.CancelEventDefinition)1 CompensateEventDefinition (org.activiti.bpmn.model.CompensateEventDefinition)1