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;
  }
  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;
  }
  private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("start1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof StartEvent);
    assertEquals("start1", flowElement.getId());

    // verify the main process data objects
    List<ValuedDataObject> dataObjects = model.getMainProcess().getDataObjects();
    assertEquals(1, dataObjects.size());

    Map<String, ValuedDataObject> objectMap = new HashMap<String, ValuedDataObject>();
    for (ValuedDataObject valueObj : dataObjects) {
      objectMap.put(valueObj.getId(), valueObj);
    }

    ValuedDataObject dataObj = objectMap.get("dObj1");
    assertEquals("dObj1", dataObj.getId());
    assertEquals("StringTest", dataObj.getName());
    assertEquals("xsd:string", dataObj.getItemSubjectRef().getStructureRef());
    assertTrue(dataObj.getValue() instanceof String);
    assertEquals("Testing123", dataObj.getValue());

    /*
     * Verify DataObject attributes extension
     */
    Map<String, String> attributes = getDataObjectAttributes(dataObj);
    assertEquals(2, attributes.size());
    for (String key : attributes.keySet()) {
      if (key.equals("Attr1")) {
        assertTrue("1".equals(attributes.get(key)));
      } else if (key.equals("Attr2")) {
        assertTrue("2".equals(attributes.get(key)));
      } else {
        fail("Unknown key value");
      }
    }

    /*
     * Verify DataObject localization extension
     */
    Localization localization = getLocalization(dataObj);
    assertEquals("rbkfn-1", localization.getResourceBundleKeyForName());
    assertEquals("rbkfd-1", localization.getResourceBundleKeyForDescription());
    assertEquals("leifn-1", localization.getLabeledEntityIdForName());
    assertEquals("leifd-1", localization.getLabeledEntityIdForDescription());

    flowElement = model.getMainProcess().getFlowElement("subprocess1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SubProcess);
    assertEquals("subprocess1", flowElement.getId());
    SubProcess subProcess = (SubProcess) flowElement;
    assertEquals(6, subProcess.getFlowElements().size());

    // verify the sub process data objects
    dataObjects = subProcess.getDataObjects();
    assertEquals(1, dataObjects.size());

    objectMap = new HashMap<String, ValuedDataObject>();
    for (ValuedDataObject valueObj : dataObjects) {
      objectMap.put(valueObj.getId(), valueObj);
    }

    dataObj = objectMap.get("dObj2");
    assertEquals("dObj2", dataObj.getId());
    assertEquals("BooleanTest", dataObj.getName());
    assertEquals("xsd:boolean", dataObj.getItemSubjectRef().getStructureRef());
    assertTrue(dataObj.getValue() instanceof Boolean);
    assertEquals(Boolean.TRUE, dataObj.getValue());

    /*
     * Verify DataObject attributes extension
     */
    attributes = getDataObjectAttributes(dataObj);
    assertEquals(2, attributes.size());
    for (String key : attributes.keySet()) {
      if (key.equals("Attr3")) {
        assertTrue("3".equals(attributes.get(key)));
      } else if (key.equals("Attr4")) {
        assertTrue("4".equals(attributes.get(key)));
      } else {
        fail("Unknown key value");
      }
    }

    /*
     * Verify DataObject localization extension
     */
    localization = getLocalization(dataObj);
    assertEquals("rbkfn-2", localization.getResourceBundleKeyForName());
    assertEquals("rbkfd-2", localization.getResourceBundleKeyForDescription());
    assertEquals("leifn-2", localization.getLabeledEntityIdForName());
    assertEquals("leifd-2", localization.getLabeledEntityIdForDescription());
  }