001/*- 002 * #%L 003 * HAPI FHIR Storage api 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.api.svc; 021 022import ca.uhn.fhir.i18n.Msg; 023import ca.uhn.fhir.interceptor.model.RequestPartitionId; 024import ca.uhn.fhir.jpa.api.pid.IResourcePidList; 025import ca.uhn.fhir.jpa.api.pid.IResourcePidStream; 026import ca.uhn.fhir.jpa.api.pid.ListWrappingPidStream; 027import jakarta.annotation.Nonnull; 028import jakarta.annotation.Nullable; 029 030import java.util.Date; 031 032public interface IBatch2DaoSvc { 033 034 /** 035 * Indicates whether reindexing all resource types is supported. Implementations are expected to provide a static response (either they support this or they don't). 036 */ 037 boolean isAllResourceTypeSupported(); 038 039 /** 040 * Fetches a page of resource IDs for all resource types. The page size is up to the discretion of the implementation. 041 * 042 * @param theStart The start of the date range, must be inclusive. 043 * @param theEnd The end of the date range, should be exclusive. 044 * @param theRequestPartitionId The request partition ID (may be <code>null</code> on non-partitioned systems) 045 * @param theUrl The search URL, or <code>null</code> to return IDs for all resources across all resource types. Null will only be supplied if {@link #isAllResourceTypeSupported()} returns <code>true</code>. 046 */ 047 default IResourcePidList fetchResourceIdsPage( 048 Date theStart, Date theEnd, @Nullable RequestPartitionId theRequestPartitionId, @Nullable String theUrl) { 049 throw new UnsupportedOperationException(Msg.code(2425) + "Not implemented unless explicitly overridden"); 050 } 051 052 // TODO: LD: eliminate this call in all other implementors 053 /** 054 * @deprecated Please call (@link {@link #fetchResourceIdsPage(Date, Date, RequestPartitionId, String)} instead. 055 * <p/> 056 * Fetches a page of resource IDs for all resource types. The page size is up to the discretion of the implementation. 057 * 058 * @param theStart The start of the date range, must be inclusive. 059 * @param theEnd The end of the date range, should be exclusive. 060 * @param thePageSize The number of records to query in each pass. 061 * @param theRequestPartitionId The request partition ID (may be <code>null</code> on non-partitioned systems) 062 * @param theUrl The search URL, or <code>null</code> to return IDs for all resources across all resource types. Null will only be supplied if {@link #isAllResourceTypeSupported()} returns <code>true</code>. 063 */ 064 @Deprecated 065 default IResourcePidList fetchResourceIdsPage( 066 Date theStart, 067 Date theEnd, 068 @Nonnull Integer thePageSize, 069 @Nullable RequestPartitionId theRequestPartitionId, 070 @Nullable String theUrl) { 071 return fetchResourceIdsPage(theStart, theEnd, theRequestPartitionId, theUrl); 072 } 073 074 default IResourcePidStream fetchResourceIdStream( 075 Date theStart, Date theEnd, RequestPartitionId theTargetPartitionId, String theUrl) { 076 return new ListWrappingPidStream(fetchResourceIdsPage( 077 theStart, theEnd, 20000 /* ResourceIdListStep.DEFAULT_PAGE_SIZE */, theTargetPartitionId, theUrl)); 078 } 079}