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.dao;
021
022import ca.uhn.fhir.jpa.model.entity.BaseTag;
023import ca.uhn.fhir.jpa.model.entity.IBaseResourceEntity;
024import ca.uhn.fhir.jpa.model.entity.ResourceTag;
025import jakarta.annotation.Nullable;
026import org.hl7.fhir.instance.model.api.IBaseResource;
027
028import java.util.Collection;
029
030public interface IJpaStorageResourceParser extends IStorageResourceParser {
031
032        /**
033         * Convert a storage entity into a FHIR resource model instance. This method may return null if the entity is not
034         * completely flushed, including the entities history entries.
035         */
036        <R extends IBaseResource> R toResource(
037                        Class<R> theResourceType,
038                        IBaseResourceEntity theEntity,
039                        Collection<ResourceTag> theTagList,
040                        boolean theForHistoryOperation);
041
042        /**
043         * Populate the metadata (Resource.meta.*) from a storage entity and other related
044         * objects pulled from the database
045         */
046        <R extends IBaseResource> R populateResourceMetadata(
047                        IBaseResourceEntity theEntitySource,
048                        boolean theForHistoryOperation,
049                        @Nullable Collection<? extends BaseTag> tagList,
050                        long theVersion,
051                        R theResourceTarget);
052
053        /**
054         * Populates a resource model object's metadata (Resource.meta.*) based on the
055         * values from a storage entity.
056         *
057         * @param theEntitySource The source
058         * @param theResourceTarget The target
059         */
060        void updateResourceMetadata(IBaseResourceEntity theEntitySource, IBaseResource theResourceTarget);
061}