org.sandev.TaskHeap.HeapCalculator
Class HeapCalculatorNode

java.lang.Object
  extended by org.sandev.TaskHeap.HeapCalculator.HeapCalculatorNodeDecl
      extended by org.sandev.TaskHeap.HeapCalculator.HeapCalculatorNodeBase
          extended by org.sandev.TaskHeap.HeapCalculator.HeapCalculatorNode
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 HeapCalculatorNode
extends HeapCalculatorNodeBase

Implementation of the HeapCalculator node.


Field Summary
static java.lang.String DAY14COLOR
           
static java.lang.String DAY1COLOR
           
static java.lang.String DAY2COLOR
           
static java.lang.String DAY30COLOR
           
static java.lang.String DAY7COLOR
           
protected static java.lang.String EXTERNALPLANSTATUS
           
static java.lang.String OLDCOLOR
           
protected static java.lang.String PARALLELPLANSTATUS
           
protected static java.lang.String SEQUENTIALPLANSTATUS
           
 
Fields inherited from class org.sandev.TaskHeap.HeapCalculator.HeapCalculatorNodeBase
ctrlwrappers, helperNodes, idLookup, incomingAsyncExternalPlanSource, incomingAsyncPlanSource, incomingAsyncTaskSource, incomingSyncAggregateUpdate, incomingSyncHeapDisplay, LOGDEBUG, LOGERROR, LOGFATAL, logger, LOGINFO, logLevel, LOGLEVEL_DEBUG, LOGLEVEL_ERROR, LOGLEVEL_FATAL, LOGLEVEL_INFO, LOGLEVEL_WARN, LOGWARN, messager, nodeInstance, outgoingSyncAggregateUpdate, outgoingSyncPlanQuery, 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.HeapCalculator.HeapCalculatorNodeDecl
peerAuthUserLookupNode, peerIDLookupNode
 
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
HeapCalculatorNode()
           
 
Method Summary
protected  java.util.Date calcRelativeDate(RelativeDeadline rel, java.util.Date date)
          Given a relative deadline definition and the due date, figure out the effective deadline date.
protected  PlanTreeElement createTree(long heapID, org.sandev.basics.util.AuthUser user)
          Given the ID of a heap, create the display tree for it using the fully expanded view of the heap owner.
protected  PlanTreeElement findElem(long refid, PlanTreeElement root)
          Search the given tree for the specified element and return it.
protected  PlanComponentInterface findPCI(long refid, PlanComponentInterface[] pcis)
          Return the component matching the given id, or null if not found.
protected  PlanTreeElement findRoot(PlanTreeElement root, long rootID)
          Walk the tree to find the specified root.
protected  java.lang.String getActivityColor(PlanComponentInterface pci, HeapAttributes ha)
          Return the activity color for the given component.
protected  int getAssignedTo(PlanTreeElement elem, HeapAssociation assoc)
          Given a work item and an association to it, return the responsibility level.
protected  int getBasicPlanStatus(PlanComponentInterface pci)
          Return the basic planStatus value assuming no current plan marked.
protected  long[] getChildIDs(PlanComponentInterface pci, PlanTreeElement elem, PlanTreeElement reftreeroot)
          Return an array of the child IDs reading first from the component or from the tree elem if the pci is null.
protected  java.util.Date getElemDueDate(PlanTreeElement elem, HeapAttributes ha, PlanComponentInterface[] pcis, PlanTreeElement reftree)
          Compute the due date for the given element.
protected  int getInitialItemExpansion(PlanComponentInterface pci)
          Return the item expansion for the given component.
protected  PlanTreeElement getInterimRefElement(PlanComponentInterface pci, PlanTreeElement parent)
          Given a component, return a temporary tree entry for it with enough information to dereference the due date.
protected  java.lang.String getLineBackground(int line, java.lang.String path, java.lang.String drillpath)
          Figure out the line number background color and return it.
protected  java.lang.String getShortDescription(PlanComponentInterface pci)
          Return the first part of the given description.
protected  java.lang.String getStatus(PlanComponentInterface pci, org.sandev.basics.util.AuthUser user)
          Return the status to display for the given component.
protected  java.lang.String getTargetCompletion(PlanTreeElement elem, ElapsedTimeCalendar cal)
          Return the targeted completion day as a canonical date string.
protected  int getTimeEstimate(PlanComponentInterface pci)
          Return the time estimate for the given component.
protected  int getTotalTime(PlanComponentInterface pci)
          Returns the estimated time unless this was closed out, in which case it returns zero.
protected  PlanTreeElement getTreeRoot(PlanTreeElement elem)
          Given a tree element, walk up to the root and return it.
protected  java.lang.String getUnderscores(java.lang.String label)
          Get the indent level corresponding to the given label.
protected  void initDueDateFields(PlanTreeElement elem, PlanComponentInterface pci)
          Intialize the element due date fields from the given component.
protected  boolean isFinishedOrClosed(PlanTreeElement elem)
          Return true if the given element is finished or closed, false otherwise.
protected  void logTree(PlanTreeElement elem)
          Dump the tree out to the log file for debugging.
protected  PlanTreeElement makeTreeElem(long planComponentID, PlanTreeElement refTreeRoot, PlanComponentInterface[] pcis, PlanTreeElement parent, java.lang.String label, org.sandev.basics.util.AuthUser user, ElapsedTimeCalendar cal, HeapAttributes ha, org.sandev.basics.util.IntReference lineNumber)
          Create a new tree element for the given ID and return it.
 void onDelivery(ExternalPlanUpdate update)
          Update our heap view to reflect the new information.
 void onDelivery(PlanUpdate update)
          Update our heap view to reflect the new information.
 void onDelivery(TaskUpdate update)
          Update our heap view to reflect the new information.
 org.sandev.basics.sandmessages.AggregateUpdate onReceive(org.sandev.basics.sandmessages.AggregateUpdate au)
          Pass the update through, then update our heap with any components that were changed before returning the result.
 HeapDisplay onReceive(HeapDisplay hd)
          Given the id of a heap and the display parameters, return the display tree.
protected  void recalcTimesFromChildren(PlanTreeElement elem)
          Recalc the timeEstimate and totalTime from the child values.
protected  void recomputeDeadlineFields(PlanTreeElement elem, ElapsedTimeCalendar cal, HeapAttributes ha, PlanComponentInterface[] pcis, PlanTreeElement reftree)
          Recompute the deadline fields for the given element.
protected  RelativeDeadline reldefForPCI(PlanComponentInterface pci)
          Given a component, return a RelativeDeadline for it.
protected  PlanTreeElement translateTree(PlanTreeElement root, PlanTreeElement parent, org.sandev.basics.util.AuthUser user, DisplayParams params, HeapAssociation assoc, org.sandev.basics.util.IntReference currPlanMark)
          Using the given tree as a source, create a full copy translating each element based on the given user and display params.
protected  void updateTree(PlanComponentInterface[] pcis, org.sandev.basics.util.AuthUser user)
          Update the heap to take into account changes to the given heap components.
 
Methods inherited from class org.sandev.TaskHeap.HeapCalculator.HeapCalculatorNodeBase
addWrapper, callAggregateUpdate, callPlanQuery, callQuery, deliver, deliverExternalPlanSource, deliverPlanSource, deliverTaskSource, fieldHasFlag, getDeploymentPrefix, getHelperNodes, getIDCache, getIDLookup, getIncomingAsyncExternalPlanSource, getIncomingAsyncExternalPlanSourceDefaultValue, getIncomingAsyncExternalPlanSourceFieldPrintValue, getIncomingAsyncExternalPlanSourceFlag, getIncomingAsyncExternalPlanSourceInvalidValue, getIncomingAsyncExternalPlanSourceMetatype, getIncomingAsyncExternalPlanSourcePrintValue, getIncomingAsyncExternalPlanSourceRange, getIncomingAsyncExternalPlanSourceValidityCheck, getIncomingAsyncPlanSource, getIncomingAsyncPlanSourceDefaultValue, getIncomingAsyncPlanSourceFieldPrintValue, getIncomingAsyncPlanSourceFlag, getIncomingAsyncPlanSourceInvalidValue, getIncomingAsyncPlanSourceMetatype, getIncomingAsyncPlanSourcePrintValue, getIncomingAsyncPlanSourceRange, getIncomingAsyncPlanSourceValidityCheck, getIncomingAsyncTaskSource, getIncomingAsyncTaskSourceDefaultValue, getIncomingAsyncTaskSourceFieldPrintValue, getIncomingAsyncTaskSourceFlag, getIncomingAsyncTaskSourceInvalidValue, getIncomingAsyncTaskSourceMetatype, getIncomingAsyncTaskSourcePrintValue, getIncomingAsyncTaskSourceRange, getIncomingAsyncTaskSourceValidityCheck, getIncomingSyncAggregateUpdate, getIncomingSyncAggregateUpdateDefaultValue, getIncomingSyncAggregateUpdateFieldPrintValue, getIncomingSyncAggregateUpdateFlag, getIncomingSyncAggregateUpdateInvalidValue, getIncomingSyncAggregateUpdateMetatype, getIncomingSyncAggregateUpdatePrintValue, getIncomingSyncAggregateUpdateRange, getIncomingSyncAggregateUpdateValidityCheck, getIncomingSyncHeapDisplay, getIncomingSyncHeapDisplayDefaultValue, getIncomingSyncHeapDisplayFieldPrintValue, getIncomingSyncHeapDisplayFlag, getIncomingSyncHeapDisplayInvalidValue, getIncomingSyncHeapDisplayMetatype, getIncomingSyncHeapDisplayPrintValue, getIncomingSyncHeapDisplayRange, getIncomingSyncHeapDisplayValidityCheck, getInstance, 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, getOutgoingSyncAggregateUpdate, getOutgoingSyncAggregateUpdateDefaultValue, getOutgoingSyncAggregateUpdateFieldPrintValue, getOutgoingSyncAggregateUpdateFlag, getOutgoingSyncAggregateUpdateInvalidValue, getOutgoingSyncAggregateUpdateMetatype, getOutgoingSyncAggregateUpdatePrintValue, getOutgoingSyncAggregateUpdateRange, getOutgoingSyncAggregateUpdateValidityCheck, getOutgoingSyncPlanQuery, getOutgoingSyncPlanQueryDefaultValue, getOutgoingSyncPlanQueryFieldPrintValue, getOutgoingSyncPlanQueryFlag, getOutgoingSyncPlanQueryInvalidValue, getOutgoingSyncPlanQueryMetatype, getOutgoingSyncPlanQueryPrintValue, getOutgoingSyncPlanQueryRange, getOutgoingSyncPlanQueryValidityCheck, getParent, getPeerAuthUserLookupNode, getPeerAuthUserLookupNodeDefaultValue, getPeerAuthUserLookupNodeFieldPrintValue, getPeerAuthUserLookupNodeFlag, getPeerAuthUserLookupNodeInvalidValue, getPeerAuthUserLookupNodeLengthMax, getPeerAuthUserLookupNodeLengthNorm, getPeerAuthUserLookupNodeMetatype, getPeerAuthUserLookupNodePrintValue, getPeerAuthUserLookupNodeRange, getPeerAuthUserLookupNodeValidityCheck, getPeerIDLookupNode, getPeerIDLookupNodeDefaultValue, getPeerIDLookupNodeFieldPrintValue, getPeerIDLookupNodeFlag, getPeerIDLookupNodeInvalidValue, getPeerIDLookupNodeLengthMax, getPeerIDLookupNodeLengthNorm, getPeerIDLookupNodeMetatype, getPeerIDLookupNodePrintValue, getPeerIDLookupNodeRange, getPeerIDLookupNodeValidityCheck, 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, getUserForID, getUserFromLogin, getUserLookup, init, log, log, logLevelActual2Print, logLevelLabelToValue, logLevelLabelToValueStatic, logLevelPrint2Actual, logLevelPrint2Key, logLevelValueToLabel, logLevelValueToLabelStatic, notifyStateChange, onFailure, onRestart, onResume, onShutdown, onStartup, onSuspend, processMessage, readConfigParamsFromNodeInstance, receive, receive, receive, restart, resume, sandNodeStateActual2Print, sandNodeStateLabelToValue, sandNodeStateLabelToValueStatic, sandNodeStatePrint2Actual, sandNodeStatePrint2Key, sandNodeStateValueToLabel, sandNodeStateValueToLabelStatic, setHelperNodes, setIDLookup, setIncomingAsyncExternalPlanSource, setIncomingAsyncExternalPlanSource, setIncomingAsyncPlanSource, setIncomingAsyncPlanSource, setIncomingAsyncTaskSource, setIncomingAsyncTaskSource, setIncomingSyncAggregateUpdate, setIncomingSyncAggregateUpdate, setIncomingSyncHeapDisplay, setIncomingSyncHeapDisplay, setLogger, setLogger, setLogLevel, setMessager, setMessager, setNodeInstance, setNodeInstance, setOutgoingSyncAggregateUpdate, setOutgoingSyncAggregateUpdate, setOutgoingSyncPlanQuery, setOutgoingSyncPlanQuery, setParent, setPeerAuthUserLookupNode, setPeerAuthUserLookupNode, setPeerIDLookupNode, setPeerIDLookupNode, 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

DAY1COLOR

public static final java.lang.String DAY1COLOR
See Also:
Constant Field Values

DAY2COLOR

public static final java.lang.String DAY2COLOR
See Also:
Constant Field Values

DAY7COLOR

public static final java.lang.String DAY7COLOR
See Also:
Constant Field Values

DAY14COLOR

public static final java.lang.String DAY14COLOR
See Also:
Constant Field Values

DAY30COLOR

public static final java.lang.String DAY30COLOR
See Also:
Constant Field Values

OLDCOLOR

public static final java.lang.String OLDCOLOR
See Also:
Constant Field Values

PARALLELPLANSTATUS

protected static final java.lang.String PARALLELPLANSTATUS
See Also:
Constant Field Values

SEQUENTIALPLANSTATUS

protected static final java.lang.String SEQUENTIALPLANSTATUS
See Also:
Constant Field Values

EXTERNALPLANSTATUS

protected static final java.lang.String EXTERNALPLANSTATUS
See Also:
Constant Field Values
Constructor Detail

HeapCalculatorNode

public HeapCalculatorNode()
Method Detail

onReceive

public HeapDisplay onReceive(HeapDisplay hd)
                      throws org.sandev.basics.structs.SandException
Given the id of a heap and the display parameters, return the display tree.

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

onReceive

public org.sandev.basics.sandmessages.AggregateUpdate onReceive(org.sandev.basics.sandmessages.AggregateUpdate au)
                                                         throws org.sandev.basics.structs.SandException
Pass the update through, then update our heap with any components that were changed before returning the result.

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

onDelivery

public void onDelivery(TaskUpdate update)
                throws org.sandev.basics.structs.SandException
Update our heap view to reflect the new information.

Overrides:
onDelivery in class HeapCalculatorNodeBase
Throws:
org.sandev.basics.structs.SandException

onDelivery

public void onDelivery(ExternalPlanUpdate update)
                throws org.sandev.basics.structs.SandException
Update our heap view to reflect the new information.

Overrides:
onDelivery in class HeapCalculatorNodeBase
Throws:
org.sandev.basics.structs.SandException

onDelivery

public void onDelivery(PlanUpdate update)
                throws org.sandev.basics.structs.SandException
Update our heap view to reflect the new information.

Overrides:
onDelivery in class HeapCalculatorNodeBase
Throws:
org.sandev.basics.structs.SandException

createTree

protected PlanTreeElement createTree(long heapID,
                                     org.sandev.basics.util.AuthUser user)
                              throws org.sandev.basics.structs.SandException
Given the ID of a heap, create the display tree for it using the fully expanded view of the heap owner.

Throws:
org.sandev.basics.structs.SandException

translateTree

protected PlanTreeElement translateTree(PlanTreeElement root,
                                        PlanTreeElement parent,
                                        org.sandev.basics.util.AuthUser user,
                                        DisplayParams params,
                                        HeapAssociation assoc,
                                        org.sandev.basics.util.IntReference currPlanMark)
Using the given tree as a source, create a full copy translating each element based on the given user and display params.


updateTree

protected void updateTree(PlanComponentInterface[] pcis,
                          org.sandev.basics.util.AuthUser user)
                   throws org.sandev.basics.structs.SandException
Update the heap to take into account changes to the given heap components. It is assumed that the given components are all from the same heap. The idea here is to build the heap tree once and then simply update it from that point forward to reflect any changes.

This method is synchronized to keep the tree display consistent even if several updates are being processed at the same time. If this ever becomes a chokepoint, then we can subdivide to synchronize on the HeapAttribute instances so only updates within the same heap have to queue up.

If there is no tree set in the HeapAttributes yet, then this method does nothing. Updates that occur in batch should not trigger creation of the heap tree, and the tree created on the next request will reflect any updates that occurred beforehand.

Since the tree itself is contantly being referenced to create displays, the update process works by making a deep copy of the entire tree, making the modifications to the copy, and then updating the HeapAttributes heap field with the result. Changing the value of the heap field in the HeapAttributes object is an atomic operation, so this should prevent any update anomalies. While it is possible in some instances to only change a part of the tree, when things are being moved around between plans this is not generally possible. Optimizing for the simple case doesn't seem worth the added complexity right now.

Throws:
org.sandev.basics.structs.SandException

getShortDescription

protected java.lang.String getShortDescription(PlanComponentInterface pci)
Return the first part of the given description. Most browsers seem to truncate around 80 characters, so that's what we use here.


getLineBackground

protected java.lang.String getLineBackground(int line,
                                             java.lang.String path,
                                             java.lang.String drillpath)
Figure out the line number background color and return it.


getBasicPlanStatus

protected int getBasicPlanStatus(PlanComponentInterface pci)
Return the basic planStatus value assuming no current plan marked.


getInitialItemExpansion

protected int getInitialItemExpansion(PlanComponentInterface pci)
Return the item expansion for the given component. If dp is null then all plans are assumed to be expanded.


getTimeEstimate

protected int getTimeEstimate(PlanComponentInterface pci)
Return the time estimate for the given component.


getTotalTime

protected int getTotalTime(PlanComponentInterface pci)
Returns the estimated time unless this was closed out, in which case it returns zero.


getUnderscores

protected java.lang.String getUnderscores(java.lang.String label)
Get the indent level corresponding to the given label. Returns a string of underscores corresponding in length to the indent.


getStatus

protected java.lang.String getStatus(PlanComponentInterface pci,
                                     org.sandev.basics.util.AuthUser user)
                              throws org.sandev.basics.structs.SandException
Return the status to display for the given component. The status for a Task is the name of the current TaskPhase, for an ExternalPlan it is "External Plan", and for a Plan this is either "Plan (seq)" or "Plan (para)".

Throws:
org.sandev.basics.structs.SandException

getActivityColor

protected java.lang.String getActivityColor(PlanComponentInterface pci,
                                            HeapAttributes ha)
Return the activity color for the given component.


recalcTimesFromChildren

protected void recalcTimesFromChildren(PlanTreeElement elem)
Recalc the timeEstimate and totalTime from the child values.


getTargetCompletion

protected java.lang.String getTargetCompletion(PlanTreeElement elem,
                                               ElapsedTimeCalendar cal)
Return the targeted completion day as a canonical date string.


isFinishedOrClosed

protected boolean isFinishedOrClosed(PlanTreeElement elem)
Return true if the given element is finished or closed, false otherwise. See the initial data for the values matched here.


findRoot

protected PlanTreeElement findRoot(PlanTreeElement root,
                                   long rootID)
Walk the tree to find the specified root. When found, return it.


getAssignedTo

protected int getAssignedTo(PlanTreeElement elem,
                            HeapAssociation assoc)
Given a work item and an association to it, return the responsibility level. The responsibilites array contains the uniqueIDs of all associated Roles, and the uniqueID of the HeapAssociation this item is assigned to (if any).


makeTreeElem

protected PlanTreeElement makeTreeElem(long planComponentID,
                                       PlanTreeElement refTreeRoot,
                                       PlanComponentInterface[] pcis,
                                       PlanTreeElement parent,
                                       java.lang.String label,
                                       org.sandev.basics.util.AuthUser user,
                                       ElapsedTimeCalendar cal,
                                       HeapAttributes ha,
                                       org.sandev.basics.util.IntReference lineNumber)
                                throws org.sandev.basics.structs.SandException
Create a new tree element for the given ID and return it. The information for the item is first copied from the given component array. If the component is not found there, then the information is copied from the existing tree element. If there is no existing tree element, then the component is retrieved from the db. This method calls itself recursively to add its children. It also relies on getInstance for a PlanComponent returning the fully resolved instance (Task, Plan or ExternalPlan). The resulting tree will not have a current plan or assignment indicators set.

Throws:
org.sandev.basics.structs.SandException

getChildIDs

protected long[] getChildIDs(PlanComponentInterface pci,
                             PlanTreeElement elem,
                             PlanTreeElement reftreeroot)
Return an array of the child IDs reading first from the component or from the tree elem if the pci is null.


initDueDateFields

protected void initDueDateFields(PlanTreeElement elem,
                                 PlanComponentInterface pci)
                          throws org.sandev.basics.structs.SandException
Intialize the element due date fields from the given component. The reldef is only filled in if a relative date is defined.

Throws:
org.sandev.basics.structs.SandException

reldefForPCI

protected RelativeDeadline reldefForPCI(PlanComponentInterface pci)
Given a component, return a RelativeDeadline for it.


recomputeDeadlineFields

protected void recomputeDeadlineFields(PlanTreeElement elem,
                                       ElapsedTimeCalendar cal,
                                       HeapAttributes ha,
                                       PlanComponentInterface[] pcis,
                                       PlanTreeElement reftree)
                                throws org.sandev.basics.structs.SandException
Recompute the deadline fields for the given element. This sets the dueDate, dueColor and slack.

Throws:
org.sandev.basics.structs.SandException

getElemDueDate

protected java.util.Date getElemDueDate(PlanTreeElement elem,
                                        HeapAttributes ha,
                                        PlanComponentInterface[] pcis,
                                        PlanTreeElement reftree)
                                 throws org.sandev.basics.structs.SandException
Compute the due date for the given element. If the due date is fixed, then this simply returns the due date set. Otherwise if the due date is relative, then we look up the reference information in the current tree. If not found in the current tree then we use the updated information in the pcis to compute the date. If the information was not modified, then we use the old information from the given reference tree. The current tree is in the process of being built when this is called, which is why we may not find the reference. But we can't wait until the tree is completed because we are working against an elapsed time calendar to calculate slack. So we have to handle the forward references here.

Throws:
org.sandev.basics.structs.SandException

calcRelativeDate

protected java.util.Date calcRelativeDate(RelativeDeadline rel,
                                          java.util.Date date)
Given a relative deadline definition and the due date, figure out the effective deadline date.


getInterimRefElement

protected PlanTreeElement getInterimRefElement(PlanComponentInterface pci,
                                               PlanTreeElement parent)
                                        throws org.sandev.basics.structs.SandException
Given a component, return a temporary tree entry for it with enough information to dereference the due date.

Throws:
org.sandev.basics.structs.SandException

findPCI

protected PlanComponentInterface findPCI(long refid,
                                         PlanComponentInterface[] pcis)
Return the component matching the given id, or null if not found.


findElem

protected PlanTreeElement findElem(long refid,
                                   PlanTreeElement root)
Search the given tree for the specified element and return it. Return null if not found.


getTreeRoot

protected PlanTreeElement getTreeRoot(PlanTreeElement elem)
Given a tree element, walk up to the root and return it.


logTree

protected void logTree(PlanTreeElement elem)
Dump the tree out to the log file for debugging.