Package ca.uhn.fhir.util
Class BundleBuilder
java.lang.Object
ca.uhn.fhir.util.BundleBuilder
This class can be used to build a Bundle resource to be used as a FHIR transaction. Convenience methods provide
support for setting various bundle fields and working with bundle parts such as metadata and entry
(method and search).
This is not yet complete, and doesn't support all FHIR features. USE WITH CAUTION as the API may change.
- Since:
- 5.1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassstatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCollectionEntry(IBaseResource theResource)Adds an entry for a Collection bundle typeaddEntry()Creates new entry and adds it to the bundleaddEntryAndReturnRequest(IBaseResource theResource)Creates new search instance for the specified entryvoidaddToEntry(IBase theEntry, String theEntryChildName, IBase theValue)Sets the specified entry field.voidaddToSearch(IBase theSearch, String theSearchFieldName, IBase theSearchFieldValue)Sets the specified search field.addTransactionCreateEntry(IBaseResource theResource)Adds an entry containing an create (POST) request.voidaddTransactionDeleteEntry(String theResourceType, String theIdPart)Adds an entry containing a delete (DELETE) request.voidaddTransactionDeleteEntry(IBaseResource theResource)Adds an entry containing a delete (DELETE) request.addTransactionUpdateEntry(IBaseResource theResource)Adds an entry containing an update (PUT) request.<T> IPrimitiveType<T>newPrimitive(String theTypeName)Creates a new primitive.<T> IPrimitiveType<T>newPrimitive(String theTypeName, T theInitialValue)Creates a new primitive instance of the specified element type.setBundleField(String theFieldName, String theFieldValue)Sets the specified primitive field on the bundle with the value provided.setMetaField(String theFieldName, IBase theFieldValue)setSearchField(IBase theSearch, String theFieldName, String theFieldValue)Sets the specified primitive field on the search entry with the value provided.setSearchField(IBase theSearch, String theFieldName, IPrimitiveType<?> theFieldValue)voidSets a value forBundle.type.
-
Constructor Details
-
BundleBuilder
Constructor
-
-
Method Details
-
setBundleField
Sets the specified primitive field on the bundle with the value provided.- Parameters:
theFieldName- Name of the primitive field.theFieldValue- Value of the field to be set.
-
setSearchField
Sets the specified primitive field on the search entry with the value provided.- Parameters:
theSearch- Search part of the entrytheFieldName- Name of the primitive field.theFieldValue- Value of the field to be set.
-
setSearchField
public BundleBuilder setSearchField(IBase theSearch, String theFieldName, IPrimitiveType<?> theFieldValue) -
addTransactionUpdateEntry
Adds an entry containing an update (PUT) request. Also sets the Bundle.type value to "transaction" if it is not already set.- Parameters:
theResource- The resource to update
-
addTransactionCreateEntry
Adds an entry containing an create (POST) request. Also sets the Bundle.type value to "transaction" if it is not already set.- Parameters:
theResource- The resource to create
-
addTransactionDeleteEntry
Adds an entry containing a delete (DELETE) request. Also sets the Bundle.type value to "transaction" if it is not already set. Note that the resource is only used to extract its ID and type, and the body of the resource is not included in the entry,- Parameters:
theResource- The resource to delete.
-
addTransactionDeleteEntry
Adds an entry containing a delete (DELETE) request. Also sets the Bundle.type value to "transaction" if it is not already set.- Parameters:
theResourceType- The type resource to delete.theIdPart- the ID of the resource to delete.
-
addCollectionEntry
Adds an entry for a Collection bundle type -
addEntry
Creates new entry and adds it to the bundle- Returns:
- Returns the new entry.
-
addSearch
Creates new search instance for the specified entry- Parameters:
entry- Entry to create search instance for- Returns:
- Returns the search instance
-
addEntryAndReturnRequest
- Parameters:
theResource-- Returns:
-
addEntryAndReturnRequest
-
getBundle
-
setMetaField
-
addToEntry
Sets the specified entry field.- Parameters:
theEntry- The entry instance to set values ontheEntryChildName- The child field name of the entry instance to be settheValue- The field value to set
-
addToSearch
Sets the specified search field.- Parameters:
theSearch- The search instance to set values ontheSearchFieldName- The child field name of the search instance to be settheSearchFieldValue- The field value to set
-
newPrimitive
Creates a new primitive.- Type Parameters:
T- Actual type of the parameterized primitive type interface- Parameters:
theTypeName- The element type for the primitive- Returns:
- Returns the new empty instance of the element definition.
-
newPrimitive
Creates a new primitive instance of the specified element type.- Type Parameters:
T- Actual type of the parameterized primitive type interface- Parameters:
theTypeName- Element type to createtheInitialValue- Initial value to be set on the new instance- Returns:
- Returns the newly created instance
-
setType
Sets a value forBundle.type. That this is a coded field so theType must be an actual valid value for this field or aDataFormatExceptionwill be thrown.
-