uk.co.agena.minerva.util.model
Class FamilyProcessor

java.lang.Object
  extended by uk.co.agena.minerva.util.model.FamilyProcessor

public abstract class FamilyProcessor
extends java.lang.Object

This abstract class contains various static utility methods for handling trees of FamilyMember objects.


Constructor Summary
FamilyProcessor()
           
 
Method Summary
static void generateParentIds(FamilyMember parent)
          Takes the supplied FamilyMember (that exists as the root of a family subtree) and goes through recursively setting the parent ID attributes of children using the ID of the parent.
static void generateParentIds(java.util.List roots)
          Assigns parent IDs to all children in a hierarchy.
static java.util.List getFamilyMembersWithParentID(java.util.List familyMemberList, int parentId)
          Takes a list of family members and returns a list of all the family members with the specified parent ID
static java.util.List linkFamilyMembers(java.util.List fms)
          Links the FamilyMembers in the list based on their IDs and parent IDs.
static java.util.List linkFamilyMembers(java.util.List familyMembers, java.util.List parentIds)
          Links up the supplied FamilyMembers into a family tree (that can have multiple roots).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FamilyProcessor

public FamilyProcessor()
Method Detail

linkFamilyMembers

public static java.util.List linkFamilyMembers(java.util.List fms)
                                        throws FamilyMemberException
Links the FamilyMembers in the list based on their IDs and parent IDs.

Parameters:
the - family members to be linked
Returns:
the root FamilyMembers in the hierarchy
Throws:
FamilyMemberException - if there is a problem linking the FamilyMembers to each other

linkFamilyMembers

public static java.util.List linkFamilyMembers(java.util.List familyMembers,
                                               java.util.List parentIds)
                                        throws FamilyMemberException
Links up the supplied FamilyMembers into a family tree (that can have multiple roots). Given a List of FamilyMembers and a corresponding List of parent IDs (such that the FamilyMember at position i in the first list has the parent with the ID at postion i in the second list), the FamilyMembers have their Lists of children set recursively. A List of the root FamilyMembers in the tree is returned. From these, all other FamilyMembers can be accessed via the hierarchy (i.e. via recursive calls to getChildren()).

Parameters:
familyMembers - the FamilyMembers to be connected
parentIds - the parent IDs of the FamilyMembers
Returns:
a List of root FamilyMembers
Throws:
FamilyMemberException

generateParentIds

public static void generateParentIds(java.util.List roots)
Assigns parent IDs to all children in a hierarchy. For a given parent, that parent's ID is assigned to the parent ID attribute of all of its children. This process continues recursively until the whole hierarchy has been handled.

Parameters:
roots - the root FamilyMembers of a hierarchy

generateParentIds

public static void generateParentIds(FamilyMember parent)
Takes the supplied FamilyMember (that exists as the root of a family subtree) and goes through recursively setting the parent ID attributes of children using the ID of the parent.

Parameters:
parent - the top-level parent in a family subtree

getFamilyMembersWithParentID

public static java.util.List getFamilyMembersWithParentID(java.util.List familyMemberList,
                                                          int parentId)
Takes a list of family members and returns a list of all the family members with the specified parent ID

Parameters:
familyMemberList - A list of family member objects
the - intetresting parent ID
Returns:


Copyright © 2006 Agena Ltd. All Rights Reserved.