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 TypeFieldDescriptionstatic final longstatic final longprotected final CodingSpyprotected DaoRegistryprotected DeleteConflictServiceprotected javax.persistence.EntityManagerprotected IForcedIdDaoprotected IIdHelperService<JpaPid>protected InMemoryResourceMatcherprotected ca.uhn.fhir.interceptor.api.IInterceptorBroadcasterprotected IJpaStorageResourceParserprotected PartitionSettingsprotected IResourceHistoryTableDaoprotected IResourceLinkDaoprotected IResourceTableDaoprotected IResourceTagDaoprotected 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, myFhirContext, myResourceVersionSvc, mySearchParamRegistry, myStorageSettings, 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) static StringencodeResource(org.hl7.fhir.instance.model.api.IBaseResource theResource, ResourceEncodingEnum theEncoding, List<String> theExcludeElements, ca.uhn.fhir.context.FhirContext theContext) protected org.springframework.context.ApplicationContextca.uhn.fhir.context.FhirContextprotected ca.uhn.fhir.interceptor.api.IInterceptorBroadcasterprotected TagDefinitiongetTagOrNull(ca.uhn.fhir.rest.api.server.storage.TransactionDetails theTransactionDetails, TagTypeEnum theTagType, String theScheme, String theTerm, String theLabel, String theVersion, Boolean theUserSelected) nullwill only be returned if the scheme and tag are both blankbooleanisLogicalReference(org.hl7.fhir.instance.model.api.IIdType theId) static StringparseContentTextIntoWords(ca.uhn.fhir.context.FhirContext theContext, org.hl7.fhir.instance.model.api.IBaseResource theResource) voidpopulateFullTextFields(ca.uhn.fhir.context.FhirContext theContext, org.hl7.fhir.instance.model.api.IBaseResource theResource, ResourceTable theEntity, ResourceIndexedSearchParams theNewParams) 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(javax.persistence.EntityManager theEntityManager) voidsetExternallyStoredResourceServiceRegistryForUnitTest(ExternallyStoredResourceServiceRegistry theExternallyStoredResourceServiceRegistry) voidsetJpaStorageResourceParserForUnitTest(IJpaStorageResourceParser theJpaStorageResourceParser) Do not call this method outside of unit testsvoidsetPartitionSettingsForUnitTest(PartitionSettings thePartitionSettings) voidsetResourceHistoryTableDao(IResourceHistoryTableDao theResourceHistoryTableDao) 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()toTagDefinitionMemoryCacheKey(TagTypeEnum theTagType, String theScheme, String theTerm, String theVersion, Boolean theUserSelected) 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 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, getResourceName, getResourceType, getStorageResourceParser, getTransactionService, patch, patchInTransaction, readEntityLatestVersion, readEntityLatestVersion, validateResourceTypeMethods inherited from class ca.uhn.fhir.jpa.dao.BaseStorageDao
clearRequestAsProcessingSubRequest, createErrorOperationOutcome, createInfoOperationOutcome, createInfoOperationOutcome, createMethodOutcomeForResourceId, createOperationOutcome, createResourceGoneException, doCallHooks, extractReferencesToAutoVersion, markRequestAsProcessingSubRequest, populateOperationOutcomeForUpdate, preProcessResourceForStorage, preProcessResourceForStorage, setSearchParamRegistry, toMethodOutcome, toMethodOutcomeLazy, translateRawParametersMethods 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, forceExpungeInExistingTransaction, getCurrentVersionId, history, history, history, metaAddOperation, metaDeleteOperation, metaGetOperation, metaGetOperation, read, read, read, readByPid, readByPid, reindex, reindex, removeTag, removeTag, search, search, search, searchForIds, searchForIds, 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
-
myForcedIdDao
-
mySearchCoordinatorSvc
-
myTerminologySvc
-
myResourceHistoryTableDao
-
myResourceTableDao
-
myResourceLinkDao
-
myResourceTagDao
-
myDeleteConflictService
-
myInterceptorBroadcaster
-
myDaoRegistry
-
myInMemoryResourceMatcher
-
myJpaStorageResourceParser
-
myPartitionSettings
-
myCodingSpy
-
-
Constructor Details
-
BaseHapiFhirDao
public BaseHapiFhirDao()
-
-
Method Details
-
setExternallyStoredResourceServiceRegistryForUnitTest
public void setExternallyStoredResourceServiceRegistryForUnitTest(ExternallyStoredResourceServiceRegistry theExternallyStoredResourceServiceRegistry) -
setSearchParamPresenceSvc
-
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
-
getTagOrNull
protected TagDefinition getTagOrNull(ca.uhn.fhir.rest.api.server.storage.TransactionDetails theTransactionDetails, TagTypeEnum theTagType, String theScheme, String theTerm, String theLabel, String theVersion, Boolean theUserSelected) nullwill only be returned if the scheme and tag are both blank -
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:
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
-
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 -
toTagDefinitionMemoryCacheKey
@Nonnull public static MemoryCacheService.TagDefinitionCacheKey toTagDefinitionMemoryCacheKey(TagTypeEnum theTagType, String theScheme, String theTerm, String theVersion, Boolean theUserSelected) -
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) -
encodeResource
public static String encodeResource(org.hl7.fhir.instance.model.api.IBaseResource theResource, ResourceEncodingEnum theEncoding, List<String> theExcludeElements, ca.uhn.fhir.context.FhirContext theContext) -
setDisableIncrementOnUpdateForUnitTest
public static void setDisableIncrementOnUpdateForUnitTest(boolean theDisableIncrementOnUpdateForUnitTest) -
setValidationDisabledForUnitTest
Do not call this method outside of unit tests
-