Model implementation for OData V4.
Every resource path (relative to the service root URL, no query options) according to "4 Resource Path" in specification "OData Version 4.0 Part 2: URL Conventions" is a valid data binding path within this model if a leading slash is added; for example "/" + "EMPLOYEES('A%2FB%26C')" to access an entity instance with key "A/B&C". Note that appropriate URI encoding is necessary. "4.5.1 Addressing Actions" needs an operation binding, see sap.ui.model.odata.v4.ODataContextBinding.
The model does not support any public events; attaching an event handler leads to an error.
Method Summary
bindContext(sPath, oContext?, mParameters?)Creates a new context binding for the given path, context and parameters. bindList(sPath, oContext?, aSorters?, aFilters?, mParameters?)Creates a new list binding for the given path and optional context which must resolve to an absolute OData path for an entity set. bindProperty(sPath, oContext?, mParameters?)Creates a new property binding for the given path. createBindingContext()Cannot create contexts at this model at will; retrieve them from a binding instead. destroy()Destroys this model and its meta model. refresh(sGroupId?)Refreshes the model by calling refresh on all bindings which have a change event handler attached. requestCanonicalPath(oEntityContext)Returns a promise for the "canonical path" of the entity for the given context. submitBatch(sGroupId)Submits the requests associated with the given application group ID in one batch request. toString()Returns a string representation of this object including the service URL. attachParseError,
attachRequestCompleted,
attachRequestFailed,
attachRequestSent,
detachParseError,
detachRequestCompleted,
detachRequestFailed,
detachRequestSent,
fireParseError,
fireRequestCompleted,
fireRequestFailed,
fireRequestSent,
getDefaultBindingMode,
getMessagesByPath,
isBindingModeSupported,
isLegacySyntax,
setDefaultBindingMode,
setMessages,
setSizeLimit Constructor Detail
new sap.ui.model.odata.v4.ODataModel(mParameters)
Constructor for a new ODataModel.
Parameters:
{object} | mParameters | The parameters |
{string} | mParameters.groupId?, Default: "$auto" | Controls the model's use of batch requests: '$auto' bundles requests from the model in a batch request which is sent automatically before rendering; '$direct' sends requests directly without batch; other values result in an error |
{string} | mParameters.serviceUrl | Root URL of the service to request data from. The path part of the URL must end with a forward slash according to OData V4 specification ABNF, rule "serviceRoot". You may append OData custom query options to the service root URL separated with a "?", for example "/MyService/?custom=foo". See specification "OData Version 4.0 Part 2: URL Conventions", "5.2 Custom Query Options". OData system query options and OData parameter aliases lead to an error. |
{string} | mParameters.synchronizationMode | Controls synchronization between different bindings which refer to the same data for the case data changes in one binding. Must be set to 'None' which means bindings are not synchronized at all; all other values are not supported and lead to an error. |
{string} | mParameters.updateGroupId? | The group ID that is used for update requests. If no update group ID is specified, mParameters.groupId is used. Valid update group IDs are undefined, '$auto', '$direct' or an application group ID, which is a non-empty string consisting of alphanumeric characters from the basic Latin alphabet, including the underscore. |
- Exceptions:
- {Error}
- If an unsupported synchronization mode is given, if the given service root URL does not end with a forward slash, if an unsupported parameter is given, if OData system query options or parameter aliases are specified as parameters, if an invalid group ID or update group ID is given.
Method Detail
Creates a new context binding for the given path, context and parameters.
This binding is inactive and will not know the bound context initially. You have to call initialize() to get it updated asynchronously and register a change listener at the binding to be informed when the bound context is available.
Parameters:
{string} | sPath | The binding path in the model; must not end with a slash |
{sap.ui.model.Context} | oContext? | The context which is required as base for a relative path |
{object} | mParameters? | Map of binding parameters which can be OData query options as specified in "OData Version 4.0 Part 2: URL Conventions" or the binding-specific parameters "$$groupId" and "$$updateGroupId". Note: Binding parameters may only be provided for absolute binding paths as only those lead to a data service request. The following OData query options are allowed: - All "5.2 Custom Query Options" except for those with a name starting with "sap-"
- The $expand, $filter, $orderby and $select "5.1 System Query Options"; OData V4 only allows $filter and $orderby inside resource paths that identify a collection. In our case here, this means you can only use them inside $expand.
All other query options lead to an error. Query options specified for the binding overwrite model query options. |
{string} | mParameters.$$groupId? | The group ID to be used for read requests triggered by this binding; if not specified, the model's group ID is used, see sap.ui.model.odata.v4.ODataModel. Valid values are undefined , '$auto' , '$direct' or application group IDs as specified in submitBatch. |
{string} | mParameters.$$updateGroupId? | The group ID to be used for update requests triggered by this binding; if not specified, the binding's parameter "$$groupId" is used and if "$$groupId" is not specified, the model's group ID is used, see sap.ui.model.odata.v4.ODataModel. For valid values, see parameter "$$groupId". |
- Since:
- 1.37.0
Exceptions:
{Error} | If disallowed binding parameters are provided |
Returns:
See:
Creates a new list binding for the given path and optional context which must resolve to an absolute OData path for an entity set.
Parameters:
{string} | sPath | The binding path in the model; must not be empty or end with a slash |
{sap.ui.model.Context} | oContext? | The context which is required as base for a relative path |
{sap.ui.model.Sorter[]} | aSorters? | The parameter aSorters is not supported and must be undefined |
{sap.ui.model.Filter[]} | aFilters? | The parameter aFilters is not supported and must be undefined |
{object} | mParameters? | Map of binding parameters which can be OData query options as specified in "OData Version 4.0 Part 2: URL Conventions" or the binding-specific parameters "$$groupId" and "$$updateGroupId". Note: Binding parameters may only be provided for absolute binding paths as only those lead to a data service request. The following OData query options are allowed: - All "5.2 Custom Query Options" except for those with a name starting with "sap-"
- The $expand, $filter, $orderby and $select "5.1 System Query Options"
All other query options lead to an error. Query options specified for the binding overwrite model query options. |
{string} | mParameters.$$groupId? | The group ID to be used for read requests triggered by this binding; if not specified, the model's group ID is used, see sap.ui.model.odata.v4.ODataModel. Valid values are undefined , '$auto' , '$direct' or application group IDs as specified in submitBatch. |
{string} | mParameters.$$updateGroupId? | The group ID to be used for update requests triggered by this binding; if not specified, the binding's parameter "$$groupId" is used and if "$$groupId" is not specified, the model's group ID is used, see sap.ui.model.odata.v4.ODataModel. For valid values, see parameter "$$groupId". |
- Since:
- 1.37.0
Exceptions:
{Error} | If disallowed binding parameters are provided |
Returns:
See:
Creates a new property binding for the given path. This binding is inactive and will not know the property value initially. You have to call
initialize() to get it updated asynchronously and register a change listener at the binding to be informed when the value is available.
Parameters:
{string} | sPath | The binding path in the model; must not be empty or end with a slash |
{sap.ui.model.Context} | oContext? | The context which is required as base for a relative path |
{object} | mParameters? | Map of binding parameters which can be OData query options as specified in "OData Version 4.0 Part 2: URL Conventions" or the binding-specific parameters "$$groupId" and "$$updateGroupId". Note: Binding parameters may only be provided for absolute binding paths as only those lead to a data service request. All "5.2 Custom Query Options" are allowed except for those with a name starting with "sap-". All other query options lead to an error. Query options specified for the binding overwrite model query options. |
{string} | mParameters.$$groupId? | The group ID to be used for read requests triggered by this binding; if not specified, the model's group ID is used, see sap.ui.model.odata.v4.ODataModel. Valid values are undefined , '$auto' , '$direct' or application group IDs as specified in submitBatch. |
{string} | mParameters.$$updateGroupId? | The group ID to be used for update requests triggered by this binding; if not specified, the binding's parameter "$$groupId" is used and if "$$groupId" is not specified, the model's group ID is used, see sap.ui.model.odata.v4.ODataModel. For valid values, see parameter "$$groupId". |
- Since:
- 1.37.0
Exceptions:
{Error} | If disallowed binding parameters are provided |
Returns:
See:
bindTree()
Method not supported
- Since:
- 1.37.0
Exceptions:
See:
createBindingContext()
Cannot create contexts at this model at will; retrieve them from a binding instead.
- Since:
- 1.37.0
Exceptions:
See:
destroy()
Destroys this model and its meta model.
- Since:
- 1.38.0
See:
destroyBindingContext()
Method not supported
- Since:
- 1.37.0
Exceptions:
See:
Returns the meta model for this ODataModel.
- Since:
- 1.37.0
Returns:
See:
getObject()
Method not supported
- Since:
- 1.37.0
Exceptions:
See:
getOriginalProperty()
Method not supported
- Since:
- 1.37.0
Exceptions:
See:
getProperty()
Method not supported
- Since:
- 1.37.0
Exceptions:
See:
isList()
Method not supported
- Since:
- 1.37.0
Exceptions:
See:
sap.ui.model.Model#isList |
refresh(sGroupId?)
Refreshes the model by calling refresh on all bindings which have a change event handler attached.
Note: When calling refresh multiple times, the result of the request triggered by the last call determines the model's data; it is independent of the order of calls to submitBatch with the given group ID.
Parameters:
{string} | sGroupId? | The group ID to be used for refresh; valid values are undefined , '$auto' , '$direct' or application group IDs as specified in submitBatch |
- Since:
- 1.37.0
Exceptions:
{Error} | If the given group ID is invalid |
See:
requestCanonicalPath(oEntityContext): Promise
Returns a promise for the "canonical path" of the entity for the given context. According to "4.3.1 Canonical URL" of the specification "OData Version 4.0 Part 2: URL Conventions", this is the "name of the entity set associated with the entity followed by the key predicate identifying the entity within the collection". Use the canonical path in
sap.ui.core.Element#bindElement to create an element binding.
Parameters:
{sap.ui.model.Context} | oEntityContext | A context in this model which must point to a non-contained OData entity |
- Since:
- 1.37.0
Returns:
{Promise} | A promise which is resolved with the canonical path (e.g. "/EMPLOYEES(ID='1')") in case of success, or rejected with an instance of Error in case of failure, e.g. when the given context does not point to an entity |
setLegacySyntax()
Method not supported
- Since:
- 1.37.0
Exceptions:
See:
submitBatch(sGroupId): Promise
Submits the requests associated with the given application group ID in one batch request.
Parameters:
{string} | sGroupId | The application group ID, which is a non-empty string consisting of alphanumeric characters from the basic Latin alphabet, including the underscore. |
- Since:
- 1.37.0
Exceptions:
{Error} | If the given group ID is not an application group ID |
Returns:
{Promise} | A promise on the outcome of the HTTP request resolving with undefined ; it is rejected with an error if the batch request itself fails |
toString(): string
Returns a string representation of this object including the service URL.
- Since:
- 1.37.0
Returns:
{string} | A string description of this model |