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.ResourceIdPredicateBuilder; 031import ca.uhn.fhir.jpa.search.builder.predicate.ResourceLinkPredicateBuilder; 032import ca.uhn.fhir.jpa.search.builder.predicate.ResourceTablePredicateBuilder; 033import ca.uhn.fhir.jpa.search.builder.predicate.SearchParamPresentPredicateBuilder; 034import ca.uhn.fhir.jpa.search.builder.predicate.SourcePredicateBuilder; 035import ca.uhn.fhir.jpa.search.builder.predicate.StringPredicateBuilder; 036import ca.uhn.fhir.jpa.search.builder.predicate.TagPredicateBuilder; 037import ca.uhn.fhir.jpa.search.builder.predicate.TokenPredicateBuilder; 038import ca.uhn.fhir.jpa.search.builder.predicate.UriPredicateBuilder; 039import org.springframework.beans.factory.annotation.Autowired; 040import org.springframework.context.ApplicationContext; 041 042public class SqlObjectFactory { 043 044 @Autowired 045 private ApplicationContext myApplicationContext; 046 047 public ComboUniqueSearchParameterPredicateBuilder newComboUniqueSearchParameterPredicateBuilder( 048 SearchQueryBuilder theSearchSqlBuilder) { 049 return myApplicationContext.getBean(ComboUniqueSearchParameterPredicateBuilder.class, theSearchSqlBuilder); 050 } 051 052 public ComboNonUniqueSearchParameterPredicateBuilder newComboNonUniqueSearchParameterPredicateBuilder( 053 SearchQueryBuilder theSearchSqlBuilder) { 054 return myApplicationContext.getBean(ComboNonUniqueSearchParameterPredicateBuilder.class, theSearchSqlBuilder); 055 } 056 057 public CoordsPredicateBuilder coordsPredicateBuilder(SearchQueryBuilder theSearchSqlBuilder) { 058 return myApplicationContext.getBean(CoordsPredicateBuilder.class, theSearchSqlBuilder); 059 } 060 061 public DatePredicateBuilder dateIndexTable(SearchQueryBuilder theSearchSqlBuilder) { 062 return myApplicationContext.getBean(DatePredicateBuilder.class, theSearchSqlBuilder); 063 } 064 065 public NumberPredicateBuilder numberIndexTable(SearchQueryBuilder theSearchSqlBuilder) { 066 return myApplicationContext.getBean(NumberPredicateBuilder.class, theSearchSqlBuilder); 067 } 068 069 public QuantityPredicateBuilder quantityIndexTable(SearchQueryBuilder theSearchSqlBuilder) { 070 return myApplicationContext.getBean(QuantityPredicateBuilder.class, theSearchSqlBuilder); 071 } 072 073 public QuantityNormalizedPredicateBuilder quantityNormalizedIndexTable(SearchQueryBuilder theSearchSqlBuilder) { 074 return myApplicationContext.getBean(QuantityNormalizedPredicateBuilder.class, theSearchSqlBuilder); 075 } 076 077 public ResourceLinkPredicateBuilder referenceIndexTable( 078 QueryStack theQueryStack, SearchQueryBuilder theSearchSqlBuilder, boolean theReversed) { 079 return myApplicationContext.getBean( 080 ResourceLinkPredicateBuilder.class, theQueryStack, theSearchSqlBuilder, theReversed); 081 } 082 083 public ResourceTablePredicateBuilder resourceTable(SearchQueryBuilder theSearchSqlBuilder) { 084 return myApplicationContext.getBean(ResourceTablePredicateBuilder.class, theSearchSqlBuilder); 085 } 086 087 public ResourceIdPredicateBuilder resourceId(SearchQueryBuilder theSearchSqlBuilder) { 088 return myApplicationContext.getBean(ResourceIdPredicateBuilder.class, theSearchSqlBuilder); 089 } 090 091 public SearchParamPresentPredicateBuilder searchParamPresentPredicateBuilder( 092 SearchQueryBuilder theSearchSqlBuilder) { 093 return myApplicationContext.getBean(SearchParamPresentPredicateBuilder.class, theSearchSqlBuilder); 094 } 095 096 public StringPredicateBuilder stringIndexTable(SearchQueryBuilder theSearchSqlBuilder) { 097 return myApplicationContext.getBean(StringPredicateBuilder.class, theSearchSqlBuilder); 098 } 099 100 public TokenPredicateBuilder tokenIndexTable(SearchQueryBuilder theSearchSqlBuilder) { 101 return myApplicationContext.getBean(TokenPredicateBuilder.class, theSearchSqlBuilder); 102 } 103 104 public UriPredicateBuilder uriIndexTable(SearchQueryBuilder theSearchSqlBuilder) { 105 return myApplicationContext.getBean(UriPredicateBuilder.class, theSearchSqlBuilder); 106 } 107 108 public TagPredicateBuilder newTagPredicateBuilder(SearchQueryBuilder theSearchSqlBuilder) { 109 return myApplicationContext.getBean(TagPredicateBuilder.class, theSearchSqlBuilder); 110 } 111 112 public SourcePredicateBuilder newSourcePredicateBuilder(SearchQueryBuilder theSearchSqlBuilder) { 113 return myApplicationContext.getBean(SourcePredicateBuilder.class, theSearchSqlBuilder); 114 } 115 116 public SearchQueryExecutor newSearchQueryExecutor(GeneratedSql theGeneratedSql, Integer theMaxResultsToFetch) { 117 return myApplicationContext.getBean(SearchQueryExecutor.class, theGeneratedSql, theMaxResultsToFetch); 118 } 119}