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.config;
021
022import ca.uhn.fhir.context.FhirContext;
023import ca.uhn.fhir.jpa.api.config.JpaStorageSettings;
024import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
025import ca.uhn.fhir.jpa.api.svc.IBatch2DaoSvc;
026import ca.uhn.fhir.jpa.api.svc.IDeleteExpungeSvc;
027import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
028import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc;
029import ca.uhn.fhir.jpa.dao.data.IResourceLinkDao;
030import ca.uhn.fhir.jpa.dao.data.IResourceTableDao;
031import ca.uhn.fhir.jpa.dao.expunge.ResourceTableFKProvider;
032import ca.uhn.fhir.jpa.dao.tx.IHapiTransactionService;
033import ca.uhn.fhir.jpa.delete.batch2.DeleteExpungeSqlBuilder;
034import ca.uhn.fhir.jpa.delete.batch2.DeleteExpungeSvcImpl;
035import ca.uhn.fhir.jpa.reindex.Batch2DaoSvcImpl;
036import ca.uhn.fhir.jpa.searchparam.MatchUrlService;
037import jakarta.persistence.EntityManager;
038import org.springframework.beans.factory.annotation.Autowired;
039import org.springframework.context.annotation.Bean;
040
041public class Batch2SupportConfig {
042
043        @Bean
044        public IBatch2DaoSvc batch2DaoSvc(
045                        IResourceTableDao theResourceTableDao,
046                        MatchUrlService theMatchUrlService,
047                        DaoRegistry theDaoRegistry,
048                        FhirContext theFhirContext,
049                        IHapiTransactionService theTransactionService) {
050                return new Batch2DaoSvcImpl(
051                                theResourceTableDao, theMatchUrlService, theDaoRegistry, theFhirContext, theTransactionService);
052        }
053
054        @Bean
055        public IDeleteExpungeSvc deleteExpungeSvc(
056                        EntityManager theEntityManager,
057                        DeleteExpungeSqlBuilder theDeleteExpungeSqlBuilder,
058                        @Autowired(required = false) IFulltextSearchSvc theFullTextSearchSvc) {
059                return new DeleteExpungeSvcImpl(theEntityManager, theDeleteExpungeSqlBuilder, theFullTextSearchSvc);
060        }
061
062        @Bean
063        DeleteExpungeSqlBuilder deleteExpungeSqlBuilder(
064                        ResourceTableFKProvider theResourceTableFKProvider,
065                        JpaStorageSettings theStorageSettings,
066                        IIdHelperService theIdHelper,
067                        IResourceLinkDao theResourceLinkDao) {
068                return new DeleteExpungeSqlBuilder(
069                                theResourceTableFKProvider, theStorageSettings, theIdHelper, theResourceLinkDao);
070        }
071}