001package ca.uhn.fhir.jpa.api.dao;
002
003/*
004 * #%L
005 * HAPI FHIR JPA API
006 * %%
007 * Copyright (C) 2014 - 2021 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.jpa.api.model.ExpungeOptions;
024import ca.uhn.fhir.jpa.api.model.ExpungeOutcome;
025import ca.uhn.fhir.rest.api.server.IBundleProvider;
026import ca.uhn.fhir.rest.api.server.RequestDetails;
027import org.hl7.fhir.instance.model.api.IBaseBundle;
028
029import javax.annotation.Nullable;
030import java.util.Date;
031import java.util.Map;
032
033/**
034 * Note that this interface is not considered a stable interface. While it is possible to build applications
035 * that use it directly, please be aware that we may modify methods, add methods, or even remove methods from
036 * time to time, even within minor point releases.
037 *
038 * @param <T>  The bundle type
039 * @param <MT> The Meta datatype type
040 */
041public interface IFhirSystemDao<T, MT> extends IDao {
042
043        ExpungeOutcome expunge(ExpungeOptions theExpungeOptions, RequestDetails theRequestDetails);
044
045        Map<String, Long> getResourceCounts();
046
047        /**
048         * Returns a cached count of resources using a cache that regularly
049         * refreshes in the background. This method will never block, and may return null if nothing is in the cache.
050         */
051        @Nullable
052        Map<String, Long> getResourceCountsFromCache();
053
054
055        IBundleProvider history(Date theDate, Date theUntil, Integer theOffset, RequestDetails theRequestDetails);
056
057        /**
058         * Not supported for DSTU1
059         *
060         * @param theRequestDetails TODO
061         */
062        MT metaGetOperation(RequestDetails theRequestDetails);
063
064        /**
065         * Implementations may implement this method to implement the $process-message
066         * operation
067         */
068        IBaseBundle processMessage(RequestDetails theRequestDetails, IBaseBundle theMessage);
069
070        /**
071         * Executes a FHIR transaction using a new database transaction. This method must
072         * not be called from within a DB transaction.
073         */
074        T transaction(RequestDetails theRequestDetails, T theResources);
075
076        /**
077         * Executes a FHIR transaction nested inside the current database transaction.
078         * This form of the transaction processor can handle write operations only (no reads)
079         */
080        default T transactionNested(RequestDetails theRequestDetails, T theResources) {
081                throw new UnsupportedOperationException();
082        }
083
084}