Search in sources :

Example 41 with SequenceFlow

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

the class BpmnAutoLayout method handleSequenceFlow.

protected void handleSequenceFlow() {
    Hashtable<String, Object> edgeStyle = new Hashtable<String, Object>();
    edgeStyle.put(mxConstants.STYLE_ORTHOGONAL, true);
    edgeStyle.put(mxConstants.STYLE_EDGE, mxEdgeStyle.ElbowConnector);
    edgeStyle.put(mxConstants.STYLE_ENTRY_X, 0.0);
    edgeStyle.put(mxConstants.STYLE_ENTRY_Y, 0.5);
    graph.getStylesheet().putCellStyle(STYLE_SEQUENCEFLOW, edgeStyle);
    Hashtable<String, Object> boundaryEdgeStyle = new Hashtable<String, Object>();
    boundaryEdgeStyle.put(mxConstants.STYLE_EXIT_X, 0.5);
    boundaryEdgeStyle.put(mxConstants.STYLE_EXIT_Y, 1.0);
    boundaryEdgeStyle.put(mxConstants.STYLE_ENTRY_X, 0.5);
    boundaryEdgeStyle.put(mxConstants.STYLE_ENTRY_Y, 1.0);
    boundaryEdgeStyle.put(mxConstants.STYLE_EDGE, mxEdgeStyle.OrthConnector);
    graph.getStylesheet().putCellStyle(STYLE_BOUNDARY_SEQUENCEFLOW, boundaryEdgeStyle);
    for (SequenceFlow sequenceFlow : sequenceFlows.values()) {
        Object sourceVertex = generatedVertices.get(sequenceFlow.getSourceRef());
        Object targetVertex = generatedVertices.get(sequenceFlow.getTargetRef());
        String style = null;
        if (handledFlowElements.get(sequenceFlow.getSourceRef()) instanceof BoundaryEvent) {
            // Sequence flow out of boundary events are handled in a
            // different way,
            // to make them visually appealing for the eye of the dear end
            // user.
            style = STYLE_BOUNDARY_SEQUENCEFLOW;
        } else {
            style = STYLE_SEQUENCEFLOW;
        }
        Object sequenceFlowEdge = graph.insertEdge(cellParent, sequenceFlow.getId(), "", sourceVertex, targetVertex, style);
        generatedSequenceFlowEdges.put(sequenceFlow.getId(), sequenceFlowEdge);
    }
}
Also used : BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) Hashtable(java.util.Hashtable) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) DataObject(org.activiti.bpmn.model.DataObject)

Example 42 with SequenceFlow

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

the class BaseBpmnXMLConverter method convertToXML.

public void convertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel model) throws Exception {
    xtw.writeStartElement(BPMN2_PREFIX, getXMLElementName(), BPMN2_NAMESPACE);
    boolean didWriteExtensionStartElement = false;
    writeDefaultAttribute(ATTRIBUTE_ID, baseElement.getId(), xtw);
    if (baseElement instanceof FlowElement) {
        writeDefaultAttribute(ATTRIBUTE_NAME, ((FlowElement) baseElement).getName(), xtw);
    }
    if (baseElement instanceof FlowNode) {
        final FlowNode flowNode = (FlowNode) baseElement;
        if (flowNode.isAsynchronous()) {
            writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, ATTRIBUTE_VALUE_TRUE, xtw);
            if (flowNode.isNotExclusive()) {
                writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_EXCLUSIVE, ATTRIBUTE_VALUE_FALSE, xtw);
            }
        }
        if (baseElement instanceof Activity) {
            final Activity activity = (Activity) baseElement;
            if (activity.isForCompensation()) {
                writeDefaultAttribute(ATTRIBUTE_ACTIVITY_ISFORCOMPENSATION, ATTRIBUTE_VALUE_TRUE, xtw);
            }
            if (StringUtils.isNotEmpty(activity.getDefaultFlow())) {
                FlowElement defaultFlowElement = model.getFlowElement(activity.getDefaultFlow());
                if (defaultFlowElement instanceof SequenceFlow) {
                    writeDefaultAttribute(ATTRIBUTE_DEFAULT, activity.getDefaultFlow(), xtw);
                }
            }
        }
        if (baseElement instanceof Gateway) {
            final Gateway gateway = (Gateway) baseElement;
            if (StringUtils.isNotEmpty(gateway.getDefaultFlow())) {
                FlowElement defaultFlowElement = model.getFlowElement(gateway.getDefaultFlow());
                if (defaultFlowElement instanceof SequenceFlow) {
                    writeDefaultAttribute(ATTRIBUTE_DEFAULT, gateway.getDefaultFlow(), xtw);
                }
            }
        }
    }
    writeAdditionalAttributes(baseElement, model, xtw);
    if (baseElement instanceof FlowElement) {
        final FlowElement flowElement = (FlowElement) baseElement;
        if (StringUtils.isNotEmpty(flowElement.getDocumentation())) {
            xtw.writeStartElement(BPMN2_PREFIX, ELEMENT_DOCUMENTATION, BPMN2_NAMESPACE);
            xtw.writeCharacters(flowElement.getDocumentation());
            xtw.writeEndElement();
        }
    }
    didWriteExtensionStartElement = writeExtensionChildElements(baseElement, didWriteExtensionStartElement, xtw);
    didWriteExtensionStartElement = writeListeners(baseElement, didWriteExtensionStartElement, xtw);
    didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(baseElement, didWriteExtensionStartElement, model.getNamespaces(), xtw);
    if (baseElement instanceof Activity) {
        final Activity activity = (Activity) baseElement;
        FailedJobRetryCountExport.writeFailedJobRetryCount(activity, xtw);
    }
    if (didWriteExtensionStartElement) {
        xtw.writeEndElement();
    }
    writeIncomingOutgoingFlowElements(baseElement, model, xtw);
    if (baseElement instanceof Activity) {
        final Activity activity = (Activity) baseElement;
        MultiInstanceExport.writeMultiInstance(activity, xtw);
    }
    writeAdditionalChildElements(baseElement, model, xtw);
    xtw.writeEndElement();
}
Also used : FlowElement(org.activiti.bpmn.model.FlowElement) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) Gateway(org.activiti.bpmn.model.Gateway) Activity(org.activiti.bpmn.model.Activity) FlowNode(org.activiti.bpmn.model.FlowNode)

Example 43 with SequenceFlow

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

the class SubprocessXMLConverter method parseSubModels.

private List<BpmnModel> parseSubModels(FlowElement subElement, Map<String, GraphicInfo> locations, Map<String, List<GraphicInfo>> flowLocations, Map<String, GraphicInfo> labelLocations) {
    List<BpmnModel> subModels = new ArrayList<BpmnModel>();
    BpmnModel subModel = new BpmnModel();
    String elementId = null;
    // find nested subprocess models
    Collection<FlowElement> subFlowElements = ((SubProcess) subElement).getFlowElements();
    // set main process in submodel to subprocess
    Process newMainProcess = new Process();
    newMainProcess.setId(subElement.getId());
    newMainProcess.getFlowElements().addAll(subFlowElements);
    newMainProcess.getArtifacts().addAll(((SubProcess) subElement).getArtifacts());
    subModel.addProcess(newMainProcess);
    for (FlowElement element : subFlowElements) {
        elementId = element.getId();
        if (element instanceof SubProcess) {
            subModels.addAll(parseSubModels(element, locations, flowLocations, labelLocations));
        }
        if (element instanceof SequenceFlow && null != flowLocations.get(elementId)) {
            // must be an edge
            subModel.getFlowLocationMap().put(elementId, flowLocations.get(elementId));
        } else {
            // do not include data objects because they do not have a corresponding shape in the BPMNDI data
            if (!(element instanceof DataObject) && null != locations.get(elementId)) {
                // must be a shape
                subModel.getLocationMap().put(elementId, locations.get(elementId));
            }
        }
        // also check for any labels
        if (null != labelLocations.get(elementId)) {
            subModel.getLabelLocationMap().put(elementId, labelLocations.get(elementId));
        }
    }
    subModels.add(subModel);
    return subModels;
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) DataObject(org.activiti.bpmn.model.DataObject) FlowElement(org.activiti.bpmn.model.FlowElement) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) ArrayList(java.util.ArrayList) Process(org.activiti.bpmn.model.Process) SubProcess(org.activiti.bpmn.model.SubProcess) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 44 with SequenceFlow

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

the class BpmnXMLConverter method processFlowElements.

protected void processFlowElements(Collection<FlowElement> flowElementList, BaseElement parentScope) {
    for (FlowElement flowElement : flowElementList) {
        if (flowElement instanceof SequenceFlow) {
            SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
            FlowNode sourceNode = getFlowNodeFromScope(sequenceFlow.getSourceRef(), parentScope);
            if (sourceNode != null) {
                sourceNode.getOutgoingFlows().add(sequenceFlow);
                sequenceFlow.setSourceFlowElement(sourceNode);
            }
            FlowNode targetNode = getFlowNodeFromScope(sequenceFlow.getTargetRef(), parentScope);
            if (targetNode != null) {
                targetNode.getIncomingFlows().add(sequenceFlow);
                sequenceFlow.setTargetFlowElement(targetNode);
            }
        } else if (flowElement instanceof BoundaryEvent) {
            BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
            FlowElement attachedToElement = getFlowNodeFromScope(boundaryEvent.getAttachedToRefId(), parentScope);
            if (attachedToElement instanceof Activity) {
                Activity attachedActivity = (Activity) attachedToElement;
                boundaryEvent.setAttachedToRef(attachedActivity);
                attachedActivity.getBoundaryEvents().add(boundaryEvent);
            }
        } else if (flowElement instanceof SubProcess) {
            SubProcess subProcess = (SubProcess) flowElement;
            processFlowElements(subProcess.getFlowElements(), subProcess);
        }
    }
}
Also used : AdhocSubProcess(org.activiti.bpmn.model.AdhocSubProcess) EventSubProcess(org.activiti.bpmn.model.EventSubProcess) SubProcess(org.activiti.bpmn.model.SubProcess) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) FlowElement(org.activiti.bpmn.model.FlowElement) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) Activity(org.activiti.bpmn.model.Activity) FlowNode(org.activiti.bpmn.model.FlowNode)

Example 45 with SequenceFlow

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

the class SequenceFlowXMLConverter method writeAdditionalAttributes.

@Override
protected void writeAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception {
    SequenceFlow sequenceFlow = (SequenceFlow) element;
    writeDefaultAttribute(ATTRIBUTE_FLOW_SOURCE_REF, sequenceFlow.getSourceRef(), xtw);
    writeDefaultAttribute(ATTRIBUTE_FLOW_TARGET_REF, sequenceFlow.getTargetRef(), xtw);
    if (StringUtils.isNotEmpty(sequenceFlow.getSkipExpression())) {
        writeDefaultAttribute(ATTRIBUTE_FLOW_SKIP_EXPRESSION, sequenceFlow.getSkipExpression(), xtw);
    }
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow)

Aggregations

SequenceFlow (org.activiti.bpmn.model.SequenceFlow)63 FlowElement (org.activiti.bpmn.model.FlowElement)34 Process (org.activiti.bpmn.model.Process)23 SubProcess (org.activiti.bpmn.model.SubProcess)19 BpmnModel (org.activiti.bpmn.model.BpmnModel)16 StartEvent (org.activiti.bpmn.model.StartEvent)15 EndEvent (org.activiti.bpmn.model.EndEvent)14 ArrayList (java.util.ArrayList)12 FlowNode (org.activiti.bpmn.model.FlowNode)12 GraphicInfo (org.activiti.bpmn.model.GraphicInfo)11 UserTask (org.activiti.bpmn.model.UserTask)11 Activity (org.activiti.bpmn.model.Activity)10 Gateway (org.activiti.bpmn.model.Gateway)9 HashMap (java.util.HashMap)7 Lane (org.activiti.bpmn.model.Lane)7 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)6 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)6 ExclusiveGateway (org.activiti.bpmn.model.ExclusiveGateway)6 Pool (org.activiti.bpmn.model.Pool)6