Package wt.change2.listeners
Class DefaultPendingChangeEventHandler
java.lang.Object
wt.services.ServiceEventListenerAdapter
wt.change2.listeners.ChangeStatusEventHandler
wt.change2.listeners.PendingChangeEventHandler
wt.change2.listeners.DefaultPendingChangeEventHandler
- All Implemented Interfaces:
KeyedEventListener
This default implementation for processing the events that can change the
pending status of changeable.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor
Supported API: trueDefaultPendingChangeEventHandler(String serviceId) Constructs event handler with specified service id. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendChangeNoticeCondition(QuerySpec querySpec, int changeIdx) Implementation of the appendChangeNoticeCondition method from PendingChangeEventHandler.protected voidappendChangeRequestCondition(QuerySpec querySpec, int changeIdx) Implementation of the appendChangeRequestCondition method from PendingChangeEventHandler.calculate(Collection<Long> changeables, ChangeItem changeItemToExclude) Calculates the value for the pending change indicator for a collection of changeables.Returns the query spec that would get the branch identifiers of changeables for which the hasPendingChange is set to false in the database.Returns the query spec that would get the branch identifiers of changeables for which the hasPendingChange attribute needs to be set in the database.getPendingStates(VersionableChangeItem changeItem) The pending change request and change notice states can be configured in wt.properties.protected QuerySpecgetQueryForPendingChangeOrder(Collection<Long> changeables, ChangeItem changeItemToExclude, String aliasForQuery) Deprecated.protected QuerySpecgetQueryForPendingChangeOrder(Collection<Long> changeables, WTCollection changeItemToExclude, String aliasForQuery, boolean notIncluded, boolean isLatestOnly) 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.voidhandleEvent_INSERT(WTCollection targets) HandleEvent method for the INSERT event for the default implementation.voidhandleEvent_NEW_VERSION(WTCollection targets) HandleEvent method for the NEW_VERSION event for the default implementation.voidhandleEvent_REASSIGN(WTCollection targets) HandleEvent method for the REASSIGN event for the default implementation.voidhandleEvent_REMOVE(WTCollection targets) HandleEvent method for the REMOVE event for the default implementation.voidhandleEvent_STATE_CHANGE(WTCollection targets) HandleEvent method for the STATE_CHANGE event for the default implementation.voidCalls the notify vetoable multi-object of the super class.Methods inherited from class wt.change2.listeners.PendingChangeEventHandler
getEventRegisterPropertyMethods inherited from class wt.change2.listeners.ChangeStatusEventHandler
appendByChangeables, appendByChangeItem, appendLatestChangeCondition, buildCompoundQuerySpec, buildCompoundQuerySpec2, buildJoinQuerySpec, getChangeableQueryClass, getChangeables, getChangeables, getGeneratedEventKeys, setChangeableQueryClass, updateChangeStatus, updateChangeStatus
-
Constructor Details
-
DefaultPendingChangeEventHandler
Default constructor
Supported API: true- Throws:
WTException
-
DefaultPendingChangeEventHandler
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:
calculatein classChangeStatusEventHandler- Parameters:
changeables- - the list containing object identifiers of changeables for which the calculation needs to be performedchangeItemToExclude- - 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.usegetQueryForPendingChangeOrder(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 performedchangeItemToExclude- - for which the calculation need to be performedaliasForQuery- - alias to be used for the query- Throws:
WTExceptionQueryExceptionWTPropertyVetoException
-
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 performedchangeItemToExclude- - for which the calculation need to be performedaliasForQuery- - alias to be used for the querynotIncluded- 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 propertywt.change2.pendingRequestStatesfromwt.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:
appendChangeRequestConditionin classPendingChangeEventHandler- Parameters:
querySpec- - query Spec to which the condition need to be appendedchangeIdx- - 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 propertywt.change2.pendingOrderStatesfor type Changeable2.HAS_PENDING_CHANGE fromwt.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:
appendChangeNoticeConditionin classPendingChangeEventHandler- Parameters:
querySpec- - query Spec to which the condition need to be appendedchangeIdx- - table index for the change item- Throws:
QueryException
-
getChangeablesToSetIndicator
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:
getChangeablesToSetIndicatorin classChangeStatusEventHandler- Returns:
- query spec
- Throws:
WTException- See Also:
-
getChangeablesToResetIndicator
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:
getChangeablesToResetIndicatorin classChangeStatusEventHandler- Returns:
- query spec
- Throws:
WTExceptionWTPropertyVetoException- 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:
WTExceptionWTPropertyVetoException
-
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:
WTExceptionWTPropertyVetoException
-
handleEvent_REASSIGN
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:
WTExceptionWTPropertyVetoException
-
handleEvent_INSERT
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:
WTExceptionWTPropertyVetoException
-
handleEvent_REMOVE
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:
WTExceptionWTPropertyVetoException
-
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:
notifyVetoableMultiObjectEventin interfaceKeyedEventListener- Overrides:
notifyVetoableMultiObjectEventin classChangeStatusEventHandler- Parameters:
event-- Throws:
WTException- thrown if any abnormal processing occurs.WTPropertyVetoException- thrown if any abnormal processing occurs.
-
getPendingStates
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:
getPendingStatesin classChangeStatusEventHandler- Returns:
- the pending change request or change order states.
-
getQueryForPendingChangeOrder(Collection, WTCollection, String, boolean, boolean)defaults to passing notIncluded and isLatestOnly as true.