Package wt.impact

Class ImpactedDelegate

java.lang.Object
wt.impact.ImpactDelegate
wt.impact.ImpactedDelegate
All Implemented Interfaces:
Serializable, Comparable<ImpactDelegate>
Direct Known Subclasses:
LotBaselineImpactedDelegate, ManagedBaselineImpactedDelegate

public abstract class ImpactedDelegate extends ImpactDelegate
Delegate used to abstract the behavior of Impacted objects.

All extended delegates must implement constructors:

  • A constructor with no arguments that calls super().
  • A constructor with only an Impacted argument that calls super(impacted).

Concrete delegate implementations must be registered in the service.properties file as:

 &ltService context="default" name="wt.impact.ImpactedDelegate"&gt
     &ltOption selector="order-number" cardinality="duplicate"
     serviceClass="delegate-class-name"
     requestor="impacted-class-name"/&lt
 &lt/Service&gt
 
 Where:
     order-number = Integer value defining the ascending order in
                    which this delegate is applied (e.g., "10").
     
     delegate-class-name = Full class name of this delegate.
     
     impacted-class-name = Full class name of the Impacted object
                           that this delegate supports.
 


Supported API: true

Extendable: true
See Also:
  • Constructor Details

    • ImpactedDelegate

      public ImpactedDelegate(Impacted impacted)
      Construct ImpactedDelegate for an Impacted object.

      Supported API: true
    • ImpactedDelegate

      public ImpactedDelegate(WTCollection impacteds)
      Construct ImpactedDelegate for a collection of Impacted objects.

      Supported API: true
  • Method Details

    • allowMultipleImpacteds

      public boolean allowMultipleImpacteds()
      Return true to allow multiple Impacted objects to be served by a single ImpactedDelegate instance, or false to force a separate ImpactedDelegate instance for each Impacted object.

      Allowing multiple Impacted objects per delegate may improve the performance of the applyXXX() methods, depending on how they are implemented. If disallowed then ordering delegates by individual Impacted object attribute values is possible.

      If false is returned then attempts to add more than one Impacted object to a delegate will cause an exception to be thrown.

      Supported API: true

    • getImpacteds

      public final WTSet getImpacteds()
      Return the immutable Impacted object set for this delegate (guaranteed non-null, may be empty).

      Supported API: true
    • getSupportedImpactorTypes

      public abstract Set<TypeIdentifier> getSupportedImpactorTypes() throws WTException
      Return immutable set of TypeIdentifier objects defining the supported Impactor types (may be null or empty). All sub-types of those returned will be supported automatically.

      Supported API: true
      Returns:
      Set of supported impactor types (null or empty for none).
      Throws:
      WTException
    • getUnsupportedImpactorTypes

      public Set<TypeIdentifier> getUnsupportedImpactorTypes() throws WTException
      Return immutable set of TypeIdentifier objects defining the unsupported Impactor sub-types (may be null or empty). Unsupported sub-types, and all of their sub-types, are subtracted from the set of supported types.

      Supported API: true
      Returns:
      Set of unsupported impactor types (null or empty for none).
      Throws:
      WTException
    • isSupported

      public final boolean isSupported(TypeIdentifier impactorTypeId, Object container) throws WTException
      Determine if an Impactor type is supported by this delegate.

      Supported API: true
      Parameters:
      impactorTypeId - TypeIdentifier of Impactor object.
      container - WTContained or WTContainerRef object used to derive the association rule's organization or site context (must be non-null).
      Returns:
      True if Impactor type is supported by this delegate.
      Throws:
      WTException
    • isSupported

      public final boolean isSupported(Impactor impactor, Object container) throws WTException
      Determine if an Impactor object is supported by this delegate.

      Supported API: true
      Parameters:
      impactor - Impactor object.
      container - WTContained or WTContainerRef object used to derive the association rule's organization or site context. If null then the Impactor object's container is used.
      Returns:
      True if Impactor object is supported by this delegate.
      Throws:
      WTException
    • applyImpacts

      public final boolean applyImpacts(ImpactorDelegate impactorDelegate) throws WTException
      Apply impacts to all Impacted objects represented by this delegate.

      Extended delegate implementations are provided by overriding method applyImpacts(), or one of its subordinate methods.

      Supported API: true

      Parameters:
      impactorDelegate - ImpactorDelegate implementation for an Impactor object. If the delegate is for and unsupported Impactors then an error message is logged and false is returned.
      Returns:
      True if impacts were applied, false if not.
      Throws:
      WTException
    • applyImpacts

      protected boolean applyImpacts() throws WTException
      Apply impacts to all Impacted objects represented by an extended delegate. May be overridden by extended delegates to meet specific requirements.

      Default order of execution:

      1. Call initializeApplyImpacts() to initialize the apply process
      2. Call filterImpactedsForApply() to remove Impacted objects that should not be applied
      3. Call ImpactorDelegate.getImpactIntents() to get impact-to-intent map
      4. Call filterImpactingObjects(WTKeyedMap) to filter out unsupported impacting objects
      5. Call invertImpactIntentMap(WTKeyedMap) to create inverted impact-to-intent map with default intents added
      6. Start transaction
      7. Call initializeApplyImpacts(Map) to initialize the apply process immediately after the transaction is started
      8. Iterate over all Impacted objects {
      9.  Iterate over all intent values returned from getIntentApplyOrder() {
      10.   Call applyImpactIntent(ImpactIntentType, Impacted, WTSet) for the current intent value
      11.  }
      12. }
      13. Call finalizeApplyImpacts(boolean) passing true to finalize the apply process before transaction commit
      14. Commit transaction
      15. Call finalizeApplyImpacts(boolean) passing false to finalize the apply process after transaction commit


      Supported API: true
      Returns:
      True if impacts were applied, false if not.
      Throws:
      WTException
    • initializeApplyImpacts

      protected void initializeApplyImpacts() throws WTException
      Initialize the apply impacts process. The default implementation does nothing. Extended delegates may override this method to implement required pre-processing. This method is called before any apply processing is performed.

      Supported API: true
      Throws:
      WTException
    • initializeApplyImpacts

      protected void initializeApplyImpacts(Map<ImpactIntentType,WTSet> intentToImpactsMap) throws WTException
      Initialize the apply impacts process. The default implementation does nothing. Extended delegates may override this method to implement required pre-processing. This method is called immediately after the database transaction is started.

      Supported API: true
      Parameters:
      intentToImpactsMap - Map of ImpactIntentType value to a set of impact objects for that intent. Map is guaranteed non-null, but may be empty. It will only contain entries for intent values actually present in the input map and returned by getIntentApplyOrder().
      Throws:
      WTException
    • finalizeApplyImpacts

      protected void finalizeApplyImpacts(boolean beforeCommit) throws WTException
      Finalize the apply impacts process. The default implementation does nothing. Extended delegates may override this method to implement required post-processing. This method is called twice: immediately before and after database transaction commit.

      Supported API: true
      Parameters:
      beforeCommit - True when called before transaction commit, and false when called after transaction commit.
      Throws:
      WTException
    • filterImpactedsForApply

      protected WTSet filterImpactedsForApply() throws WTException
      Filter out Impacted objects that should not have any impacts applied. The default implementation does no filtering. Extended delegates may override this method to filter out Impacted objects that should not be modified. For example, this method may be overridden to remove access controlled Impacted objects that are not modifiable. Extended delegates are not allowed to add additional Impacted objects to the set.

      Supported API: true
      Returns:
      Set of filtered Impacted objects.
      Throws:
      WTException
    • filterImpactingObjects

      protected void filterImpactingObjects(WTKeyedMap impactToIntentMap) throws WTException
      Filter out impacting object map entries that are not handled by a delegate implementation. The default implementation does no filtering. Extended delegates may override this method and filter out impacting object they cannot handle. This method is called early in the apply impacts process in order to reduce map size.

      Supported API: true
      Parameters:
      impactToIntentMap - Map of impacting objects to their ImpactIntentType values. Impacting objects may be the ImpactIntent object itself, or an object associated with it.
      Throws:
      WTException
    • filterImpactingObject

      protected boolean filterImpactingObject(Persistable persistable) throws WTException
      Given an impacting object, choose whether or not to filter it out of applyImpact processing before it occurs. Return true to filter out this impacted object from the list of impacted objects, otherwise return false. By default this just returns false and no objects will be filtered. Extending delegates can override this method to filter out impacted objects that may be invalid prior to applying the impact.

      Supported API: true
      Parameters:
      persistable - Impacting object to filter
      Returns:
      boolean true to filter the given object out
      Throws:
      WTException
    • getIntentApplyOrder

      protected List<ImpactIntentType> getIntentApplyOrder() throws WTException
      Get the order in which to apply the intents. The intents are applied in the ordered specified by the returned list. If the list does not contain a specific intent value then that intent will not be applied. Extended delegates may override this method and specify a different order.

      Default order:

      1. None
      2. Remove
      3. Replace
      4. Add
      5. Add or Replace Latest


      Supported API: true
      Returns:
      Ordered list of ImpactIntentType values.
      Throws:
      WTException
    • applyImpactIntent

      protected boolean applyImpactIntent(ImpactIntentType intent, Impacted impacted, WTSet impactObjs) throws WTException
      Apply the specified intent of the impacting objects on the impacted object. If an extended delegate does not support the specified intent then it should just return false.

      Supported API: true
      Parameters:
      intent - Impact intent to be applied (guaranteed non-null).
      impacted - Impacted object on which to apply the impact (guaranteed non-null).
      impactObjs - Set of impacting objects to be applied (guaranteed non-empty).
      Returns:
      True if one or more impacting objects was applied to the impacted object.
      Throws:
      WTException
    • invertImpactIntentMap

      protected final Map<ImpactIntentType,WTSet> invertImpactIntentMap(WTKeyedMap impactToIntentMap) throws WTException
      Invert an impact-intent map and assign default intents. The inversion process will also filter out map entries for intent values that will not be applied.

      Supported API: true
      Parameters:
      impactToIntentMap - Map of impact object to its ImpactIntentType value.
      Returns:
      Map of ImpactIntentType value to a set of impact objects for that intent. The impact object sets will have the same type of WTReference as the input map. Map is guaranteed non-null, but may be empty. It will only contain entries for intent values actually present in the input map and returned by getIntentApplyOrder().
      Throws:
      WTException
    • determineLaterRevisions

      protected WTSet determineLaterRevisions(WTValuedMap newToExistingRevisionMap) throws WTException
      Determine if an existing baseline member revision should be replaced with a new, later revision.

      Supported API: true
      Parameters:
      newToExistingRevisionMap - Map of new revision to existing member revision (will be inflated).
      Returns:
      Set of new revisions that are later than the existing baseline members.
      Throws:
      WTException
    • equivalentViews

      protected boolean equivalentViews(Object version1, Object version2) throws WTException
      Returns true if any of the following are true:
      1. Both versions implement ViewManageable and they have the same view.
      2. Both versions implement ViewManageable and both views are null..
      3. Neither version implements ViewManageable.
      Returns false if none of the above are true.

      Supported API: true
      Throws:
      WTException
    • compatibleOneOffs

      protected boolean compatibleOneOffs(Object version1, Object version2) throws WTException
      Returns true if any of the following are true:
      1. Both versions are one-off versions (i.e., implement OneOffVersioned and have a non-null one-off version identifier).
      2. Neither version is a one-off version.
      Returns false if none of the above are true.

      Supported API: true
      Throws:
      WTException