Package wt.change2

Class DuplicateChangeLinksCleanserDelegate

java.lang.Object
wt.change2.DuplicateChangeLinksCleanserDelegate

public abstract class DuplicateChangeLinksCleanserDelegate extends Object
Delegate for providing custom logic for cleansing duplicate change links. In this context "duplicate links" is defined as two or more links, of the same base link class, referencing the same role A and role B objects. Even if other attributes on the links have different values, the links are still considered duplicates if they reference the same role A and B objects.

By default, the utility will only delete duplicate links when all of their attributes are identical, (including soft attributes). For example, if two links have the same role A and B references, but different values for a "description" attribute, then they are considered duplicates, but not identical. The utility cannot delete either link because it is not able to determine which "description" value is correct. In this case a custom implementation for this delegate is needed to determine: 1) that a duplicate link can be deleted, and 2) which link should be kept.

By default, the utility will not examine custom modeled attributes of custom extended link classes. For these cases a custom implementation of this delegate should be provided with methods that include consideration of these attributes.

Steps for creating a custom delegate:

  1. Create a new class extending this one.
    Example: com.myCompany.MyDuplicateLinkDelegate
  2. Provide a custom implementation for method #getLinkToKeep(WTSet, Map)
  3. (Optional) Provide a custom implementation for method #canDuplicatesBeDeleted(WTSet)
  4. Declare the custom delegate with an entry in the wt.properties file.
    Example: wt.change2.DuplicateChangeLinksCleanserDelegate=com.myCompany.MyDuplicateLinkDelegate


Supported API: true

Extendable: true
See Also:
  • DuplicateChangeLinksCleanser
  • Method Details

    • canDuplicatesBeDeleted

      public boolean canDuplicatesBeDeleted(Class<?> linkClass, WTSet duplicateLinks) throws WTException
      Determine if duplicate change links can be removed by the utility. The default implementation returns true if all links have identical attribute values, or false if any two links have attributes with different values.

      Supported API: true
      Parameters:
      linkClass - - base class of duplicate link objects.
      duplicateLinks - - set of change links referencing the same role A and B objects.
      Returns:
      True if utility is allowed to remove duplicates links, or false if not allowed. If true then delegate method getLinkToKeep(Class, WTSet, Map) will be called with the same set of duplicate links to determine which one is kept.
      Throws:
      WTException
    • getLinkToKeep

      public abstract WTReference getLinkToKeep(Class<?> linkClass, WTSet duplicateLinks, Map<WTReference,List<EffGroup>> effGroups) throws WTException
      Determine which link from a set of duplicates should be kept. This method is only called for a set of duplicate links if canDuplicatesBeDeleted(Class, WTSet) returns true for that set.

      By default, the utility will keep the effectivity managed link and delete the others. If none of the duplicate links are effectivity managed then the most recently modified link is kept and the older links are deleted.

      Supported API: true

      Parameters:
      linkClass - - base class of duplicate link objects.
      duplicateLinks - - set of change links referencing the same role A and B objects.
      effGroups - - map of link reference to its list of effGroups, if the link is effectivity managed. If a link is not effectivity managed then it will not have an entry in the map.
      Returns:
      Reference of the link to be kept. All other duplicate links will be deleted. If null is returned, or if a reference to an object not in the duplicateLinks set is returned, then no duplicate links will be deleted.
      Throws:
      WTException