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
Modifier and TypeFieldDescriptionprotected CacheTagDefinitionDao
static final long
static final long
protected final CodingSpy
protected DeleteConflictService
protected jakarta.persistence.EntityManager
protected IIdHelperService
<JpaPid> protected InMemoryResourceMatcher
protected ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster
protected IJpaStorageResourceParser
protected PartitionSettings
protected ResourceHistoryCalculator
protected IResourceHistoryTableDao
protected IResourceLinkDao
protected IResourceTableDao
protected IResourceTagDao
protected ISearchCoordinatorSvc
<JpaPid> protected ITermReadSvc
static final String
Fields inherited from class ca.uhn.fhir.jpa.dao.BaseStorageResourceDao
STRICT_ERROR_HANDLER
Fields 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_SEVERITY_ERROR, OO_SEVERITY_INFO, OO_SEVERITY_WARN
Fields inherited from interface ca.uhn.fhir.jpa.api.dao.IDao
CURRENTLY_REINDEXING, RESOURCE_PID, RESOURCE_PID_KEY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addPidToResource
(IResourceLookup<JpaPid> theEntity, org.hl7.fhir.instance.model.api.IBaseResource theResource) static String
decodeResource
(byte[] theResourceBytes, ResourceEncodingEnum theResourceEncoding) protected org.springframework.context.ApplicationContext
ca.uhn.fhir.context.FhirContext
protected ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster
boolean
isLogicalReference
(org.hl7.fhir.instance.model.api.IIdType theId) static String
parseContentTextIntoWords
(ca.uhn.fhir.context.FhirContext theContext, org.hl7.fhir.instance.model.api.IBaseResource theResource) void
populateFullTextFields
(ca.uhn.fhir.context.FhirContext theContext, org.hl7.fhir.instance.model.api.IBaseResource theResource, ResourceTable theEntity, ResourceIndexedSearchParams theNewParams) 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)protected void
postDelete
(ResourceTable theEntity) Subclasses may override to provide behaviour.protected void
postPersist
(ResourceTable theEntity, T theResource, ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails) Subclasses may override to provide behaviour.protected void
postUpdate
(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) void
setApplicationContext
(org.springframework.context.ApplicationContext theApplicationContext) void
setContext
(ca.uhn.fhir.context.FhirContext theContext) void
setDaoSearchParamSynchronizer
(DaoSearchParamSynchronizer theDaoSearchParamSynchronizer) static void
setDisableIncrementOnUpdateForUnitTest
(boolean theDisableIncrementOnUpdateForUnitTest) void
setEntityManager
(jakarta.persistence.EntityManager theEntityManager) void
setExternallyStoredResourceServiceRegistryForUnitTest
(ExternallyStoredResourceServiceRegistry theExternallyStoredResourceServiceRegistry) void
setJpaStorageResourceParserForUnitTest
(IJpaStorageResourceParser theJpaStorageResourceParser) Do not call this method outside of unit testsvoid
setPartitionSettingsForUnitTest
(PartitionSettings thePartitionSettings) void
setResourceHistoryCalculator
(ResourceHistoryCalculator theResourceHistoryCalculator) void
setResourceHistoryTableDao
(IResourceHistoryTableDao theResourceHistoryTableDao) void
setSearchParamPresenceSvc
(ISearchParamPresenceSvc theSearchParamPresenceSvc) void
setSearchParamWithInlineReferencesExtractor
(SearchParamWithInlineReferencesExtractor theSearchParamWithInlineReferencesExtractor) void
setStorageSettingsForUnitTest
(JpaStorageSettings theStorageSettings) static void
setValidationDisabledForUnitTest
(boolean theValidationDisabledForUnitTest) Do not call this method outside of unit testsprotected 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.void
start()
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 void
validateMetaCount
(int theMetaCount) protected void
validateResourceForStorage
(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, getResourceName, getResourceType, getStorageResourceParser, getTransactionService, patch, patchInTransaction, readEntityLatestVersion, readEntityLatestVersion, validateResourceType
Methods inherited from class ca.uhn.fhir.jpa.dao.BaseStorageDao
clearRequestAsProcessingSubRequest, createErrorOperationOutcome, createInfoOperationOutcome, createInfoOperationOutcome, createMethodOutcomeForResourceId, createOperationOutcome, createResourceGoneException, doCallHooks, extractReferencesToAutoVersion, markRequestAsProcessingSubRequest, populateOperationOutcomeForUpdate, preProcessResourceForStorage, preProcessResourceForStorage, setMyMetaTagSorter, setSearchParamRegistry, toMethodOutcome, toMethodOutcomeLazy, translateRawParameters
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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, 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
-
INDEX_STATUS_INDEXED
- See Also:
-
INDEX_STATUS_INDEXING_FAILED
- See Also:
-
NS_JPA_PROFILE
- See Also:
-
myEntityManager
-
myIdHelperService
-
mySearchCoordinatorSvc
-
myTerminologySvc
-
myResourceHistoryTableDao
-
myResourceTableDao
-
myResourceLinkDao
-
myResourceTagDao
-
myDeleteConflictService
-
myInterceptorBroadcaster
-
myInMemoryResourceMatcher
-
myJpaStorageResourceParser
-
myPartitionSettings
-
myResourceHistoryCalculator
-
cacheTagDefinitionDao
-
myCodingSpy
-
-
Constructor Details
-
BaseHapiFhirDao
public BaseHapiFhirDao()
-
-
Method Details
-
setExternallyStoredResourceServiceRegistryForUnitTest
public void setExternallyStoredResourceServiceRegistryForUnitTest(ExternallyStoredResourceServiceRegistry theExternallyStoredResourceServiceRegistry) -
setSearchParamPresenceSvc
-
setResourceHistoryCalculator
-
getInterceptorBroadcaster
- Specified by:
getInterceptorBroadcaster
in classBaseStorageDao
-
getApplicationContext
-
setApplicationContext
public void setApplicationContext(@Nonnull org.springframework.context.ApplicationContext theApplicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
getStorageSettings
- Specified by:
getStorageSettings
in classBaseStorageDao
-
getContext
- Specified by:
getContext
in interfaceIDao
- Specified by:
getContext
in 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) -
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:
readEntity
in 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
true
if 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:
updateEntity
in 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:
updateInternal
in 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
-
populateFullTextFields
public void populateFullTextFields(ca.uhn.fhir.context.FhirContext theContext, org.hl7.fhir.instance.model.api.IBaseResource theResource, ResourceTable theEntity, ResourceIndexedSearchParams theNewParams) -
setPartitionSettingsForUnitTest
-
setJpaStorageResourceParserForUnitTest
public void setJpaStorageResourceParserForUnitTest(IJpaStorageResourceParser theJpaStorageResourceParser) Do not call this method outside of unit tests -
parseContentTextIntoWords
public static String parseContentTextIntoWords(ca.uhn.fhir.context.FhirContext theContext, 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
-