wt.projmgmt.msproject
Class Utils

java.lang.Object
  extended bywt.projmgmt.msproject.Utils

public class Utils
extends Object


Nested Class Summary
static class Utils.SortByID
          A Comparator that orders ProjectNodes according to their IDs.
static class Utils.SortByOID
          A Comparator that orders Persistables according to their object identifiers.
 
Field Summary
private static boolean EXPORT_DAYS_IN_XSD_DURATIONS
           
private static boolean EXPORT_LONG_XSD_DURATIONS
           
private static boolean EXPORT_MILLIS_IN_XSD_DATETIMES
           
private static TimeZone GMT
           
private static String GMT_NAME
           
private static char INVALID_EMAIL_CHAR_REPLACEMENT
           
static String NODES_CONTEXT_KEY
           
private static String PENDING_USER_EMAIL_SUFFIX
           
static String PREDS_CONTEXT_KEY
           
private static String RESOURCE
           
private static boolean SERVER
           
private static Utils.SortByID SORT_BY_ID
           
private static Utils.SortByOID SORT_BY_OID
           
private static char XSD_DATE_SEPARATOR
           
private static String XSD_DATE_TIME_NAME
           
private static String XSD_DATE_TIME_SEPARATOR
           
private static String XSD_DATETIME_PATTERN
           
private static char XSD_DAY_DESIGNATOR
           
private static String XSD_DOUBLE_NAME
           
private static String XSD_DURATION_NAME
           
private static String XSD_DURATION_PREFIX
           
private static DateFormat XSD_GMT_DATETIME_FORMAT
           
private static String XSD_GMT_DATETIME_PATTERN
           
private static char XSD_HOUR_DESIGNATOR
           
private static String XSD_INTEGER_NAME
           
private static char XSD_MIN_DESIGNATOR
           
private static String XSD_NEG
           
private static String XSD_POS
           
private static char XSD_SEC_DESIGNATOR
           
private static char XSD_TIME_SEPARATOR
           
private static char XSD_UTC_DESIGNATOR
           
private static String XSD_ZERO_DURATION
           
private static String XSD_ZERO_OFFSET
           
 
Constructor Summary
Utils()
           
 
Method Summary
private static void addToSet(WfContainer c, Set set, boolean getResources)
          A helper method used by getProjectResources(wt.workflow.engine.WfContainer) and getResourceAssignments(wt.workflow.engine.WfContainer).
static Timestamp alignTime(Timestamp stamp, boolean nextDay)
          Return the Timestamp that represents midnight in the current user's preferred TimeZone on the same day as the specified timestamp or on the day following the specified timestamp depending on the value of nextDay.
static Timestamp alignTime(Timestamp stamp, boolean nextDay, boolean allowNonWorking)
          Return the Timestamp that represents midnight in the current user's preferred TimeZone on the same day as the specified timestamp or on the day following the specified timestamp depending on the value of nextDay.
static Timestamp alignTime(Timestamp stamp, TimeZone tzone, boolean nextDay)
          Return the Timestamp that represents midnight in the specified TimeZone on the same day as the specified timestamp or on the day following the specified timestamp depending on the value of nextDay.
static Timestamp alignTime(Timestamp stamp, TimeZone tzone, boolean nextDay, boolean allowNonWorking)
          Return the Timestamp that represents midnight in the specified TimeZone on the same day as the specified timestamp or on the day following the specified timestamp depending on the value of nextDay.
static Timestamp alignTime(Timestamp stamp, WTUser aUser, boolean nextDay)
          Return the Timestamp that represents midnight in the specified user's preferred TimeZone on the same day as the specified timestamp or on the day following the specified timestamp depending on the value of nextDay.
static String decodeNewlines(String str)
          Used for import (for status and risk descriptions, Replace the encoded newlines with real newlines.
static String encodeNewlines(String str)
          Filters out any newlines in str and replaces with Constants.NEWLINE_EXP_ENCODING, original function for status and risk descriptions
private static Enumeration findUser(String attr_name, String attr_value)
          Finds all users in all services that have the given value for the specified attribute.
static Timestamp getActualFinish(ExecutionObject exObj)
          Get the actual finish of the ExecutionObject that should be exported to Microsoft Project.
static Timestamp getActualStart(ExecutionObject exObj, TimeToElapse duration)
          A helper method used by getActualStart(wt.projmgmt.execution.ExecutionObject, wt.workflow.definer.TimeToElapse) and getActualFinish(wt.projmgmt.execution.ExecutionObject) to get the planned start date of the ExecutionObject.
static Timestamp getActualStart(ResourceAssignmentLink link)
          Get the actual start of the ResourceAssignmentLink.
static Timestamp getDeadline(ExecutionObject exObj)
          Get the deadline of the ExecutionObject that should be exported to Microsoft Project.
static ExecutionObject getExecutionObject(ResourceAssignmentLink link)
          Get the ExecutionObject that is associated with the specified ResourceAssignmentLink.
static String getFilenameBase(ExecutionObject exObj, Locale locale, String defVal)
          Get a valid base for a filename based on the name of the specified ExecutionObject.
static String getFilenameBase(String base, Locale locale, String defVal)
          Get a valid base for a filename based on the specified base name.
static String getFilenameBase(WfContainer c, Locale locale, String defVal)
          Get a valid base for a filename based on the name of the specified WfContainer.
static long getId(Persistable p)
          Get the object identifier of the specified Persistable.
private static Timestamp getLatestWorkingDay(ExecutionObject exObj, Timestamp finish, Timestamp start, TimeToElapse duration)
          Return the latest working date that is "less than or equal to" the specified finish date and that is also "greater than or equal to" the specified start date.
static int getMaxUnits(ProjectResource resource)
          Get the maximum number of units of the resource that can be used by this project plan.
static long getMillis(Timestamp stamp)
          Return the number of milliseconds in the specified Timestamp.
static String getOffset(TimeZone tzone)
          Returns a string representing the offset of the specified TimeZone from GMT.
static int getOutlineLevel(ExecutionObject obj)
          Get the OutlineLevel of the specified ExecutionObject.
static WfContainer getParent(ProjectNode child)
          Get the parent of the specified ProjectNode.
static WTUser getPendingUser(String email)
          Get a pending user for the specified email address.
static String getPendingUserEmail(String fullName)
          Return a string that is used as the email for a pending user with a known full name but an unknown email.
static Persistable getPersistable(long id, Class clss)
          Get the Persistable with the specified long ID that is an instance of the specified Class.
static PersonResource getPersonResource(ProjectPlan plan, String name)
          Get a PersonResource with the specified name.
static PersonResource getPersonResource(ProjectPlan plan, WTUser user)
          Get a PersonResource that corresponds to the specified WTUser.
static Timestamp getPlannedFinish(ExecutionObject exObj)
          Get the estimated finish of the ExecutionObject that should be exported to Microsoft Project.
static Timestamp getPlannedStart(ExecutionObject exObj)
          Get the planned start of the ExecutionObject that should be exported to Microsoft Project.
private static Timestamp getPlannedStart(ExecutionObject exObj, TimeToElapse duration)
          A helper method used by getPlannedStart(wt.projmgmt.execution.ExecutionObject) and getPlannedFinish(wt.projmgmt.execution.ExecutionObject) to get the planned start date of the ExecutionObject.
static Timestamp getPlannedStart(ResourceAssignmentLink link)
          Get the planned start of the ResourceAssignmentLink.
static Timestamp getPlannedStart(WfExecutionObject exObj)
          Get the planned start of the WfExecutionObject that should be exported to Microsoft Project.
static ProjectCategory getProjectCategory(String name)
          Get the ProjectCategory with the specified name.
static ProjectHealthStatus getProjectHealthStatus(String name)
          Get the ProjectHealthStatus with the specified name.
static Enumeration getProjectNodes(WfContainer c)
          Return the all children of the specified WfContainer sorted in the "canonical order".
static ProjectPlan getProjectPlan(Persistable p)
          Get the ProjectPlan for the specified Persistable.
static Enumeration getProjectResources(WfContainer c)
          Return all the wt.projmgmt.resources.ProjectResources that are used by activities in the specified WfContainer.
static ProjectRiskValue getProjectRiskValue(String name)
          Get the ProjectRiskValue with the specified name.
static ProjectState getProjectState(String name)
          Get the ProjectState with the specified name.
static Enumeration getResourceAssignments(WfContainer c)
          Return all the ResourceAssignmentLinks that are used by activities in the specified WfContainer.
static int getResourceUnits(Class resClass, String strUnits)
          Get the number of units of the resource indicated by the specified String.
static String getShortName(Class c)
          Get the name of the specified class without the package name prepended.
private static Timestamp getStart(ExecutionObject exObj)
          This method calls the correct mthod based on the exObj's underlying type in order to get the planned start.
private static ProjectNode getStartAtEndSource(ExecutionObject exObj, Timestamp timeToStart, TimeToElapse duration)
          Return the source of the exObj's start date if it starts at the end of the day.
static String getSubstringAfterLastPeriod(String s)
          Get the substraing from the specified string that comes after the last period.
static String getTitle(ExecutionObject exObj)
          Get the title to use for the Microsoft Project Plan.
static WTUser getUser(String fullName, String email)
          Get a WTUser based on the specified fullName and email.
static WTUser getUserByEmail(String email)
          Get a WTUser whose WTUser.EMAIL is equal to the specified email.
private static WTUser getUserByEmail(String fullName, String email)
           
static WTUser getUserByFullName(String fullName)
          Get a WTUser whose WTUser.FULL_NAME is equal to the specified fullName.
static ProjectWorkItem getWorkItem(ExecutionObject exObj, ProjectResource resource)
          Get the ProjectWorkItem that is associated with the specified ProjectResource and ExecutionObject.
private static String getXSDDateTime(Date date, TimeZone tzone, boolean withOffset)
          Private helper method that is used by: toXSDDateTime(Timestamp, TimeZone) toXSDDateTime(Date, TimeZone)
static boolean isAllowStateChange(ExecutionObject exObj)
          Returns true if this wt.projmmgt.execution.ExecutionObject is in allow state change mode.
static boolean isStartAtEndOfDay(ExecutionObject exObj)
          Returns true if exObj starts at the end of the day.
static boolean parseXSDBoolean(String boo)
          Returns a boolean representing the value contained in the specified XSD boolean type.
static Timestamp parseXSDDateTime(String dateTime, TimeZone defaultTimeZone)
          Returns a Timestamp that is constructed based on the specified xsd:dateTime string.
static TimeToElapse parseXSDDuration(String duration)
          Returns a TimeToElapse representing the amount of time in the specified xsd:duration.
static Long parseXSDInteger(String integer)
          Returns a Long representing the value contained in the specified XSD integer type.
static Double parseXSDNumber(String number)
          Returns a Double representing the value contained in the specified XSD numeric type.
static void printMap(Map map)
          Write out the key=>value pairs in the specified Map object.
static String replaceString(String sOrigStr, String replaceWhat, String replaceWith)
          String replace function.
private static void reportXSDParseError(String xsdStr, String type, int pos)
          Report an error that occured while parsing an XSD data type.
static Work toWork(TimeToElapse duration)
          Convert the specified TimeToElapse to a Work object that represents the equivalent amount of work.
static TimeToElapse toWorkingDays(TimeToElapse workingHours)
          Convert the specified working hours to the number of working days.
static TimeToElapse toWorkingHours(TimeToElapse workingDays)
          Convert the specified working days to the number of working hours.
static String toXSDDateTime(Date date)
          Returns a string that can be used as the value of an XML element whose type is xsd:dateTime.
static String toXSDDateTime(Date date, TimeZone tzone)
          Returns a string that can be used as the value of an XML element whose type is xsd:dateTime.
static String toXSDDateTime(Date date, TimeZone tzone, boolean withOffset)
          Returns a string that can be used as the value of an XML element whose type is xsd:dateTime.
static String toXSDDateTime(Timestamp stamp)
          Returns a string that can be used as the value of an XML element whose type is xsd:dateTime.
static String toXSDDateTime(Timestamp stamp, TimeZone tzone)
          Returns a string that can be used as the value of an XML element whose type is xsd:dateTime.
static String toXSDDateTime(Timestamp stamp, TimeZone tzone, boolean withOffset)
          Returns a string that can be used as the value of an XML element whose type is xsd:dateTime.
static String toXSDDuration(long ms)
          Returns a string that can be used as the value of an XML element whose type is xsd:duration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXPORT_DAYS_IN_XSD_DURATIONS

private static final boolean EXPORT_DAYS_IN_XSD_DURATIONS
See Also:
Constant Field Values

EXPORT_LONG_XSD_DURATIONS

private static final boolean EXPORT_LONG_XSD_DURATIONS
See Also:
Constant Field Values

EXPORT_MILLIS_IN_XSD_DATETIMES

private static final boolean EXPORT_MILLIS_IN_XSD_DATETIMES
See Also:
Constant Field Values

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

NODES_CONTEXT_KEY

public static final String NODES_CONTEXT_KEY
See Also:
Constant Field Values

PREDS_CONTEXT_KEY

public static final String PREDS_CONTEXT_KEY
See Also:
Constant Field Values

SERVER

private static final boolean SERVER

XSD_ZERO_DURATION

private static final String XSD_ZERO_DURATION

XSD_ZERO_OFFSET

private static final String XSD_ZERO_OFFSET
See Also:
Constant Field Values

XSD_DATETIME_PATTERN

private static final String XSD_DATETIME_PATTERN

XSD_GMT_DATETIME_PATTERN

private static final String XSD_GMT_DATETIME_PATTERN

GMT_NAME

private static final String GMT_NAME
See Also:
Constant Field Values

GMT

private static final TimeZone GMT

XSD_GMT_DATETIME_FORMAT

private static final DateFormat XSD_GMT_DATETIME_FORMAT

XSD_DURATION_PREFIX

private static final String XSD_DURATION_PREFIX
See Also:
Constant Field Values

XSD_DATE_TIME_SEPARATOR

private static final String XSD_DATE_TIME_SEPARATOR
See Also:
Constant Field Values

XSD_DATE_SEPARATOR

private static final char XSD_DATE_SEPARATOR
See Also:
Constant Field Values

XSD_TIME_SEPARATOR

private static final char XSD_TIME_SEPARATOR
See Also:
Constant Field Values

XSD_DAY_DESIGNATOR

private static final char XSD_DAY_DESIGNATOR
See Also:
Constant Field Values

XSD_HOUR_DESIGNATOR

private static final char XSD_HOUR_DESIGNATOR
See Also:
Constant Field Values

XSD_MIN_DESIGNATOR

private static final char XSD_MIN_DESIGNATOR
See Also:
Constant Field Values

XSD_SEC_DESIGNATOR

private static final char XSD_SEC_DESIGNATOR
See Also:
Constant Field Values

XSD_UTC_DESIGNATOR

private static final char XSD_UTC_DESIGNATOR
See Also:
Constant Field Values

XSD_NEG

private static final String XSD_NEG
See Also:
Constant Field Values

XSD_POS

private static final String XSD_POS
See Also:
Constant Field Values

XSD_DATE_TIME_NAME

private static final String XSD_DATE_TIME_NAME
See Also:
Constant Field Values

XSD_DURATION_NAME

private static final String XSD_DURATION_NAME
See Also:
Constant Field Values

XSD_DOUBLE_NAME

private static final String XSD_DOUBLE_NAME
See Also:
Constant Field Values

XSD_INTEGER_NAME

private static final String XSD_INTEGER_NAME
See Also:
Constant Field Values

SORT_BY_OID

private static final Utils.SortByOID SORT_BY_OID

SORT_BY_ID

private static final Utils.SortByID SORT_BY_ID

INVALID_EMAIL_CHAR_REPLACEMENT

private static final char INVALID_EMAIL_CHAR_REPLACEMENT
See Also:
Constant Field Values

PENDING_USER_EMAIL_SUFFIX

private static final String PENDING_USER_EMAIL_SUFFIX
See Also:
Constant Field Values
Constructor Detail

Utils

public Utils()
Method Detail

getPersistable

public static Persistable getPersistable(long id,
                                         Class clss)
                                  throws WTException
Get the Persistable with the specified long ID that is an instance of the specified Class. If such an object does not exist, null is returned.

If id is zero, then null is returned (see ObjectIdentifier.UNASSIGNED_ID).

If clss is null, then the object is searched for among the WfExecutionObject objects.

Parameters:
id - the ID of the persistable
clss - the class of the persistable
Throws:
WTException

getId

public static long getId(Persistable p)
Get the object identifier of the specified Persistable. This returns the long ID value and not the ObjectIdentifier object.

Parameters:
p - the persistable to get the ID of
Returns:
the ID of the persistable

getProjectPlan

public static ProjectPlan getProjectPlan(Persistable p)
                                  throws WTException
Get the ProjectPlan for the specified Persistable. Throw an exception if the Persistable cannot have a ProjectPlan. Return null if the Persistable does not have a ProjectPlan

Parameters:
p - the persistable
Throws:
WTException

getUser

public static WTUser getUser(String fullName,
                             String email)
                      throws WTException
Get a WTUser based on the specified fullName and email. If both fullName and email are null then null is returned. The user to returned is determined using the following precedence rules:
  1. a registered user with the specified email
  2. a registered user with the specified fullName
  3. a pending user with the specified email
  4. a pending user with an email that is formed by appending @ to the fullName

If multiple users are considered equal based on the precedence rules then the first user found in the database is returned.

Parameters:
fullName - the full name of the user or null
email - the email address of the user or null
Returns:
a user or null
Throws:
WTException

getPendingUserEmail

public static String getPendingUserEmail(String fullName)
Return a string that is used as the email for a pending user with a known full name but an unknown email.

From RFC2822, the legal characters for an email address are the following: !"#$%&'*+-/0123456789=?ABCDEFGHIJKLMNOPQRSTUVWXYZ^_ `abcdefghijklmnopqrstuvwxyz{|}~

Since the email address is used to create a pending user, it also needs to be a valid name for a Windchill user. The name of a user is used as the name of that user's personal cabinet. A cabinet names cannot contain a forward slash. Therefoe, this email cannot contain a forward slash.

Parameters:
fullName - the full name of the pending user

getUserByFullName

public static WTUser getUserByFullName(String fullName)
                                throws WTException
Get a WTUser whose WTUser.FULL_NAME is equal to the specified fullName. If no such user exists return null. If the specified fullName is null then null is returned.

If multiple users with the same full name are found, only the first user is returned.

Parameters:
fullName - the full name of the user or null
Returns:
a user or null
Throws:
WTException

getPendingUser

public static WTUser getPendingUser(String email)
                             throws WTException
Get a pending user for the specified email address. Return null if the email address is null.

If multiple users are returned, then just return the first user int he list.

Parameters:
email - the email address of the pending user
Throws:
WTException
See Also:
OrganizationServicesManager.createPendingUser

getUserByEmail

public static WTUser getUserByEmail(String email)
                             throws WTException
Get a WTUser whose WTUser.EMAIL is equal to the specified email. If no such user exists return null. If the specified email is null then null is returned.

If multiple users with the same email are found, only the first user is returned.

Parameters:
email - the email address of the user or null
Returns:
a user or null
Throws:
WTException

getUserByEmail

private static WTUser getUserByEmail(String fullName,
                                     String email)
                              throws WTException
Throws:
WTException

findUser

private static Enumeration findUser(String attr_name,
                                    String attr_value)
                             throws WTException
Finds all users in all services that have the given value for the specified attribute.

This is a replacement for the following method which is now deprecated: {@link wt.org.OrganizationServicesManager#findUser(String, String)

Parameters:
attr_name - an attribute name defined in the class, e.g. WTUser.FULL_NAME, WTUser.EMAIL
attr_value - an attribute value to be matched
Throws:
WTException

getPersonResource

public static PersonResource getPersonResource(ProjectPlan plan,
                                               String name)
                                        throws WTException
Get a PersonResource with the specified name. If no such resource exists return null.

If multiple resources with the same name are found, only the first resource is returned. If name is null then null is returned.

Parameters:
plan - the project plan to look in
name - the name of the resource to find
Returns:
a person resource or null
Throws:
WTException

getPersonResource

public static PersonResource getPersonResource(ProjectPlan plan,
                                               WTUser user)
                                        throws WTException
Get a PersonResource that corresponds to the specified WTUser. If no such resource exists return null.

If multiple resources that correspond to the same user are found, only the first resource is returned.

Parameters:
plan - the project plan to look in
user - the user whose corresponding resource should be returned
Returns:
a person resource or null
Throws:
WTException

getProjectCategory

public static ProjectCategory getProjectCategory(String name)
Get the ProjectCategory with the specified name. If name does not map to a category, return the default category. If name is null then null is returned.


getProjectRiskValue

public static ProjectRiskValue getProjectRiskValue(String name)
Get the ProjectRiskValue with the specified name. If name does not map to a risk value, return the default risk value. If name is null then null is returned.


getProjectHealthStatus

public static ProjectHealthStatus getProjectHealthStatus(String name)
Get the ProjectHealthStatus with the specified name. If name does not map to a health status, return the default health status. If name is null then UNAVAILABLE is returned.


getProjectState

public static ProjectState getProjectState(String name)
Get the ProjectState with the specified name. If name does not map to a project state, return the default project state. If name is null then null is returned.


getOutlineLevel

public static int getOutlineLevel(ExecutionObject obj)
Get the OutlineLevel of the specified ExecutionObject. This returns wt.projmgmt.msproject.Constants.TASK0_OUTLINE_LEVEL if obj is not an instance of wt.projmmgt.execution.ProjectNode.


getParent

public static WfContainer getParent(ProjectNode child)
Get the parent of the specified ProjectNode.


getProjectNodes

public static Enumeration getProjectNodes(WfContainer c)
                                   throws WTException
Return the all children of the specified WfContainer sorted in the "canonical order". The list includes all children that have the specified container as an ancestor.

Throws:
WTException

getProjectResources

public static Enumeration getProjectResources(WfContainer c)
                                       throws WTException
Return all the wt.projmgmt.resources.ProjectResources that are used by activities in the specified WfContainer.

Parameters:
c - a ProjectPlan or SummaryActivity
Throws:
WTException

getResourceAssignments

public static Enumeration getResourceAssignments(WfContainer c)
                                          throws WTException
Return all the ResourceAssignmentLinks that are used by activities in the specified WfContainer.

Parameters:
c - a ProjectPlan or SummaryActivity
Throws:
WTException

addToSet

private static void addToSet(WfContainer c,
                             Set set,
                             boolean getResources)
                      throws WTException
A helper method used by getProjectResources(wt.workflow.engine.WfContainer) and getResourceAssignments(wt.workflow.engine.WfContainer). This method iterates through the container's children. If the child is a ProjectActivity then its resource assignment links or assigned resources (depending on the value of the getResources flag) are added to the set. If the child is a SummaryActivity then this method is called recursively on that summary activity. Otherwise, nothing is done with the child.

Parameters:
c - a ProjectPlan or SummaryActivity
getResources - true if resources should be added otherwise assignment links are added
Throws:
WTException

getMaxUnits

public static int getMaxUnits(ProjectResource resource)
Get the maximum number of units of the resource that can be used by this project plan.

For TimeResources this returns the maxPercentUtilization. For MaterialResources this returns the maxUnits. For any other resource types this method returns -1.


getResourceUnits

public static int getResourceUnits(Class resClass,
                                   String strUnits)
Get the number of units of the resource indicated by the specified String. The units returned are "normalized" based on the type of resource being assigned.

If no units are specified in strUnits then this method returns 0.


getExecutionObject

public static ExecutionObject getExecutionObject(ResourceAssignmentLink link)
                                          throws WTException
Get the ExecutionObject that is associated with the specified ResourceAssignmentLink. If no such object exists, return null.

NOTE: If the assignment's ResourceHolder is a ProjectActivity and the activity has a ProjectWorkItem then the work item is returned.

Parameters:
link - the resource assignment
Throws:
WTException

getWorkItem

public static ProjectWorkItem getWorkItem(ExecutionObject exObj,
                                          ProjectResource resource)
                                   throws WTException
Get the ProjectWorkItem that is associated with the specified ProjectResource and ExecutionObject. If no such work item exists, return null. If multiple work items exist, then only one work item is returned.

Parameters:
exObj - the execution object
resource - the resource
Throws:
WTException

isAllowStateChange

public static boolean isAllowStateChange(ExecutionObject exObj)
                                  throws WTException
Returns true if this wt.projmmgt.execution.ExecutionObject is in allow state change mode.

Parameters:
exObj - the execution object
Throws:
WTException

toWorkingHours

public static final TimeToElapse toWorkingHours(TimeToElapse workingDays)
Convert the specified working days to the number of working hours. The working hours amount only includes the actual amount of time worked on each day. So if there are 8 working hours per day then 5 working days equals 40 working hours.

Parameters:
workingDays - the working days

toWorkingDays

public static final TimeToElapse toWorkingDays(TimeToElapse workingHours)
Convert the specified working hours to the number of working days. The working hours amount only includes the actual amount of time worked on each day. So if there are 8 working hours per day then 5 working days equals 40 working hours.

Parameters:
workingHours - the working hours

toWork

public static final Work toWork(TimeToElapse duration)
Convert the specified TimeToElapse to a Work object that represents the equivalent amount of work.

Parameters:
duration - the duration to convert to work

getMillis

public static final long getMillis(Timestamp stamp)
Return the number of milliseconds in the specified Timestamp.


toXSDDateTime

public static final String toXSDDateTime(Timestamp stamp)
Returns a string that can be used as the value of an XML element whose type is xsd:dateTime. The date is represented in GMT. The xsd:dateTime includes the time zone offset (Z).


toXSDDateTime

public static final String toXSDDateTime(Date date)
Returns a string that can be used as the value of an XML element whose type is xsd:dateTime. The date is represented in GMT. The xsd:dateTime includes the time zone offset (Z).


toXSDDateTime

public static final String toXSDDateTime(Timestamp stamp,
                                         TimeZone tzone)
Returns a string that can be used as the value of an XML element whose type is xsd:dateTime. The date is represented in the specified TimeZone. The xsd:dateTime includes the time zone offset.


toXSDDateTime

public static final String toXSDDateTime(Date date,
                                         TimeZone tzone)
Returns a string that can be used as the value of an XML element whose type is xsd:dateTime. The date is represented in the specified TimeZone. The xsd:dateTime includes the time zone offset.


toXSDDateTime

public static final String toXSDDateTime(Timestamp stamp,
                                         TimeZone tzone,
                                         boolean withOffset)
Returns a string that can be used as the value of an XML element whose type is xsd:dateTime. The date is represented in the specified TimeZone. The value of withOffset determines whether or not the xsd:dateTime includes the time zone offset. If withOffset is true then the xsd:dateTime includes the time zone offset.


toXSDDateTime

public static final String toXSDDateTime(Date date,
                                         TimeZone tzone,
                                         boolean withOffset)
Returns a string that can be used as the value of an XML element whose type is xsd:dateTime. The date is represented in the specified TimeZone. The value of withOffset determines whether or not the xsd:dateTime includes the time zone offset. If withOffset is true then the xsd:dateTime includes the time zone offset.


getXSDDateTime

private static final String getXSDDateTime(Date date,
                                           TimeZone tzone,
                                           boolean withOffset)
Private helper method that is used by:


getOffset

public static final String getOffset(TimeZone tzone)
Returns a string representing the offset of the specified TimeZone from GMT. This is a string like -06:00.


parseXSDDateTime

public static final Timestamp parseXSDDateTime(String dateTime,
                                               TimeZone defaultTimeZone)
Returns a Timestamp that is constructed based on the specified xsd:dateTime string. If the time zone is not specified in the xsd:dateTime string then the specified defaultTimeZone is used. If the defaultTimeZone is null then GMT is used as the defaultTimeZone.

If an error occurs during parsing, null is returned.

Parameters:
dateTime - a date and time in xsd:dateTime format
defaultTimeZone - the time zone to use when it is not specified in the dateTime string
Returns:
a Timestamp or null

reportXSDParseError

private static final void reportXSDParseError(String xsdStr,
                                              String type,
                                              int pos)
Report an error that occured while parsing an XSD data type.


toXSDDuration

public static final String toXSDDuration(long ms)
Returns a string that can be used as the value of an XML element whose type is xsd:duration.


parseXSDDuration

public static final TimeToElapse parseXSDDuration(String duration)
Returns a TimeToElapse representing the amount of time in the specified xsd:duration. Returns null if the specified duration is not a valid xsd:duration.

This method currently only handles durations that contain days, hours, minutes, seconds and partial seconds.


parseXSDNumber

public static final Double parseXSDNumber(String number)
Returns a Double representing the value contained in the specified XSD numeric type. The specified argument can be an instance of xsd:decimal (?????), xsd:float, xsd:double or any types derived from these primitive types. Returns null if the specified value is null or not a valid XSD numeric value.


parseXSDInteger

public static final Long parseXSDInteger(String integer)
Returns a Long representing the value contained in the specified XSD integer type. The specified argument can be an instance of xsd:integer or any types derived from this type. Returns null if the specified value is null or not a valid XSD integer value.


parseXSDBoolean

public static final boolean parseXSDBoolean(String boo)
Returns a boolean representing the value contained in the specified XSD boolean type. The specified argument can be an instance of xsd:boolean or any types derived from this type. Returns false if the specified value is null or not a valid xsd:boolean value.


getPlannedStart

public static final Timestamp getPlannedStart(ExecutionObject exObj)
Get the planned start of the ExecutionObject that should be exported to Microsoft Project.

Parameters:
exObj - the execution object

getPlannedStart

public static final Timestamp getPlannedStart(WfExecutionObject exObj)
Get the planned start of the WfExecutionObject that should be exported to Microsoft Project.

Parameters:
exObj - the execution object

getPlannedStart

private static final Timestamp getPlannedStart(ExecutionObject exObj,
                                               TimeToElapse duration)
A helper method used by getPlannedStart(wt.projmgmt.execution.ExecutionObject) and getPlannedFinish(wt.projmgmt.execution.ExecutionObject) to get the planned start date of the ExecutionObject.


isStartAtEndOfDay

public static final boolean isStartAtEndOfDay(ExecutionObject exObj)
Returns true if exObj starts at the end of the day. See getStartAtEndSource(wt.projmgmt.execution.ExecutionObject, java.sql.Timestamp, wt.workflow.definer.TimeToElapse) for a definition of when an object starts at the end of the day.

See Also:
getStartAtEndSource(wt.projmgmt.execution.ExecutionObject, java.sql.Timestamp, wt.workflow.definer.TimeToElapse)

getStartAtEndSource

private static final ProjectNode getStartAtEndSource(ExecutionObject exObj,
                                                     Timestamp timeToStart,
                                                     TimeToElapse duration)
Return the source of the exObj's start date if it starts at the end of the day. This returns the node's ultimate predecessor that determines its end-of-day start time. If the node does not start at the end of the day then this method returns null.

This is a private helper method used by #isStartAtEndOfDay(WfExecutionObject) and #getPlannedStart(WfExecutionObject,TimeToElapse.

If duration is null then it will be computed inside this method.

A node starts at the end of the day when the following are true:

  1. timeToStart is computed
  2. duration is zero
  3. one of the following is true:
    1. the node starts at the same time as its parent and its parent starts at the end of the day
    2. the node has predecessors and its start time is equal to the finish time of one of those predecessors


getPlannedFinish

public static final Timestamp getPlannedFinish(ExecutionObject exObj)
Get the estimated finish of the ExecutionObject that should be exported to Microsoft Project.

Parameters:
exObj - the execution object

getActualStart

public static final Timestamp getActualStart(ExecutionObject exObj,
                                             TimeToElapse duration)
A helper method used by getActualStart(wt.projmgmt.execution.ExecutionObject, wt.workflow.definer.TimeToElapse) and getActualFinish(wt.projmgmt.execution.ExecutionObject) to get the planned start date of the ExecutionObject.


getActualStart

public static Timestamp getActualStart(ResourceAssignmentLink link)
                                throws WTException
Get the actual start of the ResourceAssignmentLink.

Throws:
WTException

getPlannedStart

public static Timestamp getPlannedStart(ResourceAssignmentLink link)
                                 throws WTException
Get the planned start of the ResourceAssignmentLink.

Throws:
WTException

getActualFinish

public static final Timestamp getActualFinish(ExecutionObject exObj)
Get the actual finish of the ExecutionObject that should be exported to Microsoft Project.

Parameters:
exObj - the execution object

getLatestWorkingDay

private static final Timestamp getLatestWorkingDay(ExecutionObject exObj,
                                                   Timestamp finish,
                                                   Timestamp start,
                                                   TimeToElapse duration)
Return the latest working date that is "less than or equal to" the specified finish date and that is also "greater than or equal to" the specified start date. Therefore, if finish is a working day then it is returned. If no date satisfies these constraints then finish is returned.

If start is null then it is computed inside this method if it is required.

NOTE: this is a private helper method used by getPlannedFinish(wt.projmgmt.execution.ExecutionObject) and getPlannedStart(wt.projmgmt.execution.ExecutionObject).

Parameters:
exObj - the execution object whose latest working day should be returned
finish - the object's finish date that has already been adjusted for working hours
start - the object's start date that has already been adjusted for working hours or null
duration - the object's working duration (no the elapsed duration)

getStart

private static final Timestamp getStart(ExecutionObject exObj)
This method calls the correct mthod based on the exObj's underlying type in order to get the planned start.


getDeadline

public static final Timestamp getDeadline(ExecutionObject exObj)
Get the deadline of the ExecutionObject that should be exported to Microsoft Project.

Parameters:
exObj - the execution object

alignTime

public static Timestamp alignTime(Timestamp stamp,
                                  boolean nextDay,
                                  boolean allowNonWorking)
                           throws WTException
Return the Timestamp that represents midnight in the current user's preferred TimeZone on the same day as the specified timestamp or on the day following the specified timestamp depending on the value of nextDay.

If nextDay is true then midnight on the next day is returned. Otherwise, midnight on the same day is returned.

Parameters:
stamp - the original timestamp
allowNonWorking - whether to allow a non working day or not
Throws:
WTException

alignTime

public static Timestamp alignTime(Timestamp stamp,
                                  WTUser aUser,
                                  boolean nextDay)
                           throws WTException
Return the Timestamp that represents midnight in the specified user's preferred TimeZone on the same day as the specified timestamp or on the day following the specified timestamp depending on the value of nextDay.

If nextDay is true then midnight on the next day is returned. Otherwise, midnight on the same day is returned.

Parameters:
stamp - the original timestamp
aUser - the user who timezone to align to
Throws:
WTException

alignTime

public static Timestamp alignTime(Timestamp stamp,
                                  TimeZone tzone,
                                  boolean nextDay,
                                  boolean allowNonWorking)
Return the Timestamp that represents midnight in the specified TimeZone on the same day as the specified timestamp or on the day following the specified timestamp depending on the value of nextDay.

If nextDay is true then midnight on the next day is returned. Otherwise, midnight on the same day is returned.

Parameters:
stamp - the original timestamp
tzone - the timezone
allowNonWorking - whether to allow a non working day or not

alignTime

public static Timestamp alignTime(Timestamp stamp,
                                  TimeZone tzone,
                                  boolean nextDay)
Return the Timestamp that represents midnight in the specified TimeZone on the same day as the specified timestamp or on the day following the specified timestamp depending on the value of nextDay.

If nextDay is true then midnight on the next day is returned. Otherwise, midnight on the same day is returned.

Parameters:
stamp - the original timestamp
tzone - the timezone

alignTime

public static Timestamp alignTime(Timestamp stamp,
                                  boolean nextDay)
                           throws WTException
Return the Timestamp that represents midnight in the current user's preferred TimeZone on the same day as the specified timestamp or on the day following the specified timestamp depending on the value of nextDay.

If nextDay is true then midnight on the next day is returned. Otherwise, midnight on the same day is returned.

Parameters:
stamp - the original timestamp
Throws:
WTException

getTitle

public static String getTitle(ExecutionObject exObj)
                       throws WTException
Get the title to use for the Microsoft Project Plan.

If the execution object is a ProjectPlan and belongs to a Project2 then the name of the project is used as the title rather than the name of the plan.

Throws:
WTException

getFilenameBase

public static String getFilenameBase(WfContainer c,
                                     Locale locale,
                                     String defVal)
                              throws WTException
Get a valid base for a filename based on the name of the specified WfContainer. If a valid filename cannot be constructed from the name of the container, then defVal is returned. If the container is not an instance of ExecutionObject then defVal is returned.

This method filters out characters that cannot appear in valid Windows filenames.

Throws:
WTException

getFilenameBase

public static String getFilenameBase(ExecutionObject exObj,
                                     Locale locale,
                                     String defVal)
                              throws WTException
Get a valid base for a filename based on the name of the specified ExecutionObject. If a valid filename cannot be constructed from the name of the object, then defVal is returned.

This method filters out characters that cannot appear in valid Windows filenames.

Throws:
WTException

getFilenameBase

public static String getFilenameBase(String base,
                                     Locale locale,
                                     String defVal)
Get a valid base for a filename based on the specified base name. If a valid filename cannot be constructed from the name, then defVal is returned.

This method filters out characters that cannot appear in valid Windows filenames.


printMap

public static void printMap(Map map)
Write out the key=>value pairs in the specified Map object.


getShortName

public static String getShortName(Class c)
Get the name of the specified class without the package name prepended. For example, if the class object for Class were passed as the argument, this method would return the string "Class".


getSubstringAfterLastPeriod

public static String getSubstringAfterLastPeriod(String s)
Get the substraing from the specified string that comes after the last period. For example, if the specified string is "Hello, my name is Joe. What's your name?" then the return value will be: " What's your name?".


encodeNewlines

public static String encodeNewlines(String str)
Filters out any newlines in str and replaces with Constants.NEWLINE_EXP_ENCODING, original function for status and risk descriptions


decodeNewlines

public static String decodeNewlines(String str)
Used for import (for status and risk descriptions, Replace the encoded newlines with real newlines.


replaceString

public static String replaceString(String sOrigStr,
                                   String replaceWhat,
                                   String replaceWith)
String replace function. Replaces all occurences in orig of replaceWhat with replaceWith If any of the three parameters are null, then the original string orig is returned