Class ComparisonSpec

java.lang.Object
com.ptc.core.ocmp.framework.ComparisonSpec
All Implemented Interfaces:
Externalizable, Serializable
Direct Known Subclasses:
AdvancedComparisonSpec, SimpleComparisonSpec

public abstract class ComparisonSpec extends Object implements Externalizable

Represents a specification with options specified to control and tailor the comparison result (ComparisonResult). This is the primary object consumed by the ObjComparisonService to compare business objects and compute results.

The business objects to be compared are specified in an ordered list - see getObjsToCompare(). The order in which the objects are specified is important, since it is used to construct the ComparisonResult. This is a convention followed to allow for a simpler structure of the ComparisonResult instance.

Also, the object's class (type) name of the context (first) object in the list is used to identify the object comparator to delegate the request, along with the individual attribute and link comparators (if specifed), by keying it in the external configuration resource.

Typically all the objects to be compared are either of the same type or share the same parent business object type (ex. comparing Windchill provided (typically modeled) business objects with customized objects that extend modeled type and/or with soft types). Although the framework does not mandate this fact and could support objects of different base types to be compared, if the object comparator support such a use case. See the package level documentation for comp.ptc.core.ocmp for more details.

Sample Code to construct a ComparisonSpec instance:
WTList objsToCompare = ... // construct a list of objects to be compared
SimpleComparisonSpec spec = ComparisonSpec.newSimpleInstance(objsToCompare);
// == or == AdvancedComparisonSpec spec = ComparisonSpec.newAdvancedInstance(objsToCompare);

// that's all is required to construct an instance. Other properties of the specification are optional to specify and if not specified, their defaults are used for the comparison operation. See the individual method level documentation to find out the defaults for a particular property.
spec.excludeAttrs(); // if attributes are to be excluded from the comparison operation
spec.excludeLinks(); // if links are to be excluded from the comparison operation

spec.setSelectedAttrs(...); // if attributes are not to be excluded and a custom set of attributes are to be compared, they can be set here, otherwise the default (configured in configuration resource) set of attributes will be chosen for comparison.

spec.setSelectedLinks(...); // if links are not to be excluded and a custom set of links are to be compared, they can be set here, otherwise the default (configured in configuration resource) set of links and their corresponding attributes (as well as other role object attributes) will be chosen for comparison.



Supported API: true

Extendable: false
See Also:
  • Method Details

    • getContextObjRef

      public WTReference getContextObjRef()
      The context identifies the object comparator to use for comparisons as well as the attributes and associations to consider for comparison.

      It is specified by making it the first object in the ordered list of objects to be compared.

      Supported API: true
      Returns:
      returns a reference (See WTReference) to the context object
      Throws:
      IllegalStateException - if the list of objects to be compared is found null, in which case it is not possible to identify the source object.
      See Also:
    • getContextObjTypeName

      public String getContextObjTypeName()
      The context identifies the object comparator to use for comparisons as well as the attributes and associations to consider for comparison.

      It is specified by making it the first object in the ordered list of objects to be compared.

      Supported API: true
      Returns:
      returns the (persisted) type name of the context object