Search in sources :

Example 1 with DataObject

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

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

the class BpmnAutoLayout method translateNestedSubprocessElements.

protected void translateNestedSubprocessElements(SubProcess subProcess) {
    GraphicInfo subProcessGraphicInfo = bpmnModel.getLocationMap().get(subProcess.getId());
    double subProcessX = subProcessGraphicInfo.getX();
    double subProcessY = subProcessGraphicInfo.getY();
    List<SubProcess> nestedSubProcesses = new ArrayList<SubProcess>();
    for (FlowElement flowElement : subProcess.getFlowElements()) {
        if (flowElement instanceof SequenceFlow) {
            List<GraphicInfo> graphicInfos = bpmnModel.getFlowLocationMap().get(flowElement.getId());
            for (GraphicInfo graphicInfo : graphicInfos) {
                graphicInfo.setX(graphicInfo.getX() + subProcessX + subProcessMargin);
                graphicInfo.setY(graphicInfo.getY() + subProcessY + subProcessMargin);
            }
        } else if (flowElement instanceof DataObject == false) {
            // Regular element
            GraphicInfo graphicInfo = bpmnModel.getLocationMap().get(flowElement.getId());
            graphicInfo.setX(graphicInfo.getX() + subProcessX + subProcessMargin);
            graphicInfo.setY(graphicInfo.getY() + subProcessY + subProcessMargin);
        }
        if (flowElement instanceof SubProcess) {
            nestedSubProcesses.add((SubProcess) flowElement);
        }
    }
    // Continue for next level of nested subprocesses
    for (SubProcess nestedSubProcess : nestedSubProcesses) {
        translateNestedSubprocessElements(nestedSubProcess);
    }
}
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) GraphicInfo(org.activiti.bpmn.model.GraphicInfo) ArrayList(java.util.ArrayList)

Example 3 with DataObject

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

the class BaseBpmnXMLConverter method convertToBpmnModel.

public void convertToBpmnModel(XMLStreamReader xtr, BpmnModel model, Process activeProcess, List<SubProcess> activeSubProcessList) throws Exception {
    String elementId = xtr.getAttributeValue(null, ATTRIBUTE_ID);
    String elementName = xtr.getAttributeValue(null, ATTRIBUTE_NAME);
    boolean async = parseAsync(xtr);
    boolean notExclusive = parseNotExclusive(xtr);
    String defaultFlow = xtr.getAttributeValue(null, ATTRIBUTE_DEFAULT);
    boolean isForCompensation = parseForCompensation(xtr);
    BaseElement parsedElement = convertXMLToElement(xtr, model);
    if (parsedElement instanceof Artifact) {
        Artifact currentArtifact = (Artifact) parsedElement;
        currentArtifact.setId(elementId);
        if (!activeSubProcessList.isEmpty()) {
            activeSubProcessList.get(activeSubProcessList.size() - 1).addArtifact(currentArtifact);
        } else {
            activeProcess.addArtifact(currentArtifact);
        }
    }
    if (parsedElement instanceof FlowElement) {
        FlowElement currentFlowElement = (FlowElement) parsedElement;
        currentFlowElement.setId(elementId);
        currentFlowElement.setName(elementName);
        if (currentFlowElement instanceof FlowNode) {
            FlowNode flowNode = (FlowNode) currentFlowElement;
            flowNode.setAsynchronous(async);
            flowNode.setNotExclusive(notExclusive);
            if (currentFlowElement instanceof Activity) {
                Activity activity = (Activity) currentFlowElement;
                activity.setForCompensation(isForCompensation);
                if (StringUtils.isNotEmpty(defaultFlow)) {
                    activity.setDefaultFlow(defaultFlow);
                }
            }
            if (currentFlowElement instanceof Gateway) {
                Gateway gateway = (Gateway) currentFlowElement;
                if (StringUtils.isNotEmpty(defaultFlow)) {
                    gateway.setDefaultFlow(defaultFlow);
                }
            }
        }
        if (currentFlowElement instanceof DataObject) {
            if (!activeSubProcessList.isEmpty()) {
                SubProcess subProcess = activeSubProcessList.get(activeSubProcessList.size() - 1);
                subProcess.getDataObjects().add((ValuedDataObject) parsedElement);
            } else {
                activeProcess.getDataObjects().add((ValuedDataObject) parsedElement);
            }
        }
        if (!activeSubProcessList.isEmpty()) {
            SubProcess subProcess = activeSubProcessList.get(activeSubProcessList.size() - 1);
            subProcess.addFlowElement(currentFlowElement);
        } else {
            activeProcess.addFlowElement(currentFlowElement);
        }
    }
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) BaseElement(org.activiti.bpmn.model.BaseElement) DataObject(org.activiti.bpmn.model.DataObject) ValuedDataObject(org.activiti.bpmn.model.ValuedDataObject) FlowElement(org.activiti.bpmn.model.FlowElement) Gateway(org.activiti.bpmn.model.Gateway) Activity(org.activiti.bpmn.model.Activity) Artifact(org.activiti.bpmn.model.Artifact) FlowNode(org.activiti.bpmn.model.FlowNode)

Example 4 with DataObject

use of org.activiti.bpmn.model.DataObject 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)

Aggregations

DataObject (org.activiti.bpmn.model.DataObject)4 FlowElement (org.activiti.bpmn.model.FlowElement)4 SubProcess (org.activiti.bpmn.model.SubProcess)4 ArrayList (java.util.ArrayList)3 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)3 BpmnModel (org.activiti.bpmn.model.BpmnModel)2 GraphicInfo (org.activiti.bpmn.model.GraphicInfo)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Activity (org.activiti.bpmn.model.Activity)1 Artifact (org.activiti.bpmn.model.Artifact)1 BaseElement (org.activiti.bpmn.model.BaseElement)1 FlowNode (org.activiti.bpmn.model.FlowNode)1 Gateway (org.activiti.bpmn.model.Gateway)1 Process (org.activiti.bpmn.model.Process)1 ValuedDataObject (org.activiti.bpmn.model.ValuedDataObject)1