use of org.activiti.engine.DynamicBpmnService in project Activiti by Activiti.
the class BpmnDeployer method createLocalizationValues.
protected void createLocalizationValues(String processDefinitionId, Process process) {
if (process == null) {
return;
}
CommandContext commandContext = Context.getCommandContext();
DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration().getDynamicBpmnService();
ObjectNode infoNode = dynamicBpmnService.getProcessDefinitionInfo(processDefinitionId);
boolean localizationValuesChanged = false;
List<ExtensionElement> localizationElements = process.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 processId = process.getId();
if (!isEqualToCurrentLocalizationValue(locale, processId, "name", name, infoNode)) {
dynamicBpmnService.changeLocalizationName(locale, processId, name, infoNode);
localizationValuesChanged = true;
}
if (documentation != null && !isEqualToCurrentLocalizationValue(locale, processId, "description", documentation, infoNode)) {
dynamicBpmnService.changeLocalizationDescription(locale, processId, documentation, infoNode);
localizationValuesChanged = true;
}
break;
}
}
}
boolean isFlowElementLocalizationChanged = localizeFlowElements(process.getFlowElements(), infoNode);
boolean isDataObjectLocalizationChanged = localizeDataObjectElements(process.getDataObjects(), infoNode);
if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) {
localizationValuesChanged = true;
}
if (localizationValuesChanged) {
dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
}
}
use of org.activiti.engine.DynamicBpmnService 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.engine.DynamicBpmnService 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