001package ca.uhn.fhir.jpa.api.dao;
002
003/*
004 * #%L
005 * HAPI FHIR Storage api
006 * %%
007 * Copyright (C) 2014 - 2022 Smile CDR, Inc.
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 * http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import ca.uhn.fhir.i18n.Msg;
024import ca.uhn.fhir.jpa.api.model.ExpungeOptions;
025import ca.uhn.fhir.jpa.api.model.ExpungeOutcome;
026import ca.uhn.fhir.rest.api.server.IBundleProvider;
027import ca.uhn.fhir.rest.api.server.RequestDetails;
028import org.hl7.fhir.instance.model.api.IBaseBundle;
029import org.springframework.transaction.annotation.Transactional;
030
031import javax.annotation.Nullable;
032import java.util.Date;
033import java.util.Map;
034
035/**
036 * Note that this interface is not considered a stable interface. While it is possible to build applications
037 * that use it directly, please be aware that we may modify methods, add methods, or even remove methods from
038 * time to time, even within minor point releases.
039 *
040 * @param <T>  The bundle type
041 * @param <MT> The Meta datatype type
042 */
043public interface IFhirSystemDao<T, MT> extends IDao {
044
045        ExpungeOutcome expunge(ExpungeOptions theExpungeOptions, RequestDetails theRequestDetails);
046
047        Map<String, Long> getResourceCounts();
048
049        /**
050         * Returns a cached count of resources using a cache that regularly
051         * refreshes in the background. This method will never block, and may return null if nothing is in the cache.
052         */
053        @Nullable
054        Map<String, Long> getResourceCountsFromCache();
055
056
057        IBundleProvider history(Date theDate, Date theUntil, Integer theOffset, RequestDetails theRequestDetails);
058
059        /**
060         * Not supported for DSTU1
061         *
062         * @param theRequestDetails TODO
063         */
064        @Transactional
065        MT metaGetOperation(RequestDetails theRequestDetails);
066
067        /**
068         * Implementations may implement this method to implement the $process-message
069         * operation
070         */
071        IBaseBundle processMessage(RequestDetails theRequestDetails, IBaseBundle theMessage);
072
073        /**
074         * Executes a FHIR transaction using a new database transaction. This method must
075         * not be called from within a DB transaction.
076         */
077        T transaction(RequestDetails theRequestDetails, T theResources);
078
079        /**
080         * Executes a FHIR transaction nested inside the current database transaction.
081         * This form of the transaction processor can handle write operations only (no reads)
082         */
083        default T transactionNested(RequestDetails theRequestDetails, T theResources) {
084                throw new UnsupportedOperationException(Msg.code(570));
085        }
086
087}