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.BaseHapiFhirDao<T>
- All Implemented Interfaces:
ca.uhn.fhir.jpa.api.dao.IDao
,ca.uhn.fhir.jpa.api.dao.IJpaDao<T>
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
BaseHapiFhirResourceDao
,BaseHapiFhirSystemDao
@Repository
public abstract class BaseHapiFhirDao<T extends org.hl7.fhir.instance.model.api.IBaseResource>
extends ca.uhn.fhir.jpa.dao.BaseStorageDao
implements ca.uhn.fhir.jpa.api.dao.IDao, ca.uhn.fhir.jpa.api.dao.IJpaDao<T>, org.springframework.context.ApplicationContextAware
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
static final long
protected ca.uhn.fhir.jpa.api.dao.DaoRegistry
protected DeleteConflictService
protected javax.persistence.EntityManager
protected IForcedIdDao
protected IdHelperService
protected InMemoryResourceMatcher
protected ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster
protected IResourceHistoryTableDao
protected IResourceProvenanceDao
protected IResourceTableDao
protected IResourceTagDao
protected ca.uhn.fhir.jpa.api.svc.ISearchCoordinatorSvc
protected ITermReadSvc
static final String
Fields inherited from class ca.uhn.fhir.jpa.dao.BaseStorageDao
myDaoConfig, myFhirContext, myModelConfig, myResourceVersionSvc, mySearchParamRegistry, 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addPidToResource
(IBasePersistedResource theEntity, org.hl7.fhir.instance.model.api.IBaseResource theResource) static String
decodeResource
(byte[] theResourceBytes, ResourceEncodingEnum theResourceEncoding) static String
encodeResource
(org.hl7.fhir.instance.model.api.IBaseResource theResource, ResourceEncodingEnum theEncoding, List<String> theExcludeElements, ca.uhn.fhir.context.FhirContext theContext) protected org.springframework.context.ApplicationContext
ca.uhn.fhir.jpa.api.config.DaoConfig
ca.uhn.fhir.context.FhirContext
ca.uhn.fhir.context.FhirContext
getContext
(ca.uhn.fhir.context.FhirVersionEnum theVersion) protected ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster
protected TagDefinition
getTagOrNull
(ca.uhn.fhir.rest.api.server.storage.TransactionDetails theTransactionDetails, TagTypeEnum theTagType, String theScheme, String theTerm, String theLabel) null
will only be returned if the scheme and tag are both blankprotected ca.uhn.fhir.rest.api.server.IBundleProvider
history
(ca.uhn.fhir.rest.api.server.RequestDetails theRequest, String theResourceType, Long theResourcePid, Date theRangeStartInclusive, Date theRangeEndInclusive, Integer theOffset) 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) Subclasses may override to provide behaviour.protected void
postUpdate
(ResourceTable theEntity, T theResource) 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
setDaoConfigForUnitTest
(ca.uhn.fhir.jpa.api.config.DaoConfig theDaoConfig) void
setDaoSearchParamSynchronizer
(DaoSearchParamSynchronizer theDaoSearchParamSynchronizer) static void
setDisableIncrementOnUpdateForUnitTest
(boolean theDisableIncrementOnUpdateForUnitTest) void
setEntityManager
(javax.persistence.EntityManager theEntityManager) void
setPartitionSettingsForUnitTest
(PartitionSettings thePartitionSettings) void
setResourceHistoryTableDao
(IResourceHistoryTableDao theResourceHistoryTableDao) void
setSearchParamPresenceSvc
(ISearchParamPresenceSvc theSearchParamPresenceSvc) void
setSearchParamWithInlineReferencesExtractor
(SearchParamWithInlineReferencesExtractor theSearchParamWithInlineReferencesExtractor) 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()
org.hl7.fhir.instance.model.api.IBaseResource
toResource
(BaseHasResource theEntity, boolean theForHistoryOperation) <R extends org.hl7.fhir.instance.model.api.IBaseResource>
RtoResource
(Class<R> theResourceType, IBaseResourceEntity theEntity, Collection<ResourceTag> theTagList, boolean theForHistoryOperation) toResourceName
(Class<? extends org.hl7.fhir.instance.model.api.IBaseResource> theResourceType) static ca.uhn.fhir.jpa.util.MemoryCacheService.TagDefinitionCacheKey
toTagDefinitionMemoryCacheKey
(TagTypeEnum theTagType, String theScheme, String theTerm) 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) protected ResourceTable
updateEntityForDelete
(ca.uhn.fhir.rest.api.server.RequestDetails theRequest, ca.uhn.fhir.rest.api.server.storage.TransactionDetails theTransactionDetails, ResourceTable entity) updateInternal
(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, T theResource, 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.server.storage.TransactionDetails theTransactionDetails) protected void
updateResourceMetadata
(IBaseResourceEntity theEntity, org.hl7.fhir.instance.model.api.IBaseResource theResource) 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.static void
validateResourceType
(BaseHasResource theEntity, String theResourceName) Methods inherited from class ca.uhn.fhir.jpa.dao.BaseStorageDao
clearRequestAsProcessingSubRequest, createErrorOperationOutcome, createInfoOperationOutcome, createResourceGoneException, doCallHooks, extractReferencesToAutoVersion, getResourceName, markRequestAsProcessingSubRequest, notifyInterceptors, preProcessResourceForStorage, preProcessResourceForStorage, setSearchParamRegistry, toMethodOutcome, toMethodOutcomeLazy, translateRawParameters
-
Field Details
-
INDEX_STATUS_INDEXED
- See Also:
-
INDEX_STATUS_INDEXING_FAILED
- See Also:
-
NS_JPA_PROFILE
- See Also:
-
myEntityManager
-
myIdHelperService
-
myForcedIdDao
-
myResourceProvenanceDao
-
mySearchCoordinatorSvc
-
myTerminologySvc
-
myResourceHistoryTableDao
-
myResourceTableDao
-
myResourceTagDao
-
myDeleteConflictService
-
myInterceptorBroadcaster
-
myDaoRegistry
-
myInMemoryResourceMatcher
-
-
Constructor Details
-
BaseHapiFhirDao
public BaseHapiFhirDao()
-
-
Method Details
-
setSearchParamPresenceSvc
-
getInterceptorBroadcaster
- Specified by:
getInterceptorBroadcaster
in classca.uhn.fhir.jpa.dao.BaseStorageDao
-
getApplicationContext
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext theApplicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
getConfig
- Specified by:
getConfig
in classca.uhn.fhir.jpa.dao.BaseStorageDao
-
getContext
- Specified by:
getContext
in interfaceca.uhn.fhir.jpa.api.dao.IDao
- Specified by:
getContext
in classca.uhn.fhir.jpa.dao.BaseStorageDao
-
setContext
-
getContext
-
getTagOrNull
protected TagDefinition getTagOrNull(ca.uhn.fhir.rest.api.server.storage.TransactionDetails theTransactionDetails, TagTypeEnum theTagType, String theScheme, String theTerm, String theLabel) null
will only be returned if the scheme and tag are both blank -
history
-
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
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 persisted
-
postUpdate
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 persisted
-
readEntity
public BaseHasResource readEntity(org.hl7.fhir.instance.model.api.IIdType theValueId, ca.uhn.fhir.rest.api.server.RequestDetails theRequest) -
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 folows.
- Parameters:
theTag
- The tag- Returns:
- Returns
true
if the tag should be removed
-
toResource
public org.hl7.fhir.instance.model.api.IBaseResource toResource(BaseHasResource theEntity, boolean theForHistoryOperation) - Specified by:
toResource
in interfaceca.uhn.fhir.jpa.api.dao.IDao
-
toResource
public <R extends org.hl7.fhir.instance.model.api.IBaseResource> R toResource(Class<R> theResourceType, IBaseResourceEntity theEntity, Collection<ResourceTag> theTagList, boolean theForHistoryOperation) - Specified by:
toResource
in interfaceca.uhn.fhir.jpa.api.dao.IDao
-
toResourceName
public String toResourceName(Class<? extends org.hl7.fhir.instance.model.api.IBaseResource> theResourceType) -
updateEntityForDelete
protected ResourceTable updateEntityForDelete(ca.uhn.fhir.rest.api.server.RequestDetails theRequest, ca.uhn.fhir.rest.api.server.storage.TransactionDetails theTransactionDetails, ResourceTable entity) -
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 interfaceca.uhn.fhir.jpa.api.dao.IJpaDao<T extends org.hl7.fhir.instance.model.api.IBaseResource>
-
updateInternal
public ResourceTable updateInternal(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, T theResource, 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.server.storage.TransactionDetails theTransactionDetails) - Specified by:
updateInternal
in interfaceca.uhn.fhir.jpa.api.dao.IJpaDao<T extends org.hl7.fhir.instance.model.api.IBaseResource>
-
addPidToResource
protected void addPidToResource(IBasePersistedResource theEntity, org.hl7.fhir.instance.model.api.IBaseResource theResource) -
updateResourceMetadata
protected void updateResourceMetadata(IBaseResourceEntity 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
-
setDaoConfigForUnitTest
-
populateFullTextFields
public void populateFullTextFields(ca.uhn.fhir.context.FhirContext theContext, org.hl7.fhir.instance.model.api.IBaseResource theResource, ResourceTable theEntity, ResourceIndexedSearchParams theNewParams) -
setPartitionSettingsForUnitTest
-
toTagDefinitionMemoryCacheKey
@Nonnull public static ca.uhn.fhir.jpa.util.MemoryCacheService.TagDefinitionCacheKey toTagDefinitionMemoryCacheKey(TagTypeEnum theTagType, String theScheme, String theTerm) -
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 -
validateResourceType
-