001/*-
002 * #%L
003 * HAPI FHIR JPA Server
004 * %%
005 * Copyright (C) 2014 - 2024 Smile CDR, Inc.
006 * %%
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 * You may obtain a copy of the License at
010 *
011 *      http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 * #L%
019 */
020package ca.uhn.fhir.jpa.search.builder.sql;
021
022import ca.uhn.fhir.jpa.search.builder.QueryStack;
023import ca.uhn.fhir.jpa.search.builder.predicate.ComboNonUniqueSearchParameterPredicateBuilder;
024import ca.uhn.fhir.jpa.search.builder.predicate.ComboUniqueSearchParameterPredicateBuilder;
025import ca.uhn.fhir.jpa.search.builder.predicate.CoordsPredicateBuilder;
026import ca.uhn.fhir.jpa.search.builder.predicate.DatePredicateBuilder;
027import ca.uhn.fhir.jpa.search.builder.predicate.NumberPredicateBuilder;
028import ca.uhn.fhir.jpa.search.builder.predicate.QuantityNormalizedPredicateBuilder;
029import ca.uhn.fhir.jpa.search.builder.predicate.QuantityPredicateBuilder;
030import ca.uhn.fhir.jpa.search.builder.predicate.ResourceHistoryPredicateBuilder;
031import ca.uhn.fhir.jpa.search.builder.predicate.ResourceHistoryProvenancePredicateBuilder;
032import ca.uhn.fhir.jpa.search.builder.predicate.ResourceIdPredicateBuilder;
033import ca.uhn.fhir.jpa.search.builder.predicate.ResourceLinkPredicateBuilder;
034import ca.uhn.fhir.jpa.search.builder.predicate.ResourceTablePredicateBuilder;
035import ca.uhn.fhir.jpa.search.builder.predicate.SearchParamPresentPredicateBuilder;
036import ca.uhn.fhir.jpa.search.builder.predicate.StringPredicateBuilder;
037import ca.uhn.fhir.jpa.search.builder.predicate.TagPredicateBuilder;
038import ca.uhn.fhir.jpa.search.builder.predicate.TokenPredicateBuilder;
039import ca.uhn.fhir.jpa.search.builder.predicate.UriPredicateBuilder;
040import org.springframework.beans.factory.annotation.Autowired;
041import org.springframework.context.ApplicationContext;
042
043public class SqlObjectFactory {
044
045        @Autowired
046        private ApplicationContext myApplicationContext;
047
048        public ComboUniqueSearchParameterPredicateBuilder newComboUniqueSearchParameterPredicateBuilder(
049                        SearchQueryBuilder theSearchSqlBuilder) {
050                return myApplicationContext.getBean(ComboUniqueSearchParameterPredicateBuilder.class, theSearchSqlBuilder);
051        }
052
053        public ComboNonUniqueSearchParameterPredicateBuilder newComboNonUniqueSearchParameterPredicateBuilder(
054                        SearchQueryBuilder theSearchSqlBuilder) {
055                return myApplicationContext.getBean(ComboNonUniqueSearchParameterPredicateBuilder.class, theSearchSqlBuilder);
056        }
057
058        public CoordsPredicateBuilder coordsPredicateBuilder(SearchQueryBuilder theSearchSqlBuilder) {
059                return myApplicationContext.getBean(CoordsPredicateBuilder.class, theSearchSqlBuilder);
060        }
061
062        public DatePredicateBuilder dateIndexTable(SearchQueryBuilder theSearchSqlBuilder) {
063                return myApplicationContext.getBean(DatePredicateBuilder.class, theSearchSqlBuilder);
064        }
065
066        public NumberPredicateBuilder numberIndexTable(SearchQueryBuilder theSearchSqlBuilder) {
067                return myApplicationContext.getBean(NumberPredicateBuilder.class, theSearchSqlBuilder);
068        }
069
070        public QuantityPredicateBuilder quantityIndexTable(SearchQueryBuilder theSearchSqlBuilder) {
071                return myApplicationContext.getBean(QuantityPredicateBuilder.class, theSearchSqlBuilder);
072        }
073
074        public QuantityNormalizedPredicateBuilder quantityNormalizedIndexTable(SearchQueryBuilder theSearchSqlBuilder) {
075                return myApplicationContext.getBean(QuantityNormalizedPredicateBuilder.class, theSearchSqlBuilder);
076        }
077
078        public ResourceLinkPredicateBuilder referenceIndexTable(
079                        QueryStack theQueryStack, SearchQueryBuilder theSearchSqlBuilder, boolean theReversed) {
080                return myApplicationContext.getBean(
081                                ResourceLinkPredicateBuilder.class, theQueryStack, theSearchSqlBuilder, theReversed);
082        }
083
084        public ResourceTablePredicateBuilder resourceTable(SearchQueryBuilder theSearchSqlBuilder) {
085                return myApplicationContext.getBean(ResourceTablePredicateBuilder.class, theSearchSqlBuilder);
086        }
087
088        public ResourceIdPredicateBuilder resourceId(SearchQueryBuilder theSearchSqlBuilder) {
089                return myApplicationContext.getBean(ResourceIdPredicateBuilder.class, theSearchSqlBuilder);
090        }
091
092        public SearchParamPresentPredicateBuilder searchParamPresentPredicateBuilder(
093                        SearchQueryBuilder theSearchSqlBuilder) {
094                return myApplicationContext.getBean(SearchParamPresentPredicateBuilder.class, theSearchSqlBuilder);
095        }
096
097        public StringPredicateBuilder stringIndexTable(SearchQueryBuilder theSearchSqlBuilder) {
098                return myApplicationContext.getBean(StringPredicateBuilder.class, theSearchSqlBuilder);
099        }
100
101        public TokenPredicateBuilder tokenIndexTable(SearchQueryBuilder theSearchSqlBuilder) {
102                return myApplicationContext.getBean(TokenPredicateBuilder.class, theSearchSqlBuilder);
103        }
104
105        public UriPredicateBuilder uriIndexTable(SearchQueryBuilder theSearchSqlBuilder) {
106                return myApplicationContext.getBean(UriPredicateBuilder.class, theSearchSqlBuilder);
107        }
108
109        public TagPredicateBuilder newTagPredicateBuilder(SearchQueryBuilder theSearchSqlBuilder) {
110                return myApplicationContext.getBean(TagPredicateBuilder.class, theSearchSqlBuilder);
111        }
112
113        public ResourceHistoryPredicateBuilder newResourceHistoryPredicateBuilder(SearchQueryBuilder theSearchSqlBuilder) {
114                return myApplicationContext.getBean(ResourceHistoryPredicateBuilder.class, theSearchSqlBuilder);
115        }
116
117        public ResourceHistoryProvenancePredicateBuilder newResourceHistoryProvenancePredicateBuilder(
118                        SearchQueryBuilder theSearchSqlBuilder) {
119                return myApplicationContext.getBean(ResourceHistoryProvenancePredicateBuilder.class, theSearchSqlBuilder);
120        }
121
122        public SearchQueryExecutor newSearchQueryExecutor(GeneratedSql theGeneratedSql, Integer theMaxResultsToFetch) {
123                return myApplicationContext.getBean(SearchQueryExecutor.class, theGeneratedSql, theMaxResultsToFetch);
124        }
125}