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) == false) { 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); } } }
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 (isInSubProcess(activeSubProcessList)) { final SubProcess currentSubProcess = activeSubProcessList.get(activeSubProcessList.size() - 2); currentSubProcess.addArtifact(currentArtifact); } else { activeProcess.addArtifact(currentArtifact); } } if (parsedElement instanceof FlowElement) { FlowElement currentFlowElement = (FlowElement) parsedElement; currentFlowElement.setId(elementId); currentFlowElement.setName(elementName); if (currentFlowElement instanceof Activity) { Activity activity = (Activity) currentFlowElement; activity.setAsynchronous(async); activity.setNotExclusive(notExclusive); 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); } gateway.setAsynchronous(async); gateway.setNotExclusive(notExclusive); } if (currentFlowElement instanceof DataObject) { if (activeSubProcessList.size() > 0) { activeSubProcessList .get(activeSubProcessList.size() - 1) .getDataObjects() .add((ValuedDataObject) parsedElement); } else { activeProcess.getDataObjects().add((ValuedDataObject) parsedElement); } } if (activeSubProcessList.size() > 0) { activeSubProcessList .get(activeSubProcessList.size() - 1) .addFlowElement(currentFlowElement); } else { activeProcess.addFlowElement(currentFlowElement); } } }