org.lexgrid.valuesets.helper
Class VSDServiceHelper

java.lang.Object
  extended by org.lexgrid.valuesets.helper.VSDServiceHelper

public class VSDServiceHelper
extends java.lang.Object

Helper class for Value Set Definition functions.

Author:
Sridhar Dwarkanath

Constructor Summary
VSDServiceHelper(boolean failOnAllErrors, LgMessageDirectorIF messages)
          Constructor
 
Method Summary
protected  CodedNodeSet conceptReferenceListToCodedNodeSet(ConceptReferenceList crl, ValueSetDefinition vdd, java.util.HashMap<java.lang.String,java.lang.String> refVersions, java.lang.String versionTag)
          Convert a concept reference list into a coded node set in the context of a particular value set definition
protected  java.lang.String constructKey(ConceptReference cr)
          Construct a (hopefully) unique key from a concept reference
protected  boolean equalReferences(ConceptReference r1, ConceptReference r2)
          Determine whether two concept references refer to the same thing in the context of a single coding scheme!
 AbsoluteCodingSchemeVersionReferenceList getAbsoluteCodingSchemeVersionReference(java.lang.String codingSchemeNameOrURI)
          Return a list of all the versions of the supplied coding scheme URI or local identifier that are supported by the service
 CodedNodeSet getCodedNodeSetForValueSet(ValueSetDefinition vdd, java.util.HashMap<java.lang.String,java.lang.String> refVersions, java.lang.String versionTag)
          Resolves the supplied valueSetDefinition object against the list of coding scheme versions
 java.lang.String getCodingSchemeNameForNamespaceName(Mappings maps, java.lang.String namespaceName)
          Return the local identifier of the coding scheme name associated with the supplied namespace name in the context of the supplied mapping.
static java.lang.String getCodingSchemeURIForEntityCodeNamespace(Mappings maps, java.lang.String entityCodeNamespace)
          Return the coding scheme URI that corresponds to the supplied entityCodeNamespace.
 java.util.HashSet<java.lang.String> getCodingSchemeURIs(ValueSetDefinition vdDef)
          Return a string representation the URI's of all of the coding schemes used in the supplied value domain
 LexBIGService getLexBIGService()
          Return a persistent link to the LexBIG service
 int getMaxLeafCacheSize()
          Return the maximum cache size for traversing graphs looking for leaf nodes
protected  CodedNodeSet getNodeSetForCodingScheme(ValueSetDefinition vdd, java.lang.String csName, java.util.HashMap<java.lang.String,java.lang.String> refVersions, java.lang.String versionTag)
          Return the coded node set that represents all of the concept codes in the referenced coding scheme
protected  CodedNodeSet getNodeSetForEntityReference(ValueSetDefinition vdd, EntityReference entityRef, java.util.HashMap<java.lang.String,java.lang.String> refVersions, java.lang.String versionTag)
          Return a coded node set that represents the supplied entity reference
protected  CodedNodeSet getNodeSetForPropertyReference(ValueSetDefinition vdd, PropertyReference propertyRef, java.util.HashMap<java.lang.String,java.lang.String> refVersions, java.lang.String versionTag)
          Return a coded node set that represents the supplied property reference
 ResolvedValueSetCodedNodeSet getResolvedCodedNodeSetForValueSet(ValueSetDefinition vdd, AbsoluteCodingSchemeVersionReferenceList csVersionsToUse, java.lang.String versionTag)
          Resolve a value domain definition.
 java.lang.String getURIForAssociationName(Mappings maps, java.lang.String associationName)
          Return the URI that corresponds to the supplied association name.
static java.lang.String getURIForCodingSchemeName(Mappings maps, java.lang.String codingSchemeName)
          Return the URI that corresponds to the supplied coding scheme name.
protected  boolean isCodingSchemeVersionLoaded(java.lang.String codingSchemeName, java.lang.String version)
          Checks if the supplied codingScheme and version is loaded.
 CodedNodeSet leavesOfGraph(CodedNodeGraph cng, boolean isTargetToSource, ConceptReference root, ValueSetDefinition vdd, java.util.HashMap<java.lang.String,java.lang.String> refVersions, java.lang.String versionTag)
          Return the leaf nodes for the supplied graph.
 java.util.HashMap<java.lang.String,java.lang.String> pruneVersionList(AbsoluteCodingSchemeVersionReferenceList suppliedCsVersions)
          Go over the supplied coding scheme version reference list and remove any entries that aren't supported by the service.
protected  AbsoluteCodingSchemeVersionReference resolveCSVersion(java.lang.String csName, Mappings maps, java.lang.String versionTag, java.util.HashMap<java.lang.String,java.lang.String> refVersions)
          Return the absolute reference for the supplied csName.
 void setLexBIGService(LexBIGService lbs)
          Record a persistent link to the LexBIG service for use by this and other classes
 void setMaxLeafCacheSize(int newSize)
          Set the maximum cache size to be used when traversing graphs looking for leaf nodes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VSDServiceHelper

public VSDServiceHelper(boolean failOnAllErrors,
                        LgMessageDirectorIF messages)
                 throws LBParameterException,
                        LBInvocationException
Constructor

Parameters:
sqlServer - - SQL Server URI
sqlDriver - - SQL driver name
sqlUsername - - logon user name
sqlPassword - - logon password
tablePrefix - - prefix to use (?)
failOnAllErrors - - true means fail on any load, false means try
messages - - message director
Throws:
LBParameterException
LBInvocationException
Method Detail

getCodingSchemeNameForNamespaceName

public java.lang.String getCodingSchemeNameForNamespaceName(Mappings maps,
                                                            java.lang.String namespaceName)
Return the local identifier of the coding scheme name associated with the supplied namespace name in the context of the supplied mapping. Comparison is case insensitive.

Parameters:
maps - Mappings to use for transformation
namespaceName - name to map
Returns:
local id of coding scheme if there is one, else null

getURIForCodingSchemeName

public static java.lang.String getURIForCodingSchemeName(Mappings maps,
                                                         java.lang.String codingSchemeName)
Return the URI that corresponds to the supplied coding scheme name. Comparison is case insensitive.

Parameters:
maps - - Mappings that contain the name to URI maps
codingSchemeName - - local identifier of the coding scheme
Returns:
- URI or, if missing, the coding scheme name (surrogate)

getCodingSchemeURIForEntityCodeNamespace

public static java.lang.String getCodingSchemeURIForEntityCodeNamespace(Mappings maps,
                                                                        java.lang.String entityCodeNamespace)
Return the coding scheme URI that corresponds to the supplied entityCodeNamespace. Comparison is case insensitive.

Parameters:
maps - - Mappings that contain the name to URI maps
entityCodeNamespace - - local identifier of the entityCodeNamespace
Returns:
- URI or, if missing, the coding scheme name (surrogate)

getURIForAssociationName

public java.lang.String getURIForAssociationName(Mappings maps,
                                                 java.lang.String associationName)
Return the URI that corresponds to the supplied association name. This function will use either the local association identifier or the value text. Comparison is case insensitive.

Parameters:
maps - - Mappings that contain the name to URI maps
associationName - - local identifier of the coding scheme
Returns:
- URI or, if missing, the association name (surrogate)

getCodingSchemeURIs

public java.util.HashSet<java.lang.String> getCodingSchemeURIs(ValueSetDefinition vdDef)
                                                        throws LBException
Return a string representation the URI's of all of the coding schemes used in the supplied value domain

Parameters:
vdDef - supplied value domain
Returns:
List of unique URIs. Returned as strings because we aren't all that picky about the syntax
Throws:
LBException
java.net.URISyntaxException

getAbsoluteCodingSchemeVersionReference

public AbsoluteCodingSchemeVersionReferenceList getAbsoluteCodingSchemeVersionReference(java.lang.String codingSchemeNameOrURI)
                                                                                 throws LBException
Return a list of all the versions of the supplied coding scheme URI or local identifier that are supported by the service

Parameters:
codingSchemeNameOrURI - - URI to return versions for or return all URI's if null
Returns:
AbsoluteCodingSchemeVersionReferenceList list of codingScheme and version. Names are transformed to URI's for the return
Throws:
LBException

isCodingSchemeVersionLoaded

protected boolean isCodingSchemeVersionLoaded(java.lang.String codingSchemeName,
                                              java.lang.String version)
                                       throws LBException
Checks if the supplied codingScheme and version is loaded.

Parameters:
codingSchemeName -
version -
Returns:
True; if given codingScheme/version is loader, otherwise, False.
Throws:
LBException

getResolvedCodedNodeSetForValueSet

public ResolvedValueSetCodedNodeSet getResolvedCodedNodeSetForValueSet(ValueSetDefinition vdd,
                                                                       AbsoluteCodingSchemeVersionReferenceList csVersionsToUse,
                                                                       java.lang.String versionTag)
                                                                throws LBException
Resolve a value domain definition.

Parameters:
vdd - - the value domain definition to be resolved
acsvl - - a list of coding scheme URI's and versions to be used in the resolution.
versionTag - - a tag (e.g. "production", "test", etc. used to any coding schemes not in asvl If a coding scheme does not appear in the asvl list the resolution will be as follows: 1) If the service supports a single active version of the coding scheme it will be used. 2) If there is more than one version the one that uses the supplied versionTag will be used 3) If the versionTag isn't supplied, or if none of the versions matches it, then the one marked "production" will be used 4) If there isn't one marked production, then the "latest" will be used
Returns:
ResolvedValueSetCodedNodeSet
Throws:
LBException

getCodedNodeSetForValueSet

public CodedNodeSet getCodedNodeSetForValueSet(ValueSetDefinition vdd,
                                               java.util.HashMap<java.lang.String,java.lang.String> refVersions,
                                               java.lang.String versionTag)
                                        throws LBException
Resolves the supplied valueSetDefinition object against the list of coding scheme versions

Parameters:
vdd - - the value domain to be resolved
refVersions - - a map from coding scheme URIs to the corresponding version
versionTag - - a tag (e.g. "production", "test", etc. used to resolve missing coding schemes) If a coding scheme does not appear in this list the resolution will be as follows: 1) If the service supports a single version of the coding scheme it will be used. 2) If there is more than one version the one that uses the supplied versionTag will be used 3) If the versionTag isn't supplied, or if none of the versions matches it, then the one marked "production" will be used 4) If there isn't one marked production, then the "latest" will be used
Throws:
LBException

getNodeSetForCodingScheme

protected CodedNodeSet getNodeSetForCodingScheme(ValueSetDefinition vdd,
                                                 java.lang.String csName,
                                                 java.util.HashMap<java.lang.String,java.lang.String> refVersions,
                                                 java.lang.String versionTag)
                                          throws LBException
Return the coded node set that represents all of the concept codes in the referenced coding scheme

Parameters:
vdd - - containing value set definition
csName - - local name of coding scheme within the value domain
refVersions - - map from coding scheme URI to versions. A new node will be added to this list if the coding scheme isn't already there
versionTag - - default version or tag
Returns:
coded node set that corresponds to this node or null if none available
Throws:
LBException

getNodeSetForEntityReference

protected CodedNodeSet getNodeSetForEntityReference(ValueSetDefinition vdd,
                                                    EntityReference entityRef,
                                                    java.util.HashMap<java.lang.String,java.lang.String> refVersions,
                                                    java.lang.String versionTag)
                                             throws LBException
Return a coded node set that represents the supplied entity reference

Parameters:
vdd - - containing value set definition
entityRef - - entity reference to resolve
refVersions - - fixed versions to resolve against
versionTag - - version tag to resolve elsewise
Returns:
corresponding coded node set
Throws:
LBException

getNodeSetForPropertyReference

protected CodedNodeSet getNodeSetForPropertyReference(ValueSetDefinition vdd,
                                                      PropertyReference propertyRef,
                                                      java.util.HashMap<java.lang.String,java.lang.String> refVersions,
                                                      java.lang.String versionTag)
                                               throws LBException
Return a coded node set that represents the supplied property reference

Parameters:
vdd - - containing value set definition
propertyRef - - property reference to resolve
refVersions - - fixed versions to resolve against
versionTag - - version tag to resolve elsewise
Returns:
corresponding coded node set
Throws:
LBException

leavesOfGraph

public CodedNodeSet leavesOfGraph(CodedNodeGraph cng,
                                  boolean isTargetToSource,
                                  ConceptReference root,
                                  ValueSetDefinition vdd,
                                  java.util.HashMap<java.lang.String,java.lang.String> refVersions,
                                  java.lang.String versionTag)
                           throws LBException
Return the leaf nodes for the supplied graph. As the graph to be traversed could be quite large, this is done breadth first and non-recursively. With apologies to Walt Whitman Note: were we to implement both the forward and reverse closure on transitive graphs, this routine could be replaced with the intersection of the supplied graph and the immediate children or ancestors of the top or bottom nodes respectively.

Parameters:
cng - - graph to be traversed
isTargetToSource - - direction to traverse the graph
root - - the root node to start the traverse at
vdd - - value domain definition to resolve leaf nodes against if isLeaf is set
refVersions - - map of coding Scheme URI to version (may be updated by this routine)
versionTag - - version tag (e.g. devel, production, etc.) to resolve new nodes
Returns:
- a list of all leaf nodes
Throws:
LBException

pruneVersionList

public java.util.HashMap<java.lang.String,java.lang.String> pruneVersionList(AbsoluteCodingSchemeVersionReferenceList suppliedCsVersions)
                                                                      throws LBException
Go over the supplied coding scheme version reference list and remove any entries that aren't supported by the service. If a coding scheme URI appears more than once in the list, only the first entry will be used.

Parameters:
suppliedVersions - - a list of "suggested" versions to use
Returns:
A list of unique coding scheme URIs and the corresponding versions
Throws:
LBException

setMaxLeafCacheSize

public void setMaxLeafCacheSize(int newSize)
Set the maximum cache size to be used when traversing graphs looking for leaf nodes.

Parameters:
newSize - New max size

getMaxLeafCacheSize

public int getMaxLeafCacheSize()
Return the maximum cache size for traversing graphs looking for leaf nodes


setLexBIGService

public void setLexBIGService(LexBIGService lbs)
Record a persistent link to the LexBIG service for use by this and other classes

Parameters:
lbs -

getLexBIGService

public LexBIGService getLexBIGService()
Return a persistent link to the LexBIG service

Returns:

resolveCSVersion

protected AbsoluteCodingSchemeVersionReference resolveCSVersion(java.lang.String csName,
                                                                Mappings maps,
                                                                java.lang.String versionTag,
                                                                java.util.HashMap<java.lang.String,java.lang.String> refVersions)
                                                         throws LBException
Return the absolute reference for the supplied csName. Add the entry to the refVersions if it isn't there

Parameters:
csName - - the local identifier of the coding scheme to be resolved
maps - - mappings that contain local ids to URIs
versionTag - - the version tag to use if there is more than one version in the service
refVersions - - a list of URI/version pairs that are already resolved
Returns:
the URI/Version to use or null if none can be found
Throws:
LBException

constructKey

protected java.lang.String constructKey(ConceptReference cr)
Construct a (hopefully) unique key from a concept reference

Parameters:
cr - concept reference
Returns:
unique key

equalReferences

protected boolean equalReferences(ConceptReference r1,
                                  ConceptReference r2)
Determine whether two concept references refer to the same thing in the context of a single coding scheme!

Parameters:
r1 - - first concept reference
r2 - - second concept reference
Returns:
true if the references are the same within the context of a coding scheme

conceptReferenceListToCodedNodeSet

protected CodedNodeSet conceptReferenceListToCodedNodeSet(ConceptReferenceList crl,
                                                          ValueSetDefinition vdd,
                                                          java.util.HashMap<java.lang.String,java.lang.String> refVersions,
                                                          java.lang.String versionTag)
                                                   throws LBException
Convert a concept reference list into a coded node set in the context of a particular value set definition

Parameters:
crl - - list to convert
vdd - - context to do the conversion in
refVersions - - set of already resolved versions (may have new versions added)
versionTag - - the versionTag to use if more than one version of the coding scheme exists
Returns:
corresponding coded node set
Throws:
LBException

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.