
Package ca.uhn.fhir.jpa.dao
Class BaseHapiFhirDao<T extends org.hl7.fhir.instance.model.api.IBaseResource>
java.lang.Object
ca.uhn.fhir.jpa.dao.BaseStorageDao
ca.uhn.fhir.jpa.dao.BaseStorageResourceDao<T>
ca.uhn.fhir.jpa.dao.BaseHapiFhirDao<T>
- All Implemented Interfaces:
IDao,IFhirResourceDao<T>,IJpaDao<T>,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
BaseHapiFhirResourceDao
@Repository
public abstract class BaseHapiFhirDao<T extends org.hl7.fhir.instance.model.api.IBaseResource>
extends BaseStorageResourceDao<T>
implements IDao, IJpaDao<T>, org.springframework.context.ApplicationContextAware
TODO: JA - This class has only one subclass now. Historically it was a common
ancestor for BaseHapiFhirSystemDao and BaseHapiFhirResourceDao but I've untangled
the former from this hierarchy in order to simplify moving common functionality
for resource DAOs into the hapi-fhir-storage project. This class should be merged
into BaseHapiFhirResourceDao, but that should be done in its own dedicated PR
since it'll be a noisy change.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CacheTagDefinitionDaoprotected final CodingSpyprotected DeleteConflictServiceprotected jakarta.persistence.EntityManagerprotected IIdHelperService<JpaPid> protected InMemoryResourceMatcherprotected ca.uhn.fhir.interceptor.api.IInterceptorBroadcasterprotected IJpaStorageResourceParserprotected PartitionSettingsprotected ResourceHistoryCalculatorprotected IResourceHistoryTableDaoprotected IResourceLinkDaoprotected IResourceTableDaoprotected IResourceTagDaoprotected IResourceTypeCacheSvcprotected ISearchCoordinatorSvc<JpaPid> protected ITermReadSvcstatic final StringFields inherited from class ca.uhn.fhir.jpa.dao.BaseStorageResourceDao
STRICT_ERROR_HANDLERFields inherited from class ca.uhn.fhir.jpa.dao.BaseStorageDao
MESSAGE_KEY_DELETE_RESOURCE_ALREADY_DELETED, MESSAGE_KEY_DELETE_RESOURCE_NOT_EXISTING, myDaoRegistry, myFhirContext, myMetaTagSorter, myResourceVersionSvc, mySearchParamRegistry, myStorageSettings, OO_ISSUE_CODE_INFORMATIONAL, OO_SEVERITY_ERROR, OO_SEVERITY_INFO, OO_SEVERITY_WARNFields inherited from interface ca.uhn.fhir.jpa.api.dao.IDao
CURRENTLY_REINDEXING, RESOURCE_PID, RESOURCE_PID_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddPidToResource(IResourceLookup<JpaPid> theEntity, org.hl7.fhir.instance.model.api.IBaseResource theResource) static StringdecodeResource(byte[] theResourceBytes, ResourceEncodingEnum theResourceEncoding) protected org.springframework.context.ApplicationContextca.uhn.fhir.context.FhirContextprotected ca.uhn.fhir.interceptor.api.IInterceptorBroadcasterbooleanisLogicalReference(org.hl7.fhir.instance.model.api.IIdType theId) static StringparseContentTextIntoWords(ca.uhn.fhir.context.FhirContext theContext, org.hl7.fhir.instance.model.api.IBaseResource theResource) protected ca.uhn.fhir.jpa.dao.EncodedResourcepopulateResourceIntoEntity(ca.uhn.fhir.rest.api.server.storage.TransactionDetails theTransactionDetails, ca.uhn.fhir.rest.api.server.RequestDetails theRequest, org.hl7.fhir.instance.model.api.IBaseResource theResource, ResourceTable theEntity, boolean thePerformIndexing) Returns true if the resource has changed (either the contents or the tags)protected voidpostDelete(ResourceTable theEntity) Subclasses may override to provide behaviour.protected voidpostPersist(ResourceTable theEntity, T theResource, ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails) Subclasses may override to provide behaviour.protected voidpostUpdate(ResourceTable theEntity, T theResource, ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails) Subclasses may override to provide behaviour.readEntity(org.hl7.fhir.instance.model.api.IIdType theValueId, ca.uhn.fhir.rest.api.server.RequestDetails theRequest) voidsetApplicationContext(org.springframework.context.ApplicationContext theApplicationContext) voidsetContext(ca.uhn.fhir.context.FhirContext theContext) voidsetDaoSearchParamSynchronizer(DaoSearchParamSynchronizer theDaoSearchParamSynchronizer) static voidsetDisableIncrementOnUpdateForUnitTest(boolean theDisableIncrementOnUpdateForUnitTest) voidsetEntityManager(jakarta.persistence.EntityManager theEntityManager) voidsetExternallyStoredResourceServiceRegistryForUnitTest(ExternallyStoredResourceServiceRegistry theExternallyStoredResourceServiceRegistry) voidsetInterceptorBroadcasterForUnitTest(ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster theInterceptorBroadcaster) voidsetJpaStorageResourceParserForUnitTest(IJpaStorageResourceParser theJpaStorageResourceParser) Do not call this method outside of unit testsvoidsetPartitionSettingsForUnitTest(PartitionSettings thePartitionSettings) voidsetResourceHistoryCalculator(ResourceHistoryCalculator theResourceHistoryCalculator) voidsetResourceHistoryTableDao(IResourceHistoryTableDao theResourceHistoryTableDao) voidsetResourceTypeCacheSvc(IResourceTypeCacheSvc theResourceTypeCacheSvc) voidsetSearchParamPresenceSvc(ISearchParamPresenceSvc theSearchParamPresenceSvc) voidsetSearchParamWithInlineReferencesExtractor(SearchParamWithInlineReferencesExtractor theSearchParamWithInlineReferencesExtractor) voidsetStorageSettingsForUnitTest(JpaStorageSettings theStorageSettings) static voidsetValidationDisabledForUnitTest(boolean theValidationDisabledForUnitTest) Do not call this method outside of unit testsprotected booleanshouldDroppedTagBeRemovedOnUpdate(ca.uhn.fhir.rest.api.server.RequestDetails theRequest, ResourceTag theTag) This method is called when an update to an existing resource detects that the resource supplied for update is missing a tag/profile/security label that the currently persisted resource holds.voidstart()updateEntity(ca.uhn.fhir.rest.api.server.RequestDetails theRequest, org.hl7.fhir.instance.model.api.IBaseResource theResource, IBasePersistedResource theEntity, Date theDeletedTimestampOrNull, boolean thePerformIndexing, boolean theUpdateVersion, ca.uhn.fhir.rest.api.server.storage.TransactionDetails theTransactionDetails, boolean theForceUpdate, boolean theCreateNewHistoryEntry) updateHistoryEntity(ca.uhn.fhir.rest.api.server.RequestDetails theRequest, T theResource, IBasePersistedResource<?> theEntity, IBasePersistedResource<?> theHistoryEntity, org.hl7.fhir.instance.model.api.IIdType theResourceId, ca.uhn.fhir.rest.api.server.storage.TransactionDetails theTransactionDetails, boolean isUpdatingCurrent) updateInternal(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, T theResource, String theMatchUrl, boolean thePerformIndexing, boolean theForceUpdateVersion, IBasePersistedResource theEntity, org.hl7.fhir.instance.model.api.IIdType theResourceId, org.hl7.fhir.instance.model.api.IBaseResource theOldResource, ca.uhn.fhir.rest.api.RestOperationTypeEnum theOperationType, ca.uhn.fhir.rest.api.server.storage.TransactionDetails theTransactionDetails) protected booleanupdateTags(ca.uhn.fhir.rest.api.server.storage.TransactionDetails theTransactionDetails, ca.uhn.fhir.rest.api.server.RequestDetails theRequest, org.hl7.fhir.instance.model.api.IBaseResource theResource, ResourceTable theEntity) protected voidvalidateMetaCount(int theMetaCount) protected voidvalidateResourceForStorage(T theResource, ResourceTable theEntityToSave) This method is invoked immediately before storing a new resource, or an update to an existing resource to allow the DAO to ensure that it is valid for persistence.Methods inherited from class ca.uhn.fhir.jpa.dao.BaseStorageResourceDao
deleteExpunge, doUpdateForUpdateOrPatch, getDeleteExpungeJobSubmitter, getMatchResourceUrlService, getMatchUrlService, getRequestPartitionHelperService, getResourceName, getResourceType, getStorageResourceParser, getTransactionService, patch, patchInTransaction, readEntityLatestVersion, readEntityLatestVersion, validateResourceTypeMethods inherited from class ca.uhn.fhir.jpa.dao.BaseStorageDao
addIssueToOperationOutcomeForAutoCreatedPlaceholder, clearRequestAsProcessingSubRequest, createErrorOperationOutcome, createInfoOperationOutcome, createInfoOperationOutcome, createMethodOutcomeForResourceId, createResourceGoneException, createWarnOperationOutcome, doCallHooks, extractReferencesToAutoVersion, extractReferencesToAvoidReplacement, markRequestAsProcessingSubRequest, populateOperationOutcomeForUpdate, preProcessResourceForStorage, preProcessResourceForStorage, setMyMetaTagSorter, setSearchParamRegistry, toMethodOutcome, toMethodOutcomeLazy, translateRawParameters, verifyResourceIdIsValidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ca.uhn.fhir.jpa.api.dao.IFhirResourceDao
create, create, create, create, create, delete, delete, delete, deleteByUrl, deleteByUrl, deletePidList, deletePidList, expunge, expunge, expunge, fetchAllVersionsOfResources, forceExpungeInExistingTransaction, getCurrentVersionId, getReindexJobStatus, history, history, history, metaAddOperation, metaDeleteOperation, metaGetOperation, metaGetOperation, read, read, read, readByPid, readByPid, reindex, reindex, removeTag, removeTag, search, search, search, searchForIds, searchForIds, searchForIdStream, searchForResourceIds, searchForResources, translateRawParameters, update, update, update, update, update, update, validate, validateCriteriaAndReturnResourceDefinition
-
Field Details
-
NS_JPA_PROFILE
- See Also:
-
myEntityManager
-
myIdHelperService
-
mySearchCoordinatorSvc
-
myTerminologySvc
-
myResourceHistoryTableDao
-
myResourceTableDao
-
myResourceLinkDao
-
myResourceTagDao
-
myDeleteConflictService
-
myInterceptorBroadcaster
-
myInMemoryResourceMatcher
-
myJpaStorageResourceParser
-
myPartitionSettings
-
myResourceHistoryCalculator
-
cacheTagDefinitionDao
-
myResourceTypeCacheSvc
-
myCodingSpy
-
-
Constructor Details
-
BaseHapiFhirDao
public BaseHapiFhirDao()
-
-
Method Details
-
setExternallyStoredResourceServiceRegistryForUnitTest
public void setExternallyStoredResourceServiceRegistryForUnitTest(ExternallyStoredResourceServiceRegistry theExternallyStoredResourceServiceRegistry) -
setSearchParamPresenceSvc
-
setResourceHistoryCalculator
-
setInterceptorBroadcasterForUnitTest
public void setInterceptorBroadcasterForUnitTest(ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster theInterceptorBroadcaster) -
getInterceptorBroadcaster
- Specified by:
getInterceptorBroadcasterin classBaseStorageDao
-
getApplicationContext
-
setApplicationContext
public void setApplicationContext(@Nonnull org.springframework.context.ApplicationContext theApplicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
getStorageSettings
- Specified by:
getStorageSettingsin classBaseStorageDao
-
getContext
- Specified by:
getContextin interfaceIDao- Specified by:
getContextin classBaseStorageDao
-
setContext
-
isLogicalReference
-
populateResourceIntoEntity
protected ca.uhn.fhir.jpa.dao.EncodedResource populateResourceIntoEntity(ca.uhn.fhir.rest.api.server.storage.TransactionDetails theTransactionDetails, ca.uhn.fhir.rest.api.server.RequestDetails theRequest, org.hl7.fhir.instance.model.api.IBaseResource theResource, ResourceTable theEntity, boolean thePerformIndexing) Returns true if the resource has changed (either the contents or the tags) -
updateTags
protected boolean updateTags(ca.uhn.fhir.rest.api.server.storage.TransactionDetails theTransactionDetails, ca.uhn.fhir.rest.api.server.RequestDetails theRequest, org.hl7.fhir.instance.model.api.IBaseResource theResource, ResourceTable theEntity) -
postDelete
Subclasses may override to provide behaviour. Called when a pre-existing resource has been updated in the database- Parameters:
theEntity- The resource
-
postPersist
protected void postPersist(ResourceTable theEntity, T theResource, ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails) Subclasses may override to provide behaviour. Called when a resource has been inserted into the database for the first time.- Parameters:
theEntity- The entity being updated (Do not modify the entity! Undefined behaviour will occur!)theResource- The resource being persistedtheRequestDetails- The request details, needed for partition support
-
postUpdate
protected void postUpdate(ResourceTable theEntity, T theResource, ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails) Subclasses may override to provide behaviour. Called when a pre-existing resource has been updated in the database- Parameters:
theEntity- The resourcetheResource- The resource being persistedtheRequestDetails- The request details, needed for partition support
-
readEntity
public BaseHasResource readEntity(org.hl7.fhir.instance.model.api.IIdType theValueId, ca.uhn.fhir.rest.api.server.RequestDetails theRequest) - Specified by:
readEntityin interfaceIFhirResourceDao<T extends org.hl7.fhir.instance.model.api.IBaseResource>
-
shouldDroppedTagBeRemovedOnUpdate
protected boolean shouldDroppedTagBeRemovedOnUpdate(ca.uhn.fhir.rest.api.server.RequestDetails theRequest, ResourceTag theTag) This method is called when an update to an existing resource detects that the resource supplied for update is missing a tag/profile/security label that the currently persisted resource holds.The default implementation removes any profile declarations, but leaves tags and security labels in place. Subclasses may choose to override and change this behaviour.
See Updates to Tags, Profiles, and Security Labels for a description of the logic that the default behaviour follows.
- Parameters:
theTag- The tag- Returns:
- Returns
trueif the tag should be removed
-
setEntityManager
-
setSearchParamWithInlineReferencesExtractor
public void setSearchParamWithInlineReferencesExtractor(SearchParamWithInlineReferencesExtractor theSearchParamWithInlineReferencesExtractor) -
setResourceHistoryTableDao
-
setDaoSearchParamSynchronizer
-
updateEntity
public ResourceTable updateEntity(ca.uhn.fhir.rest.api.server.RequestDetails theRequest, org.hl7.fhir.instance.model.api.IBaseResource theResource, IBasePersistedResource theEntity, Date theDeletedTimestampOrNull, boolean thePerformIndexing, boolean theUpdateVersion, ca.uhn.fhir.rest.api.server.storage.TransactionDetails theTransactionDetails, boolean theForceUpdate, boolean theCreateNewHistoryEntry) - Specified by:
updateEntityin interfaceIJpaDao<T extends org.hl7.fhir.instance.model.api.IBaseResource>
-
updateHistoryEntity
public IBasePersistedResource<?> updateHistoryEntity(ca.uhn.fhir.rest.api.server.RequestDetails theRequest, T theResource, IBasePersistedResource<?> theEntity, IBasePersistedResource<?> theHistoryEntity, org.hl7.fhir.instance.model.api.IIdType theResourceId, ca.uhn.fhir.rest.api.server.storage.TransactionDetails theTransactionDetails, boolean isUpdatingCurrent) -
updateInternal
public DaoMethodOutcome updateInternal(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, T theResource, String theMatchUrl, boolean thePerformIndexing, boolean theForceUpdateVersion, IBasePersistedResource theEntity, org.hl7.fhir.instance.model.api.IIdType theResourceId, @Nullable org.hl7.fhir.instance.model.api.IBaseResource theOldResource, ca.uhn.fhir.rest.api.RestOperationTypeEnum theOperationType, ca.uhn.fhir.rest.api.server.storage.TransactionDetails theTransactionDetails) - Specified by:
updateInternalin interfaceIJpaDao<T extends org.hl7.fhir.instance.model.api.IBaseResource>
-
addPidToResource
protected void addPidToResource(IResourceLookup<JpaPid> theEntity, org.hl7.fhir.instance.model.api.IBaseResource theResource) -
validateMetaCount
-
validateResourceForStorage
This method is invoked immediately before storing a new resource, or an update to an existing resource to allow the DAO to ensure that it is valid for persistence. By default, checks for the "subsetted" tag and rejects resources which have it. Subclasses should call the superclass implementation to preserve this check.- Parameters:
theResource- The resource that is about to be persistedtheEntityToSave- TODO
-
start
-
setStorageSettingsForUnitTest
-
setPartitionSettingsForUnitTest
-
setJpaStorageResourceParserForUnitTest
public void setJpaStorageResourceParserForUnitTest(IJpaStorageResourceParser theJpaStorageResourceParser) Do not call this method outside of unit tests -
setResourceTypeCacheSvc
-
parseContentTextIntoWords
@Nullable public static String parseContentTextIntoWords(@Nonnull ca.uhn.fhir.context.FhirContext theContext, @Nullable org.hl7.fhir.instance.model.api.IBaseResource theResource) -
decodeResource
public static String decodeResource(byte[] theResourceBytes, ResourceEncodingEnum theResourceEncoding) -
setDisableIncrementOnUpdateForUnitTest
public static void setDisableIncrementOnUpdateForUnitTest(boolean theDisableIncrementOnUpdateForUnitTest) -
setValidationDisabledForUnitTest
Do not call this method outside of unit tests
-