use of org.activiti.bpmn.model.ExtensionElement 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);
}
}
}
use of org.activiti.bpmn.model.ExtensionElement in project Activiti by Activiti.
the class ValuedDataObjectWithExtensionsConverterTest method getDataObjectAttributes.
protected Map<String, String> getDataObjectAttributes(BaseElement dObj) {
Map<String, String> attributes = null;
if (null != dObj) {
List<ExtensionElement> attributesExtension = dObj.getExtensionElements().get(ELEMENT_DATA_ATTRIBUTES);
if (null != attributesExtension && !attributesExtension.isEmpty()) {
attributes = new HashMap<String, String>();
List<ExtensionElement> attributeExtensions = attributesExtension.get(0).getChildElements().get(ELEMENT_DATA_ATTRIBUTE);
for (ExtensionElement attributeExtension : attributeExtensions) {
attributes.put(attributeExtension.getAttributeValue(YOURCO_EXTENSIONS_NAMESPACE, ATTRIBUTE_NAME), attributeExtension.getAttributeValue(YOURCO_EXTENSIONS_NAMESPACE, ATTRIBUTE_VALUE));
}
}
}
return attributes;
}
use of org.activiti.bpmn.model.ExtensionElement in project Activiti by Activiti.
the class BpmnDeployer method localizeFlowElements.
protected boolean localizeFlowElements(Collection<FlowElement> flowElements, ObjectNode infoNode) {
boolean localizationValuesChanged = false;
if (flowElements == null) {
return localizationValuesChanged;
}
CommandContext commandContext = Context.getCommandContext();
DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration().getDynamicBpmnService();
for (FlowElement flowElement : flowElements) {
if (flowElement instanceof UserTask || flowElement instanceof SubProcess) {
List<ExtensionElement> localizationElements = flowElement.getExtensionElements().get("localization");
if (localizationElements != null) {
for (ExtensionElement localizationElement : localizationElements) {
if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX.equals(localizationElement.getNamespacePrefix())) {
String locale = localizationElement.getAttributeValue(null, "locale");
String name = localizationElement.getAttributeValue(null, "name");
String documentation = null;
List<ExtensionElement> documentationElements = localizationElement.getChildElements().get("documentation");
if (documentationElements != null) {
for (ExtensionElement documentationElement : documentationElements) {
documentation = StringUtils.trimToNull(documentationElement.getElementText());
break;
}
}
String flowElementId = flowElement.getId();
if (isEqualToCurrentLocalizationValue(locale, flowElementId, "name", name, infoNode) == false) {
dynamicBpmnService.changeLocalizationName(locale, flowElementId, name, infoNode);
localizationValuesChanged = true;
}
if (documentation != null && isEqualToCurrentLocalizationValue(locale, flowElementId, "description", documentation, infoNode) == false) {
dynamicBpmnService.changeLocalizationDescription(locale, flowElementId, documentation, infoNode);
localizationValuesChanged = true;
}
break;
}
}
}
if (flowElement instanceof SubProcess) {
SubProcess subprocess = (SubProcess) flowElement;
boolean isFlowElementLocalizationChanged = localizeFlowElements(subprocess.getFlowElements(), infoNode);
boolean isDataObjectLocalizationChanged = localizeDataObjectElements(subprocess.getDataObjects(), infoNode);
if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) {
localizationValuesChanged = true;
}
}
}
}
return localizationValuesChanged;
}
use of org.activiti.bpmn.model.ExtensionElement in project Activiti by Activiti.
the class BpmnDeployer method localizeDataObjectElements.
protected boolean localizeDataObjectElements(List<ValuedDataObject> dataObjects, ObjectNode infoNode) {
boolean localizationValuesChanged = false;
CommandContext commandContext = Context.getCommandContext();
DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration().getDynamicBpmnService();
for (ValuedDataObject dataObject : dataObjects) {
List<ExtensionElement> localizationElements = dataObject.getExtensionElements().get("localization");
if (localizationElements != null) {
for (ExtensionElement localizationElement : localizationElements) {
if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX.equals(localizationElement.getNamespacePrefix())) {
String locale = localizationElement.getAttributeValue(null, "locale");
String name = localizationElement.getAttributeValue(null, "name");
String documentation = null;
List<ExtensionElement> documentationElements = localizationElement.getChildElements().get("documentation");
if (documentationElements != null) {
for (ExtensionElement documentationElement : documentationElements) {
documentation = StringUtils.trimToNull(documentationElement.getElementText());
break;
}
}
if (name != null && isEqualToCurrentLocalizationValue(locale, dataObject.getId(), DynamicBpmnConstants.LOCALIZATION_NAME, name, infoNode) == false) {
dynamicBpmnService.changeLocalizationName(locale, dataObject.getId(), name, infoNode);
localizationValuesChanged = true;
}
if (documentation != null && isEqualToCurrentLocalizationValue(locale, dataObject.getId(), DynamicBpmnConstants.LOCALIZATION_DESCRIPTION, documentation, infoNode) == false) {
dynamicBpmnService.changeLocalizationDescription(locale, dataObject.getId(), documentation, infoNode);
localizationValuesChanged = true;
}
}
}
}
}
return localizationValuesChanged;
}
Aggregations