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);
}
}
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;
}
Aggregations