Class sap.ui.generic.app.transaction.DraftControllerModule: sap/ui/generic/app/transaction/DraftController


Gives access to runtime draft handling for applications. Assuming state-less communication, each single data modification request (or change set in an OData $batch request) is a "mini-transaction", which saves data to the database. The class implements the transactional interaction patterns specified for OData services that support draft documents and provides methods for draft-specific actions, for example validate, prepare, activate.

Additionally, it handles transactional request processing, ensures concurrency control and correct ETag handling. It provides access to the simple interaction patterns of runtime handling for drafts according to the draft specification. These can be combined as required by client applications. Additionally, error handling is provided to notify client implementations of error situations. The event fatalError is thrown, if fatal errors occur during execution of OData requests.


Since: 1.30.0.
Constructor Summary
new sap.ui.generic.app.transaction.DraftController(oModel, oQueue)Constructor for a new draft controller instance.
Method Summary
sap.ui.generic.app.transaction.DraftController.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.generic.app.transaction.DraftController with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.generic.app.transaction.DraftController.getMetadata()Returns a metadata object for class sap.ui.generic.app.transaction.DraftController.
activateDraftEntity(oContext)Submits changes to the back-end and activates a draft entity in the back-end.
createEditDraftEntity(oContext, bPreserveChanges?)Creates an edit draft in the back-end.
createNewDraftEntity(sEntitySet, sPath)Creates a new edit draft on the client and sends it to the back-end.
destroy()Frees all resources claimed during the life-time of this instance.
getDraftContext()Returns the current draft context instance.
getDraftForActiveEntity(oContext)Retrieves a possibly existing draft entity for the given active entity using the binding context of the active entity from the back-end.
hasActiveEntity(oContext)Checks whether an entity has an active entity associated.
isActiveEntity(oContext)Checks whether an entity set is active.
prepareDraftEntity(oContext)Submits changes to the back-end and prepares an existing draft entity in the back-end for later activation by invoking the preparation action.
saveAndPrepareDraftEntity(oContext, mParameters)Submits changes to the back-end and prepares a draft entity in the back-end for later activation by invoking the preparation action.
validateDraftEntity(oContext)Submits changes to the back-end and prepares an existing draft entity in the back-end for later activation by invoking the validation action.
Constructor Detail
new sap.ui.generic.app.transaction.DraftController(oModel, oQueue)
Constructor for a new draft controller instance.
Parameters:
{sap.ui.model.odata.ODataModel}oModel The OData model currently used
{sap.ui.generic.app.util.Queue}oQueue Optional HTTP request queue
Exceptions:
{Error}
Throws an error if no model is handed over as input parameter
Method Detail
sap.ui.generic.app.transaction.DraftController.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.generic.app.transaction.DraftController with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in Object.extend.

Parameters:
{string}sClassName Name of the class being created
{object}oClassInfo? Object literal with information about the class
{function}FNMetaImpl? Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
{function} Created class / constructor function
sap.ui.generic.app.transaction.DraftController.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.generic.app.transaction.DraftController.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
activateDraftEntity(oContext): Promise
Submits changes to the back-end and activates a draft entity in the back-end.
Parameters:
{sap.ui.model.Context}oContext The given binding context
Returns:
{Promise} A Promise for asynchronous execution
createEditDraftEntity(oContext, bPreserveChanges?): Promise
Creates an edit draft in the back-end. Additionally, possible changes that have been collected on the client are sent to the back-end.
Parameters:
{sap.ui.model.Context}oContext The given binding context
{boolean}bPreserveChanges? Set to true to avoid the creation of a new draft when unsaved changes exist in the back-end
Returns:
{Promise} A Promise for asynchronous execution
createNewDraftEntity(sEntitySet, sPath): Promise
Creates a new edit draft on the client and sends it to the back-end. Additionally, possible changes that have been collected on the client are sent to the back-end.
Parameters:
{string}sEntitySet The name of the entity set
{string}sPath Path identifying the new entity instance
Returns:
{Promise} A Promise for asynchronous execution of the request
destroy()
Frees all resources claimed during the life-time of this instance.
Returns the current draft context instance. If no instance exists, it is created lazily.
Returns:
{sap.ui.generic.app.transaction.DraftContext} The current draft context instance
getDraftForActiveEntity(oContext): Promise
Retrieves a possibly existing draft entity for the given active entity using the binding context of the active entity from the back-end.
Parameters:
{sap.ui.model.Context}oContext The binding context of the active entity
Since:
1.32.0
Exceptions:
{Error} Throws an error if no context is handed over as input parameter
Returns:
{Promise} A Promise for asynchronous execution
hasActiveEntity(oContext): boolean
Checks whether an entity has an active entity associated.
Parameters:
{sap.ui.model.Context}oContext The given binding context
Since:
1.32.0
Returns:
{boolean}true, if an active entity exists, false otherwise
isActiveEntity(oContext): boolean
Checks whether an entity set is active. The entity set name is derived from the given binding context
Parameters:
{sap.ui.model.Context}oContext The given binding context
Exceptions:
{Error} Throws an error if no context is handed over as input parameter
Returns:
{boolean}true, if a given entity set is active, false otherwise
prepareDraftEntity(oContext): Promise
Submits changes to the back-end and prepares an existing draft entity in the back-end for later activation by invoking the preparation action.
Parameters:
{sap.ui.model.Context}oContext The given binding context
Returns:
{Promise} A Promise for asynchronous execution
saveAndPrepareDraftEntity(oContext, mParameters): Promise
Submits changes to the back-end and prepares a draft entity in the back-end for later activation by invoking the preparation action.
Parameters:
{sap.ui.model.Context}oContext The given binding context
{map}mParameters Parameters to control the behavior of the request
Returns:
{Promise} A Promise for asynchronous execution
validateDraftEntity(oContext): Promise
Submits changes to the back-end and prepares an existing draft entity in the back-end for later activation by invoking the validation action.
Parameters:
{sap.ui.model.Context}oContext The given binding context
Returns:
{Promise} A Promise for asynchronous execution