Class ESIObjectComparisonUtility

java.lang.Object
com.ptc.windchill.esi.utl.ESIObjectComparisonUtility

public class ESIObjectComparisonUtility extends Object
Utility class for comparing objects that are getting published using ESI. Object Comparison framework(OCMP) has been used for difference calculation.

Supported API: true

Extendable: false
  • Method Details

    • compareObjects

      public static ComparisonResult compareObjects(Persistable currentIteration, Persistable previousIteration, Set linksToCompare) throws WTException
      Compares two iterations of an object and returns the difference in the form of a ComparisonResult object. Does the following :
      1. Constructs an instance of SimpleComparisonSpec object and sets current and previous iterations on it for comparison.
      2. If the input argument linksToCompare is null or is an empty set, it invokes the method autoSelectLinks() on SimpleComparisonSpec so that the necessary link meta data will be retrieved from the object comparison configuration resource; otherwise, it invokes the method setSelectedLinks().
      3. Finally it invokes the method ObjComparisonHelper.service.compareDomainObjs(), passing in the SimpleComparisonSpec object.


      Supported API: true
      Parameters:
      currentIteration - - Current iteration of a Persistable object.
      previousIteration - - Previous iteration of a Persistable object.
      linksToCompare - - Set of link types on the current and previous iterations that are to be compared.
      Returns:
      ComparisonResult object which will have the difference between the current and previous iterations.
      Throws:
      WTException
    • computeLinkDifferences

      public static HashSet<Persistable>[] computeLinkDifferences(ComparisonResult result)
      Computes the added, deleted, changed and unchanged links information from the input comparison result. In the returned array of HashSets, the elements at indices 0, 1, 2 and 3 contain all the added, deleted, changed and unchanged links respectively.

      Supported API: true
      Parameters:
      result - ComparisonResult object from which to fetch the difference information. This is typically the output that results from a call to ObjComparisonHelper.service.compareDomainObjs(ComparisonSpec).
      Returns:
      An array of HashSets.
    • computeLinkDifferencesInfo

      public static Map<String,Object> computeLinkDifferencesInfo(ComparisonResult comparisonResult)
      Computes the added, deleted, changed and unchanged links information from the input comparison result. Returns a MAP containing difference information of the links.

      In the returned Map, the value for the key "LINK_DIFFERENCES" is an array of sets. In this array of sets, the elements at indices 0, 1, 2 and 3 contain all the added, deleted, changed and unchanged links respectively. The map also contains key CURRENT_LINKS_TO_PREVIOUS_LINKS_MAP with a map as a value, holding link object valid for current iteration and old link for previous iteration.

      Supported API: true
      Parameters:
      comparisonResult - -THe ComparisonResult object from which to fetch the difference information. This is typically the output that results from a call to ObjComparisonHelper.service.compareDomainObjs(ComparisonSpec).
      Returns:
      - The map containing link difference information.
    • computeAttrDifferences

      public static HashMap computeAttrDifferences(ComparisonResult result)
      Computes the attribute difference information between links from the input comparison result. The returned HashMap contains logical type identifiers of the relevant links as keys and certain Maps as values; each key in the value Map is a string of the form <Role B object master identifier>_<attribute name>, and the value is the old value of the given attribute that was changed.

      Supported API: true
      Parameters:
      result - ComparisonResult object from which to fetch the difference information. This is typically the output that results from a call to ObjComparisonHelper.service.compareDomainObjs(ComparisonSpec).
      Returns:
      A HashMap of keys and values that provide the old attribute values.
      Key Value
      <Role B object master identifier>_<attribute name> Is the old value of the attribute.
    • compareOptionSets

      public static Map<String,Object> compareOptionSets(OptionSet currentObj, OptionSet previousObj) throws WTException
      Compares two iterations of a OptionSet. This method internally invokes the object comparison frame work.

      Supported API: true

      Parameters:
      currentObj - - Current iteration of a OptionSet.
      previousObj - - Previous iteration of a OptionSet.
      Returns:
      Returns the comparison result in a Map. This Map object holds the attribute and link differences as two separate maps following keys.
      Key Value
      ESIObjectComparisonUtility.ATTRIBUTE_DIFF_INFORMATION A map object which holds the attribute differences as follows.
      Key Value
      Fully qualified class name of the link class A Map containing attribute information for each link.
      Key Value
      <Role B object master identifier>_<attribute name> Is the old value of the attribute.
      Check the method computeAttrDifferences(ComparisonResult) for more information.
      ESIObjectComparisonUtility.LINK_DIFFERENCES An array of Set objects which holds the link differences. Set in array at various indexes is as follows
      Index-0 : all the added OptionSetMemberLink objects.
      Index-1 : all the deleted OptionSetMemberLink objects,
      Index-2: all the changed OptionSetMemberLink objects,
      Index-3: all the Unchanged OptionSetMemberLink objects
      Throws:
      WTException