Class DefaultPendingChangeEventHandler

All Implemented Interfaces:
KeyedEventListener

public class DefaultPendingChangeEventHandler extends PendingChangeEventHandler
This default implementation for processing the events that can change the pending status of changeable.
See Also:
  • Constructor Details

    • DefaultPendingChangeEventHandler

      public DefaultPendingChangeEventHandler() throws WTException
      Default constructor

      Supported API: true
      Throws:
      WTException
    • DefaultPendingChangeEventHandler

      public DefaultPendingChangeEventHandler(String serviceId) throws WTException
      Constructs event handler with specified service id.

      Supported API: true
      Parameters:
      serviceId -
      Throws:
      WTException
  • Method Details

    • calculate

      protected HashMap<Long,Boolean> calculate(Collection<Long> changeables, ChangeItem changeItemToExclude) throws WTException
      Calculates the value for the pending change indicator for a collection of changeables. The change item will be excluded in the calculation, if specified. For the pending change calculation, the predecessor version of the change item is excluded in the calculation on a revise of a change item event.

      Supported API: true
      Specified by:
      calculate in class ChangeStatusEventHandler
      Parameters:
      changeables - - the list containing object identifiers of changeables for which the calculation needs to be performed
      changeItemToExclude - - the change item that need to be exclude from the calculation
      Returns:
      map where the keys are the object identifiers and the value indicates if the change status is on or off
      Throws:
      WTException
    • getQueryForPendingChangeOrder

      protected QuerySpec getQueryForPendingChangeOrder(Collection<Long> changeables, ChangeItem changeItemToExclude, String aliasForQuery) throws WTException
      Deprecated.
      use getQueryForPendingChangeOrder(Collection, WTCollection, String, boolean, boolean) defaults to passing notIncluded and isLatestOnly as true.
      Returns the query spec that would append the conditions that make changeables associated to the change order pending in the default implementation.The query spec would not include the columns that need to retrieved from database. The columns of interest need to be added to the query spec, before being executed. The alias prefix would be specified if the query will be used as sub query.

      Supported API: true
      Parameters:
      changeables - - for which the calculation needs to be performed
      changeItemToExclude - - for which the calculation need to be performed
      aliasForQuery - - alias to be used for the query
      Throws:
      WTException
      QueryException
      WTPropertyVetoException
    • getQueryForPendingChangeOrder

      protected QuerySpec getQueryForPendingChangeOrder(Collection<Long> changeables, WTCollection changeItemToExclude, String aliasForQuery, boolean notIncluded, boolean isLatestOnly) throws WTException
      Returns the query spec that would append the conditions that make changeables associated to the change order pending in the default implementation.The query spec would not include the columns that need to retrieved from database. The columns of interest need to be added to the query spec, before being executed. The alias prefix would be specified if the query will be used as sub query.

      Supported API: true
      Parameters:
      changeables - - for which the calculation needs to be performed
      changeItemToExclude - - for which the calculation need to be performed
      aliasForQuery - - alias to be used for the query
      notIncluded - change items are not included in the query
      Throws:
      WTException
    • appendChangeRequestCondition

      protected void appendChangeRequestCondition(QuerySpec querySpec, int changeIdx) throws QueryException
      Implementation of the appendChangeRequestCondition method from PendingChangeEventHandler. By default, the change request is pending if the life cycle state matches a state defined in the property wt.change2.pendingRequestStates from wt.properties. The current implementation would append the following condition phrase to the specified query spec, where A0 is the changeIdx(the table index for the change Item):
       
       A0.statestate = 'IMPLEMENTATION
       
       


      Supported API: true
      Specified by:
      appendChangeRequestCondition in class PendingChangeEventHandler
      Parameters:
      querySpec - - query Spec to which the condition need to be appended
      changeIdx - - table index for the change item
      Throws:
      QueryException
    • appendChangeNoticeCondition

      protected void appendChangeNoticeCondition(QuerySpec querySpec, int changeIdx) throws QueryException
      Implementation of the appendChangeNoticeCondition method from PendingChangeEventHandler. By default, the change notice is pending if the life cycle state matches a state defined in the property wt.change2.pendingOrderStates for type Changeable2.HAS_PENDING_CHANGE from wt.properties. The current implementation would append the following condition phrase to the specified query spec, where A0 is the changeIdx(the table index for the change Item):
       
       A0.statestate = 'IMPLEMENTATION
       


      Supported API: true
      Specified by:
      appendChangeNoticeCondition in class PendingChangeEventHandler
      Parameters:
      querySpec - - query Spec to which the condition need to be appended
      changeIdx - - table index for the change item
      Throws:
      QueryException
    • getChangeablesToSetIndicator

      public StatementSpec getChangeablesToSetIndicator() throws WTException
      Returns the query spec that would get the branch identifiers of changeables for which the hasPendingChange attribute needs to be set in the database. It is the implementation of the getChangeablesToSetIndicator method from ChangeStatusEventHandler. Only sets the Changeable2.HAS_PENDING_CHANGE attributes.

      Supported API: true
      Specified by:
      getChangeablesToSetIndicator in class ChangeStatusEventHandler
      Returns:
      query spec
      Throws:
      WTException
      See Also:
    • getChangeablesToResetIndicator

      public QuerySpec getChangeablesToResetIndicator() throws WTException, WTPropertyVetoException
      Returns the query spec that would get the branch identifiers of changeables for which the hasPendingChange is set to false in the database. It is the implementation of the getChangeablesToSetIndicator method from ChangeStatusEventHandler. Only resets the Changeable2.HAS_PENDING_CHANGE attributes.

      Supported API: true
      Specified by:
      getChangeablesToResetIndicator in class ChangeStatusEventHandler
      Returns:
      query spec
      Throws:
      WTException
      WTPropertyVetoException
      See Also:
    • handleEvent_NEW_VERSION

      public void handleEvent_NEW_VERSION(WTCollection targets) throws WTException, WTPropertyVetoException
      HandleEvent method for the NEW_VERSION event for the default implementation.

      On a Revise event of a change object, if the change object of the latest revision is in a non-pending state, and the predecessor version is in a pending state, we would recalculate to determine if the changeables are pending by the any other changes and update the flag accordingly.

      On a revise of a changeable, the pending change is reset

      Supported API: true
      Parameters:
      targets -
      Throws:
      WTException
      WTPropertyVetoException
    • handleEvent_STATE_CHANGE

      public void handleEvent_STATE_CHANGE(WTCollection targets) throws WTException, WTPropertyVetoException
      HandleEvent method for the STATE_CHANGE event for the default implementation.

      On a state Change event, where the change item moves from non pending to pending, if the changeables as affected data do not have pending change due to other changes, it will set Pending Change flag to true.

      When the change moves to non-pending state the affected data is calculated to determine if the changeable is pending in any other changes.

      Supported API: true
      Parameters:
      targets -
      Throws:
      WTException
      WTPropertyVetoException
    • handleEvent_REASSIGN

      public void handleEvent_REASSIGN(WTCollection targets) throws WTException, WTPropertyVetoException
      HandleEvent method for the REASSIGN event for the default implementation.

      On a Reassign of the life cycle event which in turn could set the state of the target object, the pending change needs to be reflected appropriatly.

      If the change item is set to a pending state and the changeables as affected data do not have pending change due to other changes, it will set Pending Change flag to true.

      If the change is set to non-pending state the changeables as affected data is calculated to determine if the changeable is pending in any other changes.

      Supported API: true
      Parameters:
      targets -
      Throws:
      WTException
      WTPropertyVetoException
    • handleEvent_INSERT

      public void handleEvent_INSERT(WTCollection targets) throws WTException, WTPropertyVetoException
      HandleEvent method for the INSERT event for the default implementation.

      On an insert of an affected data link, if the changeable does not have a pending change by other changes, it will set pending change flag to true.
      Supported API: true
      Parameters:
      targets -
      Throws:
      WTException
      WTPropertyVetoException
    • handleEvent_REMOVE

      public void handleEvent_REMOVE(WTCollection targets) throws WTException, WTPropertyVetoException
      HandleEvent method for the REMOVE event for the default implementation.

      On a Remove of affected data links, the changeables are recalculated to determine if it is pending in other changes and update the flag accordingly.

      On the removal of latest revision of a change item, the pending change flag would be calculated based on the life cycle state of the predecessor version of change item.

      Supported API: true
      Parameters:
      targets -
      Throws:
      WTException
      WTPropertyVetoException
    • notifyVetoableMultiObjectEvent

      public void notifyVetoableMultiObjectEvent(Object event) throws WTException, WTPropertyVetoException
      Calls the notify vetoable multi-object of the super class. If this class is extended for customization make sure that this method is overridden as shown -
       
       @Override
       public void notifyVetoableMultiObjectEvent(Object event) throws Exception {
           super.notifyVetoableMultiObjectEvent(event);
       }
       
       


      Supported API: true
      Specified by:
      notifyVetoableMultiObjectEvent in interface KeyedEventListener
      Overrides:
      notifyVetoableMultiObjectEvent in class ChangeStatusEventHandler
      Parameters:
      event -
      Throws:
      WTException - thrown if any abnormal processing occurs.
      WTPropertyVetoException - thrown if any abnormal processing occurs.
    • getPendingStates

      public List<String> getPendingStates(VersionableChangeItem changeItem)
      The pending change request and change notice states can be configured in wt.properties. To configure change request pending states update the "wt.change2.pendingRequestStates" property. To configure change notice pending states update the "wt.change2.pendingOrderStates" property.

      Supported API: true
      Overrides:
      getPendingStates in class ChangeStatusEventHandler
      Returns:
      the pending change request or change order states.