wt.projmgmt.msproject.mppobject
Class MPPPlanBuilder

java.lang.Object
  extended bywt.projmgmt.msproject.DefaultSAXContentHandler
      extended bywt.projmgmt.msproject.ChildContentHandler
          extended bywt.projmgmt.msproject.mppobject.MPPObjectBuilder
              extended bywt.projmgmt.msproject.mppobject.MPPPlanBuilder
All Implemented Interfaces:
ContentHandler, ContentHandler

public class MPPPlanBuilder
extends MPPObjectBuilder

A ContentHandler that builds a MPPPlan from the data contained in a section of the document it is parsing.


Field Summary
private static int MAP_INIT_CAPACITY
           
private static String RESOURCE
           
 
Fields inherited from class wt.projmgmt.msproject.mppobject.MPPObjectBuilder
 
Fields inherited from class wt.projmgmt.msproject.ChildContentHandler
 
Constructor Summary
MPPPlanBuilder(ContentHandler parent)
          Create a handler that builds a MPPPlan from a particular portion of the document being scanned.
 
Method Summary
private static void addToStack(MPPTask task, Stack taskStack)
          This method is a utility method used by the #setParents method.
private static void assignResources(MPPPlan plan, Map asgnmts, Map tasks, Map resources)
          Add the specified assignments to the plan.
protected  MPPObject createObject()
          Create the MPPObject that should be populated by this builder.
private static MPPExecutionObject getInScopeParent(MPPTask task, TaskScope scope)
          Get the in scope parent for the specified task.
private static Map getInScopePredecessors(MPPTask task, Map tasks, TaskScope scope)
          Find the in scope predecessors for the specified task.
private static Map getInScopeTasks(Map tasks, TaskScope scope)
          Return the tasks in the specified Map that are in scope based on the import info.
 MPPPlan getPlan()
           
private static boolean isInScope(MPPTask task, TaskScope scope)
          Return true if the specified task is in scope (based on the import info).
protected  boolean isScopeEnd(String namespaceURL, String localName, String qName)
          Returns true when the specified element indicates the end of this handler's scope
protected  boolean isUnsupported(String namespaceURL, String localName, String qName)
          Returns true if the specified element contains data that should be ignored by this builder.
private  void processTask0(MPPTask task0)
          Copy the attributes from Task 0 to this builder's plan.
 void setAssignments(Map asgnmts)
          Add the valid resource assignments to their tasks.
private static void setParent(Collection tasks, MPPPlan plan)
          Build the parent/child relationships between the tasks.
private  void setPlan(Collection collection)
          Set the plan on each of the objects in the specified Collection.
 void setResources(Map resources)
          Set the resources on this builder's project plan object.
 void setTasks(Map tasks)
          Set the tasks on this builder's project plan object.
 
Methods inherited from class wt.projmgmt.msproject.mppobject.MPPObjectBuilder
characters, endElement, getObject, isObjectValid, reset, setScope, startElement
 
Methods inherited from class wt.projmgmt.msproject.ChildContentHandler
getDocumentLocator, getImportInfo, getParent, getReader, setDocumentLocator, setParent
 
Methods inherited from class wt.projmgmt.msproject.DefaultSAXContentHandler
endDocument, endPrefixMapping, ignorableWhitespace, outputEndElement, outputStartElement, processingInstruction, skippedEntity, startDocument, startPrefixMapping
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, skippedEntity, startDocument, startPrefixMapping
 

Field Detail

MAP_INIT_CAPACITY

private static final int MAP_INIT_CAPACITY
See Also:
Constant Field Values

RESOURCE

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

MPPPlanBuilder

public MPPPlanBuilder(ContentHandler parent)
Create a handler that builds a MPPPlan from a particular portion of the document being scanned.

When the end tag for the specified scope element is encontered, control is passed back to the parent handler.

Parameters:
parent - the parent handler
Method Detail

createObject

protected MPPObject createObject()
Description copied from class: MPPObjectBuilder
Create the MPPObject that should be populated by this builder.

Specified by:
createObject in class MPPObjectBuilder

getPlan

public final MPPPlan getPlan()

isUnsupported

protected boolean isUnsupported(String namespaceURL,
                                String localName,
                                String qName)
Description copied from class: MPPObjectBuilder
Returns true if the specified element contains data that should be ignored by this builder. If this returns true for a particular element, then control will be turned over to a IgnoreContentHandler until the element is complete.

Specified by:
isUnsupported in class MPPObjectBuilder

isScopeEnd

protected boolean isScopeEnd(String namespaceURL,
                             String localName,
                             String qName)
Description copied from class: MPPObjectBuilder
Returns true when the specified element indicates the end of this handler's scope

Overrides:
isScopeEnd in class MPPObjectBuilder

setTasks

public final void setTasks(Map tasks)
Set the tasks on this builder's project plan object. Before setting the tasks on the plan, pre-process the set of tasks based on the import settings. This involves the following actions:

setResources

public final void setResources(Map resources)
Set the resources on this builder's project plan object. Before setting the resources on the plan, set the plan of each resource to be this builder's plan.


setAssignments

public final void setAssignments(Map asgnmts)
Add the valid resource assignments to their tasks. A valid assignment is one for which the following is true:

setPlan

private final void setPlan(Collection collection)
Set the plan on each of the objects in the specified Collection.


processTask0

private final void processTask0(MPPTask task0)
Copy the attributes from Task 0 to this builder's plan.


setParent

private static final void setParent(Collection tasks,
                                    MPPPlan plan)
Build the parent/child relationships between the tasks.

Parameters:
tasks - a map of the tasks
plan - parent of tasks whose outline level equals 1

addToStack

private static final void addToStack(MPPTask task,
                                     Stack taskStack)
This method is a utility method used by the #setParents method.


getInScopeTasks

private static final Map getInScopeTasks(Map tasks,
                                         TaskScope scope)
Return the tasks in the specified Map that are in scope based on the import info. Also, make sure that the parent and predecessors of each task are in scope.


getInScopeParent

private static final MPPExecutionObject getInScopeParent(MPPTask task,
                                                         TaskScope scope)
Get the in scope parent for the specified task.


getInScopePredecessors

private static final Map getInScopePredecessors(MPPTask task,
                                                Map tasks,
                                                TaskScope scope)
Find the in scope predecessors for the specified task. A A Map is returned where the keys are the MS Project UID of the predecessors and the values are the ProjectLinkTypes. If no in scope predecessors exist then an empty map is returned.


isInScope

private static final boolean isInScope(MPPTask task,
                                       TaskScope scope)
Return true if the specified task is in scope (based on the import info). Otherwise, return false.

Blank line tasks are never in scope. These tasks have an outline level equal to zero and an ID number not equal to zero. The plan summary task (task 0) has an outline level equal to zero and an ID equal to zero. This tasks is Ok.


assignResources

private static final void assignResources(MPPPlan plan,
                                          Map asgnmts,
                                          Map tasks,
                                          Map resources)
Add the specified assignments to the plan. This method filters out invalid assignments.

An assignment is valid if both its task and its resource are available in the plan and its task is an activity.

Microsoft Project supports creating assignments with more task types than ProjectLink. This method filters out the assignments that are not supported by ProjectLink.