Class AbstractQueryBuilder<T1>

  • All Implemented Interfaces:
    QueryBuilder<T1>
    Direct Known Subclasses:
    JDBCQueryBuilder

    public abstract class AbstractQueryBuilder<T1>
    extends Object
    implements QueryBuilder<T1>
    This class defines a reusable method structure and common functionality for a FHIR persistence query builder.
    • Constructor Detail

      • AbstractQueryBuilder

        public AbstractQueryBuilder()
    • Method Detail

      • extractReferenceFromUrl

        public static String extractReferenceFromUrl​(String parmValue)
        Examines the passed ParamaterValue, and checks to see if the value is a URL. If it is, the {ResourceType/id} part of the URL path is extracted and returned. For example: If the input value is http://localhost:8080/fhir/Patient/123, then Patient/123 is returned.
        Parameters:
        parmValue - A valid String parameter value that may or may not contain a URL.
        Returns:
        String - The last 2 segments of the URL path is returned if the passed parmValue is a URL; otherwise, null is returned.
      • isAbsoluteURL

        public static boolean isAbsoluteURL​(String s)
      • buildQueryParm

        protected T1 buildQueryParm​(Class<?> resourceType,
                                    QueryParameter queryParm)
                             throws Exception
        Builds a query segment for the passed query parameter.
        Parameters:
        resourceType - - A valid FHIR Resource type
        queryParm - - A Parameter object describing the name, value and type of search parm.
        Returns:
        T1 - An object representing the selector query segment for the passed search parm.
        Throws:
        Exception
      • processReferenceParm

        protected abstract T1 processReferenceParm​(Class<?> resourceType,
                                                   QueryParameter queryParm)
                                            throws Exception
        Creates a query segment for a Reference type parameter.
        Parameters:
        resourceType - - The resource type.
        queryParm - - The query parameter.
        Returns:
        T1 - An object containing query segment.
        Throws:
        Exception
      • processChainedReferenceParm

        protected abstract T1 processChainedReferenceParm​(QueryParameter queryParm)
                                                   throws Exception
        Contains special logic for handling chained reference search parameters.
        Parameters:
        queryParm - - The query parameter.
        Returns:
        T1 - An object containing a query segment.
        Throws:
        FHIRPersistenceException
        Exception
      • processReverseChainedReferenceParm

        protected abstract T1 processReverseChainedReferenceParm​(Class<?> resourceType,
                                                                 QueryParameter queryParm)
                                                          throws Exception
        Contains special logic for handling reverse chained reference search parameters.
        Parameters:
        resourceType - - The resource type.
        queryParm - - The query parameter.
        Returns:
        T1 - An object containing a query segment.
        Throws:
        FHIRPersistenceException
        Exception
      • processInclusionCriteria

        protected abstract T1 processInclusionCriteria​(QueryParameter queryParm)
                                                throws Exception
        Contains special logic for handling Compartment based searches.
        Parameters:
        queryParm - - The query parameter.
        Returns:
        T1 - An object containing a query segment.
        Throws:
        FHIRPersistenceException
        Exception
      • processDateParm

        protected abstract T1 processDateParm​(Class<?> resourceType,
                                              QueryParameter queryParm)
                                       throws Exception
        Creates a query segment for a Date type parameter.
        Parameters:
        resourceType - - The resource type.
        queryParm - - The query parameter.
        Returns:
        T1 - An object containing query segment.
        Throws:
        Exception
      • processTokenParm

        protected abstract T1 processTokenParm​(Class<?> resourceType,
                                               QueryParameter queryParm)
                                        throws FHIRPersistenceException
        Creates a query segment for a Token type parameter.
        Parameters:
        resourceType - - The resource type.
        queryParm - - The query parameter.
        Returns:
        T1 - An object containing query segment.
        Throws:
        FHIRPersistenceException
      • processNumberParm

        protected abstract T1 processNumberParm​(Class<?> resourceType,
                                                QueryParameter queryParm)
                                         throws FHIRPersistenceException
        Creates a query segment for a Number type parameter.
        Parameters:
        resourceType - - The resource type.
        queryParm - - The query parameter.
        Returns:
        T1 - An object containing query segment.
        Throws:
        FHIRPersistenceException
      • processQuantityParm

        protected abstract T1 processQuantityParm​(Class<?> resourceType,
                                                  QueryParameter queryParm)
                                           throws Exception
        Creates a query segment for a Quantity type parameter.
        Parameters:
        resourceType - - The resource type.
        queryParm - - The query parameter.
        Returns:
        T1 - An object containing query segment.
        Throws:
        Exception
      • processCompositeParm

        protected abstract T1 processCompositeParm​(Class<?> resourceType,
                                                   QueryParameter queryParm)
                                            throws FHIRPersistenceException
        Creates a query segment for a Composite type parameter.
        Parameters:
        resourceType - - The resource type.
        queryParm - - The query parameter
        Returns:
        T1 - An object containing query segment
        Throws:
        FHIRPersistenceException
      • processLocationPosition

        protected T1 processLocationPosition​(List<QueryParameter> queryParameters,
                                             String paramTableAlias)
                                      throws FHIRPersistenceException
        This method executes special logic for a Token type query that maps to a LocationPosition data type.
        Parameters:
        queryParameters - The entire collection of query input parameters
        paramTableAlias - the alias name of the parameter table
        Returns:
        T1 - A query segment related to a LocationPosition
        Throws:
        FHIRPersistenceException
      • buildLocationQuerySegment

        protected abstract T1 buildLocationQuerySegment​(String parmName,
                                                        List<Bounding> boundingAreas,
                                                        String paramTableAlias)
                                                 throws FHIRPersistenceException
        Builds a query segment for the passed parameter name using the geospatial data contained with the passed BoundingBox
        Parameters:
        parmName - - The name of the search parameter
        boundingAreas - - Container for the geospatial data needed to construct the query segment.
        paramTableAlias - the alias name of the parameter table
        Returns:
        T1 - The query segment necessary for searching locations that are inside the bounding box.
        Throws:
        FHIRPersistenceException