org.LexGrid.LexBIG.Impl.helpers.graph
Class GHolder

java.lang.Object
  extended by org.LexGrid.LexBIG.Impl.helpers.graph.GHolder

public class GHolder
extends java.lang.Object

Class to help me get from the SQL database to the graph object.

Version:
subversion $Revision: $ checked in on $Date: $
Author:
Dan Armbrust, Thomas Johnson, Jesse Erdmann, Kevin Peterson

Constructor Summary
GHolder(java.lang.String internalCodingSchemeName, java.lang.String internalVersionString, ConceptReference focusNode, boolean resolveForward, boolean resolveReverse)
          Constructs a new container to hold concept graph representations.
 
Method Summary
 ConceptReference addAssociation(java.lang.String sourceCodeSystem, java.lang.String sourceCodeNamespace, java.lang.String sourceCode, java.lang.String[] sourceCodeTypes, java.lang.String sourceCodeEntityDescription, java.lang.String relationName, java.lang.String associationName, java.lang.String targetCodeSystem, java.lang.String targetCodeNamespace, java.lang.String targetCode, java.lang.String[] targetCodeTypes, java.lang.String targetCodeEntityDescription, NameAndValueList qualifiers, boolean forward, java.lang.String internalCodeSystemName, java.lang.String internalVersionString)
          Add an edge to the graph.
protected  void addAssociationChildren(GNode oldParent, GAssociation oldAssoc, GNode newParent, GAssociation newAssoc)
          Copy child nodes from the old parent/association to the new.
 void addAssociationInfo(java.lang.String sourceCodeSystem, java.lang.String sourceCodeNamespace, java.lang.String sourceCode, java.lang.String[] sourceCodeTypes, java.lang.String sourceCodeEntityDescription, java.lang.String relationName, java.lang.String associationName, java.lang.String targetCodeSystem, java.lang.String targetCodeNamespace, java.lang.String targetCode, java.lang.String[] targetCodeTypes, java.lang.String targetCodeEntityDescription, NameAndValueList qualifiers, boolean forward, java.lang.String internalCodeSystemName, java.lang.String internalVersionString)
          Add an edge to the graph.
protected  void addNode(GNode node)
          Basic addition of a node to those tracked by the graph.
 ConceptReference addNode(java.lang.String codeSystem, java.lang.String codeNamespace, java.lang.String code, java.lang.String[] codeTypes, java.lang.String entityDescription, java.lang.String internalCodeSystemName, java.lang.String internalVersion, boolean forward)
          Returns a graph node based on the given information; a new node is added to the graph if necessary.
protected  AssociationList buildAssociationList(GNode node, boolean forward, int currentDepth, int resolveCodedEntryDepth, int resolveAssociationDepth, LocalNameList restrictToProperties, CodedNodeSet.PropertyType[] restrictToPropertyTypes, SortOptionList sortBy, Filter[] filters, boolean keepLastAssociationLevelUnresolved)
          Create and return the list of associations for the given node, resolved to the specified depth and modified according to parameter values.
protected  ResolvedConceptReference buildResolvedConceptReference(GNode currentNode, int resolveCodedEntryDepth, int resolveAssociationDepth, LocalNameList restrictToProperties, CodedNodeSet.PropertyType[] restrictToPropertyTypes, SortOptionList sortByProperty, Filter[] filters, boolean keepLastAssociationLevelUnresolved)
           
protected  GAssociationInfo getAssociationInfo(java.lang.String internalCodeSystemName, java.lang.String internalVersionString, java.lang.String associationName, java.lang.String relationName)
          Returns a shared structure containing identifying information for the given association; a new information object is automatically created if necessary.
protected  java.util.Iterator<GNode> getChildlessNodes(SortOptionList sortBy)
          Returns all nodes maintained by the graph that are target but not source of any relationship.
protected  GNode getNode(java.lang.String codeSystem, java.lang.String codeNamespace, java.lang.String code, java.lang.String[] codeTypes, java.lang.String entityDescription, boolean flagParentlessIfNew, boolean flagChildlessIfNew, java.lang.String internalCodeSystemName, java.lang.String internalVersionString, java.lang.String associationName)
          Locates and returns a graph node based on the given information; a new node is added to the graph if necessary.
 int getNodeCount()
          Returns the total number of nodes tracked by the graph.
 CodedNodeSet getNodeList()
           
protected  java.util.Iterator<GNode> getParentlessNodes(SortOptionList sortBy)
          Returns all nodes maintained by the graph that are source but not target of any relationship.
 ResolvedConceptReferenceList getResolvedConceptReferenceList(int resolveCodedEntryDepth, int resolveAssociationDepth, LocalNameList restrictToProperties, CodedNodeSet.PropertyType[] restrictToPropertyTypes, SortOptionList sortByProperty, LocalNameList filterOptions, boolean keepLastAssociationLevelUnresolved)
          Returns the fully resolved contents of the graph.
protected  java.util.Iterator<GNode> getSortedNodeIterator(SortOptionList sortBy, java.util.Set<GNode> nodes)
          Returns an iterator that will sort the given nodes according to the specified sort options.
 void intersection(GHolder holder)
          Performs a boolean intersection of this graph holder with another.
protected  boolean isResultsSkipped()
           
protected  void listHelper(ResolvedConceptReferenceList list, GNode currentNode, int resolveCodedEntryDepth, int resolveAssociationDepth, LocalNameList restrictToProperties, CodedNodeSet.PropertyType[] restrictToPropertyTypes, SortOptionList sortByProperty, Filter[] filters, boolean keepLastAssociationLevelUnresolved)
           
protected  void removeNode(java.lang.String nodeKey)
          Removes the node identified by the given key from those tracked by the graph.
protected  void resetNodePrintedFlags()
          For each node that is tracked, this class maintains an indication of whether or not the node has been included in the results in order to prevent recursion.
 void setResultsSkipped(boolean resultsSkipped)
           
 java.lang.String toString()
           
 void union(GHolder holder)
          Performs a boolean union of this graph holder with another.
protected  Filter[] validateFilters(LocalNameList filterOptions)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GHolder

public GHolder(java.lang.String internalCodingSchemeName,
               java.lang.String internalVersionString,
               ConceptReference focusNode,
               boolean resolveForward,
               boolean resolveReverse)
Constructs a new container to hold concept graph representations.

Parameters:
internalCodingSchemeName - The coding scheme name for associated nodes; not null.
internalVersionString - The coding scheme version for associated nodes; not null.
focusNode - The starting point for resolved relations; null for absolute root.
resolveForward - Whether relations are to be resolved in the forward direction.
resolveReverse - Whether relations are to be resolved in the reverse direction.
Method Detail

addAssociation

public ConceptReference addAssociation(java.lang.String sourceCodeSystem,
                                       java.lang.String sourceCodeNamespace,
                                       java.lang.String sourceCode,
                                       java.lang.String[] sourceCodeTypes,
                                       java.lang.String sourceCodeEntityDescription,
                                       java.lang.String relationName,
                                       java.lang.String associationName,
                                       java.lang.String targetCodeSystem,
                                       java.lang.String targetCodeNamespace,
                                       java.lang.String targetCode,
                                       java.lang.String[] targetCodeTypes,
                                       java.lang.String targetCodeEntityDescription,
                                       NameAndValueList qualifiers,
                                       boolean forward,
                                       java.lang.String internalCodeSystemName,
                                       java.lang.String internalVersionString)
                                throws MissingResourceException,
                                       UnexpectedInternalError,
                                       LBParameterException
Add an edge to the graph.

If the association is new, return a reference to the concept defined by the association endpoint based on specified direction (if forward, this is the target concept; if reverse, it is the source concept). If the association is already defined, returns null.

Parameters:
sourceCodeSystem -
sourceCodeNamespace -
sourceCode -
sourceCodeTypes -
relationName -
associationName -
targetCodeSystem -
targetCodeNamespace -
targetCode -
targetCodeTypes -
qualifiers -
forward -
internalCodeSystemName -
internalVersionString -
Returns:
org.LexGrid.LexBIG.DataModel.Core.ConceptReference
Throws:
MissingResourceException
UnexpectedInternalError
LBParameterException

addAssociationInfo

public void addAssociationInfo(java.lang.String sourceCodeSystem,
                               java.lang.String sourceCodeNamespace,
                               java.lang.String sourceCode,
                               java.lang.String[] sourceCodeTypes,
                               java.lang.String sourceCodeEntityDescription,
                               java.lang.String relationName,
                               java.lang.String associationName,
                               java.lang.String targetCodeSystem,
                               java.lang.String targetCodeNamespace,
                               java.lang.String targetCode,
                               java.lang.String[] targetCodeTypes,
                               java.lang.String targetCodeEntityDescription,
                               NameAndValueList qualifiers,
                               boolean forward,
                               java.lang.String internalCodeSystemName,
                               java.lang.String internalVersionString)
                        throws MissingResourceException,
                               UnexpectedInternalError,
                               LBParameterException
Add an edge to the graph.

If the association is new, return a reference to the concept defined by the association endpoint based on specified direction (if forward, this is the target concept; if reverse, it is the source concept). If the association is already defined, returns null.

Parameters:
sourceCodeSystem -
sourceCodeNamespace -
sourceCode -
sourceCodeTypes -
relationName -
associationName -
targetCodeSystem -
targetCodeNamespace -
targetCode -
targetCodeTypes -
qualifiers -
forward -
internalCodeSystemName -
internalVersionString -
Throws:
MissingResourceException
UnexpectedInternalError
LBParameterException

addAssociationChildren

protected void addAssociationChildren(GNode oldParent,
                                      GAssociation oldAssoc,
                                      GNode newParent,
                                      GAssociation newAssoc)
Copy child nodes from the old parent/association to the new.

Parameters:
oldParent -
oldAssoc -
newParent -
newAssoc -

addNode

protected void addNode(GNode node)
Basic addition of a node to those tracked by the graph.

Parameters:
node -

addNode

public ConceptReference addNode(java.lang.String codeSystem,
                                java.lang.String codeNamespace,
                                java.lang.String code,
                                java.lang.String[] codeTypes,
                                java.lang.String entityDescription,
                                java.lang.String internalCodeSystemName,
                                java.lang.String internalVersion,
                                boolean forward)
                         throws MissingResourceException,
                                UnexpectedInternalError
Returns a graph node based on the given information; a new node is added to the graph if necessary.

Parameters:
codeSystem -
codeNamespace -
code -
codeTypes -
internalCodeSystemName -
internalVersion -
forward -
Returns:
A GNode based on the provided info; not null.
Throws:
MissingResourceException
UnexpectedInternalError

buildAssociationList

protected AssociationList buildAssociationList(GNode node,
                                               boolean forward,
                                               int currentDepth,
                                               int resolveCodedEntryDepth,
                                               int resolveAssociationDepth,
                                               LocalNameList restrictToProperties,
                                               CodedNodeSet.PropertyType[] restrictToPropertyTypes,
                                               SortOptionList sortBy,
                                               Filter[] filters,
                                               boolean keepLastAssociationLevelUnresolved)
                                        throws LBParameterException,
                                               UnexpectedInternalError,
                                               MissingResourceException
Create and return the list of associations for the given node, resolved to the specified depth and modified according to parameter values. The method will recurse as necessary to achieve the requested depth.

Parameters:
node - Focus node.
forward - Indicates whether the we are resolving source or target relations for the node.
currentDepth - Tracks depth for purposes of recursion.
resolveCodedEntryDepth - Depth in the graph to resolve coded entries. -1 means don't resolve anything - just return the concept references, 0 means resolve just the root nodes, 1 means resolve 1 deep, etc.
resolveAssociationDepth - Number of hops to resolve associations. 0 means leave all associations unresolved, 1 means immediate neighbors, etc. -1 means follow the entire closure of the graph.
propertyNames - Local names of properties to resolve. If not empty and not null, only properties matching the given names are included for resolved concepts.
propertyTypes - Indicates whether to resolve only specific property categories, regardless of the assigned name. Any of the enumerated PropertyType values can be specified. If not empty and not null, only properties matching the given types are included for resolved concepts.
sortOptions - List of sort options to apply during resolution. If supplied, the sort algorithms will be applied in the order provided. Any algorithms not valid to be applied in context of node set iteration, as specified in the sort extension description, will result in a parameter exception. Available algorithms can be retrieved through the LexBIGService getSortExtensions() method after being defined to the LexBIGServiceManager extension registry.
filters -
Returns:
org.LexGrid.LexBIG.DataModel.Collections.AssociationList
Throws:
LBParameterException
UnexpectedInternalError
MissingResourceException

buildResolvedConceptReference

protected ResolvedConceptReference buildResolvedConceptReference(GNode currentNode,
                                                                 int resolveCodedEntryDepth,
                                                                 int resolveAssociationDepth,
                                                                 LocalNameList restrictToProperties,
                                                                 CodedNodeSet.PropertyType[] restrictToPropertyTypes,
                                                                 SortOptionList sortByProperty,
                                                                 Filter[] filters,
                                                                 boolean keepLastAssociationLevelUnresolved)
                                                          throws UnexpectedInternalError,
                                                                 MissingResourceException,
                                                                 LBParameterException
Throws:
UnexpectedInternalError
MissingResourceException
LBParameterException

getAssociationInfo

protected GAssociationInfo getAssociationInfo(java.lang.String internalCodeSystemName,
                                              java.lang.String internalVersionString,
                                              java.lang.String associationName,
                                              java.lang.String relationName)
                                       throws LBParameterException,
                                              UnexpectedInternalError,
                                              MissingResourceException
Returns a shared structure containing identifying information for the given association; a new information object is automatically created if necessary.

Parameters:
internalCodeSystemName -
internalVersionString -
associationName -
relationName -
Throws:
LBParameterException
UnexpectedInternalError
MissingResourceException

getChildlessNodes

protected java.util.Iterator<GNode> getChildlessNodes(SortOptionList sortBy)
Returns all nodes maintained by the graph that are target but not source of any relationship. If none exists, then return nodes that are a target but not a source of any relationship in which it participates, sorted according to the given options.

Parameters:
sortBy -

getNode

protected GNode getNode(java.lang.String codeSystem,
                        java.lang.String codeNamespace,
                        java.lang.String code,
                        java.lang.String[] codeTypes,
                        java.lang.String entityDescription,
                        boolean flagParentlessIfNew,
                        boolean flagChildlessIfNew,
                        java.lang.String internalCodeSystemName,
                        java.lang.String internalVersionString,
                        java.lang.String associationName)
                 throws MissingResourceException,
                        UnexpectedInternalError
Locates and returns a graph node based on the given information; a new node is added to the graph if necessary.

Parameters:
codeSystem -
codeNamespace -
code -
codeTypes -
flagParentlessIfNew -
flagChildlessIfNew -
internalCodeSystemName -
internalVersionString -
associationName -
Returns:
A GNode based on the provided info; not null.
Throws:
MissingResourceException
UnexpectedInternalError

getNodeCount

public int getNodeCount()
Returns the total number of nodes tracked by the graph.

Returns:
int

getNodeList

public CodedNodeSet getNodeList()
                         throws LBInvocationException
Throws:
LBInvocationException

getParentlessNodes

protected java.util.Iterator<GNode> getParentlessNodes(SortOptionList sortBy)
Returns all nodes maintained by the graph that are source but not target of any relationship. If none exists, return nodes that are a source not not a target for at least one relationship in which it participates, sorted according to the given options.

Parameters:
sortBy -

getResolvedConceptReferenceList

public ResolvedConceptReferenceList getResolvedConceptReferenceList(int resolveCodedEntryDepth,
                                                                    int resolveAssociationDepth,
                                                                    LocalNameList restrictToProperties,
                                                                    CodedNodeSet.PropertyType[] restrictToPropertyTypes,
                                                                    SortOptionList sortByProperty,
                                                                    LocalNameList filterOptions,
                                                                    boolean keepLastAssociationLevelUnresolved)
                                                             throws MissingResourceException,
                                                                    UnexpectedInternalError,
                                                                    LBParameterException
Returns the fully resolved contents of the graph.

Parameters:
resolveCodedEntryDepth -
resolveAssociationDepth -
restrictToProperties -
restrictToPropertyTypes -
sortByProperty -
filterOptions -
Throws:
MissingResourceException
UnexpectedInternalError
LBParameterException

getSortedNodeIterator

protected java.util.Iterator<GNode> getSortedNodeIterator(SortOptionList sortBy,
                                                          java.util.Set<GNode> nodes)
Returns an iterator that will sort the given nodes according to the specified sort options.

Parameters:
sortBy -
nodes -

intersection

public void intersection(GHolder holder)
Performs a boolean intersection of this graph holder with another. Upon completion, only nodes common to both are preserved.

Parameters:
holder -

isResultsSkipped

protected boolean isResultsSkipped()
Returns:
the resultsSkipped

listHelper

protected void listHelper(ResolvedConceptReferenceList list,
                          GNode currentNode,
                          int resolveCodedEntryDepth,
                          int resolveAssociationDepth,
                          LocalNameList restrictToProperties,
                          CodedNodeSet.PropertyType[] restrictToPropertyTypes,
                          SortOptionList sortByProperty,
                          Filter[] filters,
                          boolean keepLastAssociationLevelUnresolved)
                   throws UnexpectedInternalError,
                          MissingResourceException,
                          LBParameterException
Throws:
UnexpectedInternalError
MissingResourceException
LBParameterException

removeNode

protected void removeNode(java.lang.String nodeKey)
Removes the node identified by the given key from those tracked by the graph.

Parameters:
nodeKey -

resetNodePrintedFlags

protected void resetNodePrintedFlags()
For each node that is tracked, this class maintains an indication of whether or not the node has been included in the results in order to prevent recursion. This method clears all flags.


setResultsSkipped

public void setResultsSkipped(boolean resultsSkipped)
Parameters:
resultsSkipped - the resultsSkipped to set

union

public void union(GHolder holder)
Performs a boolean union of this graph holder with another. Upon completion, nodes for both are tracked.

Parameters:
holder -

validateFilters

protected Filter[] validateFilters(LocalNameList filterOptions)
                            throws LBParameterException
Throws:
LBParameterException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Copyright: (c) 2004-2006 Mayo Foundation for Medical Education and Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the triple-shield Mayo logo are trademarks and service marks of MFMER.