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 Details

  • Constructor Details

  • Method Details

    • setSearchParamPresenceSvc

      public void setSearchParamPresenceSvc(ISearchParamPresenceSvc theSearchParamPresenceSvc)
    • getInterceptorBroadcaster

      protected ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster getInterceptorBroadcaster()
      Specified by:
      getInterceptorBroadcaster in class ca.uhn.fhir.jpa.dao.BaseStorageDao
    • getApplicationContext

      protected org.springframework.context.ApplicationContext getApplicationContext()
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext theApplicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • getConfig

      public ca.uhn.fhir.jpa.api.config.DaoConfig getConfig()
      Specified by:
      getConfig in class ca.uhn.fhir.jpa.dao.BaseStorageDao
    • getContext

      public ca.uhn.fhir.context.FhirContext getContext()
      Specified by:
      getContext in interface ca.uhn.fhir.jpa.api.dao.IDao
      Specified by:
      getContext in class ca.uhn.fhir.jpa.dao.BaseStorageDao
    • setContext

      @Autowired public void setContext(ca.uhn.fhir.context.FhirContext theContext)
    • getContext

      public ca.uhn.fhir.context.FhirContext getContext(ca.uhn.fhir.context.FhirVersionEnum theVersion)
    • 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

      protected 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)
    • isLogicalReference

      public boolean isLogicalReference(org.hl7.fhir.instance.model.api.IIdType theId)
    • 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

      protected void postDelete(ResourceTable theEntity)
      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)
      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

      protected void postUpdate(ResourceTable theEntity, T theResource)
      Subclasses may override to provide behaviour. Called when a pre-existing resource has been updated in the database
      Parameters:
      theEntity - The resource
      theResource - 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 interface ca.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 interface ca.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

      public void setEntityManager(javax.persistence.EntityManager theEntityManager)
    • setSearchParamWithInlineReferencesExtractor

      public void setSearchParamWithInlineReferencesExtractor(SearchParamWithInlineReferencesExtractor theSearchParamWithInlineReferencesExtractor)
    • setResourceHistoryTableDao

      public void setResourceHistoryTableDao(IResourceHistoryTableDao theResourceHistoryTableDao)
    • setDaoSearchParamSynchronizer

      public void setDaoSearchParamSynchronizer(DaoSearchParamSynchronizer theDaoSearchParamSynchronizer)
    • 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 interface ca.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 interface ca.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

      protected void validateMetaCount(int theMetaCount)
    • validateResourceForStorage

      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. 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 persisted
      theEntityToSave - TODO
    • start

      @PostConstruct public void start()
    • setDaoConfigForUnitTest

      public void setDaoConfigForUnitTest(ca.uhn.fhir.jpa.api.config.DaoConfig theDaoConfig)
    • populateFullTextFields

      public void populateFullTextFields(ca.uhn.fhir.context.FhirContext theContext, org.hl7.fhir.instance.model.api.IBaseResource theResource, ResourceTable theEntity, ResourceIndexedSearchParams theNewParams)
    • setPartitionSettingsForUnitTest

      public void setPartitionSettingsForUnitTest(PartitionSettings thePartitionSettings)
    • 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

      public static void setValidationDisabledForUnitTest(boolean theValidationDisabledForUnitTest)
      Do not call this method outside of unit tests
    • validateResourceType

      public static void validateResourceType(BaseHasResource theEntity, String theResourceName)