wt.projmgmt.msproject.mppobject
Class MPPPlan

java.lang.Object
  extended bywt.projmgmt.msproject.mppobject.MPPObject
      extended bywt.projmgmt.msproject.mppobject.MPPExecutionObject
          extended bywt.projmgmt.msproject.mppobject.MPPPlan
All Implemented Interfaces:
Comparable

public class MPPPlan
extends MPPExecutionObject

An object that represents data from a Microsoft Project Plan project. A project has tasks, resources and assignments.


Field Summary
private  Collection assignments
           
private  ProjectCategory category
           
private  Timestamp currentDate
           
private  int idOffset
           
private  ImportInfo importInfo
           
private  Timestamp now
           
private  ProjectPlan projectPlan
           
private static String RESOURCE
           
private  Map resources
           
private  List sortedTasks
           
private  Map tasks
           
 
Fields inherited from class wt.projmgmt.msproject.mppobject.MPPExecutionObject
 
Fields inherited from class wt.projmgmt.msproject.mppobject.MPPObject
 
Constructor Summary
MPPPlan()
           
 
Method Summary
 WTUser addAdministrator(WTUser user)
          If this project plan belongs to a ContainerTeamManaged, add the WTUser to the container's administrator role.
 void addAssignment(MPPAssignment assignment)
          Add a new resource assignment to this plan.
 WTUser addMember(WTUser user)
          If this project plan belongs to a ContainerTeamManaged, add the WTUser to the container's team.
private  WTUser addMember(WTUser user, Role role)
          If this project plan belongs to a ContainerTeamManaged, add the WTUser to the container's team.
private  int computeIdOffset()
          Compute the offset to be applied to a task's ID number.
protected  Persistable createPersistable()
          Create a new Persistable that is of the correct type for this object.
private  ExecutionObject fixRollup(WfContainer c, boolean nested)
          Adjusts the rollups of the plan MSP doesn't know about deliverables so this is called after importing to fix the rollups to coincide with project link.
 Collection getAssignments()
          Return the resource assignments for this plan.
 ProjectCategory getCategory()
          Get the category for this execution object that is specified in the XML.
 WfContainer getContainer()
          Get the persistable WfContainer that this plan object corresponds to.
 Timestamp getCurrentDate()
          Get the current date for this object's plan.
protected  String getGenericName()
          Return a generic name fo the this object.
 int getIdOffset()
          Return the offset that should be applied to a task's ID number when it is updated.
 ImportInfo getImportInfo()
          Return the ImportInfo that should be used when persisting this object.
 WTUser getManager()
          Get the manager of this project plan that is specified in the XML.
protected  String getNameElement()
          Return the name of the XML element that should be used to obtain the value of this object's name.
 MPPPlan getPlan()
          Get the plan that this object belongs to.
 ProjectPlan getProjectPlan()
          Get the ProjectPlan that contains this object.
 MPPResource getResource(long uid)
          Get the resource with the specified UID.
 Map getResources()
          Get the set of resources in this project.
 List getSortedTasks()
          Get the set of tasks in this project.
 MPPTask getTask(long uid)
          Get the task with the specified UID.
 Map getTasks()
          Get the set of tasks in this project.
private  WTRoleHolder2 getTeam()
          If this project plan belongs to a ContainerTeamManaged, return that container's team.
private  WTContainer getWTContainer()
          Get the WTContainer that this project plan belongs to.
 boolean isContainer()
          Return true if this object is a container for other project plan nodes.
protected  boolean isOwnable()
          Return true if the ownership of this object should be assigned to the owner specified in the XML.
 boolean isRollUpCost()
          Return true if the total cost and actual cost of this task are rolled-up.
 boolean isRollUpFinishDate()
          Return true if the estimated finish date of this task is rolled-up.
 boolean isRollUpPercentComplete()
          Return true if the percent complete of this task is rolled-up.
 boolean isRollUpWork()
          Return true if the total work and actual work of this task are rolled-up.
 boolean isStartAtEndOfDay()
          Returns true if the the object should start at the end of the working day instead of at the beginning.
 boolean isStartComputed()
          Return true if the planned start date of this task is computed.
protected  boolean isValidPersistable(Persistable p)
          Make sure that the specified Persistable is of the right type for this object.
private  void makeRoomForChildren(int childCount)
          Move all the nodes below the point where tasks are being inserted down to make room for the new tasks.
private  void saveAssignments()
          Update and save each of the assignments in this project plan.
private  void saveResources()
          Update and save each of the resources in this project plan.
private  void saveTasks()
          Update and save each of the tasks in this project plan.
private static void saveWithFeedback(Collection objects)
          Save the objects in the collection and report feedback to the client.
 void setContainer(WfContainer c)
          Set the persistable WfContainer that this plan object corresponds to.
 void setImportInfo(ImportInfo info)
          Set the ImportInfo that should be used when persisting this object.
 void setPlan(MPPPlan plan)
          Set the plan that this object belongs to.
 void setProjectPlan(ProjectPlan projectPlan)
          Set the ProjectPlan that corresponds to the project plan of this plan's persistable.
 void setResources(Map resources)
          Set the set of resources in this project.
 void setTasks(Map tasks)
          Set the set of tasks in this project.
private static void sortTasksAndRemoveIdGaps(List tasks)
          Sort the list of tasks and assign IDs to the tasks such that there are no gaps in the ID sequence.
protected  ExecutionObject updateName(ExecutionObject exObj)
          Don't update the name of the WfContainer being imported into.
 Persistable updatePersistable(Persistable p)
          Update values on the ExecutionObject based on the data in this MPPExecutionObject.
protected  ProjectPlan updateProjectPlan(ProjectPlan plan)
          Update the values that are specific to this ProjectPlan.
protected  WfExecutionObject updateTimeToStart(WfExecutionObject exObj)
          If the ProjectLink planned start date is being preserved then don't update timeToStart or isStartComputed.
protected  WfExecutionObject validatePlannedStart(WfExecutionObject wfExObj)
          Validate the imported planned start date.
 
Methods inherited from class wt.projmgmt.msproject.mppobject.MPPExecutionObject
addChild, alignTime, alignTime, doDataRollUp, getActualCost, getActualWork, getAlignedDeadline, getAlignedDuration, getAlignedEstimatedFinishDate, getAlignedTimeToStart, getChildren, getConstraintDate, getConstraintType, getCost, getDuration, getElapsedDuration, getEstimatedFinishDate, getExecutionObject, getExecutionState, getHealthStatus, getOwner, getPercentComplete, getPercentWorkComplete, getRiskDescription, getRiskValue, getRolledUpHealthStatus, getStatusDescription, getTimeToStart, getUser, getWork, getWorkingDays, isCreateTasksMode, isManualExecutionMode, isRollUpRequired, isRollUpStatus, isTrackCostsMode, isValidUpdateState, parseXSDDateTime, printNoUpdate, rollUpData, setRolledUpHealthStatus, updateCost, updateExecutionObject, updateWfExecutionObject, updateWork
 
Methods inherited from class wt.projmgmt.msproject.mppobject.MPPObject
compareTo, containsKey, entrySet, get, getID, getName, getObjectIdentifier, getPersistable, getPersistableClass, getPersistableID, getUID, keySet, print, printImpl, printMsg, printNoUpdate, printNoUpdate, printRollUp, printUpdate, printUpdate, put, refreshPersistable, savePersistable, setID, setPersistable, toString, updatePersistableCache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

now

private final Timestamp now

currentDate

private Timestamp currentDate

idOffset

private int idOffset

projectPlan

private ProjectPlan projectPlan

importInfo

private ImportInfo importInfo

category

private ProjectCategory category

tasks

private Map tasks

sortedTasks

private List sortedTasks

resources

private Map resources

assignments

private final Collection assignments
Constructor Detail

MPPPlan

public MPPPlan()
Method Detail

getGenericName

protected final String getGenericName()
Description copied from class: MPPObject
Return a generic name fo the this object. The object's ID is appended to the result of this method to form the object's name when it doesn't have a name.

Specified by:
getGenericName in class MPPObject

getNameElement

protected final String getNameElement()
Description copied from class: MPPObject
Return the name of the XML element that should be used to obtain the value of this object's name.

Specified by:
getNameElement in class MPPObject

getPlan

public final MPPPlan getPlan()
Description copied from class: MPPObject
Get the plan that this object belongs to.

Overrides:
getPlan in class MPPObject

setPlan

public final void setPlan(MPPPlan plan)
Description copied from class: MPPObject
Set the plan that this object belongs to.

Overrides:
setPlan in class MPPObject

isContainer

public final boolean isContainer()
Description copied from class: MPPObject
Return true if this object is a container for other project plan nodes. Plans, summary activities and subprojects are considered to be containers.

Overrides:
isContainer in class MPPObject

getCurrentDate

public Timestamp getCurrentDate()
Description copied from class: MPPObject
Get the current date for this object's plan.

Overrides:
getCurrentDate in class MPPObject

isStartComputed

public final boolean isStartComputed()
Return true if the planned start date of this task is computed. This method always returns false if getImportInfo().isImportStartDate() returns true. Otherwise, it returns super.isStartComputed().

Overrides:
isStartComputed in class MPPExecutionObject

isStartAtEndOfDay

public final boolean isStartAtEndOfDay()
Description copied from class: MPPExecutionObject
Returns true if the the object should start at the end of the working day instead of at the beginning.

Specified by:
isStartAtEndOfDay in class MPPExecutionObject

isRollUpFinishDate

public final boolean isRollUpFinishDate()
Description copied from class: MPPExecutionObject
Return true if the estimated finish date of this task is rolled-up.

Specified by:
isRollUpFinishDate in class MPPExecutionObject

isRollUpPercentComplete

public final boolean isRollUpPercentComplete()
Description copied from class: MPPExecutionObject
Return true if the percent complete of this task is rolled-up.

Specified by:
isRollUpPercentComplete in class MPPExecutionObject

isRollUpWork

public final boolean isRollUpWork()
Description copied from class: MPPExecutionObject
Return true if the total work and actual work of this task are rolled-up.

Specified by:
isRollUpWork in class MPPExecutionObject

isRollUpCost

public final boolean isRollUpCost()
Description copied from class: MPPExecutionObject
Return true if the total cost and actual cost of this task are rolled-up.

Specified by:
isRollUpCost in class MPPExecutionObject

getIdOffset

public final int getIdOffset()
Return the offset that should be applied to a task's ID number when it is updated. This accounts for cases when the target of the import is not a ProjectPlan.

In order to prevent the offset from being computed before the children of the import target have been deleted, this method throws an exception until updatePersistable(wt.fc.Persistable) is called.

Returns:
the offset to be applied to task ID numbers

computeIdOffset

private final int computeIdOffset()
                           throws WTException
Compute the offset to be applied to a task's ID number. This is called in updatePersistable(wt.fc.Persistable).

Throws:
WTException

getProjectPlan

public final ProjectPlan getProjectPlan()
Description copied from class: MPPObject
Get the ProjectPlan that contains this object.

Overrides:
getProjectPlan in class MPPObject

setProjectPlan

public final void setProjectPlan(ProjectPlan projectPlan)
Set the ProjectPlan that corresponds to the project plan of this plan's persistable. This persistable may or may not be the same persistable that is returned by the MPPObject.getPersistable() method.

This plan provides the container in which ProjectNodes and ProjectResources are created.

This method must be use to set the project plan before MPPObject.savePersistable() is called on this object.

Parameters:
projectPlan - the project plan that

getImportInfo

public ImportInfo getImportInfo()
Description copied from class: MPPObject
Return the ImportInfo that should be used when persisting this object.

Overrides:
getImportInfo in class MPPObject

setImportInfo

public void setImportInfo(ImportInfo info)
Set the ImportInfo that should be used when persisting this object.


getCategory

public final ProjectCategory getCategory()
Description copied from class: MPPExecutionObject
Get the category for this execution object that is specified in the XML.

Specified by:
getCategory in class MPPExecutionObject

isOwnable

protected final boolean isOwnable()
Description copied from class: MPPExecutionObject
Return true if the ownership of this object should be assigned to the owner specified in the XML.

Specified by:
isOwnable in class MPPExecutionObject

getManager

public final WTUser getManager()
                        throws WTException
Get the manager of this project plan that is specified in the XML.

Throws:
WTException

createPersistable

protected Persistable createPersistable()
                                 throws WTException
Description copied from class: MPPObject
Create a new Persistable that is of the correct type for this object.

Specified by:
createPersistable in class MPPObject
Throws:
WTException

updatePersistable

public Persistable updatePersistable(Persistable p)
                              throws WTException,
                                     WTPropertyVetoException
Description copied from class: MPPExecutionObject
Update values on the ExecutionObject based on the data in this MPPExecutionObject.

Subclass should call super.updatePersistable if they override this method so that the ExecutionObject and WfExecutionObject attributes are updated.

Overrides:
updatePersistable in class MPPExecutionObject
Throws:
WTException
WTPropertyVetoException

validatePlannedStart

protected final WfExecutionObject validatePlannedStart(WfExecutionObject wfExObj)
                                                throws WTException
Validate the imported planned start date.

Throws:
WTException

updateProjectPlan

protected final ProjectPlan updateProjectPlan(ProjectPlan plan)
                                       throws WTException,
                                              WTPropertyVetoException
Update the values that are specific to this ProjectPlan. These include the following values:

Throws:
WTException
WTPropertyVetoException

updateTimeToStart

protected final WfExecutionObject updateTimeToStart(WfExecutionObject exObj)
If the ProjectLink planned start date is being preserved then don't update timeToStart or isStartComputed.

Overrides:
updateTimeToStart in class MPPExecutionObject
Parameters:
exObj - the object to update

updateName

protected ExecutionObject updateName(ExecutionObject exObj)
                              throws WTException
Don't update the name of the WfContainer being imported into.

Overrides:
updateName in class MPPExecutionObject
Throws:
WTException

saveResources

private final void saveResources()
                          throws WTException,
                                 WTPropertyVetoException
Update and save each of the resources in this project plan.

Throws:
WTException
WTPropertyVetoException

saveTasks

private final void saveTasks()
                      throws WTException,
                             WTPropertyVetoException
Update and save each of the tasks in this project plan.

Throws:
WTException
WTPropertyVetoException

makeRoomForChildren

private final void makeRoomForChildren(int childCount)
                                throws WTException
Move all the nodes below the point where tasks are being inserted down to make room for the new tasks.

Throws:
WTException

saveAssignments

private final void saveAssignments()
                            throws WTException,
                                   WTPropertyVetoException
Update and save each of the assignments in this project plan.

Throws:
WTException
WTPropertyVetoException

isValidPersistable

protected boolean isValidPersistable(Persistable p)
                              throws WTException
Description copied from class: MPPObject
Make sure that the specified Persistable is of the right type for this object. Return false if null is passed to the method.

This class's implementation of this method ensures that the perisitable is in the right ProjectPlan. Subclasses that override this method should be sure to make a call to super so that this code is executed.

Overrides:
isValidPersistable in class MPPExecutionObject
Throws:
WTException

getContainer

public final WfContainer getContainer()
                               throws WTException
Get the persistable WfContainer that this plan object corresponds to.

Throws:
WTException
See Also:
wt.projmgmt.msproject.mppobject.MPPThing#getPersistable

setContainer

public final void setContainer(WfContainer c)
Set the persistable WfContainer that this plan object corresponds to.

Parameters:
c - the persistable container that this plan maps to
See Also:
wt.projmgmt.msproject.mppobject.MPPThing#setPersistable

getTask

public MPPTask getTask(long uid)
Get the task with the specified UID. This UID is from the XML file (this IDs is not the Windchill ObjectIdentifier ID).

Returns null if no such task exists.

Parameters:
uid - the task UID

getTasks

public Map getTasks()
Get the set of tasks in this project. The keys of the Map are the UIDs for the tasks from the XML file (these IDs are not the Windchill ObjectIdentifier IDs).

Returns:
a mapping from UIDs to tasks

setTasks

public void setTasks(Map tasks)
Set the set of tasks in this project. The keys of the Map are the UIDs for the tasks from the XML file (these IDs are not the Windchill ObjectIdentifier IDs).

The sorted tasks collection is also initialized.

Parameters:
tasks - the tasks for the project
Throws:
RuntimeException - if the tasks have already been set

getSortedTasks

public final List getSortedTasks()
Get the set of tasks in this project. A list of the tasks is returned. The list is sorted by the task's IDs.

Returns:
a sorted list of the tasks in this project plan

getResource

public MPPResource getResource(long uid)
Get the resource with the specified UID. This UID is from the XML file (this IDs is not necessarily the Windchill ObjectIdentifier ID).

Returns null if no such resource exists.

Parameters:
uid - the resource UID

getResources

public Map getResources()
Get the set of resources in this project. The keys of the Map are the UIDs for the resources from the XML file (these IDs are not necessarily the Windchill ObjectIdentifier IDs).

Returns:
a mapping from UIDs to resources

setResources

public void setResources(Map resources)
Set the set of resources in this project. The keys of the Map are the UIDs for the resources from the XML file (these IDs are not necessarily the Windchill ObjectIdentifier IDs).

Parameters:
resources - the resources for the project
Throws:
RuntimeException - if the resources have already been set

getAssignments

public Collection getAssignments()
Return the resource assignments for this plan.

Returns:
a collection of the plan's assignments

addAssignment

public void addAssignment(MPPAssignment assignment)
Add a new resource assignment to this plan.

Parameters:
assignment - the resource assignment

getWTContainer

private final WTContainer getWTContainer()
Get the WTContainer that this project plan belongs to.


getTeam

private final WTRoleHolder2 getTeam()
If this project plan belongs to a ContainerTeamManaged, return that container's team. Otherwise, return null.


addMember

public final WTUser addMember(WTUser user)
                       throws WTException
If this project plan belongs to a ContainerTeamManaged, add the WTUser to the container's team.

Throws:
WTException

addMember

private final WTUser addMember(WTUser user,
                               Role role)
                        throws WTException
If this project plan belongs to a ContainerTeamManaged, add the WTUser to the container's team.

Throws:
WTException

addAdministrator

public final WTUser addAdministrator(WTUser user)
                              throws WTException
If this project plan belongs to a ContainerTeamManaged, add the WTUser to the container's administrator role.

Throws:
WTException

sortTasksAndRemoveIdGaps

private static final void sortTasksAndRemoveIdGaps(List tasks)
Sort the list of tasks and assign IDs to the tasks such that there are no gaps in the ID sequence.

Parameters:
tasks - the tasks

saveWithFeedback

private static final void saveWithFeedback(Collection objects)
                                    throws WTException,
                                           WTPropertyVetoException
Save the objects in the collection and report feedback to the client.

Parameters:
objects - the objects to be saved
Throws:
WTException
WTPropertyVetoException

fixRollup

private ExecutionObject fixRollup(WfContainer c,
                                  boolean nested)
                           throws WTException
Adjusts the rollups of the plan MSP doesn't know about deliverables so this is called after importing to fix the rollups to coincide with project link. if nested is true, recursively goes through nested summaries and calls ProjMonitorHelper.service.rollUpValues if nested is false, only the top level passd in container is adjusted This is usually called in rollup deliverable mode. Also, it is called if the import mode is Append to make sure the plan is correct after adding new nodes.

Parameters:
c - starting point
nested - whether or not to traverse into summaries or not.
Throws:
WTException