Class DuplicateChangeLinksCleanserDelegate
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:
- Create a new class extending this one.
Example:com.myCompany.MyDuplicateLinkDelegate - Provide a custom implementation for method
#getLinkToKeep(WTSet, Map) - (Optional) Provide a custom implementation for method
#canDuplicatesBeDeleted(WTSet) - 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 Summary
Modifier and TypeMethodDescriptionbooleancanDuplicatesBeDeleted(Class<?> linkClass, WTSet duplicateLinks) Determine if duplicate change links can be removed by the utility.abstract WTReferencegetLinkToKeep(Class<?> linkClass, WTSet duplicateLinks, Map<WTReference, List<EffGroup>> effGroups) Determine which link from a set of duplicates should be kept.
-
Method Details
-
canDuplicatesBeDeleted
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 WTExceptionDetermine which link from a set of duplicates should be kept. This method is only called for a set of duplicate links ifcanDuplicatesBeDeleted(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
-