Search in sources :

Example 16 with SequenceFlow

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

the class DefaultProcessDiagramGenerator method initProcessDiagramCanvas.

protected static DefaultProcessDiagramCanvas initProcessDiagramCanvas(BpmnModel bpmnModel, String activityFontName, String labelFontName, String annotationFontName) {
    // We need to calculate maximum values to know how big the image will be in its entirety
    double minX = Double.MAX_VALUE;
    double maxX = 0;
    double minY = Double.MAX_VALUE;
    double maxY = 0;
    for (Pool pool : bpmnModel.getPools()) {
        GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(pool.getId());
        minX = graphicInfo.getX();
        maxX = graphicInfo.getX() + graphicInfo.getWidth();
        minY = graphicInfo.getY();
        maxY = graphicInfo.getY() + graphicInfo.getHeight();
    }
    List<FlowNode> flowNodes = gatherAllFlowNodes(bpmnModel);
    for (FlowNode flowNode : flowNodes) {
        GraphicInfo flowNodeGraphicInfo = bpmnModel.getGraphicInfo(flowNode.getId());
        if (flowNodeGraphicInfo == null) {
            continue;
        }
        // width
        if (flowNodeGraphicInfo.getX() + flowNodeGraphicInfo.getWidth() > maxX) {
            maxX = flowNodeGraphicInfo.getX() + flowNodeGraphicInfo.getWidth();
        }
        if (flowNodeGraphicInfo.getX() < minX) {
            minX = flowNodeGraphicInfo.getX();
        }
        // height
        if (flowNodeGraphicInfo.getY() + flowNodeGraphicInfo.getHeight() > maxY) {
            maxY = flowNodeGraphicInfo.getY() + flowNodeGraphicInfo.getHeight();
        }
        if (flowNodeGraphicInfo.getY() < minY) {
            minY = flowNodeGraphicInfo.getY();
        }
        for (SequenceFlow sequenceFlow : flowNode.getOutgoingFlows()) {
            List<GraphicInfo> graphicInfoList = bpmnModel.getFlowLocationGraphicInfo(sequenceFlow.getId());
            if (graphicInfoList != null) {
                for (GraphicInfo graphicInfo : graphicInfoList) {
                    // width
                    if (graphicInfo.getX() > maxX) {
                        maxX = graphicInfo.getX();
                    }
                    if (graphicInfo.getX() < minX) {
                        minX = graphicInfo.getX();
                    }
                    // height
                    if (graphicInfo.getY() > maxY) {
                        maxY = graphicInfo.getY();
                    }
                    if (graphicInfo.getY() < minY) {
                        minY = graphicInfo.getY();
                    }
                }
            }
        }
    }
    List<Artifact> artifacts = gatherAllArtifacts(bpmnModel);
    for (Artifact artifact : artifacts) {
        GraphicInfo artifactGraphicInfo = bpmnModel.getGraphicInfo(artifact.getId());
        if (artifactGraphicInfo != null) {
            // width
            if (artifactGraphicInfo.getX() + artifactGraphicInfo.getWidth() > maxX) {
                maxX = artifactGraphicInfo.getX() + artifactGraphicInfo.getWidth();
            }
            if (artifactGraphicInfo.getX() < minX) {
                minX = artifactGraphicInfo.getX();
            }
            // height
            if (artifactGraphicInfo.getY() + artifactGraphicInfo.getHeight() > maxY) {
                maxY = artifactGraphicInfo.getY() + artifactGraphicInfo.getHeight();
            }
            if (artifactGraphicInfo.getY() < minY) {
                minY = artifactGraphicInfo.getY();
            }
        }
        List<GraphicInfo> graphicInfoList = bpmnModel.getFlowLocationGraphicInfo(artifact.getId());
        if (graphicInfoList != null) {
            for (GraphicInfo graphicInfo : graphicInfoList) {
                // width
                if (graphicInfo.getX() > maxX) {
                    maxX = graphicInfo.getX();
                }
                if (graphicInfo.getX() < minX) {
                    minX = graphicInfo.getX();
                }
                // height
                if (graphicInfo.getY() > maxY) {
                    maxY = graphicInfo.getY();
                }
                if (graphicInfo.getY() < minY) {
                    minY = graphicInfo.getY();
                }
            }
        }
    }
    int nrOfLanes = 0;
    for (Process process : bpmnModel.getProcesses()) {
        for (Lane l : process.getLanes()) {
            nrOfLanes++;
            GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(l.getId());
            if (graphicInfo != null) {
                // width
                if (graphicInfo.getX() + graphicInfo.getWidth() > maxX) {
                    maxX = graphicInfo.getX() + graphicInfo.getWidth();
                }
                if (graphicInfo.getX() < minX) {
                    minX = graphicInfo.getX();
                }
                // height
                if (graphicInfo.getY() + graphicInfo.getHeight() > maxY) {
                    maxY = graphicInfo.getY() + graphicInfo.getHeight();
                }
                if (graphicInfo.getY() < minY) {
                    minY = graphicInfo.getY();
                }
            }
        }
    }
    // Special case, see https://activiti.atlassian.net/browse/ACT-1431
    if (flowNodes.isEmpty() && bpmnModel.getPools().isEmpty() && nrOfLanes == 0) {
        // Nothing to show
        minX = 0;
        minY = 0;
    }
    return new DefaultProcessDiagramCanvas((int) maxX + 10, (int) maxY + 10, (int) minX, (int) minY, activityFontName, labelFontName, annotationFontName);
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow) GraphicInfo(org.activiti.bpmn.model.GraphicInfo) Lane(org.activiti.bpmn.model.Lane) EventSubProcess(org.activiti.bpmn.model.EventSubProcess) Process(org.activiti.bpmn.model.Process) SubProcess(org.activiti.bpmn.model.SubProcess) Artifact(org.activiti.bpmn.model.Artifact) Pool(org.activiti.bpmn.model.Pool) FlowNode(org.activiti.bpmn.model.FlowNode)

Example 17 with SequenceFlow

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

the class SubprocessXMLConverter method parseSubModels.

protected List<BpmnModel> parseSubModels(BpmnModel model) {
    List<BpmnModel> subModels = new ArrayList<BpmnModel>();
    // find all subprocesses
    Collection<FlowElement> flowElements = model.getMainProcess().getFlowElements();
    Map<String, GraphicInfo> locations = new HashMap<String, GraphicInfo>();
    Map<String, List<GraphicInfo>> flowLocations = new HashMap<String, List<GraphicInfo>>();
    Map<String, GraphicInfo> labelLocations = new HashMap<String, GraphicInfo>();
    locations.putAll(model.getLocationMap());
    flowLocations.putAll(model.getFlowLocationMap());
    labelLocations.putAll(model.getLabelLocationMap());
    // include main process as separate model
    BpmnModel mainModel = new BpmnModel();
    // set main process in submodel to subprocess
    mainModel.addProcess(model.getMainProcess());
    String elementId = null;
    for (FlowElement element : flowElements) {
        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
            mainModel.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
                mainModel.getLocationMap().put(elementId, locations.get(elementId));
            }
        }
        // also check for any labels
        if (null != labelLocations.get(elementId)) {
            mainModel.getLabelLocationMap().put(elementId, labelLocations.get(elementId));
        }
    }
    // add main process model to list
    subModels.add(mainModel);
    return subModels;
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) HashMap(java.util.HashMap) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) ArrayList(java.util.ArrayList) GraphicInfo(org.activiti.bpmn.model.GraphicInfo) BpmnModel(org.activiti.bpmn.model.BpmnModel) DataObject(org.activiti.bpmn.model.DataObject) FlowElement(org.activiti.bpmn.model.FlowElement) ArrayList(java.util.ArrayList) List(java.util.List)

Example 18 with SequenceFlow

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

the class SequenceFlowXMLConverter method writeAdditionalChildElements.

@Override
protected void writeAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception {
    SequenceFlow sequenceFlow = (SequenceFlow) element;
    if (StringUtils.isNotEmpty(sequenceFlow.getConditionExpression())) {
        xtw.writeStartElement(ELEMENT_FLOW_CONDITION);
        xtw.writeAttribute(XSI_PREFIX, XSI_NAMESPACE, "type", "tFormalExpression");
        xtw.writeCData(sequenceFlow.getConditionExpression());
        xtw.writeEndElement();
    }
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow)

Example 19 with SequenceFlow

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

the class SequenceFlowXMLConverter method convertXMLToElement.

@Override
protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
    SequenceFlow sequenceFlow = new SequenceFlow();
    BpmnXMLUtil.addXMLLocation(sequenceFlow, xtr);
    sequenceFlow.setSourceRef(xtr.getAttributeValue(null, ATTRIBUTE_FLOW_SOURCE_REF));
    sequenceFlow.setTargetRef(xtr.getAttributeValue(null, ATTRIBUTE_FLOW_TARGET_REF));
    sequenceFlow.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
    sequenceFlow.setSkipExpression(xtr.getAttributeValue(null, ATTRIBUTE_FLOW_SKIP_EXPRESSION));
    parseChildElements(getXMLElementName(), sequenceFlow, model, xtr);
    return sequenceFlow;
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow)

Example 20 with SequenceFlow

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

the class TakeOutgoingSequenceFlowsOperation method run.

@Override
public void run() {
    FlowElement currentFlowElement = getCurrentFlowElement(execution);
    // Compensation check
    if ((currentFlowElement instanceof Activity) && (((Activity) currentFlowElement)).isForCompensation()) {
        /*
       * If the current flow element is part of a compensation, we don't always
       * want to follow the regular rules of leaving an activity.
       * More specifically, if there are no outgoing sequenceflow, we simply must stop
       * the execution there and don't go up in the scopes as we usually do
       * to find the outgoing sequenceflow
       */
        cleanupCompensation();
        return;
    }
    // When leaving the current activity, we need to delete any related execution (eg active boundary events)
    cleanupExecutions(currentFlowElement);
    if (currentFlowElement instanceof FlowNode) {
        handleFlowNode((FlowNode) currentFlowElement);
    } else if (currentFlowElement instanceof SequenceFlow) {
        handleSequenceFlow();
    }
}
Also used : FlowElement(org.activiti.bpmn.model.FlowElement) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) Activity(org.activiti.bpmn.model.Activity) FlowNode(org.activiti.bpmn.model.FlowNode)

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