Beispiel #1
0
 protected String printConstraints(
     @NonNull Map<EModelElement, Set<LeafConstrainingNode>> allConstraints) {
   StringBuilder s = new StringBuilder();
   ArrayList<EModelElement> sortedList = new ArrayList<EModelElement>(allConstraints.keySet());
   //		Collections.sort(sortedList, new Comparator<EClassifier>()
   //		{
   //			public int compare(EClassifier o1, EClassifier o2) {
   //				return o1.getName().compareTo(o2.getName());
   //			}
   //		});
   for (@SuppressWarnings("null") @NonNull EModelElement eObject : sortedList) {
     Set<LeafConstrainingNode> constraints = allConstraints.get(eObject);
     if ((constraints != null) && (constraints.size() > 0)) {
       LeafConstrainingNode firstConstraint = constraints.iterator().next();
       ConstraintLocator constraintLocator = firstConstraint.getConstraintLocator();
       s.append("\t");
       s.append(constraintLocator.getLabel(eObject));
       s.append(":");
       for (ConstrainingNode constraint : constraints) {
         s.append(" \'" + constraint.getLabel() + "'");
       }
     }
     s.append("\n");
   }
   return s.toString();
 }
Beispiel #2
0
 /**
  * Create the ResultValidatableNode,ResultConstrainingNode cross-linkage between constrainedObject
  * and each child constraint of constrainingType.
  */
 protected void createResultNodes(
     @NonNull EObject constrainedObject, @NonNull URI constrainingType) {
   ConstrainingNode constrainingNode = allConstrainingNodes.get(constrainingType);
   if (constrainingNode != null) {
     List<ConstrainingNode> children = constrainingNode.getChildren();
     if (children.size() > 0) {
       ValidatableNode validatable = getValidatableNode(constrainedObject);
       for (@SuppressWarnings("null") @NonNull ConstrainingNode leafConstrainingNode : children) {
         ResultConstrainingNode resultConstrainingNode = createResultConstrainingNode();
         ResultValidatableNode resultValidatableNode = createResultValidatableNode();
         resultConstrainingNode.setResultValidatableNode(resultValidatableNode);
         resultConstrainingNode.setLabel(validatable.getLabel());
         resultValidatableNode.setLabel(leafConstrainingNode.getLabel());
         leafConstrainingNode.getChildren().add(resultConstrainingNode);
         validatable.getChildren().add(resultValidatableNode);
       }
     }
   }
 }
Beispiel #3
0
 //
 //	Create the child LeafConstrainingNodes for each EClass
 //
 protected void createLeafConstrainingNodes(
     @NonNull Map<EModelElement, Set<LeafConstrainingNode>> allConstraints) {
   //		for (EClass eClass : eClasses) {
   for (@SuppressWarnings("null") @NonNull
   EModelElement constrainedType : allConstraints.keySet()) {
     //			System.out.println(eClass);
     //			if (eClass.getName().contains("In")) {
     //				System.out.println(eClass);
     //			}
     ConstrainingNode classConstrainingNode = getConstrainingNode(constrainedType);
     List<ConstrainingNode> children = classConstrainingNode.getChildren();
     //			for (@SuppressWarnings("null")@NonNull EModelElement eachConstrainedType :
     // allConstrainedTypes) {
     Set<LeafConstrainingNode> someConstraints = allConstraints.get(constrainedType);
     if (someConstraints != null) {
       children.addAll(someConstraints);
     }
     //			}
   }
 }
Beispiel #4
0
 /**
  * Return the ConstrainingNode node for EObject creating any parent ConstrainingNodes that are
  * required to ensure that the returned ConstrainingNode is installed in the root.
  */
 public @NonNull ConstrainingNode getConstrainingNode(@NonNull EObject eObject) {
   URI uri = getURI(eObject);
   ConstrainingNode constrainingNode = allConstrainingNodes.get(uri);
   if (constrainingNode == null) {
     EObject eContainer = eObject.eContainer();
     if (eContainer == null) {
       RootConstrainingNode rootConstrainingNode = createRootConstrainingNode();
       rootNode.getConstrainingNodes().add(rootConstrainingNode);
       constrainingNode = rootConstrainingNode;
     }
     //			else if (eObject instanceof EClass) {
     //				constrainingNode = ValidationFactory.eINSTANCE.createLeafConstrainingNode();
     //			ConstrainingNode parentConstrainingNode = getConstrainingNode(eContainer);
     //				parentConstrainingNode.getChildren().add(constrainingNode);
     //			}
     else {
       constrainingNode = createConstrainingNode();
       ConstrainingNode parentConstrainingNode = getConstrainingNode(eContainer);
       parentConstrainingNode.getChildren().add(constrainingNode);
     }
     constrainingNode.setConstrainingObject(eObject);
     constrainingNode.setLabel(validityManager.getLabel(eObject));
     constrainingNode.setEnabled(true);
     allConstrainingNodes.put(uri, constrainingNode);
   }
   return constrainingNode;
 }
Beispiel #5
0
 protected String printConstrainingNodes(@NonNull Set<EClass> eClasses) {
   StringBuilder s = new StringBuilder();
   ArrayList<EClass> sortedList = new ArrayList<EClass>(eClasses);
   Collections.sort(
       sortedList,
       new Comparator<EClass>() {
         public int compare(EClass o1, EClass o2) {
           return o1.getName().compareTo(o2.getName());
         }
       });
   for (EClass eClass : sortedList) {
     s.append("\t" + eClass.getName() + ":");
     ConstrainingNode classConstrainingNode = allConstrainingNodes.get(eClass);
     if (classConstrainingNode != null) {
       for (ConstrainingNode constraint : classConstrainingNode.getChildren()) {
         s.append(" \'" + constraint.getLabel() + "'");
       }
     }
     s.append("\n");
   }
   return s.toString();
 }