Primavera Integration API 7.0

com.primavera.integration.util
Class BOHierarchyMap

java.lang.Object
  extended by com.primavera.integration.util.BOHierarchyMap

public class BOHierarchyMap
extends java.lang.Object

This utility class is used to aid in the building of hierarchies of business objects loaded from the database. The hierarchical business objects (ActivityCode, CostAccount, Document, EPS, FundingSource, OBS, ProjectCode, ResourceCode, Resource, Role, WBS) are usually retrieved from the database in a non-hierarchical order. Using this class can help ensure that the hierarchy is fully loaded.

Add business objects to the map using the addKey() method. When all business objects have been added, you can verify that the hierarchy is complete by calling validateIntegrity(). You can use the getRootKeys() method and recursively call the getKeyChildren() method to quickly traverse the entire hierarchy.

For dealing with incomplete hierarchies, there are getMissingParents(), getOrphans(), and moveOrphansToRoot() methods. An orphan is an object whose parent was specified when addKey was called, but whose parent object itself was never explicitly added.

To visually inspect the hierarchy, use the toString() method.


Constructor Summary
BOHierarchyMap()
          Class constructor
BOHierarchyMap(java.lang.String sName)
          Class constructor specifying a business object class name associated with this map
 
Method Summary
 void addKey(ObjectId objectId, ObjectId parentObjectId)
          Adds a new key to the map
 void addKey(ObjectId objectId, ObjectId parentObjectId, java.lang.Object oValue)
          Adds a new key and its value to the map
 void clear()
          Removes all mappings from this map.
 ObjectId[] getAllKeys()
          Gets all keys in this map
 ObjectId[] getKeyChildren(ObjectId objectId)
          Gets a key's children object ids
 ObjectId getKeyParent(ObjectId objectId)
          Gets a key's parent object id
 ObjectId[] getMissingParents()
          Gets ObjectIds of parents that were never added
 java.lang.String getName()
          Gets the name of the business object class associated with this map
 ObjectId[] getOrphans()
          Gets ObjectIds of all orphans (keys with parents that were never added)
 ObjectId[] getRootKeys()
          Gets the root key(s) in this map.
 java.util.Set<com.primavera.integration.util.KeyInfo> getUniqueValues()
          Gets all unique values in this map
 java.lang.Object getValue(ObjectId objectId)
          Gets the value for a particular key
 boolean isEmpty()
          Returns true if this map contains no key-value mappings.
 void moveOrphansToRoot()
          Moves all orphans (keys with parents that were never added) to the root
 void setName(java.lang.String sName)
          Sets the name of the business object class associated with this map
 void setValue(ObjectId objectId, java.lang.Object o)
          Sets the value for a particular key
 int size()
          Returns the number of key-value mappings in this map.
 java.lang.String toString()
          Gets a string representation of this object.
 void validateIntegrity()
          Checks the tree for parents that were never added.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BOHierarchyMap

public BOHierarchyMap()
Class constructor


BOHierarchyMap

public BOHierarchyMap(java.lang.String sName)
Class constructor specifying a business object class name associated with this map

Parameters:
sName - the name of the business object class name associated with this map
Method Detail

size

public int size()
Returns the number of key-value mappings in this map.

Returns:
int the number of key-value mappings in this map.

isEmpty

public boolean isEmpty()
Returns true if this map contains no key-value mappings.

Returns:
boolean true if this map contains no key-value mappings.

clear

public void clear()
Removes all mappings from this map.


setName

public void setName(java.lang.String sName)
Sets the name of the business object class associated with this map

Parameters:
sName - the class name

getName

public java.lang.String getName()
Gets the name of the business object class associated with this map

Returns:
String the name of the associated business object class

addKey

public void addKey(ObjectId objectId,
                   ObjectId parentObjectId)
Adds a new key to the map

Parameters:
objectId - the object id of the key
parentObjectId - the object id of the key's parent. This parameter is null for root keys

addKey

public void addKey(ObjectId objectId,
                   ObjectId parentObjectId,
                   java.lang.Object oValue)
Adds a new key and its value to the map

Parameters:
objectId - the object id of the key
parentObjectId - the object id of the key's parent. This parameter is null for root keys
oValue - the value associated with the key, usually the business object reference

setValue

public void setValue(ObjectId objectId,
                     java.lang.Object o)
              throws KeyNotFoundException
Sets the value for a particular key

Parameters:
objectId - the object id of the key
o - the value to be associated with the key
Throws:
KeyNotFoundException - if the key does not exist in the map

getValue

public java.lang.Object getValue(ObjectId objectId)
                          throws KeyNotFoundException
Gets the value for a particular key

Parameters:
objectId - the object id of the key
Returns:
Object the value to associated with the key, which can be null
Throws:
KeyNotFoundException - if the key does not exist in the map

getKeyParent

public ObjectId getKeyParent(ObjectId objectId)
                      throws KeyNotFoundException
Gets a key's parent object id

Parameters:
objectId - the object id of the key
Returns:
Object the object id of the key's parent
Throws:
KeyNotFoundException - if the key does not exist in the map

getKeyChildren

public ObjectId[] getKeyChildren(ObjectId objectId)
                          throws KeyNotFoundException
Gets a key's children object ids

Parameters:
objectId - the object id of the key
Returns:
Object[] the object ids of the key's children
Throws:
KeyNotFoundException - if the key does not exist in the map

getRootKeys

public ObjectId[] getRootKeys()
Gets the root key(s) in this map. A root key has no parent

Returns:
Object[] the object ids of the root key(s)

getAllKeys

public ObjectId[] getAllKeys()
Gets all keys in this map

Returns:
Object[] the object ids of the keys

getUniqueValues

public java.util.Set<com.primavera.integration.util.KeyInfo> getUniqueValues()
Gets all unique values in this map

Returns:
Set the set of unique values

getMissingParents

public ObjectId[] getMissingParents()
Gets ObjectIds of parents that were never added

Returns:
Object[] An array of missing parents

validateIntegrity

public void validateIntegrity()
                       throws KeyNotFoundException
Checks the tree for parents that were never added.

Throws:
KeyNotFoundException - if a parent was never added

getOrphans

public ObjectId[] getOrphans()
Gets ObjectIds of all orphans (keys with parents that were never added)

Returns:
Object[] An array of orphan objectIds

moveOrphansToRoot

public void moveOrphansToRoot()
Moves all orphans (keys with parents that were never added) to the root


toString

public java.lang.String toString()
Gets a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
the String representation of this object

Primavera Integration API 7.0

Copyright © 2003, 2009, Oracle and/or its affiliates. All rights reserved.