org.sandev.TaskHeap.UpdateManager
Class UpdateManagerNode

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

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.
protected  org.sandev.basics.util.AuthUserLookup userLookup
          The instance we use for looking up users.
 
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, outgoingSyncAggregateUpdate, outgoingSyncExternalPlanQuery, outgoingSyncPlanQuery, outgoingSyncPlanRecalc, 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
 
Fields inherited from class org.sandev.TaskHeap.UpdateManager.UpdateManagerNodeDecl
notify, userLookupInstanceName
 
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  org.sandev.basics.structs.AggregateUpdate addImpliedUpdates(org.sandev.basics.structs.AggregateUpdate au)
          Add any additional updates that are implied by the given updates to the given AggregateUpdate message.
 org.sandev.basics.structs.AggregateUpdate callAggregateUpdate(org.sandev.basics.structs.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.structs.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.
 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)
          Instance lookup utility.
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.
 org.sandev.basics.util.AuthUserLookup getUserLookup()
          initializing accessor for userLookup.
protected  org.sandev.basics.structs.AggregateUpdate heapUpdate(org.sandev.basics.structs.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  org.sandev.basics.structs.AggregateUpdate onReceive(org.sandev.basics.structs.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.
 void setUserLookup(org.sandev.basics.util.AuthUserLookup val)
          mutator for userLookup
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 verifyParentRef(long childID, long parentID, long userID, java.util.ArrayList al, org.sandev.basics.structs.AggregateUpdate au)
          Given a child make sure there is an update pending that sets its parent reference appropriately.
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)
          Check that the given update is ok.
 
Methods inherited from class org.sandev.TaskHeap.UpdateManager.UpdateManagerNodeBase
addNotify, addNotify, addWrapper, callExternalPlanQuery, callPlanQuery, callPlanRecalc, callTaskQuery, callTaskTypeQuery, clearNotify, deliver, fieldHasFlag, 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, getNotify, getNotify, getNotifyDefaultValue, getNotifyElementInvalidValue, getNotifyFlag, getNotifyInvalidValue, getNotifyMetatype, getNotifyRange, getNotifyValidityCheck, getOutgoingAsyncStats, getOutgoingAsyncStatsDefaultValue, getOutgoingAsyncStatsFieldPrintValue, getOutgoingAsyncStatsFlag, getOutgoingAsyncStatsInvalidValue, getOutgoingAsyncStatsMetatype, getOutgoingAsyncStatsPrintValue, getOutgoingAsyncStatsRange, getOutgoingAsyncStatsValidityCheck, getOutgoingSyncAggregateUpdate, getOutgoingSyncAggregateUpdateDefaultValue, getOutgoingSyncAggregateUpdateFieldPrintValue, getOutgoingSyncAggregateUpdateFlag, getOutgoingSyncAggregateUpdateInvalidValue, getOutgoingSyncAggregateUpdateMetatype, getOutgoingSyncAggregateUpdatePrintValue, getOutgoingSyncAggregateUpdateRange, getOutgoingSyncAggregateUpdateValidityCheck, getOutgoingSyncExternalPlanQuery, getOutgoingSyncExternalPlanQueryDefaultValue, getOutgoingSyncExternalPlanQueryFieldPrintValue, getOutgoingSyncExternalPlanQueryFlag, getOutgoingSyncExternalPlanQueryInvalidValue, getOutgoingSyncExternalPlanQueryMetatype, getOutgoingSyncExternalPlanQueryPrintValue, getOutgoingSyncExternalPlanQueryRange, getOutgoingSyncExternalPlanQueryValidityCheck, getOutgoingSyncPlanQuery, getOutgoingSyncPlanQueryDefaultValue, getOutgoingSyncPlanQueryFieldPrintValue, getOutgoingSyncPlanQueryFlag, getOutgoingSyncPlanQueryInvalidValue, getOutgoingSyncPlanQueryMetatype, getOutgoingSyncPlanQueryPrintValue, getOutgoingSyncPlanQueryRange, getOutgoingSyncPlanQueryValidityCheck, getOutgoingSyncPlanRecalc, getOutgoingSyncPlanRecalcDefaultValue, getOutgoingSyncPlanRecalcFieldPrintValue, getOutgoingSyncPlanRecalcFlag, getOutgoingSyncPlanRecalcInvalidValue, getOutgoingSyncPlanRecalcMetatype, getOutgoingSyncPlanRecalcPrintValue, getOutgoingSyncPlanRecalcRange, getOutgoingSyncPlanRecalcValidityCheck, getOutgoingSyncTaskQuery, getOutgoingSyncTaskQueryDefaultValue, getOutgoingSyncTaskQueryFieldPrintValue, getOutgoingSyncTaskQueryFlag, getOutgoingSyncTaskQueryInvalidValue, getOutgoingSyncTaskQueryMetatype, getOutgoingSyncTaskQueryPrintValue, getOutgoingSyncTaskQueryRange, getOutgoingSyncTaskQueryValidityCheck, getOutgoingSyncTaskTypeQuery, getOutgoingSyncTaskTypeQueryDefaultValue, getOutgoingSyncTaskTypeQueryFieldPrintValue, getOutgoingSyncTaskTypeQueryFlag, getOutgoingSyncTaskTypeQueryInvalidValue, getOutgoingSyncTaskTypeQueryMetatype, getOutgoingSyncTaskTypeQueryPrintValue, getOutgoingSyncTaskTypeQueryRange, getOutgoingSyncTaskTypeQueryValidityCheck, getParent, 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, getUserLookupInstanceName, getUserLookupInstanceNameDefaultValue, getUserLookupInstanceNameFieldPrintValue, getUserLookupInstanceNameFlag, getUserLookupInstanceNameInvalidValue, getUserLookupInstanceNameLengthMax, getUserLookupInstanceNameLengthNorm, getUserLookupInstanceNameMetatype, getUserLookupInstanceNamePrintValue, getUserLookupInstanceNameRange, getUserLookupInstanceNameValidityCheck, init, insertNotify, log, log, logLevelActual2Print, logLevelLabelToValue, logLevelPrint2Actual, logLevelPrint2Key, logLevelValueToLabel, notifyContains, notifyIndexOf, notifyStateChange, onFailure, onRestart, onResume, onShutdown, onSuspend, receive, receive, receive, removeNotify, removeNotifyValue, resolveNotifyReferences, resolveNotifyReferencesNoLookup, resolveNotifyReferencesNonCrit, restart, resume, sandNodeStateActual2Print, sandNodeStateLabelToValue, sandNodeStatePrint2Actual, sandNodeStatePrint2Key, sandNodeStateValueToLabel, send, setHelperNodes, setIncomingSyncAggregateUpdate, setIncomingSyncAggregateUpdate, setIncomingSyncStatsQuery, setIncomingSyncStatsQuery, setLogger, setLogger, setLogLevel, setMessager, setMessager, setNodeInstance, setNodeInstance, setNotify, setNotify, setOutgoingAsyncStats, setOutgoingAsyncStats, setOutgoingSyncAggregateUpdate, setOutgoingSyncAggregateUpdate, setOutgoingSyncExternalPlanQuery, setOutgoingSyncExternalPlanQuery, setOutgoingSyncPlanQuery, setOutgoingSyncPlanQuery, setOutgoingSyncPlanRecalc, setOutgoingSyncPlanRecalc, setOutgoingSyncTaskQuery, setOutgoingSyncTaskQuery, setOutgoingSyncTaskTypeQuery, setOutgoingSyncTaskTypeQuery, setParent, setSandNodeErrorMessage, setSandNodeErrorMessage, setSandNodeState, setSandRoot, setupSecureReceive, setupSubscriptions, setUserLookupInstanceName, setUserLookupInstanceName, shutdown, sizeofNotify, 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.


userLookup

protected org.sandev.basics.util.AuthUserLookup userLookup
The instance we use for looking up users.

Constructor Detail

UpdateManagerNode

public UpdateManagerNode()
Method Detail

getUserLookup

public org.sandev.basics.util.AuthUserLookup getUserLookup()
initializing accessor for userLookup. Not synchronized


setUserLookup

public void setUserLookup(org.sandev.basics.util.AuthUserLookup val)
mutator for userLookup


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
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
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
Instance lookup utility.

Specified by:
getInstance in interface org.sandev.basics.util.IDLookup
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.structs.AggregateUpdate onReceive(org.sandev.basics.structs.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.

Since most updates actually consist of a single update, we optimize that case.

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

callAggregateUpdate

public org.sandev.basics.structs.AggregateUpdate callAggregateUpdate(org.sandev.basics.structs.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)
                     throws UpdateManagerException
Check that the given update is ok. If something is invalid, then throw.

Throws:
UpdateManagerException

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.structs.AggregateUpdate addImpliedUpdates(org.sandev.basics.structs.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

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.


heapUpdate

protected org.sandev.basics.structs.AggregateUpdate heapUpdate(org.sandev.basics.structs.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.structs.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.structs.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.


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.