Search in sources :

Example 1 with FlowNode

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

the class DefaultProcessDiagramGenerator method generateProcessDiagram.

protected DefaultProcessDiagramCanvas generateProcessDiagram(BpmnModel bpmnModel, String imageType, List<String> highLightedActivities, List<String> highLightedFlows, String activityFontName, String labelFontName, String annotationFontName, ClassLoader customClassLoader, double scaleFactor) {
    prepareBpmnModel(bpmnModel);
    DefaultProcessDiagramCanvas processDiagramCanvas = initProcessDiagramCanvas(bpmnModel, imageType, activityFontName, labelFontName, annotationFontName, customClassLoader);
    // Draw pool shape, if process is participant in collaboration
    for (Pool pool : bpmnModel.getPools()) {
        GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(pool.getId());
        processDiagramCanvas.drawPoolOrLane(pool.getName(), graphicInfo);
    }
    // Draw lanes
    for (Process process : bpmnModel.getProcesses()) {
        for (Lane lane : process.getLanes()) {
            GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(lane.getId());
            processDiagramCanvas.drawPoolOrLane(lane.getName(), graphicInfo);
        }
    }
    // Draw activities and their sequence-flows
    for (Process process : bpmnModel.getProcesses()) {
        for (FlowNode flowNode : process.findFlowElementsOfType(FlowNode.class)) {
            drawActivity(processDiagramCanvas, bpmnModel, flowNode, highLightedActivities, highLightedFlows, scaleFactor);
        }
    }
    // Draw artifacts
    for (Process process : bpmnModel.getProcesses()) {
        for (Artifact artifact : process.getArtifacts()) {
            drawArtifact(processDiagramCanvas, bpmnModel, artifact);
        }
        List<SubProcess> subProcesses = process.findFlowElementsOfType(SubProcess.class, true);
        if (subProcesses != null) {
            for (SubProcess subProcess : subProcesses) {
                for (Artifact subProcessArtifact : subProcess.getArtifacts()) {
                    drawArtifact(processDiagramCanvas, bpmnModel, subProcessArtifact);
                }
            }
        }
    }
    return processDiagramCanvas;
}
Also used : EventSubProcess(org.activiti.bpmn.model.EventSubProcess) SubProcess(org.activiti.bpmn.model.SubProcess) GraphicInfo(org.activiti.bpmn.model.GraphicInfo) Lane(org.activiti.bpmn.model.Lane) Pool(org.activiti.bpmn.model.Pool) EventSubProcess(org.activiti.bpmn.model.EventSubProcess) Process(org.activiti.bpmn.model.Process) SubProcess(org.activiti.bpmn.model.SubProcess) Artifact(org.activiti.bpmn.model.Artifact) FlowNode(org.activiti.bpmn.model.FlowNode)

Example 2 with FlowNode

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

the class DefaultWorkflowDefinitionConversionListener method afterStepsConversion.

public void afterStepsConversion(WorkflowDefinitionConversion conversion) {
    // Add end-event to process
    Process process = conversion.getProcess();
    EndEvent endEvent = new EndEvent();
    endEvent.setId(END_EVENT_ID);
    process.addFlowElement(endEvent);
    // Sequence flow from last created activity to end
    SequenceFlow sequenceFlow = new SequenceFlow();
    sequenceFlow.setId(conversion.getUniqueNumberedId(ConversionConstants.DEFAULT_SEQUENCEFLOW_PREFIX));
    sequenceFlow.setSourceRef(conversion.getLastActivityId());
    sequenceFlow.setTargetRef(END_EVENT_ID);
    process.addFlowElement(sequenceFlow);
    // To make the generated workflow compatible with some tools (eg the
    // Modeler, but also others),
    // We must add the ingoing and outgoing sequence flow to each of the flow
    // nodes
    SequenceFlowMapping sequenceFlowMapping = generateSequenceflowMappings(process);
    for (FlowNode flowNode : process.findFlowElementsOfType(FlowNode.class)) {
        List<SequenceFlow> incomingSequenceFlow = sequenceFlowMapping.getIncomingSequenceFlowMapping().get(flowNode.getId());
        if (incomingSequenceFlow != null) {
            flowNode.setIncomingFlows(incomingSequenceFlow);
        }
        List<SequenceFlow> outgoingSequenceFlow = sequenceFlowMapping.getOutgoingSequenceFlowMapping().get(flowNode.getId());
        if (outgoingSequenceFlow != null) {
            flowNode.setOutgoingFlows(outgoingSequenceFlow);
        }
    }
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow) EndEvent(org.activiti.bpmn.model.EndEvent) Process(org.activiti.bpmn.model.Process) FlowNode(org.activiti.bpmn.model.FlowNode)

Example 3 with FlowNode

use of org.activiti.bpmn.model.FlowNode 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()) {
                activeSubProcessList.get(activeSubProcessList.size() - 1).getDataObjects().add((ValuedDataObject) parsedElement);
            } else {
                activeProcess.getDataObjects().add((ValuedDataObject) parsedElement);
            }
        }
        if (!activeSubProcessList.isEmpty()) {
            activeSubProcessList.get(activeSubProcessList.size() - 1).addFlowElement(currentFlowElement);
        } else {
            activeProcess.addFlowElement(currentFlowElement);
        }
    }
}
Also used : 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 FlowNode

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

the class BaseBpmnXMLConverter method convertToXML.

public void convertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel model) throws Exception {
    xtw.writeStartElement(getXMLElementName());
    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(ELEMENT_DOCUMENTATION);
            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();
    }
    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 5 with FlowNode

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

the class BpmnXMLConverter method processFlowElements.

private 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);
            }
            FlowNode targetNode = getFlowNodeFromScope(sequenceFlow.getTargetRef(), parentScope);
            if (targetNode != null) {
                targetNode.getIncomingFlows().add(sequenceFlow);
            }
        } else if (flowElement instanceof BoundaryEvent) {
            BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
            FlowElement attachedToElement = getFlowNodeFromScope(boundaryEvent.getAttachedToRefId(), parentScope);
            if (attachedToElement != null) {
                boundaryEvent.setAttachedToRef((Activity) attachedToElement);
                ((Activity) attachedToElement).getBoundaryEvents().add(boundaryEvent);
            }
        } else if (flowElement instanceof SubProcess) {
            SubProcess subProcess = (SubProcess) flowElement;
            processFlowElements(subProcess.getFlowElements(), subProcess);
        }
    }
}
Also used : 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)

Aggregations

FlowNode (org.activiti.bpmn.model.FlowNode)9 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)7 Activity (org.activiti.bpmn.model.Activity)6 FlowElement (org.activiti.bpmn.model.FlowElement)6 SubProcess (org.activiti.bpmn.model.SubProcess)6 Artifact (org.activiti.bpmn.model.Artifact)4 EventSubProcess (org.activiti.bpmn.model.EventSubProcess)4 Gateway (org.activiti.bpmn.model.Gateway)4 GraphicInfo (org.activiti.bpmn.model.GraphicInfo)4 Process (org.activiti.bpmn.model.Process)4 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)3 Lane (org.activiti.bpmn.model.Lane)2 MultiInstanceLoopCharacteristics (org.activiti.bpmn.model.MultiInstanceLoopCharacteristics)2 Pool (org.activiti.bpmn.model.Pool)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Association (org.activiti.bpmn.model.Association)1 BaseElement (org.activiti.bpmn.model.BaseElement)1 CallActivity (org.activiti.bpmn.model.CallActivity)1