org.sandev.TaskHeap.util
Class PlanComponentUtil

java.lang.Object
  extended by org.sandev.TaskHeap.util.PlanComponentUtil

public class PlanComponentUtil
extends java.lang.Object

Useful utility methods for dealing with PlanComponent derived classes.


Constructor Summary
PlanComponentUtil()
           
 
Method Summary
static boolean externalPlanDue(ExternalPlan ep, int defaultLatencyHours)
          Return true if the given ExternalPlan is due for refresh, false otherwise.
static java.util.Date getDueDate(PlanComponentInterface pci, org.sandev.basics.util.IDLookup lookup, org.sandev.basics.util.AuthUser user)
          Return when this task is due, either using the current fixed due date or computing the relative date.
static java.lang.String getName(org.sandev.basics.structs.SandStructMessage ssm)
          Return the value of the name field, or the empty string if this is not a PlanComponentStruct derived message.
static Note[] getNotes(org.sandev.basics.structs.SandStructMessage ssm)
          Return the notes array of the given PlanComponent message, or an empty array otherwise.
static long getParent(org.sandev.basics.structs.SandStructMessage ssm)
          Return the parent id of the given PlanComponent message, or zero if none was found.
static org.sandev.basics.structs.SandPersistMessage getUpdatedInstance(java.lang.String classname, long id, org.sandev.basics.util.IDLookup lookup, org.sandev.basics.util.AuthUser user, org.sandev.basics.structs.SandUpdateMessage[] updates)
          Return the requested instance looking first in the updates and then via the lookup.
static java.util.Calendar roundDate(java.util.Calendar cal, PlanComponentInterface pci)
          Round the calendar as specified in the plan component.
static PlanComponentInterface[] sortComponents(PlanComponentInterface[] comps, org.sandev.basics.util.IDLookup lookup, org.sandev.basics.util.AuthUser user)
          Sort the given PlanComponentInterface array and return the result.
static void sortElements(Plan plan, org.sandev.basics.util.IDLookup lookup, org.sandev.basics.util.AuthUser user, org.sandev.basics.structs.SandUpdateMessage[] updates)
          Given a Plan, sort its components.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlanComponentUtil

public PlanComponentUtil()
Method Detail

getName

public static java.lang.String getName(org.sandev.basics.structs.SandStructMessage ssm)
Return the value of the name field, or the empty string if this is not a PlanComponentStruct derived message.


getParent

public static long getParent(org.sandev.basics.structs.SandStructMessage ssm)
Return the parent id of the given PlanComponent message, or zero if none was found.


getNotes

public static Note[] getNotes(org.sandev.basics.structs.SandStructMessage ssm)
Return the notes array of the given PlanComponent message, or an empty array otherwise.


getDueDate

public static java.util.Date getDueDate(PlanComponentInterface pci,
                                        org.sandev.basics.util.IDLookup lookup,
                                        org.sandev.basics.util.AuthUser user)
                                 throws org.sandev.basics.structs.SandException
Return when this task is due, either using the current fixed due date or computing the relative date. If no due date is in effect then this returns a date 20 years in the future.

Throws:
org.sandev.basics.structs.SandException

roundDate

public static java.util.Calendar roundDate(java.util.Calendar cal,
                                           PlanComponentInterface pci)
Round the calendar as specified in the plan component.


sortComponents

public static PlanComponentInterface[] sortComponents(PlanComponentInterface[] comps,
                                                      org.sandev.basics.util.IDLookup lookup,
                                                      org.sandev.basics.util.AuthUser user)
                                               throws org.sandev.basics.structs.SandException
Sort the given PlanComponentInterface array and return the result. PlanComponents are ordered based on their due date. If no due date is set, then the component should not be moved. So only comps with due dates set are candidates to be swapped around here. This does kind of a bubble sort since that's easiest to read/implement and were not talking many elements here.

Throws:
org.sandev.basics.structs.SandException

sortElements

public static void sortElements(Plan plan,
                                org.sandev.basics.util.IDLookup lookup,
                                org.sandev.basics.util.AuthUser user,
                                org.sandev.basics.structs.SandUpdateMessage[] updates)
                         throws org.sandev.basics.structs.SandException
Given a Plan, sort its components. The updated instance is used if found in the given updates, otherwise it is retrieved via the lookup.

Throws:
org.sandev.basics.structs.SandException

getUpdatedInstance

public static org.sandev.basics.structs.SandPersistMessage getUpdatedInstance(java.lang.String classname,
                                                                              long id,
                                                                              org.sandev.basics.util.IDLookup lookup,
                                                                              org.sandev.basics.util.AuthUser user,
                                                                              org.sandev.basics.structs.SandUpdateMessage[] updates)
                                                                       throws org.sandev.basics.structs.SandException
Return the requested instance looking first in the updates and then via the lookup.

Throws:
org.sandev.basics.structs.SandException

externalPlanDue

public static boolean externalPlanDue(ExternalPlan ep,
                                      int defaultLatencyHours)
Return true if the given ExternalPlan is due for refresh, false otherwise. The defaultLatencyHours corresponds to the latency defined for the HeapAttributes.

Larger latencies like 2x/day etc are computed based on their hourly offset from the current time. We don't want the system doing everything for everyone at noon and midnight each day. If someone really wants that then they can simply do a manual refresh to anchor the base latency time where they want it.