Esempio n. 1
0
  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.getName(),
                        DynamicBpmnConstants.LOCALIZATION_NAME,
                        name,
                        infoNode)
                    == false) {
              dynamicBpmnService.changeLocalizationName(
                  locale, dataObject.getName(), name, infoNode);
              localizationValuesChanged = true;
            }

            if (documentation != null
                && isEqualToCurrentLocalizationValue(
                        locale,
                        dataObject.getName(),
                        DynamicBpmnConstants.LOCALIZATION_DESCRIPTION,
                        documentation,
                        infoNode)
                    == false) {

              dynamicBpmnService.changeLocalizationDescription(
                  locale, dataObject.getName(), documentation, infoNode);
              localizationValuesChanged = true;
            }
          }
        }
      }
    }

    return localizationValuesChanged;
  }
  protected static ExtensionElement getExtensionElement(String key, ValuedDataObject dataObj) {
    Map<String, List<ExtensionElement>> extensionElements = dataObj.getExtensionElements();

    if (extensionElements.size() > 0) {
      return extensionElements.get(key).get(0);
    }
    return null;
  }