Package com.primavera.integration.util
Class BOHierarchyMap
java.lang.Object
com.primavera.integration.util.BOHierarchyMap
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
ConstructorsConstructorDescriptionClass constructorBOHierarchyMap(String sName) Class constructor specifying a business object class name associated with this map -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new key to the mapvoidAdds a new key and its value to the mapvoidclear()Removes all mappings from this map.ObjectId[]Gets all keys in this mapObjectId[]getKeyChildren(ObjectId objectId) Gets a key's children object idsgetKeyParent(ObjectId objectId) Gets a key's parent object idObjectId[]Gets ObjectIds of parents that were never addedgetName()Gets the name of the business object class associated with this mapObjectId[]Gets ObjectIds of all orphans (keys with parents that were never added)ObjectId[]Gets the root key(s) in this map.Set<com.primavera.integration.util.KeyInfo>Gets all unique values in this mapGets the value for a particular keybooleanisEmpty()Returns true if this map contains no key-value mappings.voidMoves all orphans (keys with parents that were never added) to the rootvoidSets the name of the business object class associated with this mapvoidSets the value for a particular keyintsize()Returns the number of key-value mappings in this map.toString()Gets a string representation of this object.voidChecks the tree for parents that were never added.
-
Constructor Details
-
BOHierarchyMap
public BOHierarchyMap()Class constructor -
BOHierarchyMap
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 Details
-
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
Sets the name of the business object class associated with this map- Parameters:
sName- the class name
-
getName
Gets the name of the business object class associated with this map- Returns:
- String the name of the associated business object class
-
addKey
Adds a new key to the map- Parameters:
objectId- the object id of the keyparentObjectId- the object id of the key's parent. This parameter is null for root keys
-
addKey
Adds a new key and its value to the map- Parameters:
objectId- the object id of the keyparentObjectId- the object id of the key's parent. This parameter is null for root keysoValue- the value associated with the key, usually the business object reference
-
setValue
Sets the value for a particular key- Parameters:
objectId- the object id of the keyo- the value to be associated with the key- Throws:
KeyNotFoundException- if the key does not exist in the map
-
getValue
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
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
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
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
Gets all keys in this map- Returns:
- Object[] the object ids of the keys
-
getUniqueValues
Gets all unique values in this map- Returns:
- Set the set of unique values
-
getMissingParents
Gets ObjectIds of parents that were never added- Returns:
- Object[] An array of missing parents
-
validateIntegrity
Checks the tree for parents that were never added.- Throws:
KeyNotFoundException- if a parent was never added
-
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
Gets a string representation of this object.
-