コード例 #1
0
  /*
   * Validates that all required properties are filled in for a given node.
   */
  private void validateNodeProperties(Node node, StringBuilder errBuilder) {
    if (Thread.currentThread().isInterrupted()) {
      return;
    }
    List<PropertyConstraint> violatedConstraints =
        controller.getDomainProfileService().validateProperties(node, node.getNodeType());
    if (!violatedConstraints.isEmpty()) {
      markNodeAsInvalid(node);

      if (node.getFileInfo() != null) {
        errBuilder.append(node.getFileInfo().getLocation().toString()).append("\n");
      } else {
        errBuilder.append(node.getIdentifier().toString()).append("\n");
      }

      for (PropertyConstraint violation : violatedConstraints) {
        errBuilder.append("\t--").append(violation.getPropertyType().getLabel()).append("\n");
      }

      errBuilder.append("\n");
    } else {
      markNodeAsValid(node);
    }

    if (node.getChildren() != null) {
      for (Node child : node.getChildren()) {
        validateNodeProperties(child, errBuilder);
        if (Thread.currentThread().isInterrupted()) {
          break;
        }
      }
    }
  }
コード例 #2
0
  @Override
  public List<NodeType> getPossibleChildTypes(Node node) {
    List<NodeType> childNodes = new ArrayList<>();
    for (NodeType nodeType : controller.getPrimaryDomainProfile().getNodeTypes()) {
      if (nodeType.getParentConstraints() != null) {
        for (NodeConstraint parentConstraint : nodeType.getParentConstraints()) {
          if (parentConstraint.matchesAny()
              || (parentConstraint.getNodeType() != null
                  && parentConstraint.getNodeType().equals(node.getNodeType()))) {
            childNodes.add(nodeType);
            break;
          }
        }
      }
    }

    return childNodes;
  }
コード例 #3
0
  private boolean updateUnassignedNode(Node node) {
    if (!node.isIgnored()) {
      if (node.getNodeType() == null) {
        if (!getController()
            .getDomainProfileService()
            .assignNodeTypes(getController().getPrimaryDomainProfile(), node)) {
          return false;
        }
      }

      if (node.getChildren() != null) {
        for (Node child : node.getChildren()) {
          if (!updateUnassignedNode(child)) {
            return false;
          }
        }
      }
    }

    return true;
  }