Ejemplo n.º 1
0
 private void removeFormNameFromLabel(Map<String, FormElement> formElementMap) {
   for (String key : formElementMap.keySet()) {
     FormElement element = formElementMap.get(key);
     String label = FormUtils.removeFormNameFromLabel(element.getLabel());
     element.setLabel(label);
   }
 }
Ejemplo n.º 2
0
  private void recursivelyAddFormElements(
      Map<String, FormElement> formElementMap, NodeList nodeList, String uri) {
    for (int i = 0; i < nodeList.getLength(); i++) {
      Node element = nodeList.item(i);
      if (hasChildElements(element)) {

        if (element.hasAttributes()) { // repeat group
          String localUri = uri + SLASH + element.getNodeName();
          FormElement formElement =
              new FormElementBuilder()
                  .setName(localUri)
                  .setLabel(localUri)
                  .setType(FieldTypeConstants.REPEAT_GROUP)
                  .setChildren(new ArrayList<FormElement>())
                  .createFormElement();
          formElementMap.put(formElement.getName(), formElement);
          recursivelyAddGroup(
              formElementMap,
              element.getChildNodes(),
              uri + SLASH + element.getNodeName(),
              formElement.getChildren(),
              formElement);
        } else {
          recursivelyAddFormElements(
              formElementMap, element.getChildNodes(), uri + SLASH + element.getNodeName());
        }
      } else if (element.getNodeType() == Node.ELEMENT_NODE) {
        String localUri = uri + SLASH + element.getNodeName();
        FormElement formElement =
            new FormElementBuilder().setName(localUri).setLabel(localUri).createFormElement();
        formElementMap.put(formElement.getName(), formElement);
      }
    }
  }
Ejemplo n.º 3
0
 private List<FormElement> createFormElementListFromMap(Map<String, FormElement> formElementMap) {
   List<FormElement> formElements = new ArrayList<>();
   for (FormElement formElement : formElementMap.values()) {
     if (formElement.getType().equals(FieldTypeConstants.REPEAT_GROUP)
         || !formElement.isPartOfRepeatGroup()) {
       formElements.add(formElement);
     }
   }
   return formElements;
 }
Ejemplo n.º 4
0
  private void addBindInformationToFormFields(
      Map<String, FormElement> formElementMap, NodeList binds) {
    for (int i = 0; i < binds.getLength(); i++) {
      Node bind = binds.item(i);
      NamedNodeMap attributes = bind.getAttributes();
      String fieldUri = attributes.getNamedItem(NODE_SET).getNodeValue();
      FormElement formElement = formElementMap.get(fieldUri);
      Node typeNode = attributes.getNamedItem(TYPE);

      if (formElement != null) {
        String type;
        if (typeNode == null) {
          type = STRING;
        } else {
          type = typeNode.getNodeValue();
        }
        formElement.setType(type);
      }
    }
  }