Class SearchQueryRenderer
- java.lang.Object
-
- org.linuxforhealth.fhir.persistence.jdbc.domain.SearchQueryRenderer
-
- All Implemented Interfaces:
SearchQueryVisitor<QueryData>
public class SearchQueryRenderer extends java.lang.Object implements SearchQueryVisitor<QueryData>
Used to render the domain model into a physical, executable query modeled as a Select statement. The domain model knows about resources and parameters. This class is used to translate the logical structure of the query into a physical one, using the correct table names, join predicates and filter expressions.
-
-
Constructor Summary
Constructors Constructor Description SearchQueryRenderer(IDatabaseTranslator translator, JDBCIdentityCache identityCache, int rowOffset, int rowsPerPage, boolean includeResourceData, SchemaType schemaType)Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QueryDataaddCanonicalParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm)Filter the query using the given canonical parameterQueryDataaddChained(QueryData queryData, QueryParameter currentParm)Add a chain subquery element as part of a chained parameter searchQueryDataaddCompositeParam(QueryData queryData, QueryParameter queryParm)Add a composite query parameter filter to the queryQueryDataaddCompositeParam(QueryData queryData, QueryParameter queryParm, boolean isMissing)Add a composite query which only tests missing/not missing, not the actual parameter valueQueryDataaddDateParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm)Filter the query using the given date parametervoidaddFilter(QueryData queryData, java.lang.String resourceType, QueryParameter currentParm)Add a filter predicate to the given chained sub-query element.protected voidaddIdFilter(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm)Add a filter on the LOGICAL_ID for the given query parameter valuesQueryDataaddIncludeFilter(QueryData queryData, InclusionParameter inclusionParm, java.util.List<java.lang.Long> logicalResourceIds)QueryDataaddInclusionParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm)Special case to handle inclusion related to compartment-based searchesQueryDataaddLocationParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm)Filter the query using the given location (lat/lng) paramQueryDataaddLocationPosition(QueryData queryData, java.util.List<QueryParameter> queryParameters)QueryDataaddMissingParam(QueryData queryData, QueryParameter queryParm, boolean isMissing)Add a missing (NOT EXISTS) parameter clause to the queryQueryDataaddNumberParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm)Filter the query using the given number parameterQueryDataaddPagination(QueryData queryData)Add pagination (LIMIT/OFFSET) to the queryQueryDataaddQuantityParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm)Filter the query using the given quantity parameterQueryDataaddReferenceParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm)Filter the query using the given reference parameterQueryDataaddReverseChained(QueryData queryData, QueryParameter currentParm)Add a reverse chain subquery element as part of a chained parameter searchQueryDataaddRevIncludeFilter(QueryData queryData, InclusionParameter inclusionParm, java.util.List<java.lang.Long> logicalResourceIds)QueryDataaddSecurityParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm)Filter the query using the given security query parameterQueryDataaddSorting(QueryData queryData, java.lang.String lrAlias)Add sorting (order by) to the queryvoidaddSortParam(QueryData queryData, java.lang.String code, SearchConstants.Type type, Sort.Direction direction)Add the given sort parameter to the sort queryQueryDataaddStringParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm)Filter the query using the given string parameterQueryDataaddTagParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm)Filter the query using the given tag query parameterQueryDataaddTokenParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm)Filter the query using the given parameter id and token valueQueryDataaddWholeSystemDataFilter(QueryData queryData, java.lang.String resourceType, java.util.List<java.lang.Long> logicalResourceIds)QueryDataaddWholeSystemResourceTypeFilter(QueryData queryData, java.util.List<java.lang.Integer> resourceTypeIds)QueryDataaddWholeSystemSorting(QueryData queryData, java.util.List<DomainSortParameter> sortParms, java.lang.String lrAlias)Add sorting (order by) for whole-system search to the queryQueryDatacountRoot(java.lang.String rootResourceType)The root query (select statement) for a count queryQueryDatadataRoot(java.lang.String rootResourceType, int resourceTypeId)The root query (select statement) for the data queryprotected longgetCanonicalId(java.lang.String canonicalValue)Get the id for the given canonicalValue (cache lookup).protected intgetCodeSystemId(java.lang.String codeSystemName)Get the id for the given code system name (cache lookup)protected java.lang.LonggetCommonTokenValueId(java.lang.String system, java.lang.String code)Get the common token value id matching the unique tuple {system, code}protected java.util.List<java.lang.Long>getCommonTokenValueIdList(java.lang.String code)Get a list of common token values matching the given codeprotected java.util.Set<java.lang.Long>getCommonTokenValueIds(java.util.Collection<CommonTokenValue> tokenValues)Get the common token value ids for the passed list of token values {system, code}.protected WhereFragmentgetDateFilter(QueryParameter queryParm, java.lang.String paramAlias)Add a filter predicate to the given exists sub-queryprotected WhereFragmentgetFilterPredicate(QueryData queryData, QueryParameter queryParm)Get a simple filter predicate which can be used in the WHERE clause of a search query.protected WhereFragmentgetIdentifierFilter(QueryParameter queryParm, java.lang.String paramAlias)protected WhereFragmentgetLocationFilter(QueryParameter queryParm, java.lang.String paramAlias)Add a filter predicate to the given exists sub-queryprotected java.util.List<java.lang.Long>getLogicalResourceIdList(java.lang.String logicalId)Obtain the list of logical_resource_id values that match the given logicalId.protected java.util.Set<java.lang.Long>getLogicalResourceIds(java.util.Collection<ResourceReferenceValue> referenceValues)Obtain the logical_resource_id values for each of the given ResourceReferenceValues.protected java.lang.StringgetLRAlias(int aliasIndex)Get the string to use as a logical resource alias for the given aliasIndex valueprotected intgetNextAliasIndex()Get the next index number to use as a parameter table aliasprotected WhereFragmentgetNumberFilter(QueryParameter queryParm, java.lang.String paramAlias)Get a filter predicate for the given number query parameterprotected OperatorgetOperator(QueryParameter queryParameter)Get the operator we need to use for matching values for this parameterprotected OperatorgetOperator(QueryParameter queryParm, java.lang.String defaultOverride)Map the Modifier in the passed Parameter to a supported query operator.protected java.lang.StringgetParamAlias(int aliasIndex)Get the string to use as a parameter table alias for the given aliasIndex valueQueryDatagetParameterBaseQuery(QueryData parent)Get the join to which we want to attach all the parameter tables.protected intgetParameterNameId(java.lang.String parameterName)Get the id for the given parameter name (cache lookup)protected WhereFragmentgetQuantityFilter(QueryParameter queryParm, java.lang.String paramAlias)Add a filter predicate to the given exists sub-queryprotected WhereFragmentgetReferenceFilter(QueryParameter queryParm, java.lang.String paramAlias)Create a filter predicate for the given reference query parameterprotected WhereFragmentgetReferenceFilter(QueryParameter queryParm, java.lang.String paramAlias, java.util.List<java.lang.Long> logicalResourceIdList)protected WhereFragmentgetReferenceStrFilter(QueryParameter queryParm, java.lang.String paramAlias, java.util.List<java.lang.String> ambiguousResourceReferenceTokenValues)Create a filter predicate for the given reference query parameter using the ambiguousprotected java.lang.StringgetRefParamTable(ExpNode filter, java.lang.String resourceType, java.lang.String paramAlias)Compute the reference parameter table name we want to use to join with.protected java.lang.StringgetSortParameterTableName(java.lang.String resourceType, java.lang.String code, SearchConstants.Type type)Returns the name of the database table corresponding to the code and type of the passed sort parameter.protected WhereFragmentgetStringFilter(QueryParameter queryParm, java.lang.String paramAlias)Add a filter expression to the given parameter sub-query (which is used as an EXISTS clause)protected WhereFragmentgetTokenFilter(QueryParameter queryParm, java.lang.String paramAlias)Get the filter predicate for the given token query parameter.protected java.lang.StringgetTokenParamTable(ExpNode filter, java.lang.String resourceType, java.lang.String paramAlias, boolean filterIsOptimized)Compute the token parameter table name we want to use to join with.QueryDataincludeRoot(java.lang.String rootResourceType)The root query (select statement) for the include query.protected booleanisOptimizedTokenParamFilter(ExpNode filter, java.lang.String paramAlias)Inspect the filter expression to see if it mentions the TOKEN_VALUE or CODE_SYSTEM_ID columns.QueryDatajoinResources(QueryData queryData, boolean includeResourceTypeId)Finish the data query by wrapping the root and joining the resources tableprotected intnullCheck(java.lang.Integer value)Use -1 as a simple substitute for null literal ids because we know -1 will never exist as a value in the database (for fields populated by sequence values).protected longnullCheck(java.lang.Long value)Use -1 as a simple substitute for null literal ids because we know -1 will never exist as a value in the database (for fields populated by sequence values).protected WhereFragmentparamFilter(QueryParameter queryParm, java.lang.String paramTableAlias)Get the filter predicate expression for the given query parameter taking into account its type, modifiers etc.java.lang.StringparamValuesColumnName(SearchConstants.Type paramType)Get the column name to use for the given paramTypejava.lang.StringparamValuesTableName(java.lang.String resourceType, QueryParameter queryParm)Get the parameter values table name (e.g.protected java.lang.StringresourceLogicalResources(java.lang.String resourceType)Get the table name for the xx_logical_resources table where xx is the resource type nameprotected java.lang.StringresourceResources(java.lang.String resourceType)Get the table name for the xx_resources table where xx is the resource type nameprotected java.lang.StringresourceTypeField(java.lang.String resourceType, int resourceTypeId)QueryDatasortRoot(java.lang.String rootResourceType)The root of the FHIR search sort queryQueryDatawholeSystemDataRoot(java.lang.String rootResourceType, int rootResourceTypeId)The root of the FHIR whole-system data search queryQueryDatawholeSystemFilterRoot()The root of the FHIR whole-system filter search queryQueryDatawrapInclude(QueryData query)QueryDatawrapWholeSystem(java.util.List<QueryData> queries, boolean isCountQuery)The wrapper for whole-system search
-
-
-
Constructor Detail
-
SearchQueryRenderer
public SearchQueryRenderer(IDatabaseTranslator translator, JDBCIdentityCache identityCache, int rowOffset, int rowsPerPage, boolean includeResourceData, SchemaType schemaType)
Public constructor- Parameters:
translator-identityCache-rowOffset-rowsPerPage-includeResourceData-schemaType-
-
-
Method Detail
-
getNextAliasIndex
protected int getNextAliasIndex()
Get the next index number to use as a parameter table alias- Returns:
-
resourceLogicalResources
protected java.lang.String resourceLogicalResources(java.lang.String resourceType)
Get the table name for the xx_logical_resources table where xx is the resource type name- Parameters:
resourceType-- Returns:
- the table name
-
resourceTypeField
protected java.lang.String resourceTypeField(java.lang.String resourceType, int resourceTypeId)
-
resourceResources
protected java.lang.String resourceResources(java.lang.String resourceType)
Get the table name for the xx_resources table where xx is the resource type name- Parameters:
resourceType-- Returns:
-
getParameterNameId
protected int getParameterNameId(java.lang.String parameterName) throws FHIRPersistenceExceptionGet the id for the given parameter name (cache lookup)- Parameters:
parameterName-- Returns:
- Throws:
FHIRPersistenceException
-
getCommonTokenValueId
protected java.lang.Long getCommonTokenValueId(java.lang.String system, java.lang.String code) throws FHIRPersistenceExceptionGet the common token value id matching the unique tuple {system, code}- Parameters:
system-code-- Returns:
- Throws:
FHIRPersistenceException
-
getCommonTokenValueIds
protected java.util.Set<java.lang.Long> getCommonTokenValueIds(java.util.Collection<CommonTokenValue> tokenValues) throws FHIRPersistenceException
Get the common token value ids for the passed list of token values {system, code}.- Parameters:
tokenValues-- Returns:
- Throws:
FHIRPersistenceException
-
getLogicalResourceIds
protected java.util.Set<java.lang.Long> getLogicalResourceIds(java.util.Collection<ResourceReferenceValue> referenceValues) throws FHIRPersistenceException
Obtain the logical_resource_id values for each of the given ResourceReferenceValues.- Parameters:
referenceValues-- Returns:
- Throws:
FHIRPersistenceException
-
getLogicalResourceIdList
protected java.util.List<java.lang.Long> getLogicalResourceIdList(java.lang.String logicalId) throws FHIRPersistenceExceptionObtain the list of logical_resource_id values that match the given logicalId.- Parameters:
logicalId-- Returns:
- Throws:
FHIRPersistenceException
-
getCommonTokenValueIdList
protected java.util.List<java.lang.Long> getCommonTokenValueIdList(java.lang.String code) throws FHIRPersistenceExceptionGet a list of common token values matching the given code- Parameters:
code-- Returns:
- Throws:
FHIRPersistenceException
-
getCodeSystemId
protected int getCodeSystemId(java.lang.String codeSystemName) throws FHIRPersistenceExceptionGet the id for the given code system name (cache lookup)- Parameters:
codeSystemName-- Returns:
- Throws:
FHIRPersistenceException
-
getCanonicalId
protected long getCanonicalId(java.lang.String canonicalValue) throws FHIRPersistenceExceptionGet the id for the given canonicalValue (cache lookup).- Parameters:
canonicalValue-- Returns:
- the database id, or -1 if the value does not exist
- Throws:
FHIRPersistenceException
-
countRoot
public QueryData countRoot(java.lang.String rootResourceType)
Description copied from interface:SearchQueryVisitorThe root query (select statement) for a count query- Specified by:
countRootin interfaceSearchQueryVisitor<QueryData>- Returns:
-
dataRoot
public QueryData dataRoot(java.lang.String rootResourceType, int resourceTypeId)
Description copied from interface:SearchQueryVisitorThe root query (select statement) for the data query- Specified by:
dataRootin interfaceSearchQueryVisitor<QueryData>- Returns:
-
getParameterBaseQuery
public QueryData getParameterBaseQuery(QueryData parent)
Description copied from interface:SearchQueryVisitorGet the join to which we want to attach all the parameter tables. This makes it easier to build different styles of joins- Specified by:
getParameterBaseQueryin interfaceSearchQueryVisitor<QueryData>- Returns:
-
joinResources
public QueryData joinResources(QueryData queryData, boolean includeResourceTypeId)
Description copied from interface:SearchQueryVisitorFinish the data query by wrapping the root and joining the resources table- Specified by:
joinResourcesin interfaceSearchQueryVisitor<QueryData>includeResourceTypeId- include the resource_type_id in the select column list- Returns:
-
includeRoot
public QueryData includeRoot(java.lang.String rootResourceType)
Description copied from interface:SearchQueryVisitorThe root query (select statement) for the include query. This query is different than the data root because of the need to support version references for _include searches. For this, we join: xx_RESOURCES.LOGICAL_RESOURCE_ID = xx_LOGICAL_RESOURCES.LOGICAL_RESOURCE_ID and allow the filter to specify the version_id constraint. However, we still need to assert that the resource has not been deleted, so we keep: xx_LOGICAL_RESOURCES.IS_DELETED = 'N'- Specified by:
includeRootin interfaceSearchQueryVisitor<QueryData>- Returns:
-
wrapInclude
public QueryData wrapInclude(QueryData query)
- Specified by:
wrapIncludein interfaceSearchQueryVisitor<QueryData>- Returns:
-
sortRoot
public QueryData sortRoot(java.lang.String rootResourceType)
Description copied from interface:SearchQueryVisitorThe root of the FHIR search sort query- Specified by:
sortRootin interfaceSearchQueryVisitor<QueryData>- Returns:
-
wholeSystemFilterRoot
public QueryData wholeSystemFilterRoot()
Description copied from interface:SearchQueryVisitorThe root of the FHIR whole-system filter search query- Specified by:
wholeSystemFilterRootin interfaceSearchQueryVisitor<QueryData>- Returns:
-
wholeSystemDataRoot
public QueryData wholeSystemDataRoot(java.lang.String rootResourceType, int rootResourceTypeId)
Description copied from interface:SearchQueryVisitorThe root of the FHIR whole-system data search query- Specified by:
wholeSystemDataRootin interfaceSearchQueryVisitor<QueryData>- Returns:
-
wrapWholeSystem
public QueryData wrapWholeSystem(java.util.List<QueryData> queries, boolean isCountQuery)
Description copied from interface:SearchQueryVisitorThe wrapper for whole-system search- Specified by:
wrapWholeSystemin interfaceSearchQueryVisitor<QueryData>- Returns:
-
getTokenFilter
protected WhereFragment getTokenFilter(QueryParameter queryParm, java.lang.String paramAlias) throws FHIRPersistenceException
Get the filter predicate for the given token query parameter.- Parameters:
queryParm- the token query parameterparamAlias- the alias used for the token values table- Throws:
FHIRPersistenceException
-
getStringFilter
protected WhereFragment getStringFilter(QueryParameter queryParm, java.lang.String paramAlias) throws FHIRPersistenceException
Add a filter expression to the given parameter sub-query (which is used as an EXISTS clause)- Parameters:
paramExists- the query statement to which we need to add the filter predicatequeryParm- the query parameter for which we need to compute and add the filter predicateparamAlias- the alias for the query parameter table- Returns:
- Throws:
FHIRPersistenceException
-
addSorting
public QueryData addSorting(QueryData queryData, java.lang.String lrAlias)
Description copied from interface:SearchQueryVisitorAdd sorting (order by) to the query- Specified by:
addSortingin interfaceSearchQueryVisitor<QueryData>- Returns:
-
addWholeSystemSorting
public QueryData addWholeSystemSorting(QueryData queryData, java.util.List<DomainSortParameter> sortParms, java.lang.String lrAlias)
Description copied from interface:SearchQueryVisitorAdd sorting (order by) for whole-system search to the query- Specified by:
addWholeSystemSortingin interfaceSearchQueryVisitor<QueryData>- Returns:
-
addPagination
public QueryData addPagination(QueryData queryData)
Description copied from interface:SearchQueryVisitorAdd pagination (LIMIT/OFFSET) to the query- Specified by:
addPaginationin interfaceSearchQueryVisitor<QueryData>- Returns:
-
paramValuesTableName
public java.lang.String paramValuesTableName(java.lang.String resourceType, QueryParameter queryParm)Get the parameter values table name (e.g. Patient_STR_VALUES) for the given resource and parameter type. Note that this is now different from the original QuerySegmentAggregator implementation - it does not differentiate on chaining...that is left up to the building logic.- Parameters:
resourceType-paramType-- Returns:
-
paramValuesColumnName
public java.lang.String paramValuesColumnName(SearchConstants.Type paramType)
Get the column name to use for the given paramType- Parameters:
paramType-- Returns:
-
getFilterPredicate
protected WhereFragment getFilterPredicate(QueryData queryData, QueryParameter queryParm) throws FHIRPersistenceException
Get a simple filter predicate which can be used in the WHERE clause of a search query. This is used at the "leaf level" of parameter processing, where the queryParm relates to a single parameter (i.e. it is the caller's responsibility to handle chaining and other more complex behavior.- Parameters:
queryData-queryParm-- Returns:
- Throws:
FHIRPersistenceException
-
addIdFilter
protected void addIdFilter(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm) throws FHIRPersistenceException
Add a filter on the LOGICAL_ID for the given query parameter values- Parameters:
queryData-resourceType-queryParm-- Throws:
FHIRPersistenceException
-
getNumberFilter
protected WhereFragment getNumberFilter(QueryParameter queryParm, java.lang.String paramAlias) throws FHIRPersistenceException
Get a filter predicate for the given number query parameter- Parameters:
queryParm-paramAlias-- Throws:
FHIRPersistenceException
-
getQuantityFilter
protected WhereFragment getQuantityFilter(QueryParameter queryParm, java.lang.String paramAlias) throws FHIRPersistenceException
Add a filter predicate to the given exists sub-query- Parameters:
queryParm-paramAlias-- Throws:
FHIRPersistenceException
-
getDateFilter
protected WhereFragment getDateFilter(QueryParameter queryParm, java.lang.String paramAlias)
Add a filter predicate to the given exists sub-query- Parameters:
queryParm-paramAlias-
-
getLocationFilter
protected WhereFragment getLocationFilter(QueryParameter queryParm, java.lang.String paramAlias) throws FHIRPersistenceException
Add a filter predicate to the given exists sub-query- Parameters:
queryParm-paramAlias-- Throws:
FHIRPersistenceException
-
getParamAlias
protected java.lang.String getParamAlias(int aliasIndex)
Get the string to use as a parameter table alias for the given aliasIndex value- Parameters:
aliasIndex-- Returns:
-
getLRAlias
protected java.lang.String getLRAlias(int aliasIndex)
Get the string to use as a logical resource alias for the given aliasIndex value- Parameters:
aliasIndex-- Returns:
-
getTokenParamTable
protected java.lang.String getTokenParamTable(ExpNode filter, java.lang.String resourceType, java.lang.String paramAlias, boolean filterIsOptimized)
Compute the token parameter table name we want to use to join with. This method inspects the content of the given filterExpNode. If the filter contains a reference to the TOKEN_VALUE column, the returned table name will be based on xx_TOKEN_VALUES_V, otherwise it will be based on xx_RESOURCE_TOKEN_REFS. The latter is preferable because it eliminates an unnecessary join, improves cardinality estimation and (usually) results in a better execution plan.- Parameters:
filter-resourceType-paramAlias-- Returns:
-
isOptimizedTokenParamFilter
protected boolean isOptimizedTokenParamFilter(ExpNode filter, java.lang.String paramAlias)
Inspect the filter expression to see if it mentions the TOKEN_VALUE or CODE_SYSTEM_ID columns. If neither of these columns is mentioned, we can optimize to use only the xx_resource_token_refs which leads to much better overall cardinality estimation by the query optimizer.- Parameters:
filter-paramAlias-- Returns:
-
getRefParamTable
protected java.lang.String getRefParamTable(ExpNode filter, java.lang.String resourceType, java.lang.String paramAlias)
Compute the reference parameter table name we want to use to join with. This method inspects the content of the given filterExpNode. If the filter contains a reference to the LOGICAL_ID column, the returned table name will be based on xx_REF_VALUES_V, otherwise it will be based on xx_REF_VALUES. The latter is preferable because it eliminates an unnecessary join, improves cardinality estimation and (usually) results in a better execution plan.- Parameters:
filter-resourceType-paramAlias-- Returns:
-
getIdentifierFilter
protected WhereFragment getIdentifierFilter(QueryParameter queryParm, java.lang.String paramAlias) throws FHIRPersistenceException
- Throws:
FHIRPersistenceException
-
getReferenceFilter
protected WhereFragment getReferenceFilter(QueryParameter queryParm, java.lang.String paramAlias) throws FHIRPersistenceException
Create a filter predicate for the given reference query parameter- Parameters:
queryParm-paramAlias-- Throws:
FHIRPersistenceException
-
getReferenceFilter
protected WhereFragment getReferenceFilter(QueryParameter queryParm, java.lang.String paramAlias, java.util.List<java.lang.Long> logicalResourceIdList) throws FHIRPersistenceException
- Throws:
FHIRPersistenceException
-
getReferenceStrFilter
protected WhereFragment getReferenceStrFilter(QueryParameter queryParm, java.lang.String paramAlias, java.util.List<java.lang.String> ambiguousResourceReferenceTokenValues) throws FHIRPersistenceException
Create a filter predicate for the given reference query parameter using the ambiguous- Parameters:
queryParm-paramAlias-- Throws:
FHIRPersistenceException
-
nullCheck
protected int nullCheck(java.lang.Integer value)
Use -1 as a simple substitute for null literal ids because we know -1 will never exist as a value in the database (for fields populated by sequence values).- Parameters:
value-- Returns:
-
nullCheck
protected long nullCheck(java.lang.Long value)
Use -1 as a simple substitute for null literal ids because we know -1 will never exist as a value in the database (for fields populated by sequence values).- Parameters:
value-- Returns:
-
getOperator
protected Operator getOperator(QueryParameter queryParameter)
Get the operator we need to use for matching values for this parameter- Parameters:
queryParameter-- Returns:
-
getOperator
protected Operator getOperator(QueryParameter queryParm, java.lang.String defaultOverride)
Map the Modifier in the passed Parameter to a supported query operator. If the mapping results in the default operator, override the default operator with the passed operator if the passed operator is not null.- Parameters:
queryParm- - A valid query Parameter.defaultOverride- - An operator that should override the default operator.- Returns:
- A supported operator.
-
paramFilter
protected WhereFragment paramFilter(QueryParameter queryParm, java.lang.String paramTableAlias) throws FHIRPersistenceException
Get the filter predicate expression for the given query parameter taking into account its type, modifiers etc.- Parameters:
paramTableAlias-queryParm-- Returns:
- a valid expression
- Throws:
FHIRPersistenceException
-
addLocationPosition
public QueryData addLocationPosition(QueryData queryData, java.util.List<QueryParameter> queryParameters) throws FHIRPersistenceException
- Specified by:
addLocationPositionin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addInclusionParam
public QueryData addInclusionParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm) throws FHIRPersistenceException
Description copied from interface:SearchQueryVisitorSpecial case to handle inclusion related to compartment-based searches- Specified by:
addInclusionParamin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addIncludeFilter
public QueryData addIncludeFilter(QueryData queryData, InclusionParameter inclusionParm, java.util.List<java.lang.Long> logicalResourceIds) throws FHIRPersistenceException
- Specified by:
addIncludeFilterin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addRevIncludeFilter
public QueryData addRevIncludeFilter(QueryData queryData, InclusionParameter inclusionParm, java.util.List<java.lang.Long> logicalResourceIds) throws FHIRPersistenceException
- Specified by:
addRevIncludeFilterin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addWholeSystemDataFilter
public QueryData addWholeSystemDataFilter(QueryData queryData, java.lang.String resourceType, java.util.List<java.lang.Long> logicalResourceIds) throws FHIRPersistenceException
- Specified by:
addWholeSystemDataFilterin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addWholeSystemResourceTypeFilter
public QueryData addWholeSystemResourceTypeFilter(QueryData queryData, java.util.List<java.lang.Integer> resourceTypeIds) throws FHIRPersistenceException
- Specified by:
addWholeSystemResourceTypeFilterin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addTokenParam
public QueryData addTokenParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm) throws FHIRPersistenceException
Description copied from interface:SearchQueryVisitorFilter the query using the given parameter id and token value- Specified by:
addTokenParamin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addTagParam
public QueryData addTagParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm) throws FHIRPersistenceException
Description copied from interface:SearchQueryVisitorFilter the query using the given tag query parameter- Specified by:
addTagParamin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addSecurityParam
public QueryData addSecurityParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm) throws FHIRPersistenceException
Description copied from interface:SearchQueryVisitorFilter the query using the given security query parameter- Specified by:
addSecurityParamin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addStringParam
public QueryData addStringParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm) throws FHIRPersistenceException
Description copied from interface:SearchQueryVisitorFilter the query using the given string parameter- Specified by:
addStringParamin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addCanonicalParam
public QueryData addCanonicalParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm) throws FHIRPersistenceException
Description copied from interface:SearchQueryVisitorFilter the query using the given canonical parameter- Specified by:
addCanonicalParamin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addMissingParam
public QueryData addMissingParam(QueryData queryData, QueryParameter queryParm, boolean isMissing) throws FHIRPersistenceException
Description copied from interface:SearchQueryVisitorAdd a missing (NOT EXISTS) parameter clause to the query- Specified by:
addMissingParamin interfaceSearchQueryVisitor<QueryData>isMissing- true if the condition should be that the parameter does not exist- Returns:
- Throws:
FHIRPersistenceException
-
addChained
public QueryData addChained(QueryData queryData, QueryParameter currentParm) throws FHIRPersistenceException
Description copied from interface:SearchQueryVisitorAdd a chain subquery element as part of a chained parameter search- Specified by:
addChainedin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addFilter
public void addFilter(QueryData queryData, java.lang.String resourceType, QueryParameter currentParm) throws FHIRPersistenceException
Description copied from interface:SearchQueryVisitorAdd a filter predicate to the given chained sub-query element. This must be the last element of the chain.- Specified by:
addFilterin interfaceSearchQueryVisitor<QueryData>- Throws:
FHIRPersistenceException
-
addReverseChained
public QueryData addReverseChained(QueryData queryData, QueryParameter currentParm) throws FHIRPersistenceException
Description copied from interface:SearchQueryVisitorAdd a reverse chain subquery element as part of a chained parameter search- Specified by:
addReverseChainedin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addNumberParam
public QueryData addNumberParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm) throws FHIRPersistenceException
Description copied from interface:SearchQueryVisitorFilter the query using the given number parameter- Specified by:
addNumberParamin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addQuantityParam
public QueryData addQuantityParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm) throws FHIRPersistenceException
Description copied from interface:SearchQueryVisitorFilter the query using the given quantity parameter- Specified by:
addQuantityParamin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addDateParam
public QueryData addDateParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm) throws FHIRPersistenceException
Description copied from interface:SearchQueryVisitorFilter the query using the given date parameter- Specified by:
addDateParamin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addLocationParam
public QueryData addLocationParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm) throws FHIRPersistenceException
Description copied from interface:SearchQueryVisitorFilter the query using the given location (lat/lng) param- Specified by:
addLocationParamin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addReferenceParam
public QueryData addReferenceParam(QueryData queryData, java.lang.String resourceType, QueryParameter queryParm) throws FHIRPersistenceException
Description copied from interface:SearchQueryVisitorFilter the query using the given reference parameter- Specified by:
addReferenceParamin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addCompositeParam
public QueryData addCompositeParam(QueryData queryData, QueryParameter queryParm) throws FHIRPersistenceException
Description copied from interface:SearchQueryVisitorAdd a composite query parameter filter to the query- Specified by:
addCompositeParamin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addCompositeParam
public QueryData addCompositeParam(QueryData queryData, QueryParameter queryParm, boolean isMissing) throws FHIRPersistenceException
Description copied from interface:SearchQueryVisitorAdd a composite query which only tests missing/not missing, not the actual parameter value- Specified by:
addCompositeParamin interfaceSearchQueryVisitor<QueryData>- Returns:
- Throws:
FHIRPersistenceException
-
addSortParam
public void addSortParam(QueryData queryData, java.lang.String code, SearchConstants.Type type, Sort.Direction direction) throws FHIRPersistenceException
Description copied from interface:SearchQueryVisitorAdd the given sort parameter to the sort query- Specified by:
addSortParamin interfaceSearchQueryVisitor<QueryData>- Throws:
FHIRPersistenceException
-
getSortParameterTableName
protected java.lang.String getSortParameterTableName(java.lang.String resourceType, java.lang.String code, SearchConstants.Type type) throws FHIRPersistenceExceptionReturns the name of the database table corresponding to the code and type of the passed sort parameter.- Parameters:
code- A SortParameter codetype- A SortParameter type- Returns:
- String - A database table name
- Throws:
FHIRPersistenceException
-
-