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