org.sandev.TaskHeap.UpdateManager
Class UpdateManagerNode

java.lang.Object
  extended by org.sandev.TaskHeap.UpdateManager.UpdateManagerNodeDecl
      extended by org.sandev.TaskHeap.UpdateManager.UpdateManagerNodeBase
          extended by org.sandev.TaskHeap.UpdateManager.UpdateManagerNode
All Implemented Interfaces:
org.sandev.basics.nodecommon.Controllable, org.sandev.basics.nodecommon.Loggable, org.sandev.basics.nodecommon.Messageable, org.sandev.basics.util.AuthUserLookup, org.sandev.basics.util.IDLookup

public class UpdateManagerNode
extends UpdateManagerNodeBase
implements org.sandev.basics.util.IDLookup, org.sandev.basics.util.AuthUserLookup

Implementation of UpdateManagerNode.


Field Summary
protected  long startupTime
          The timestamp when this node started.
 
Fields inherited from class org.sandev.TaskHeap.UpdateManager.UpdateManagerNodeBase
ctrlwrappers, helperNodes, incomingSyncAggregateUpdate, incomingSyncStatsQuery, LOGDEBUG, LOGERROR, LOGFATAL, logger, LOGINFO, logLevel, LOGLEVEL_DEBUG, LOGLEVEL_ERROR, LOGLEVEL_FATAL, LOGLEVEL_INFO, LOGLEVEL_WARN, LOGWARN, messager, nodeInstance, outgoingAsyncStats, outgoingSyncAccountQuery, outgoingSyncAggregateUpdate, outgoingSyncCacheActionRegistration, outgoingSyncExternalPlanQuery, outgoingSyncHeapAttributesQuery, outgoingSyncPlanQuery, outgoingSyncSystemStatusQuery, outgoingSyncTaskQuery, outgoingSyncTaskTypeQuery, parent, sandNodeErrorMessage, sandNodeState, SANDNODESTATE_FAILED, SANDNODESTATE_FAILING, SANDNODESTATE_RESUMING, SANDNODESTATE_RUNNING, SANDNODESTATE_STARTING, SANDNODESTATE_STOPPED, SANDNODESTATE_STOPPING, SANDNODESTATE_SUSPENDED, SANDNODESTATE_SUSPENDING, SANDNODESTATE_UNDEFINED, sandRoot, userLookup
 
Fields inherited from class org.sandev.TaskHeap.UpdateManager.UpdateManagerNodeDecl
peerAuthUserLookupNode
 
Fields inherited from interface org.sandev.basics.nodecommon.Controllable
OPERATION_FAIL, OPERATION_RESUME, OPERATION_SHUTDOWN, OPERATION_STARTUP, OPERATION_STR_FAIL, OPERATION_STR_RESUME, OPERATION_STR_SHUTDOWN, OPERATION_STR_STARTUP, OPERATION_STR_SUSPEND, OPERATION_STR_UNDEFINED, OPERATION_STRINGS, OPERATION_SUSPEND, OPERATION_UNDEFINED, SHUTDOWN_ERROR_RESTART_GLOBAL, SHUTDOWN_ERROR_RESTART_LOCAL, SHUTDOWN_ERROR_TERMINATE, SHUTDOWN_NORMAL, STATE_FAILED, STATE_FAILING, STATE_RESUMING, STATE_RUNNING, STATE_STARTING, STATE_STOPPED, STATE_STOPPING, STATE_STR_FAILED, STATE_STR_FAILING, STATE_STR_RESUMING, STATE_STR_RUNNING, STATE_STR_STARTING, STATE_STR_STOPPED, STATE_STR_STOPPING, STATE_STR_SUSPENDED, STATE_STR_SUSPENDING, STATE_STR_UNDEFINED, STATE_STRINGS, STATE_SUSPENDED, STATE_SUSPENDING, STATE_UNDEFINED
 
Constructor Summary
UpdateManagerNode()
           
 
Method Summary
protected  void addImpliedHeapAssociationUpdates(org.sandev.basics.structs.SandUpdateMessage sum, org.sandev.basics.sandmessages.AggregateUpdate au, org.sandev.basics.util.AuthUser authUser, java.util.ArrayList al)
          Add any HeapAssociation updates needed for the given update.
protected  void addImpliedPlanComponentUpdates(org.sandev.basics.structs.SandUpdateMessage sum, org.sandev.basics.structs.SandUpdateMessage[] updates, org.sandev.basics.util.AuthUser authUser, java.util.ArrayList al)
          Add any additional updates necessary to track the given plan component update.
protected  org.sandev.basics.sandmessages.AggregateUpdate addImpliedUpdates(org.sandev.basics.sandmessages.AggregateUpdate au)
          Add any additional updates that are implied by the given updates to the given AggregateUpdate message.
protected  void addInitialHeapPlans(HeapAttributes heap, org.sandev.basics.util.AuthUser authUser, org.sandev.basics.sandmessages.AggregateUpdate au, java.util.ArrayList al)
          Add the initial top level plans for the given heap.
 org.sandev.basics.sandmessages.AggregateUpdate callAggregateUpdate(org.sandev.basics.sandmessages.AggregateUpdate au)
          Override any synchronous outbound AggregateUpdate call to update our cached information along the way.
protected  void confirmChildReferences(PlanUpdate pu, java.util.ArrayList al, org.sandev.basics.sandmessages.AggregateUpdate au)
          Make sure that any referenced instances have this Plan as the parent, and make sure no previously referenced instances still reference this Plan.
protected static org.sandev.basics.structs.SandPersistMessage findFromUpdates(long id, java.util.ArrayList al)
          If there is an existing update in the list for the given ID, then return that instance.
protected  org.sandev.basics.structs.SandUpdateMessage findUpdate(long id, org.sandev.basics.structs.SandUpdateMessage[] updates, java.util.ArrayList al)
          Look for an existing update of the specified instance and return the latest, or null if not found.
protected  boolean fixReference(Plan plan, long childID, boolean hasChild)
          Given a plan that either hasChild or not, add the reference or remove it as needed.
protected  Account getAccountForUsername(java.lang.String username)
          Given a username, return the associated Account or null if not found.
 java.lang.String getDeploymentPrefix()
          Return the prefix for this deployment.
 org.sandev.basics.structs.SandPersistMessage getInstance(java.lang.String classname, long id, org.sandev.basics.util.AuthUser user)
          Lookup the specified class instance.
protected  long getParentForInstance(org.sandev.basics.structs.SandInstanceMessage sim)
          Return the parent uniqueID for the PlanComponent derived instance, or zero if there is no parent reference.
protected  long getParentForUpdate(org.sandev.basics.structs.SandUpdateMessage sum)
          Return the parent uniqueID for the PlanComponent derived update, or zero if there is no parent reference.
 org.sandev.basics.util.AuthUser getUserForID(long id)
          Convenience passthrough call to our configured AuthUserLookup.
 org.sandev.basics.util.AuthUser getUserFromLogin(java.lang.String username, java.lang.String password)
          Convenience passthrough call to our configured AuthUserLookup.
protected  org.sandev.basics.sandmessages.AggregateUpdate heapUpdate(org.sandev.basics.sandmessages.AggregateUpdate au)
          Handle the specified updates to the overall TaskHeap.
protected  boolean isRecalcExempt(org.sandev.basics.structs.SandUpdateMessage sum)
          Return true if this update is exempt from recalc processing, false otherwise.
protected  boolean isTopLevelPlan(org.sandev.basics.structs.SandPersistMessage spm)
          Return true if the given SandPersistMessage is one of the top level plans, false otherwise.
protected  java.lang.String linkref(org.sandev.basics.structs.SandPersistMessage spm)
          Given a persistent message, return a link to it on the main screen.
protected  org.sandev.basics.sandmessages.AggregateUpdate onReceive(org.sandev.basics.sandmessages.AggregateUpdate msg)
          Process the updates, including any bookkeeping for updates to Plans or Tasks.
protected  org.sandev.basics.sandmessages.Stats onReceive(org.sandev.basics.sandmessages.StatsQuery msg)
          Return our current stats
protected  void onStartup()
          Init our stats.
protected  void recalcParents(long parentID, long userID, java.util.ArrayList al)
          Recalc the specified Plan, and any containing Plans recursively upward, appending the resulting updates to the specified list.
protected  void recalcPlan(Plan plan, long userID, java.util.ArrayList al)
          Recalc the given plan.
protected  org.sandev.basics.structs.SandUpdateMessage[] removeDuplicateRecalcs(org.sandev.basics.structs.SandUpdateMessage[] sums)
          We only want one PlanUpdate added per action.
protected  void removeReferenceToChild(org.sandev.basics.structs.SandInstanceMessage child, org.sandev.basics.util.AuthUser user, java.util.ArrayList al)
          Given some form of PlanComponent derived update message, append an update as necessary to remove it from its parent.
protected  boolean timeEstimateChanged(org.sandev.basics.structs.SandUpdateMessage sum)
          Return true if the timeEstimate for the given update has changed.
protected  void updateParentRef(long childID, long parentID, long userID, java.util.ArrayList al)
          Given a child, append an update to change its parent reference.
protected  void verifyAccount(AccountUpdate update, org.sandev.basics.sandmessages.ErrorInfoCollection eic)
          Verify that this Account is ok to go.
protected  void verifyHeapAttributes(HeapAttributesUpdate hau, org.sandev.basics.sandmessages.ErrorInfoCollection eic)
          Verify that this HeapAttributesUpdate is ok to go.
protected  void verifyNoPlanOrphans(org.sandev.basics.structs.SandUpdateMessage sum)
          Throw if this is a plan with children that would be orphaned should the plan be deleted.
protected  void verifyNotRelativeDateBase(org.sandev.basics.structs.SandUpdateMessage sum)
          Throw if the given PlanComponentInterface is referenced by another to compute its due date.
protected  void verifyParentRef(long childID, long parentID, long userID, java.util.ArrayList al, org.sandev.basics.sandmessages.AggregateUpdate au)
          Given a child make sure there is an update pending that sets its parent reference appropriately.
protected  void verifyPCIUpdate(org.sandev.basics.structs.SandUpdateMessage sum, org.sandev.basics.sandmessages.ErrorInfoCollection eic, org.sandev.basics.sandmessages.AggregateUpdate msg)
          Verify that the given update of a PlanComponentInterface is ok.
protected  void verifyReferenceToChild(long parentID, long childID, boolean hasChild, org.sandev.basics.structs.SandUpdateMessage[] updates, org.sandev.basics.util.AuthUser user, java.util.ArrayList al)
          Verify that there is a PlanUpdate for the given parent that either adds the child reference, or removes it, based on whether it now hasChild or not.
protected  void verifyTaskPhaseValid(Task task, org.sandev.basics.util.AuthUser user)
          Verify that the TaskPhase associated with the given Task is valid according to its TaskType.
protected  void verifyUpdate(org.sandev.basics.structs.SandUpdateMessage sum, org.sandev.basics.sandmessages.AggregateUpdate msg)
          Check that the given update is ok.
 
Methods inherited from class org.sandev.TaskHeap.UpdateManager.UpdateManagerNodeBase
addWrapper, cacheCriticalUpdates, cacheTrack, callAccountQuery, callCacheActionRegistration, callExternalPlanQuery, callHeapAttributesQuery, callPlanQuery, callQuery, callSystemStatusQuery, callTaskQuery, callTaskTypeQuery, copyAndFilterInstance, deliver, fieldHasFlag, getAuthFilter, getDataImportExport, getHelperNodes, getIDCache, getIncomingSyncAggregateUpdate, getIncomingSyncAggregateUpdateDefaultValue, getIncomingSyncAggregateUpdateFieldPrintValue, getIncomingSyncAggregateUpdateFlag, getIncomingSyncAggregateUpdateInvalidValue, getIncomingSyncAggregateUpdateMetatype, getIncomingSyncAggregateUpdatePrintValue, getIncomingSyncAggregateUpdateRange, getIncomingSyncAggregateUpdateValidityCheck, getIncomingSyncStatsQuery, getIncomingSyncStatsQueryDefaultValue, getIncomingSyncStatsQueryFieldPrintValue, getIncomingSyncStatsQueryFlag, getIncomingSyncStatsQueryInvalidValue, getIncomingSyncStatsQueryMetatype, getIncomingSyncStatsQueryPrintValue, getIncomingSyncStatsQueryRange, getIncomingSyncStatsQueryValidityCheck, getLogger, getLoggerDefaultValue, getLoggerFieldPrintValue, getLoggerFlag, getLoggerInvalidValue, getLoggerMetatype, getLoggerPrintValue, getLoggerRange, getLoggerValidityCheck, getLogLevel, getLogLevelActualVals, getLogLevelDefaultValue, getLogLevelEnumSummary, getLogLevelFieldPrintValue, getLogLevelFlag, getLogLevelInvalidValue, getLogLevelKeyVals, getLogLevelMetatype, getLogLevelPrintVals, getLogLevelPrintValue, getLogLevelRange, getLogLevelValidityCheck, getMessager, getMessagerDefaultValue, getMessagerFieldPrintValue, getMessagerFlag, getMessagerInvalidValue, getMessagerMetatype, getMessagerPrintValue, getMessagerRange, getMessagerValidityCheck, getNodeInstance, getNodeInstanceDefaultValue, getNodeInstanceFieldPrintValue, getNodeInstanceFlag, getNodeInstanceInvalidValue, getNodeInstanceMetatype, getNodeInstanceName, getNodeInstancePrintValue, getNodeInstanceRange, getNodeInstanceValidityCheck, getOutgoingAsyncStats, getOutgoingAsyncStatsDefaultValue, getOutgoingAsyncStatsFieldPrintValue, getOutgoingAsyncStatsFlag, getOutgoingAsyncStatsInvalidValue, getOutgoingAsyncStatsMetatype, getOutgoingAsyncStatsPrintValue, getOutgoingAsyncStatsRange, getOutgoingAsyncStatsValidityCheck, getOutgoingSyncAccountQuery, getOutgoingSyncAccountQueryDefaultValue, getOutgoingSyncAccountQueryFieldPrintValue, getOutgoingSyncAccountQueryFlag, getOutgoingSyncAccountQueryInvalidValue, getOutgoingSyncAccountQueryMetatype, getOutgoingSyncAccountQueryPrintValue, getOutgoingSyncAccountQueryRange, getOutgoingSyncAccountQueryValidityCheck, getOutgoingSyncAggregateUpdate, getOutgoingSyncAggregateUpdateDefaultValue, getOutgoingSyncAggregateUpdateFieldPrintValue, getOutgoingSyncAggregateUpdateFlag, getOutgoingSyncAggregateUpdateInvalidValue, getOutgoingSyncAggregateUpdateMetatype, getOutgoingSyncAggregateUpdatePrintValue, getOutgoingSyncAggregateUpdateRange, getOutgoingSyncAggregateUpdateValidityCheck, getOutgoingSyncCacheActionRegistration, getOutgoingSyncCacheActionRegistrationDefaultValue, getOutgoingSyncCacheActionRegistrationFieldPrintValue, getOutgoingSyncCacheActionRegistrationFlag, getOutgoingSyncCacheActionRegistrationInvalidValue, getOutgoingSyncCacheActionRegistrationMetatype, getOutgoingSyncCacheActionRegistrationPrintValue, getOutgoingSyncCacheActionRegistrationRange, getOutgoingSyncCacheActionRegistrationValidityCheck, getOutgoingSyncExternalPlanQuery, getOutgoingSyncExternalPlanQueryDefaultValue, getOutgoingSyncExternalPlanQueryFieldPrintValue, getOutgoingSyncExternalPlanQueryFlag, getOutgoingSyncExternalPlanQueryInvalidValue, getOutgoingSyncExternalPlanQueryMetatype, getOutgoingSyncExternalPlanQueryPrintValue, getOutgoingSyncExternalPlanQueryRange, getOutgoingSyncExternalPlanQueryValidityCheck, getOutgoingSyncHeapAttributesQuery, getOutgoingSyncHeapAttributesQueryDefaultValue, getOutgoingSyncHeapAttributesQueryFieldPrintValue, getOutgoingSyncHeapAttributesQueryFlag, getOutgoingSyncHeapAttributesQueryInvalidValue, getOutgoingSyncHeapAttributesQueryMetatype, getOutgoingSyncHeapAttributesQueryPrintValue, getOutgoingSyncHeapAttributesQueryRange, getOutgoingSyncHeapAttributesQueryValidityCheck, getOutgoingSyncPlanQuery, getOutgoingSyncPlanQueryDefaultValue, getOutgoingSyncPlanQueryFieldPrintValue, getOutgoingSyncPlanQueryFlag, getOutgoingSyncPlanQueryInvalidValue, getOutgoingSyncPlanQueryMetatype, getOutgoingSyncPlanQueryPrintValue, getOutgoingSyncPlanQueryRange, getOutgoingSyncPlanQueryValidityCheck, getOutgoingSyncSystemStatusQuery, getOutgoingSyncSystemStatusQueryDefaultValue, getOutgoingSyncSystemStatusQueryFieldPrintValue, getOutgoingSyncSystemStatusQueryFlag, getOutgoingSyncSystemStatusQueryInvalidValue, getOutgoingSyncSystemStatusQueryMetatype, getOutgoingSyncSystemStatusQueryPrintValue, getOutgoingSyncSystemStatusQueryRange, getOutgoingSyncSystemStatusQueryValidityCheck, getOutgoingSyncTaskQuery, getOutgoingSyncTaskQueryDefaultValue, getOutgoingSyncTaskQueryFieldPrintValue, getOutgoingSyncTaskQueryFlag, getOutgoingSyncTaskQueryInvalidValue, getOutgoingSyncTaskQueryMetatype, getOutgoingSyncTaskQueryPrintValue, getOutgoingSyncTaskQueryRange, getOutgoingSyncTaskQueryValidityCheck, getOutgoingSyncTaskTypeQuery, getOutgoingSyncTaskTypeQueryDefaultValue, getOutgoingSyncTaskTypeQueryFieldPrintValue, getOutgoingSyncTaskTypeQueryFlag, getOutgoingSyncTaskTypeQueryInvalidValue, getOutgoingSyncTaskTypeQueryMetatype, getOutgoingSyncTaskTypeQueryPrintValue, getOutgoingSyncTaskTypeQueryRange, getOutgoingSyncTaskTypeQueryValidityCheck, getParent, getPeerAuthUserLookupNode, getPeerAuthUserLookupNodeDefaultValue, getPeerAuthUserLookupNodeFieldPrintValue, getPeerAuthUserLookupNodeFlag, getPeerAuthUserLookupNodeInvalidValue, getPeerAuthUserLookupNodeLengthMax, getPeerAuthUserLookupNodeLengthNorm, getPeerAuthUserLookupNodeMetatype, getPeerAuthUserLookupNodePrintValue, getPeerAuthUserLookupNodeRange, getPeerAuthUserLookupNodeValidityCheck, getSandNodeErrorMessage, getSandNodeErrorMessageDefaultValue, getSandNodeErrorMessageFieldPrintValue, getSandNodeErrorMessageFlag, getSandNodeErrorMessageInvalidValue, getSandNodeErrorMessageLengthMax, getSandNodeErrorMessageLengthNorm, getSandNodeErrorMessageMetatype, getSandNodeErrorMessagePrintValue, getSandNodeErrorMessageRange, getSandNodeErrorMessageValidityCheck, getSandNodeState, getSandNodeStateActualVals, getSandNodeStateDefaultValue, getSandNodeStateEnumSummary, getSandNodeStateFieldPrintValue, getSandNodeStateFlag, getSandNodeStateInvalidValue, getSandNodeStateKeyVals, getSandNodeStateMetatype, getSandNodeStatePrintVals, getSandNodeStatePrintValue, getSandNodeStateRange, getSandNodeStateValidityCheck, getSandRoot, getServername, getUserLookup, hasFullAccess, init, instanceCacheFault, isCachedClass, isImmediatelyCached, log, log, logLevelActual2Print, logLevelLabelToValue, logLevelLabelToValueStatic, logLevelPrint2Actual, logLevelPrint2Key, logLevelValueToLabel, logLevelValueToLabelStatic, notifyStateChange, onFailure, onRestart, onResume, onShutdown, onSuspend, processMessage, readConfigParamsFromNodeInstance, receive, receive, receive, restart, resume, sandNodeStateActual2Print, sandNodeStateLabelToValue, sandNodeStateLabelToValueStatic, sandNodeStatePrint2Actual, sandNodeStatePrint2Key, sandNodeStateValueToLabel, sandNodeStateValueToLabelStatic, send, setHelperNodes, setIncomingSyncAggregateUpdate, setIncomingSyncAggregateUpdate, setIncomingSyncStatsQuery, setIncomingSyncStatsQuery, setLogger, setLogger, setLogLevel, setMessager, setMessager, setNodeInstance, setNodeInstance, setOutgoingAsyncStats, setOutgoingAsyncStats, setOutgoingSyncAccountQuery, setOutgoingSyncAccountQuery, setOutgoingSyncAggregateUpdate, setOutgoingSyncAggregateUpdate, setOutgoingSyncCacheActionRegistration, setOutgoingSyncCacheActionRegistration, setOutgoingSyncExternalPlanQuery, setOutgoingSyncExternalPlanQuery, setOutgoingSyncHeapAttributesQuery, setOutgoingSyncHeapAttributesQuery, setOutgoingSyncPlanQuery, setOutgoingSyncPlanQuery, setOutgoingSyncSystemStatusQuery, setOutgoingSyncSystemStatusQuery, setOutgoingSyncTaskQuery, setOutgoingSyncTaskQuery, setOutgoingSyncTaskTypeQuery, setOutgoingSyncTaskTypeQuery, setParent, setPeerAuthUserLookupNode, setPeerAuthUserLookupNode, setSandNodeErrorMessage, setSandNodeErrorMessage, setSandNodeState, setSandRoot, setupSecureReceive, setupSubscriptions, setUserLookup, shutdown, startup, suspend, systemwideShutdown, validTransition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

startupTime

protected long startupTime
The timestamp when this node started.

Constructor Detail

UpdateManagerNode

public UpdateManagerNode()
Method Detail

getUserForID

public org.sandev.basics.util.AuthUser getUserForID(long id)
                                             throws org.sandev.basics.structs.SandException
Convenience passthrough call to our configured AuthUserLookup.

Specified by:
getUserForID in interface org.sandev.basics.util.AuthUserLookup
Overrides:
getUserForID in class UpdateManagerNodeBase
Throws:
org.sandev.basics.structs.SandException

getUserFromLogin

public org.sandev.basics.util.AuthUser getUserFromLogin(java.lang.String username,
                                                        java.lang.String password)
                                                 throws org.sandev.basics.structs.SandException
Convenience passthrough call to our configured AuthUserLookup. Defined for AuthUserLookup interface signature completion.

Specified by:
getUserFromLogin in interface org.sandev.basics.util.AuthUserLookup
Overrides:
getUserFromLogin in class UpdateManagerNodeBase
Throws:
org.sandev.basics.structs.SandException

getInstance

public org.sandev.basics.structs.SandPersistMessage getInstance(java.lang.String classname,
                                                                long id,
                                                                org.sandev.basics.util.AuthUser user)
                                                         throws org.sandev.basics.structs.SandException
Lookup the specified class instance. Overrides the base implementation to handle looking up PlanComponents as specific class instances.

Specified by:
getInstance in interface org.sandev.basics.util.IDLookup
Overrides:
getInstance in class UpdateManagerNodeBase
Throws:
org.sandev.basics.structs.SandException

onStartup

protected void onStartup()
                  throws org.sandev.basics.structs.SandException
Init our stats.

Overrides:
onStartup in class UpdateManagerNodeBase
Throws:
org.sandev.basics.structs.SandException

onReceive

protected org.sandev.basics.sandmessages.Stats onReceive(org.sandev.basics.sandmessages.StatsQuery msg)
                                                  throws org.sandev.basics.structs.SandException
Return our current stats

Overrides:
onReceive in class UpdateManagerNodeBase
Throws:
org.sandev.basics.structs.SandException

onReceive

protected org.sandev.basics.sandmessages.AggregateUpdate onReceive(org.sandev.basics.sandmessages.AggregateUpdate msg)
                                                            throws org.sandev.basics.structs.SandException
Process the updates, including any bookkeeping for updates to Plans or Tasks. This method walks the updates, inserting additional updates as necessary.

Overrides:
onReceive in class UpdateManagerNodeBase
Throws:
org.sandev.basics.structs.SandException

callAggregateUpdate

public org.sandev.basics.sandmessages.AggregateUpdate callAggregateUpdate(org.sandev.basics.sandmessages.AggregateUpdate au)
                                                                   throws org.sandev.basics.structs.SandException
Override any synchronous outbound AggregateUpdate call to update our cached information along the way.

Overrides:
callAggregateUpdate in class UpdateManagerNodeBase
Throws:
org.sandev.basics.structs.SandException

verifyUpdate

protected void verifyUpdate(org.sandev.basics.structs.SandUpdateMessage sum,
                            org.sandev.basics.sandmessages.AggregateUpdate msg)
                     throws org.sandev.basics.structs.SandException
Check that the given update is ok. If something is invalid, then throw. All components being added must have a parent specified. The initial top level plans for each heap have no parent, but they are created via direct data import which doesn't go through here.

Throws:
org.sandev.basics.structs.SandException

verifyAccount

protected void verifyAccount(AccountUpdate update,
                             org.sandev.basics.sandmessages.ErrorInfoCollection eic)
                      throws org.sandev.basics.structs.SandException
Verify that this Account is ok to go. Complain if not.

Throws:
org.sandev.basics.structs.SandException

getAccountForUsername

protected Account getAccountForUsername(java.lang.String username)
                                 throws org.sandev.basics.structs.SandException
Given a username, return the associated Account or null if not found. The username is specified as unique, but we can't rely on a user friendly message coming back from the Persister if this constraint is violated. This supports checking up front.

Throws:
org.sandev.basics.structs.SandException

verifyHeapAttributes

protected void verifyHeapAttributes(HeapAttributesUpdate hau,
                                    org.sandev.basics.sandmessages.ErrorInfoCollection eic)
                             throws org.sandev.basics.structs.SandException
Verify that this HeapAttributesUpdate is ok to go. Complain if not.

Throws:
org.sandev.basics.structs.SandException

verifyPCIUpdate

protected void verifyPCIUpdate(org.sandev.basics.structs.SandUpdateMessage sum,
                               org.sandev.basics.sandmessages.ErrorInfoCollection eic,
                               org.sandev.basics.sandmessages.AggregateUpdate msg)
                        throws org.sandev.basics.structs.SandException
Verify that the given update of a PlanComponentInterface is ok.

Throws:
org.sandev.basics.structs.SandException

isTopLevelPlan

protected boolean isTopLevelPlan(org.sandev.basics.structs.SandPersistMessage spm)
Return true if the given SandPersistMessage is one of the top level plans, false otherwise.


addImpliedUpdates

protected org.sandev.basics.sandmessages.AggregateUpdate addImpliedUpdates(org.sandev.basics.sandmessages.AggregateUpdate au)
                                                                    throws org.sandev.basics.structs.SandException
Add any additional updates that are implied by the given updates to the given AggregateUpdate message. Return the given AggregateUpdate with the additions (if any).

Throws:
org.sandev.basics.structs.SandException

addImpliedHeapAssociationUpdates

protected void addImpliedHeapAssociationUpdates(org.sandev.basics.structs.SandUpdateMessage sum,
                                                org.sandev.basics.sandmessages.AggregateUpdate au,
                                                org.sandev.basics.util.AuthUser authUser,
                                                java.util.ArrayList al)
                                         throws org.sandev.basics.structs.SandException
Add any HeapAssociation updates needed for the given update.

Throws:
org.sandev.basics.structs.SandException

addInitialHeapPlans

protected void addInitialHeapPlans(HeapAttributes heap,
                                   org.sandev.basics.util.AuthUser authUser,
                                   org.sandev.basics.sandmessages.AggregateUpdate au,
                                   java.util.ArrayList al)
                            throws org.sandev.basics.structs.SandException
Add the initial top level plans for the given heap.

Throws:
org.sandev.basics.structs.SandException

addImpliedPlanComponentUpdates

protected void addImpliedPlanComponentUpdates(org.sandev.basics.structs.SandUpdateMessage sum,
                                              org.sandev.basics.structs.SandUpdateMessage[] updates,
                                              org.sandev.basics.util.AuthUser authUser,
                                              java.util.ArrayList al)
                                       throws org.sandev.basics.structs.SandException
Add any additional updates necessary to track the given plan component update.

Throws:
org.sandev.basics.structs.SandException

verifyReferenceToChild

protected void verifyReferenceToChild(long parentID,
                                      long childID,
                                      boolean hasChild,
                                      org.sandev.basics.structs.SandUpdateMessage[] updates,
                                      org.sandev.basics.util.AuthUser user,
                                      java.util.ArrayList al)
                               throws org.sandev.basics.structs.SandException
Verify that there is a PlanUpdate for the given parent that either adds the child reference, or removes it, based on whether it now hasChild or not.

Throws:
org.sandev.basics.structs.SandException

findUpdate

protected org.sandev.basics.structs.SandUpdateMessage findUpdate(long id,
                                                                 org.sandev.basics.structs.SandUpdateMessage[] updates,
                                                                 java.util.ArrayList al)
Look for an existing update of the specified instance and return the latest, or null if not found. Searches the updates first, then the ArrayList, returning the last matching SandUpdateMessage found.


fixReference

protected boolean fixReference(Plan plan,
                               long childID,
                               boolean hasChild)
Given a plan that either hasChild or not, add the reference or remove it as needed. Returns true if modified, false otherwise.


verifyNoPlanOrphans

protected void verifyNoPlanOrphans(org.sandev.basics.structs.SandUpdateMessage sum)
                            throws org.sandev.basics.structs.SandException
Throw if this is a plan with children that would be orphaned should the plan be deleted.

Throws:
org.sandev.basics.structs.SandException

verifyNotRelativeDateBase

protected void verifyNotRelativeDateBase(org.sandev.basics.structs.SandUpdateMessage sum)
                                  throws org.sandev.basics.structs.SandException
Throw if the given PlanComponentInterface is referenced by another to compute its due date. The user will need to change the referencing PCI before deleting this one. Dangling references are not easy to track down and manage otherwise.

We check this using separate Plan and Task queries so the message actually contains the correct type of PlanComponent.

Throws:
org.sandev.basics.structs.SandException

linkref

protected java.lang.String linkref(org.sandev.basics.structs.SandPersistMessage spm)
Given a persistent message, return a link to it on the main screen. If this gets useful elsewhere then we'll move it to util.


heapUpdate

protected org.sandev.basics.sandmessages.AggregateUpdate heapUpdate(org.sandev.basics.sandmessages.AggregateUpdate au)
                                                             throws org.sandev.basics.structs.SandException
Handle the specified updates to the overall TaskHeap. Essentially we walk the updates, inserting additional updates as needed. Higher level actions are composed of the smaller atomic actions, so for example moving a Task from one Plan to another is a PlanUpdate to remove the Task and a PlanUpdate to associate the Task. The base actions are:

Recalc is handled in the PlanCalculator via a PlanRecalc synchronous request. Multiple simultaneous requests are handled concurrently, subject only to transactional constraints on the underlying data updates.

Implementation notes:

  1. There is some possibility that the bookkeeping done here could potentially conflict with an advanced UI function trying to handle all bookkeeping itself. If this becomes an issue in the future, then this method will need to adjust downstream updates accordingly.

Throws:
org.sandev.basics.structs.SandException

isRecalcExempt

protected boolean isRecalcExempt(org.sandev.basics.structs.SandUpdateMessage sum)
Return true if this update is exempt from recalc processing, false otherwise. Some updates are the result of macro level UI actions programmed as buttons. These actions are self contained and do not require recalculation.


removeDuplicateRecalcs

protected org.sandev.basics.structs.SandUpdateMessage[] removeDuplicateRecalcs(org.sandev.basics.structs.SandUpdateMessage[] sums)
We only want one PlanUpdate added per action. But we can easily end up recalculating the same Plan twice if a Task or other PlanComponent is moved from one Plan to another, so we filter out duplicate recalcs before actually doing the updates.

This works by removing any plan recalc updates that have a subsequent update later on in the array.


confirmChildReferences

protected void confirmChildReferences(PlanUpdate pu,
                                      java.util.ArrayList al,
                                      org.sandev.basics.sandmessages.AggregateUpdate au)
                               throws org.sandev.basics.structs.SandException
Make sure that any referenced instances have this Plan as the parent, and make sure no previously referenced instances still reference this Plan.

Throws:
org.sandev.basics.structs.SandException

removeReferenceToChild

protected void removeReferenceToChild(org.sandev.basics.structs.SandInstanceMessage child,
                                      org.sandev.basics.util.AuthUser user,
                                      java.util.ArrayList al)
                               throws org.sandev.basics.structs.SandException
Given some form of PlanComponent derived update message, append an update as necessary to remove it from its parent. So for example, given a TaskUpdate for a Task 5032 with parent Plan 1034, append a PlanUpdate removing the reference to Task 5032 from Plan 1034.

We recalculate the parent as part of this processing, to avoid requiring two separate update actions for the same parent Plan.

Throws:
org.sandev.basics.structs.SandException

getParentForUpdate

protected long getParentForUpdate(org.sandev.basics.structs.SandUpdateMessage sum)
                           throws org.sandev.basics.structs.SandException
Return the parent uniqueID for the PlanComponent derived update, or zero if there is no parent reference.

Throws:
org.sandev.basics.structs.SandException

getParentForInstance

protected long getParentForInstance(org.sandev.basics.structs.SandInstanceMessage sim)
                             throws org.sandev.basics.structs.SandException
Return the parent uniqueID for the PlanComponent derived instance, or zero if there is no parent reference.

Throws:
org.sandev.basics.structs.SandException

timeEstimateChanged

protected boolean timeEstimateChanged(org.sandev.basics.structs.SandUpdateMessage sum)
                               throws org.sandev.basics.structs.SandException
Return true if the timeEstimate for the given update has changed. The timeEstimate is considered to have changed if the recordStatus has changed, since deleting something effectively means its timeEstimate is now zero. Likewise for closed or finished tasks.

Throws:
org.sandev.basics.structs.SandException

verifyParentRef

protected void verifyParentRef(long childID,
                               long parentID,
                               long userID,
                               java.util.ArrayList al,
                               org.sandev.basics.sandmessages.AggregateUpdate au)
                        throws org.sandev.basics.structs.SandException
Given a child make sure there is an update pending that sets its parent reference appropriately. To do this we walk the outstanding updates looking for the last one with this childID. If we find an existing update, then we make sure that the parentID is filled out appropriately. Otherwise we call updateParentRef.

Throws:
org.sandev.basics.structs.SandException

updateParentRef

protected void updateParentRef(long childID,
                               long parentID,
                               long userID,
                               java.util.ArrayList al)
                        throws org.sandev.basics.structs.SandException
Given a child, append an update to change its parent reference. So for example given a Task 5032 whose parent is now 1043, append a TaskUpdate for Task 5032 setting its parent reference to 1043.

Throws:
org.sandev.basics.structs.SandException

recalcParents

protected void recalcParents(long parentID,
                             long userID,
                             java.util.ArrayList al)
                      throws org.sandev.basics.structs.SandException
Recalc the specified Plan, and any containing Plans recursively upward, appending the resulting updates to the specified list. To avoid adding duplicate updates, and to keep the entire resulting AggregateUpdate consistent within itself, we want to re-use any existing updates in the given list before adding a new one. If we don't do this, then we might lose a child reference that had been added earlier.

Throws:
org.sandev.basics.structs.SandException

recalcPlan

protected void recalcPlan(Plan plan,
                          long userID,
                          java.util.ArrayList al)
                   throws org.sandev.basics.structs.SandException
Recalc the given plan.

Throws:
org.sandev.basics.structs.SandException

verifyTaskPhaseValid

protected void verifyTaskPhaseValid(Task task,
                                    org.sandev.basics.util.AuthUser user)
                             throws org.sandev.basics.structs.SandException
Verify that the TaskPhase associated with the given Task is valid according to its TaskType. Default to the first phase referenced in the TaskType if not valid. The Task instance is modified directly, an exception is thrown if anything goes seriously wrong.

Throws:
org.sandev.basics.structs.SandException

getDeploymentPrefix

public java.lang.String getDeploymentPrefix()
Return the prefix for this deployment.

Overrides:
getDeploymentPrefix in class UpdateManagerNodeBase

findFromUpdates

protected static org.sandev.basics.structs.SandPersistMessage findFromUpdates(long id,
                                                                              java.util.ArrayList al)
If there is an existing update in the list for the given ID, then return that instance. Otherwise return null.