Class SimpleBundleProvider

java.lang.Object
ca.uhn.fhir.rest.server.SimpleBundleProvider
All Implemented Interfaces:
IBundleProvider
Direct Known Subclasses:
BundleProviderWithNamedPages

public class SimpleBundleProvider extends Object implements IBundleProvider
  • Constructor Details

    • SimpleBundleProvider

      public SimpleBundleProvider(org.hl7.fhir.instance.model.api.IBaseResource theResource)
      Constructor
    • SimpleBundleProvider

      Create an empty bundle
    • SimpleBundleProvider

      public SimpleBundleProvider(List<? extends org.hl7.fhir.instance.model.api.IBaseResource> theList)
      Constructor
    • SimpleBundleProvider

      public SimpleBundleProvider(org.hl7.fhir.instance.model.api.IBaseResource... theList)
      Constructor
      Since:
      6.8.0
    • SimpleBundleProvider

      public SimpleBundleProvider(List<? extends org.hl7.fhir.instance.model.api.IBaseResource> theList, String theUuid)
    • SimpleBundleProvider

      public SimpleBundleProvider(int theSize)
      Constructor that provides only a size but no actual data (useful for _count = 0)
  • Method Details

    • getCurrentPageOffset

      Description copied from interface: IBundleProvider
      If the results in this bundle were produced using an offset query (as opposed to a query using continuation pointers, page IDs, etc.) the page offset can be returned here. The server should then attempt to form paging links that use _offset instead of opaque page IDs.
      Specified by:
      getCurrentPageOffset in interface IBundleProvider
      Since:
      5.5.0
    • setCurrentPageOffset

      public void setCurrentPageOffset(Integer theCurrentPageOffset)
      Since:
      5.5.0
    • getCurrentPageSize

      Description copied from interface: IBundleProvider
      If IBundleProvider.getCurrentPageOffset() returns a non-null value, this method must also return the actual page size used
      Specified by:
      getCurrentPageSize in interface IBundleProvider
      Since:
      5.5.0
    • setCurrentPageSize

      public void setCurrentPageSize(Integer theCurrentPageSize)
      Since:
      5.5.0
    • getList

      protected List<? extends org.hl7.fhir.instance.model.api.IBaseResource> getList()
      Returns the results stored in this provider
    • getPublished

      public org.hl7.fhir.instance.model.api.IPrimitiveType<Date> getPublished()
      Description copied from interface: IBundleProvider
      Returns the instant as of which this result was created. The result of this value is used to populate the lastUpdated value on search result/history result bundles.
      Specified by:
      getPublished in interface IBundleProvider
    • setPublished

      public void setPublished(org.hl7.fhir.instance.model.api.IPrimitiveType<Date> thePublished)
      By default this class uses the object creation date/time (for this object) to determine the published date but this method may be used to specify an alternate date/time
    • getResources

      @Nonnull public List<org.hl7.fhir.instance.model.api.IBaseResource> getResources(int theFromIndex, int theToIndex, @Nonnull ResponsePage.ResponsePageBuilder theResponsePageBuilder)
      Description copied from interface: IBundleProvider
      Load the given collection of resources by index, plus any additional resources per the server's processing rules (e.g. _include'd resources, OperationOutcome, etc.). For example, if the method is invoked with index 0,10 the method might return 10 search results, plus an additional 20 resources which matched a client's _include specification.

      Note that if this bundle provider was loaded using a page ID (i.e. via IPagingProvider.retrieveResultList(RequestDetails, String, String) because IBundleProvider.getNextPageId() provided a value on the previous page, then the indexes should be ignored and the whole page returned.

      Specified by:
      getResources in interface IBundleProvider
      Parameters:
      theFromIndex - The low index (inclusive) to return
      theToIndex - The high index (exclusive) to return
      theResponsePageBuilder - The ResponsePageBuilder. The builder will add values needed for the response page.
      Returns:
      A list of resources. The size of this list must be at least theToIndex - theFromIndex.
    • getUuid

      public String getUuid()
      Description copied from interface: IBundleProvider
      Returns the UUID associated with this search. Note that this does not need to return a non-null value unless it a IPagingProvider is being used that requires UUIDs being returned.

      In other words, if you are using the default FifoMemoryPagingProvider in your server, it is fine for this method to simply return null since FifoMemoryPagingProvider does not use the value anyhow. On the other hand, if you are creating a custom IPagingProvider implementation you might use this method to communicate the search ID back to the provider.

      Note that the UUID returned by this method corresponds to the search, and not to the individual page.

      Specified by:
      getUuid in interface IBundleProvider
    • setTotalResourcesRequestedReturned

      public void setTotalResourcesRequestedReturned(int theAmount)
    • preferredPageSize

      Defaults to null
      Specified by:
      preferredPageSize in interface IBundleProvider
      Returns:
      Returns the preferred page size or null
    • setPreferredPageSize

      public void setPreferredPageSize(Integer thePreferredPageSize)
      Sets the preferred page size to be returned by preferredPageSize(). Default is null.
    • setSize

      Sets the total number of results, if this provider corresponds to a single page within a larger search result
    • size

      public Integer size()
      Description copied from interface: IBundleProvider
      Returns the total number of results which match the given query (exclusive of any _include's or OperationOutcome). May return null if the total size is not known or would be too expensive to calculate.
      Specified by:
      size in interface IBundleProvider
    • toString

      public String toString()
      Overrides:
      toString in class Object