Search in sources :

Example 6 with Transaction

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

the class BpmnXMLConverter method createXML.

protected void createXML(FlowElement flowElement, BpmnModel model, XMLStreamWriter xtw) throws Exception {
    if (flowElement instanceof SubProcess) {
        SubProcess subProcess = (SubProcess) flowElement;
        if (flowElement instanceof Transaction) {
            xtw.writeStartElement(ELEMENT_TRANSACTION);
        } else if (flowElement instanceof AdhocSubProcess) {
            xtw.writeStartElement(ELEMENT_ADHOC_SUBPROCESS);
        } else {
            xtw.writeStartElement(BPMN2_PREFIX, ELEMENT_SUBPROCESS, BPMN2_NAMESPACE);
        }
        xtw.writeAttribute(ATTRIBUTE_ID, subProcess.getId());
        if (StringUtils.isNotEmpty(subProcess.getName())) {
            xtw.writeAttribute(ATTRIBUTE_NAME, subProcess.getName());
        } else {
            xtw.writeAttribute(ATTRIBUTE_NAME, "subProcess");
        }
        if (subProcess instanceof EventSubProcess) {
            xtw.writeAttribute(ATTRIBUTE_TRIGGERED_BY, ATTRIBUTE_VALUE_TRUE);
        } else if (!(subProcess instanceof Transaction)) {
            if (subProcess.isAsynchronous()) {
                BpmnXMLUtil.writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, ATTRIBUTE_VALUE_TRUE, xtw);
                if (subProcess.isNotExclusive()) {
                    BpmnXMLUtil.writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_EXCLUSIVE, ATTRIBUTE_VALUE_FALSE, xtw);
                }
            }
        } else if (subProcess instanceof AdhocSubProcess) {
            AdhocSubProcess adhocSubProcess = (AdhocSubProcess) subProcess;
            BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_CANCEL_REMAINING_INSTANCES, String.valueOf(adhocSubProcess.isCancelRemainingInstances()), xtw);
            if (StringUtils.isNotEmpty(adhocSubProcess.getOrdering())) {
                BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_ORDERING, adhocSubProcess.getOrdering(), xtw);
            }
        }
        if (StringUtils.isNotEmpty(subProcess.getDocumentation())) {
            xtw.writeStartElement(BPMN2_PREFIX, ELEMENT_DOCUMENTATION, BPMN2_NAMESPACE);
            xtw.writeCharacters(subProcess.getDocumentation());
            xtw.writeEndElement();
        }
        boolean didWriteExtensionStartElement = ActivitiListenerExport.writeListeners(subProcess, false, xtw);
        didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(subProcess, didWriteExtensionStartElement, model.getNamespaces(), xtw);
        if (didWriteExtensionStartElement) {
            // closing extensions element
            xtw.writeEndElement();
        }
        MultiInstanceExport.writeMultiInstance(subProcess, xtw);
        if (subProcess instanceof AdhocSubProcess) {
            AdhocSubProcess adhocSubProcess = (AdhocSubProcess) subProcess;
            if (StringUtils.isNotEmpty(adhocSubProcess.getCompletionCondition())) {
                xtw.writeStartElement(ELEMENT_COMPLETION_CONDITION);
                xtw.writeCData(adhocSubProcess.getCompletionCondition());
                xtw.writeEndElement();
            }
        }
        for (FlowElement subElement : subProcess.getFlowElements()) {
            createXML(subElement, model, xtw);
        }
        for (Artifact artifact : subProcess.getArtifacts()) {
            createXML(artifact, model, xtw);
        }
        xtw.writeEndElement();
    } else {
        BaseBpmnXMLConverter converter = convertersToXMLMap.get(flowElement.getClass());
        if (converter == null) {
            throw new XMLException("No converter for " + flowElement.getClass() + " found");
        }
        converter.convertToXML(xtw, flowElement, model);
    }
}
Also used : AdhocSubProcess(org.activiti.bpmn.model.AdhocSubProcess) EventSubProcess(org.activiti.bpmn.model.EventSubProcess) SubProcess(org.activiti.bpmn.model.SubProcess) AdhocSubProcess(org.activiti.bpmn.model.AdhocSubProcess) XMLException(org.activiti.bpmn.exceptions.XMLException) Transaction(org.activiti.bpmn.model.Transaction) FlowElement(org.activiti.bpmn.model.FlowElement) EventSubProcess(org.activiti.bpmn.model.EventSubProcess) Artifact(org.activiti.bpmn.model.Artifact)

Example 7 with Transaction

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

the class SubProcessJsonConverter method convertJsonToElement.

protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) {
    SubProcess subProcess = null;
    if (getPropertyValueAsBoolean("istransaction", elementNode)) {
        subProcess = new Transaction();
    } else {
        subProcess = new SubProcess();
    }
    JsonNode childShapesArray = elementNode.get(EDITOR_CHILD_SHAPES);
    processor.processJsonElements(childShapesArray, modelNode, subProcess, shapeMap, formMap, decisionTableMap, model);
    JsonNode processDataPropertiesNode = elementNode.get(EDITOR_SHAPE_PROPERTIES).get(PROPERTY_DATA_PROPERTIES);
    if (processDataPropertiesNode != null) {
        List<ValuedDataObject> dataObjects = BpmnJsonConverterUtil.convertJsonToDataProperties(processDataPropertiesNode, subProcess);
        subProcess.setDataObjects(dataObjects);
        subProcess.getFlowElements().addAll(dataObjects);
    }
    return subProcess;
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) ValuedDataObject(org.activiti.bpmn.model.ValuedDataObject) Transaction(org.activiti.bpmn.model.Transaction) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Aggregations

Transaction (org.activiti.bpmn.model.Transaction)7 SubProcess (org.activiti.bpmn.model.SubProcess)5 FlowElement (org.activiti.bpmn.model.FlowElement)4 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)3 CompensateEventDefinition (org.activiti.bpmn.model.CompensateEventDefinition)3 Activity (org.activiti.bpmn.model.Activity)2 AdhocSubProcess (org.activiti.bpmn.model.AdhocSubProcess)2 EventSubProcess (org.activiti.bpmn.model.EventSubProcess)2 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 XMLException (org.activiti.bpmn.exceptions.XMLException)1 Artifact (org.activiti.bpmn.model.Artifact)1 CallActivity (org.activiti.bpmn.model.CallActivity)1 CancelEventDefinition (org.activiti.bpmn.model.CancelEventDefinition)1 ErrorEventDefinition (org.activiti.bpmn.model.ErrorEventDefinition)1 EventDefinition (org.activiti.bpmn.model.EventDefinition)1 GraphicInfo (org.activiti.bpmn.model.GraphicInfo)1