Search in sources :

Example 11 with Artifact

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

the class BaseBpmnJsonConverter method convertToBpmnModel.

public void convertToBpmnModel(JsonNode elementNode, JsonNode modelNode, ActivityProcessor processor, BaseElement parentElement, Map<String, JsonNode> shapeMap, BpmnModel bpmnModel) {
    this.processor = processor;
    this.model = bpmnModel;
    BaseElement baseElement = convertJsonToElement(elementNode, modelNode, shapeMap);
    baseElement.setId(BpmnJsonConverterUtil.getElementId(elementNode));
    if (baseElement instanceof FlowElement) {
        FlowElement flowElement = (FlowElement) baseElement;
        flowElement.setName(getPropertyValueAsString(PROPERTY_NAME, elementNode));
        flowElement.setDocumentation(getPropertyValueAsString(PROPERTY_DOCUMENTATION, elementNode));
        BpmnJsonConverterUtil.convertJsonToListeners(elementNode, flowElement);
        if (baseElement instanceof Activity) {
            Activity activity = (Activity) baseElement;
            activity.setAsynchronous(getPropertyValueAsBoolean(PROPERTY_ASYNCHRONOUS, elementNode));
            activity.setNotExclusive(!getPropertyValueAsBoolean(PROPERTY_EXCLUSIVE, elementNode));
            String multiInstanceType = getPropertyValueAsString(PROPERTY_MULTIINSTANCE_TYPE, elementNode);
            String multiInstanceCardinality = getPropertyValueAsString(PROPERTY_MULTIINSTANCE_CARDINALITY, elementNode);
            String multiInstanceCollection = getPropertyValueAsString(PROPERTY_MULTIINSTANCE_COLLECTION, elementNode);
            String multiInstanceCondition = getPropertyValueAsString(PROPERTY_MULTIINSTANCE_CONDITION, elementNode);
            if (StringUtils.isNotEmpty(multiInstanceType) && !"none".equalsIgnoreCase(multiInstanceType)) {
                String multiInstanceVariable = getPropertyValueAsString(PROPERTY_MULTIINSTANCE_VARIABLE, elementNode);
                MultiInstanceLoopCharacteristics multiInstanceObject = new MultiInstanceLoopCharacteristics();
                if ("sequential".equalsIgnoreCase(multiInstanceType)) {
                    multiInstanceObject.setSequential(true);
                } else {
                    multiInstanceObject.setSequential(false);
                }
                multiInstanceObject.setLoopCardinality(multiInstanceCardinality);
                multiInstanceObject.setInputDataItem(multiInstanceCollection);
                multiInstanceObject.setElementVariable(multiInstanceVariable);
                multiInstanceObject.setCompletionCondition(multiInstanceCondition);
                activity.setLoopCharacteristics(multiInstanceObject);
            }
        } else if (baseElement instanceof Gateway) {
            JsonNode flowOrderNode = getProperty(PROPERTY_SEQUENCEFLOW_ORDER, elementNode);
            if (flowOrderNode != null) {
                flowOrderNode = BpmnJsonConverterUtil.validateIfNodeIsTextual(flowOrderNode);
                JsonNode orderArray = flowOrderNode.get("sequenceFlowOrder");
                if (orderArray != null && orderArray.size() > 0) {
                    for (JsonNode orderNode : orderArray) {
                        ExtensionElement orderElement = new ExtensionElement();
                        orderElement.setName("EDITOR_FLOW_ORDER");
                        orderElement.setElementText(orderNode.asText());
                        flowElement.addExtensionElement(orderElement);
                    }
                }
            }
        }
    }
    if (baseElement instanceof FlowElement) {
        FlowElement flowElement = (FlowElement) baseElement;
        if (flowElement instanceof SequenceFlow) {
            ExtensionElement idExtensionElement = new ExtensionElement();
            idExtensionElement.setName("EDITOR_RESOURCEID");
            idExtensionElement.setElementText(elementNode.get(EDITOR_SHAPE_ID).asText());
            flowElement.addExtensionElement(idExtensionElement);
        }
        if (parentElement instanceof Process) {
            ((Process) parentElement).addFlowElement(flowElement);
        } else if (parentElement instanceof SubProcess) {
            ((SubProcess) parentElement).addFlowElement(flowElement);
        } else if (parentElement instanceof Lane) {
            Lane lane = (Lane) parentElement;
            lane.getFlowReferences().add(flowElement.getId());
            lane.getParentProcess().addFlowElement(flowElement);
        }
    } else if (baseElement instanceof Artifact) {
        Artifact artifact = (Artifact) baseElement;
        if (parentElement instanceof Process) {
            ((Process) parentElement).addArtifact(artifact);
        } else if (parentElement instanceof SubProcess) {
            ((SubProcess) parentElement).addArtifact(artifact);
        } else if (parentElement instanceof Lane) {
            Lane lane = (Lane) parentElement;
            lane.getFlowReferences().add(artifact.getId());
            lane.getParentProcess().addArtifact(artifact);
        }
    }
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) ExtensionElement(org.activiti.bpmn.model.ExtensionElement) Lane(org.activiti.bpmn.model.Lane) Activity(org.activiti.bpmn.model.Activity) JsonNode(com.fasterxml.jackson.databind.JsonNode) Process(org.activiti.bpmn.model.Process) SubProcess(org.activiti.bpmn.model.SubProcess) Artifact(org.activiti.bpmn.model.Artifact) BaseElement(org.activiti.bpmn.model.BaseElement) MultiInstanceLoopCharacteristics(org.activiti.bpmn.model.MultiInstanceLoopCharacteristics) FlowElement(org.activiti.bpmn.model.FlowElement) Gateway(org.activiti.bpmn.model.Gateway)

Aggregations

Artifact (org.activiti.bpmn.model.Artifact)11 SubProcess (org.activiti.bpmn.model.SubProcess)11 Process (org.activiti.bpmn.model.Process)8 FlowElement (org.activiti.bpmn.model.FlowElement)7 EventSubProcess (org.activiti.bpmn.model.EventSubProcess)6 FlowNode (org.activiti.bpmn.model.FlowNode)6 GraphicInfo (org.activiti.bpmn.model.GraphicInfo)5 Lane (org.activiti.bpmn.model.Lane)5 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)5 Pool (org.activiti.bpmn.model.Pool)4 XMLException (org.activiti.bpmn.exceptions.XMLException)3 Activity (org.activiti.bpmn.model.Activity)3 Gateway (org.activiti.bpmn.model.Gateway)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 OutputStreamWriter (java.io.OutputStreamWriter)2 XMLOutputFactory (javax.xml.stream.XMLOutputFactory)2 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)2 AdhocSubProcess (org.activiti.bpmn.model.AdhocSubProcess)2 Association (org.activiti.bpmn.model.Association)2 BaseElement (org.activiti.bpmn.model.BaseElement)2