@Override
  protected void processAssociationPersist(
      NodeRef nodeRef,
      Map<QName, AssociationDefinition> assocDefs,
      Map<QName, ChildAssociationDefinition> childAssocDefs,
      FieldData fieldData,
      List<org.alfresco.repo.forms.processor.node.AbstractAssocCommand> assocCommands) {
    if (getLogger().isDebugEnabled())
      getLogger().debug("Processing field " + fieldData + " for association persistence");

    String fieldName = fieldData.getName();
    Matcher m =
        this.associationNamePattern.matcher(
            fieldName.replaceAll(DOT_CHARACTER_REPLACEMENT, DOT_CHARACTER));
    if (m.matches()) {
      String qNamePrefix = m.group(1);
      String localName = m.group(2);
      String assocSuffix = m.group(3);

      QName fullQName = QName.createQName(qNamePrefix, localName, namespaceService);

      // ensure that the association being persisted is defined in the model
      AssociationDefinition assocDef = assocDefs.get(fullQName);

      // TODO: if the association is not defined on the node, check for the association
      // in all models, however, the source of an association can be critical so we
      // can't just look up the association in the model regardless. We need to
      // either check the source class of the node and the assoc def match or we
      // check that the association was defined as part of an aspect (where by it's
      // nature can have any source type)

      // SIDE : since forms and model are generated by SIDE we make the assertion that fields are
      // valid, so no advanced validation are done
      if (assocDef == null) {
        if (getLogger().isWarnEnabled()) {
          getLogger()
              .debug(
                  "Field '"
                      + fieldName
                      + "' as an association definition can not be found in the current model");
        }
        assocDef = this.dictionaryService.getAssociation(fullQName);

        if (assocDef == null) {
          if (getLogger().isWarnEnabled()) {
            getLogger()
                .warn(
                    "Ignoring field '"
                        + fieldName
                        + "' as an association definition can not be found in ANY models ");
          }
          return;
        } else {
          if (getLogger().isDebugEnabled()) {
            getLogger()
                .debug(
                    "Field '"
                        + fieldName
                        + "' Found as an association definition in another model : "
                        + assocDef.getModel().getName());
          }
        }
      }

      String value = (String) fieldData.getValue();
      String[] nodeRefs = value.split(",");

      // Each element in this array will be a new target node in association
      // with the current node.
      for (String nextTargetNode : nodeRefs) {
        if (nextTargetNode.length() > 0) {
          if (NodeRef.isNodeRef(nextTargetNode)) {
            if (assocSuffix.equals(ASSOC_DATA_ADDED_SUFFIX)) {
              if (assocDef.isChild()) {
                assocCommands.add(
                    new AddChildAssocCommand(nodeRef, new NodeRef(nextTargetNode), fullQName));
              } else {
                assocCommands.add(
                    new AddAssocCommand(nodeRef, new NodeRef(nextTargetNode), fullQName));
              }
            } else if (assocSuffix.equals(ASSOC_DATA_REMOVED_SUFFIX)) {
              if (assocDef.isChild()) {
                assocCommands.add(
                    new RemoveChildAssocCommand(nodeRef, new NodeRef(nextTargetNode), fullQName));
              } else {
                assocCommands.add(
                    new RemoveAssocCommand(nodeRef, new NodeRef(nextTargetNode), fullQName));
              }
            } else {
              if (getLogger().isWarnEnabled()) {
                StringBuilder msg = new StringBuilder();
                msg.append("Ignoring 'fieldName ")
                    .append(fieldName)
                    .append("' as it does not have one of the expected suffixes (")
                    .append(ASSOC_DATA_ADDED_SUFFIX)
                    .append(" or ")
                    .append(ASSOC_DATA_REMOVED_SUFFIX)
                    .append(")");
                getLogger().warn(msg.toString());
              }
            }
          } else {
            if (getLogger().isWarnEnabled()) {
              StringBuilder msg = new StringBuilder();
              msg.append("targetNode ")
                  .append(nextTargetNode)
                  .append(" is not a valid NodeRef and has been ignored.");
              getLogger().warn(msg.toString());
            }
          }
        }
      }
    } else if (getLogger().isWarnEnabled()) {
      getLogger().warn("Ignoring unrecognised field '" + fieldName + "'");
    }
  }