org.eclipse.ohf.ihe.xds.consumer.query
Class QueryBuilderUtils

java.lang.Object
  extended by org.eclipse.ohf.ihe.xds.consumer.query.QueryBuilderUtils

public class QueryBuilderUtils
extends java.lang.Object

Static utilites to aid in building XDS consumer SQL query clauses and other components for use by developers wishing to extends query capabilites of the IHE XDS Consumer (Transaction ITI-16: Query Registry)

Author:
Sarah Knoop
See Also:
IHE Technical Framework, for example use, for example use

Constructor Summary
QueryBuilderUtils()
           
 
Method Summary
static java.lang.String buildCodeClause(java.lang.String codeUUID, CodedMetadataType[] codes)
          Builds a code query sub clause (Classification): conjuncts the atoms ( metadataCode.classifiedObject = doc.id, metadataCode.classificationSchemd = XDS uuid of the code selected, code.nodeRepresentation (= or IN) codes)
static java.lang.String buildDateTimeClause(java.lang.String slotName, java.lang.String from, java.lang.String to)
          Builds the date/time range query sub clause (included the lower time bound, but excludes the upper time bound).
static java.lang.String buildIdClause(java.lang.String idSchemeUUID, java.lang.String[] idValues)
          Builds a id query sub clause (ExternalIdentifier): conjuncts the atoms (metadataId.registryObject = DocEntry || SubSet || Folder, metadataId.identificationScheme = XDS uuid of the id selected, metadataId.value (= or IN) idValues)
static java.lang.String buildListArgs(java.lang.String[] args)
          Builds coma separade list of arguments
static java.lang.String buildStatusClause(java.lang.String metadataUUID, AvailabilityStatusType[] status)
          Builds the status sub clause of a query
static java.lang.String convert(java.lang.String input)
          XML escapes any '&' found in the parameter.
static int validCodeList(CodedMetadataType[] codes)
          Checks to see if the code list provided has one coding scheme documented for each code, or none at all
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryBuilderUtils

public QueryBuilderUtils()
Method Detail

convert

public static java.lang.String convert(java.lang.String input)
XML escapes any '&' found in the parameter. This is particularly important when a query parameter includes metadata attributes that use HL7 v2.5 data types. Any '&' found in the input string will be converted to '&' If the '&' that is found already begins a string '&', then no translation is done. This conversion routine does not handle the XML escaping of '<' or '>', but possibly can in the future
FIXME SEK - need to think of a way to handle this ... need to XML-ify the HL7 strings. Should not be in this class, rather the HL7 library.

Parameters:
input - string to XML escape
Returns:
the converted string

buildCodeClause

public static java.lang.String buildCodeClause(java.lang.String codeUUID,
                                               CodedMetadataType[] codes)
                                        throws MalformedQueryException
Builds a code query sub clause (Classification): conjuncts the atoms ( metadataCode.classifiedObject = doc.id, metadataCode.classificationSchemd = XDS uuid of the code selected, code.nodeRepresentation (= or IN) codes)

Parameters:
codeUUID - uuid of metadata code element (see UUIDs), non null
codes - list of coded values and corresponding code scheme names, non null, and must have at least one (non-null) element at index zero.
Returns:
Returns the constructed clause as a string.
Throws:
MalformedQueryException - if null parameters were given or the codeUUID could not be identified

buildIdClause

public static java.lang.String buildIdClause(java.lang.String idSchemeUUID,
                                             java.lang.String[] idValues)
                                      throws MalformedQueryException
Builds a id query sub clause (ExternalIdentifier): conjuncts the atoms (metadataId.registryObject = DocEntry || SubSet || Folder, metadataId.identificationScheme = XDS uuid of the id selected, metadataId.value (= or IN) idValues)

Parameters:
idSchemeUUID - IHE assigned identification scheme UUID (see UUIDs)
idValues - list of ids represented as strings, non null, and must have at least one (non-null) element at index zero.
Returns:
Returns the constructed clause as a string.
Throws:
MalformedQueryException - if null parameters were given or the idSchemeUUID could not be identified

buildDateTimeClause

public static java.lang.String buildDateTimeClause(java.lang.String slotName,
                                                   java.lang.String from,
                                                   java.lang.String to)
                                            throws MalformedQueryException
Builds the date/time range query sub clause (included the lower time bound, but excludes the upper time bound). Date/times are expected to be formatted per the IHE specification.

Parameters:
slotName - date/time metadata attribute name to be selected among metadata time slot name constants provided in DocumentEntryConstants, SubmissionSetConstants or FolderConstants , non null
from - start time, non null
to - end time, non null
Returns:
Returns the constructed clause as a string.
Throws:
MalformedQueryException - if null parameters were given or the slotName could not be identified

buildStatusClause

public static java.lang.String buildStatusClause(java.lang.String metadataUUID,
                                                 AvailabilityStatusType[] status)
                                          throws MalformedQueryException
Builds the status sub clause of a query

Parameters:
metadataUUID - obj id of metadata componnet: doc entry, sub set or folder, non null
status - list of status, non null
Returns:
Returns the constructed clause as a string.
Throws:
MalformedQueryException - if null parameters were given or the metadataUUID could not be identified

buildListArgs

public static java.lang.String buildListArgs(java.lang.String[] args)
Builds coma separade list of arguments


validCodeList

public static int validCodeList(CodedMetadataType[] codes)
Checks to see if the code list provided has one coding scheme documented for each code, or none at all

Parameters:
codes - array of CodedMetadataTypes to validate
Returns:
return -1 if the list is invalid, return 0 if there are no coding schemes and return 1 if each code has a corresponding coding scheme.