wt.projmgmt.msproject.mppobject
Class MPPObject

java.lang.Object
  extended bywt.projmgmt.msproject.mppobject.MPPObject
All Implemented Interfaces:
Comparable
Direct Known Subclasses:
MPPAssignment, MPPExecutionObject, MPPResource

public abstract class MPPObject
extends Object
implements Comparable

An object that represents data from a Microsoft Project Plan.


Field Summary
private  int id
           
private  Map map
           
private static int MAP_INIT_CAPACITY
           
private  Persistable persistable
           
private  MPPPlan plan
           
 
Constructor Summary
MPPObject()
           
 
Method Summary
 int compareTo(Object o)
          Instances of MPPObject are naturally ordered according to their ID numbers.
 boolean containsKey(String key)
          Returns true if this object contains a mapping for the specified key.
protected abstract  Persistable createPersistable()
          Create a new Persistable that is of the correct type for this object.
 Set entrySet()
          Returns a set view of the mappings contained in this map.
 String get(String key)
          Returns the value to which this object maps the specified key.
 Timestamp getCurrentDate()
          Get the current date for this object's plan.
protected abstract  String getGenericName()
          Return a generic name fo the this object.
 int getID()
          Get the value of the object's ID attribute.
 ImportInfo getImportInfo()
          Return the ImportInfo that should be used when persisting this object.
 String getName()
          Return the name assigned to this object.
protected abstract  String getNameElement()
          Return the name of the XML element that should be used to obtain the value of this object's name.
 ObjectIdentifier getObjectIdentifier()
          Get the object's ObjectIdentifier.
 Persistable getPersistable()
          Get the Persistable object that this object maps to.
 Class getPersistableClass()
          Retutn the Class of this object's Persistable.
 long getPersistableID()
          Retutn the ID of this object's Persistable.
 MPPPlan getPlan()
          Get the plan that this object belongs to.
 ProjectPlan getProjectPlan()
          Get the ProjectPlan that contains this object.
 long getUID()
          Get the value of the object's UID attribute.
 boolean isContainer()
          Return true if this object is a container for other project plan nodes.
protected  boolean isValidPersistable(Persistable p)
          Make sure that the specified Persistable is of the right type for this object.
 Set keySet()
          Returns a set view of the keys contained in this object.
 void print()
           
protected  void printImpl()
           
protected  void printMsg(String msg)
          Print out a message.
protected  void printNoUpdate(String key)
          Print out a message indicating that an attribute is being skipped.
protected  void printNoUpdate(String key, String msg)
          Print out a message indicating that an attribute is being skipped and the reason why it is being skipped.
protected  void printRollUp(String key)
          Print out a message indicating that an attribute is being rolled-up.
protected  void printUpdate(String key)
          Print out a message indicating what attribute is being updated.
protected  void printUpdate(String key, Object value)
          Print out a message indicating what attribute is being updated.
 String put(String key, String value)
          Associates the specified value with the specified key in this object.
protected  Persistable refreshPersistable()
          Retrieve the Persistable that corresponds to this object from the database.
 Persistable savePersistable()
          Update and save the persistable that coresponds to this object.
protected  void setID(int id)
          Set the value of the object's ID attribute.
protected  void setPersistable(Persistable p)
          Set the persistable that this object maps to.
 void setPlan(MPPPlan plan)
          Set the plan that this object belongs to.
 String toString()
           
protected abstract  Persistable updatePersistable(Persistable p)
          Update the specified Persistable with the data in this object.
protected  void updatePersistableCache(Persistable p)
          Update the persistable cache on this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAP_INIT_CAPACITY

private static final int MAP_INIT_CAPACITY
See Also:
Constant Field Values

id

private int id

plan

private MPPPlan plan

persistable

private Persistable persistable

map

private final Map map
Constructor Detail

MPPObject

public MPPObject()
Method Detail

getName

public String getName()
Return the name assigned to this object.


getGenericName

protected abstract String getGenericName()
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.


getNameElement

protected abstract String getNameElement()
Return the name of the XML element that should be used to obtain the value of this object's name.


compareTo

public int compareTo(Object o)
Instances of MPPObject are naturally ordered according to their ID numbers.

Specified by:
compareTo in interface Comparable

getID

public final int getID()
Get the value of the object's ID attribute. This is the value of this object's ID element in the XML file.

Throws:
RuntimeException - if the object does not have an ID or its ID is malformed.

setID

protected final void setID(int id)
Set the value of the object's ID attribute.

When there are gaps in the sequence of ID that are contained in the XML data this method is used to reassign IDs so that the gaps are removed.

Parameters:
id - the object's ID

getUID

public long getUID()
Get the value of the object's UID attribute. This is the value of this object's UID element in the XML file.


getPlan

public MPPPlan getPlan()
Get the plan that this object belongs to.


setPlan

public void setPlan(MPPPlan plan)
Set the plan that this object belongs to.

Throws:
RuntimeException - if the plan has already been set

isContainer

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


getProjectPlan

public ProjectPlan getProjectPlan()
Get the ProjectPlan that contains this object.


getCurrentDate

public Timestamp getCurrentDate()
Get the current date for this object's plan.


getImportInfo

public ImportInfo getImportInfo()
Return the ImportInfo that should be used when persisting this object.


getPersistableID

public final long getPersistableID()
Retutn the ID of this object's Persistable.

If the object has not been mapped to a persistable yet then this returns the long specified by it's Constants.ID_ALIAS extended attribute. If this ID is malformed (or no ID is specified) then zero is returned (see ObjectIdentifier.UNASSIGNED_ID).


getPersistableClass

public final Class getPersistableClass()
Retutn the Class of this object's Persistable.

If the object has not been mapped to a persistable yet then this return the Class specified by it's Constants.CLASS_ALIAS extended attribute. If the class is not found (or no class is specified) return null.


getObjectIdentifier

public ObjectIdentifier getObjectIdentifier()
Get the object's ObjectIdentifier. The OID is obtained by using two extended attributes. One attribute contains the object's long id value (Constants.ID_ALIAS) and the other contains the object's Java class name (Constants.CLASS_ALIAS).

Returns null if the object does not have an OID or the OID data is malformed.


getPersistable

public final Persistable getPersistable()
                                 throws WTException
Get the Persistable object that this object maps to. Return null if no such persistable exists.

Throws:
WTException

setPersistable

protected final void setPersistable(Persistable p)
Set the persistable that this object maps to. This method can be used to specify an object to update other than the object specified by the XML.


updatePersistableCache

protected final void updatePersistableCache(Persistable p)
Update the persistable cache on this object. This method allows instances to update their own cache if necessary.


refreshPersistable

protected Persistable refreshPersistable()
                                  throws WTException
Retrieve the Persistable that corresponds to this object from the database. Return null if no such persistable exists.

Throws:
WTException

createPersistable

protected abstract Persistable createPersistable()
                                          throws WTException
Create a new Persistable that is of the correct type for this object.

Throws:
WTException

isValidPersistable

protected boolean isValidPersistable(Persistable p)
                              throws WTException
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.

Throws:
WTException

savePersistable

public final Persistable savePersistable()
                                  throws WTException,
                                         WTPropertyVetoException
Update and save the persistable that coresponds to this object. If a persistable does not exist, first create it.

Throws:
WTException
WTPropertyVetoException

updatePersistable

protected abstract Persistable updatePersistable(Persistable p)
                                          throws WTException,
                                                 WTPropertyVetoException
Update the specified Persistable with the data in this object.

Throws:
WTException
WTPropertyVetoException

get

public String get(String key)
Returns the value to which this object maps the specified key. Returns null if the object contains no mapping for this key.

Parameters:
key - key whose associated value is to be returned
Returns:
the value to which this map maps the specified key, or null if the object contains no mapping for this key

put

public String put(String key,
                  String value)
Associates the specified value with the specified key in this object. If the object previously contained a mapping for this key, the old value is replaced.

Parameters:
key - key with which the specified value is to be associated
value - value to be associated with the specified key
Returns:
previous value associated with specified key, or null if there was no mapping for key.

containsKey

public boolean containsKey(String key)
Returns true if this object contains a mapping for the specified key.

Parameters:
key - key whose presence in this object is to be tested
Returns:
true if this object contains a mapping for the specified key

keySet

public Set keySet()
Returns a set view of the keys contained in this object. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll retainAll, and clear operations. It does not support the add or addAll operations.

Returns:
a set view of the keys contained in this object

entrySet

public Set entrySet()
Returns a set view of the mappings contained in this map. Each element in the returned set is a Map.Entry. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

Returns:
a set view of the mappings contained in this map

toString

public String toString()

print

public final void print()

printImpl

protected void printImpl()

printUpdate

protected final void printUpdate(String key)
Print out a message indicating what attribute is being updated.

Parameters:
key - the name of the attribute being updated

printUpdate

protected final void printUpdate(String key,
                                 Object value)
Print out a message indicating what attribute is being updated.

Parameters:
key - the name of the attribute being updated
value - the value that is being used to update the arttribute

printNoUpdate

protected final void printNoUpdate(String key)
Print out a message indicating that an attribute is being skipped.

Parameters:
key - the name of the attribute being skipped

printNoUpdate

protected final void printNoUpdate(String key,
                                   String msg)
Print out a message indicating that an attribute is being skipped and the reason why it is being skipped.

Parameters:
key - the name of the attribute being skipped
msg - the reason why it is being skipped

printRollUp

protected final void printRollUp(String key)
Print out a message indicating that an attribute is being rolled-up. Also print out the value that was specified in the XML file. This is the value that is being ignored in favor of rolling up the value.

Parameters:
key - the name of the attribute being skipped

printMsg

protected final void printMsg(String msg)
Print out a message.

Parameters:
msg - the message to print out