org.eclipse.ocl.examples.emf.validation.validity.manager
Class ValidityModel

java.lang.Object
  extended by org.eclipse.ocl.examples.emf.validation.validity.manager.ValidityModel
Direct Known Subclasses:
IDEValidityManager.IDEValidityModel, StandaloneValidityModel

public class ValidityModel
extends java.lang.Object


Field Summary
protected  ValidityManager validityManager
           
static int WORK_FOR_ALL_SET_INPUT
           
static int WORK_FOR_CLEAN_UP
           
static int WORK_FOR_CREATE_MODEL
           
 
Constructor Summary
ValidityModel(ValidityManager validityManager, java.util.Collection<org.eclipse.emf.ecore.resource.Resource> newResources)
          The Constructor.
 
Method Summary
 java.util.Set<ConstrainingURI> accumulateConstrainingURIs(java.util.Set<ConstrainingURI> constrainingURIs, TypeURI typeURI)
           
 void addConstrainingFilter(IVisibilityFilter filter)
           
 void addFilteredSeverity(Severity severity)
           
 void addValidatableFilter(IVisibilityFilter filter)
           
protected  java.util.Set<org.eclipse.emf.ecore.EClass> analyzeResource(org.eclipse.emf.ecore.resource.Resource resource)
           
protected  java.util.Map<org.eclipse.emf.ecore.EPackage,java.util.Set<org.eclipse.emf.ecore.resource.Resource>> analyzeResources(java.util.Collection<org.eclipse.emf.ecore.resource.Resource> resources, org.eclipse.emf.common.util.Monitor monitor, int worked)
          Looks for all EPackages in the source Resources.
protected  java.util.Set<TypeURI> buildTypeClosure(org.eclipse.emf.ecore.EObject constrainingObject)
          Return all types that may provide constraints to an instance of aType.
protected  ConstrainingNode createConstrainingNode()
          Creates a ConstrainingNode.
 LeafConstrainingNode createLeafConstrainingNode()
          creates a LeafConstrainingNode
protected  void createLeafConstrainingNodes(java.util.Map<org.eclipse.emf.ecore.EObject,java.util.Set<LeafConstrainingNode>> allConstraints, org.eclipse.emf.common.util.Monitor monitor)
          Create the child LeafConstrainingNodes for each EModelElement that provides constraints
protected  Result createResult(org.eclipse.core.runtime.IProgressMonitor monitor)
          Return a new Result object, or return null if the creation process is to be aborted.
protected  ResultConstrainingNode createResultConstrainingNode()
          Creates a ResultConstrainingNode.
protected  void createResultNodes(java.util.Collection<org.eclipse.emf.ecore.resource.Resource> resources, org.eclipse.emf.common.util.Monitor monitor, int worked)
          Create the ResultValidatableNode,ResultConstrainingNode cross-linkage for all validateableObject,constraint pairs.
protected  void createResultNodes(org.eclipse.emf.ecore.EObject constrainedObject, ConstrainingURI constrainingURI)
          Create the ResultValidatableNode,ResultConstrainingNode cross-linkage between constrainedObject and each child constraint of constrainingType.
protected  void createResultNodes(ValidatableNode validatable, ConstrainingNode constrainingNode)
           
protected  boolean createResults(java.util.List<Result> results, java.util.List<? extends ValidatableNode> validatableNodes, org.eclipse.core.runtime.IProgressMonitor monitor)
          Created Results of all validatableNodes.
protected  ResultSet createResultSet()
          Creates a ResultSet.
 ResultSet createResultSet(org.eclipse.core.runtime.IProgressMonitor monitor)
          Return a new ResultSet object containing an initial result for every enabled combination of ValidatableNode and ConstrainingNode.
protected  ResultValidatableNode createResultValidatableNode()
          Creates a ResultValidatableNode
protected  RootConstrainingNode createRootConstrainingNode()
           
protected  RootValidatableNode createRootValidatableNode()
           
protected  ValidatableNode createValidatableNode()
           
 java.lang.String getConstrainingLabel(org.eclipse.emf.ecore.EObject eObject)
          Returns the eObject label
 ConstrainingNode getConstrainingNode(org.eclipse.emf.ecore.EObject constrainingObject)
          Return the ConstrainingNode node for EObject creating any parent ConstrainingNodes that are required to ensure that the returned ConstrainingNode is installed in the root.
protected  java.util.List<ConstraintLocator> getConstraintLocators(java.lang.String nsURI)
           
 java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResources()
           
 java.lang.String getResultConstrainingLabel(ValidatableNode validatableNode)
           
protected  java.lang.StringBuilder getResultPath(java.lang.StringBuilder s, AbstractNode abstractNode)
           
 java.lang.String getResultValidatableLabel(ConstrainingNode constrainingNode)
           
 RootNode getRootNode()
           
protected  ValidatableNode getValidatableNode(org.eclipse.emf.ecore.EObject eObject)
          Return the ValidatableNode node for EObject creating any ValidatableNodes that are required to ensure that the returned ValidatableNode is installed in the root.
 void init(org.eclipse.emf.common.util.Monitor monitor)
          Initialize the ValidityModel
protected  java.util.Map<org.eclipse.emf.ecore.EObject,java.util.Set<LeafConstrainingNode>> locateConstraints(java.util.Map<org.eclipse.emf.ecore.EPackage,java.util.Set<org.eclipse.emf.ecore.resource.Resource>> ePackage2resources, org.eclipse.emf.common.util.Monitor monitor, int worked)
          Find all constraints for each EClass
 void refreshModel(java.util.List<AbstractNode> grayedValidatableNodes, java.util.List<AbstractNode> grayedConstrainingNodes)
           
 void removeConstrainingFilter(IVisibilityFilter filter)
           
 void removeFilteredSeverity(Severity severity)
           
 void removeValidatableFilter(IVisibilityFilter filter)
           
protected
<T extends AbstractNode>
void
sortEList(org.eclipse.emf.common.util.EList<T> nodes, java.util.Comparator<AbstractNode> comparator)
          Sorts the list.
protected
<T extends AbstractNode>
void
sortNodes(org.eclipse.emf.common.util.EList<T> nodes, java.util.Comparator<AbstractNode> comparator)
          Sorts the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WORK_FOR_CLEAN_UP

public static final int WORK_FOR_CLEAN_UP
See Also:
Constant Field Values

WORK_FOR_CREATE_MODEL

public static final int WORK_FOR_CREATE_MODEL
See Also:
Constant Field Values

WORK_FOR_ALL_SET_INPUT

public static final int WORK_FOR_ALL_SET_INPUT
See Also:
Constant Field Values

validityManager

@NonNull
protected final ValidityManager validityManager
Constructor Detail

ValidityModel

public ValidityModel(@NonNull
                     ValidityManager validityManager,
                     @NonNull
                     java.util.Collection<org.eclipse.emf.ecore.resource.Resource> newResources)
The Constructor.

Parameters:
validityManager - The ValidityManager
newResources - All resources found in the resourceSet
Method Detail

accumulateConstrainingURIs

@Nullable
public java.util.Set<ConstrainingURI> accumulateConstrainingURIs(@Nullable
                                                                          java.util.Set<ConstrainingURI> constrainingURIs,
                                                                          @NonNull
                                                                          TypeURI typeURI)

addConstrainingFilter

public void addConstrainingFilter(@NonNull
                                  IVisibilityFilter filter)

addFilteredSeverity

public void addFilteredSeverity(@NonNull
                                Severity severity)

addValidatableFilter

public void addValidatableFilter(@NonNull
                                 IVisibilityFilter filter)

analyzeResources

@NonNull
protected java.util.Map<org.eclipse.emf.ecore.EPackage,java.util.Set<org.eclipse.emf.ecore.resource.Resource>> analyzeResources(@NonNull
                                                                                                                                        java.util.Collection<org.eclipse.emf.ecore.resource.Resource> resources,
                                                                                                                                        @NonNull
                                                                                                                                        org.eclipse.emf.common.util.Monitor monitor,
                                                                                                                                        int worked)
Looks for all EPackages in the source Resources.

Parameters:
resources - the Collection of all resources in the resourceSet
Returns:
a map containing all EPackages of all resources

analyzeResource

protected java.util.Set<org.eclipse.emf.ecore.EClass> analyzeResource(org.eclipse.emf.ecore.resource.Resource resource)

buildTypeClosure

@NonNull
protected java.util.Set<TypeURI> buildTypeClosure(@NonNull
                                                          org.eclipse.emf.ecore.EObject constrainingObject)
Return all types that may provide constraints to an instance of aType.

Parameters:
aType - a modelElement
Returns:
all types that may provide constraints to an instance if aType.

createConstrainingNode

@NonNull
protected ConstrainingNode createConstrainingNode()
Creates a ConstrainingNode.

Returns:
the created ConstrainingNode

createLeafConstrainingNode

@NonNull
public LeafConstrainingNode createLeafConstrainingNode()
creates a LeafConstrainingNode

Returns:
the created LeafConstrainingNode

createLeafConstrainingNodes

protected void createLeafConstrainingNodes(@NonNull
                                           java.util.Map<org.eclipse.emf.ecore.EObject,java.util.Set<LeafConstrainingNode>> allConstraints,
                                           @NonNull
                                           org.eclipse.emf.common.util.Monitor monitor)
Create the child LeafConstrainingNodes for each EModelElement that provides constraints

Parameters:
allConstraints - the map of all model elements and their LeafConstrainingNodes

createResult

@Nullable
protected Result createResult(@Nullable
                                       org.eclipse.core.runtime.IProgressMonitor monitor)
Return a new Result object, or return null if the creation process is to be aborted.

The default implementation always return an object. Derived implementations may cancel in response to a progress monitor request.

Parameters:
monitor - the corresponding monitor
Returns:
the created new Result object

createResultConstrainingNode

@NonNull
protected ResultConstrainingNode createResultConstrainingNode()
Creates a ResultConstrainingNode.

Returns:
the created ResultConstrainingNode

createResultNodes

protected void createResultNodes(@NonNull
                                 java.util.Collection<org.eclipse.emf.ecore.resource.Resource> resources,
                                 @NonNull
                                 org.eclipse.emf.common.util.Monitor monitor,
                                 int worked)
Create the ResultValidatableNode,ResultConstrainingNode cross-linkage for all validateableObject,constraint pairs.

Parameters:
resources - the resources

createResultNodes

protected void createResultNodes(@NonNull
                                 org.eclipse.emf.ecore.EObject constrainedObject,
                                 @NonNull
                                 ConstrainingURI constrainingURI)
Create the ResultValidatableNode,ResultConstrainingNode cross-linkage between constrainedObject and each child constraint of constrainingType.

Parameters:
constrainedObject - the constraining object
constrainingType - the uri of the constrainingNode

createResultNodes

protected void createResultNodes(@NonNull
                                 ValidatableNode validatable,
                                 @NonNull
                                 ConstrainingNode constrainingNode)

createResultSet

@NonNull
protected ResultSet createResultSet()
Creates a ResultSet.

Returns:
the created ResultSet

createResultSet

@Nullable
public ResultSet createResultSet(@Nullable
                                          org.eclipse.core.runtime.IProgressMonitor monitor)
Return a new ResultSet object containing an initial result for every enabled combination of ValidatableNode and ConstrainingNode. Returns null if the creation process was aborted.

Parameters:
monitor - the corresponding monitor
Returns:
the ResultSet

createResultValidatableNode

@NonNull
protected ResultValidatableNode createResultValidatableNode()
Creates a ResultValidatableNode

Returns:
the created ResultValidatableNode

createResults

protected boolean createResults(@NonNull
                                java.util.List<Result> results,
                                @NonNull
                                java.util.List<? extends ValidatableNode> validatableNodes,
                                @Nullable
                                org.eclipse.core.runtime.IProgressMonitor monitor)
Created Results of all validatableNodes.

Parameters:
results - the created results
validatableNodes - the validatableNodes
monitor - the corresponding monitor
Returns:
true if the results are created well, false otherwise

createRootConstrainingNode

@NonNull
protected RootConstrainingNode createRootConstrainingNode()
Returns:
the created RootConstrainingNode

createRootValidatableNode

@NonNull
protected RootValidatableNode createRootValidatableNode()
Returns:
the created RootValidatableNode

createValidatableNode

@NonNull
protected ValidatableNode createValidatableNode()
Returns:
the created ValidatableNode

getConstrainingLabel

@NonNull
public java.lang.String getConstrainingLabel(@NonNull
                                                     org.eclipse.emf.ecore.EObject eObject)
Returns the eObject label

Parameters:
eObject -
Returns:
The eObject label

getConstrainingNode

@NonNull
public ConstrainingNode getConstrainingNode(@NonNull
                                                    org.eclipse.emf.ecore.EObject constrainingObject)
Return the ConstrainingNode node for EObject creating any parent ConstrainingNodes that are required to ensure that the returned ConstrainingNode is installed in the root.

Parameters:
eObject -
Returns:
the ConstrainingNode node for EObject

getResources

@NonNull
public java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResources()
Returns:
all resources

getResultConstrainingLabel

@NonNull
public java.lang.String getResultConstrainingLabel(@NonNull
                                                           ValidatableNode validatableNode)

getResultPath

@NonNull
protected java.lang.StringBuilder getResultPath(@NonNull
                                                        java.lang.StringBuilder s,
                                                        @Nullable
                                                        AbstractNode abstractNode)

getResultValidatableLabel

@NonNull
public java.lang.String getResultValidatableLabel(@NonNull
                                                          ConstrainingNode constrainingNode)

getRootNode

@NonNull
public RootNode getRootNode()
Returns:
the root node

getValidatableNode

@NonNull
protected ValidatableNode getValidatableNode(@NonNull
                                                     org.eclipse.emf.ecore.EObject eObject)
Return the ValidatableNode node for EObject creating any ValidatableNodes that are required to ensure that the returned ValidatableNode is installed in the root.

Parameters:
eObject - the modelElement
Returns:
the ValidatableNode node for EObject

init

public void init(@NonNull
                 org.eclipse.emf.common.util.Monitor monitor)
Initialize the ValidityModel


locateConstraints

@Nullable
protected java.util.Map<org.eclipse.emf.ecore.EObject,java.util.Set<LeafConstrainingNode>> locateConstraints(@NonNull
                                                                                                                      java.util.Map<org.eclipse.emf.ecore.EPackage,java.util.Set<org.eclipse.emf.ecore.resource.Resource>> ePackage2resources,
                                                                                                                      @NonNull
                                                                                                                      org.eclipse.emf.common.util.Monitor monitor,
                                                                                                                      int worked)
Find all constraints for each EClass

Parameters:
ePackage2resources - the map of all ePackages and their resources
Returns:
all constraints for each EClass

refreshModel

public void refreshModel(@Nullable
                         java.util.List<AbstractNode> grayedValidatableNodes,
                         @Nullable
                         java.util.List<AbstractNode> grayedConstrainingNodes)

removeConstrainingFilter

public void removeConstrainingFilter(@NonNull
                                     IVisibilityFilter filter)

removeFilteredSeverity

public void removeFilteredSeverity(@NonNull
                                   Severity severity)

removeValidatableFilter

public void removeValidatableFilter(@NonNull
                                    IVisibilityFilter filter)

getConstraintLocators

protected java.util.List<ConstraintLocator> getConstraintLocators(@NonNull
                                                                  java.lang.String nsURI)

sortEList

protected <T extends AbstractNode> void sortEList(@NonNull
                                                  org.eclipse.emf.common.util.EList<T> nodes,
                                                  @NonNull
                                                  java.util.Comparator<AbstractNode> comparator)
Sorts the list.

Parameters:
nodes - the list of nodes needing to be sorted.

sortNodes

protected <T extends AbstractNode> void sortNodes(@NonNull
                                                  org.eclipse.emf.common.util.EList<T> nodes,
                                                  @NonNull
                                                  java.util.Comparator<AbstractNode> comparator)
Sorts the list.

Parameters:
nodes - the list of nodes needing to be sorted.