Class sap.ui.model.odata.ODataMetaModelModule: sap/ui/model/odata/ODataMetaModel
Implementation of an OData meta model which offers a unified access to both OData V2 meta data and V4 annotations. It uses the existing sap.ui.model.odata.ODataMetadata as a foundation and merges V4 annotations from the existing sap.ui.model.odata.ODataAnnotations directly into the corresponding model element.
Also, annotations from the "http://www.sap.com/Protocols/SAPData" namespace are lifted up from the extensions
array and transformed from objects into simple properties with an "sap:" prefix for their name. Note that this happens in addition, thus the following example shows both representations. This way, such annotations can be addressed via a simple relative path instead of searching an array.
{ "name" : "BusinessPartnerID", "extensions" : [{ "name" : "label", "value" : "Bus. Part. ID", "namespace" : "http://www.sap.com/Protocols/SAPData" }], "sap:label" : "Bus. Part. ID" }
As of 1.29.0, the corresponding vocabulary-based annotations for the following "SAP Annotations for OData Version 2.0" are added, if they are not yet defined in the V4 annotations:
label
;creatable
,deletable
,deletable-path
,pageable
,requires-filter
,searchable
,topable
,updatable
andupdatable-path
on entity sets;creatable
,display-format
("UpperCase" and "NonNegative"),field-control
,filterable
,filter-restriction
,heading
,precision
,quickinfo
,required-in-filter
,sortable
,text
,unit
,updatable
andvisible
on properties;semantics
; the following values are supported:- "bday", "city", "country", "email" (including support for types, for example "email;type=home,pref"), "familyname", "givenname", "honorific", "middlename", "name", "nickname", "note", "org", "org-unit", "org-role", "photo", "pobox", "region", "street", "suffix", "tel" (including support for types, for example "tel;type=cell,pref"), "title" and "zip" (mapped to V4 annotation
com.sap.vocabularies.Communication.v1.Contact
); - "class", "dtend", "dtstart", "duration", "fbtype", "location", "status", "transp" and "wholeday" (mapped to V4 annotation
com.sap.vocabularies.Communication.v1.Event
); - "body", "from", "received", "sender" and "subject" (mapped to V4 annotation
com.sap.vocabularies.Communication.v1.Message
); - "completed", "due", "percent-complete" and "priority" (mapped to V4 annotation
com.sap.vocabularies.Communication.v1.Task
).
- "bday", "city", "country", "email" (including support for types, for example "email;type=home,pref"), "familyname", "givenname", "honorific", "middlename", "name", "nickname", "note", "org", "org-unit", "org-role", "photo", "pobox", "region", "street", "suffix", "tel" (including support for types, for example "tel;type=cell,pref"), "title" and "zip" (mapped to V4 annotation
{ "name" : "BusinessPartnerID", ... "sap:label" : "Bus. Part. ID", "com.sap.vocabularies.Common.v1.Label" : { "String" : "Bus. Part. ID" } }
This model is read-only and thus only supports OneTime binding mode. No events (parseError, requestCompleted, requestFailed, requestSent) are fired!
Within the meta model, the objects are arranged in arrays. /dataServices/schema
, for example, is an array of schemas where each schema has an entityType
property with an array of entity types, and so on. So, /dataServices/schema/0/entityType/16
can be the path to the entity type with name "Order" in the schema with namespace "MySchema". However, these paths are not stable: If an entity type with lower index is removed from the schema, the path to Order
changes to /dataServices/schema/0/entityType/15
.
To avoid problems with changing indexes, getObject and getProperty support XPath-like queries for the indexes (since 1.29.1). Each index can be replaced by a query in square brackets. You can, for example, address the schema using the path /dataServices/schema/[${namespace}==='MySchema']
or the entity using /dataServices/schema/[${namespace}==='MySchema']/entityType/[sap.ui.core==='Order']
.
The syntax inside the square brackets is the same as in expression binding. The query is executed for each object in the array until the result is true (truthy) for the first time. This object is then chosen.
BEWARE: Access to this OData meta model will fail before the promise returned by loaded has been resolved!
Since: 1.27.0.
ODataMetaModel
, but rather use getMetaModel instead!sClassName
and enriches it with the information contained in oClassInfo
.Promise
which is resolved with a map representing the com.sap.vocabularies.Common.v1.ValueList
annotations of the given property or rejected with an error.ODataMetaModel
, but rather use getMetaModel instead! {sap.ui.model.odata.ODataMetadata} | oMetadata | the OData model's meta data object |
{sap.ui.model.odata.ODataAnnotations} | oAnnotations? | the OData model's annotations object |
{object} | oODataModelInterface? | the private interface object of the OData model which provides friend access to selected methods |
{function} | oODataModelInterface.addAnnotationUrl? | the addAnnotationUrl method of the OData model, in case this feature is supported |
{Promise} | oODataModelInterface.annotationsLoadedPromise? | a promise which is resolved by the OData model once meta data and annotations have been fully loaded |
sClassName
and enriches it with the information contained in oClassInfo
. oClassInfo
might contain the same kind of information as described in sap.ui.model.MetaModel.extend.
{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 |
{function} | Created class / constructor function |
{sap.ui.base.Metadata} | Metadata object describing this class |
{string} | sPath? | an absolute path pointing to an entity or property, e.g. "/ProductSet(1)/ToSupplier/BusinessPartnerID"; this equals the resource path component of a URI according to OData V2 URI conventions |
{Error} | in case no context can be determined |
{sap.ui.model.Context} | the context for the corresponding meta data object, i.e. an entity type or its property, or null in case no path is given |
{object} | oEntityType | an entity type as returned by getODataEntityType |
{string} | sName | the name of a navigation property within this entity type |
{object} | the OData association end or null if no such association end is found |
{object} | oEntityType | an entity type as returned by getODataEntityType |
{string} | sName | the name of a navigation property within this entity type |
{object} | the OData association set end or null if no such association set end is found |
{string} | sQualifiedName | a qualified name, e.g. "ACME.Address" |
{boolean} | bAsPath? | determines whether the complex type is returned as a path or as an object |
{object|string} | (the path to) the complex type with the given qualified name; undefined (for a path) or null (for an object) if no such type is found |
{boolean} | bAsPath? | determines whether the entity container is returned as a path or as an object |
{object|string} | (the path to) the default entity container; undefined (for a path) or null (for an object) if no such container is found |
{string} | sName | a simple name, e.g. "ProductSet" |
{boolean} | bAsPath? | determines whether the entity set is returned as a path or as an object |
{object|string} | (the path to) the entity set with the given simple name; undefined (for a path) or null (for an object) if no such set is found |
{string} | sQualifiedName | a qualified name, e.g. "ACME.Product" |
{boolean} | bAsPath? | determines whether the entity type is returned as a path or as an object |
{object|string} | (the path to) the entity type with the given qualified name; undefined (for a path) or null (for an object) if no such type is found |
{string} | sName | a simple or qualified name, e.g. "Save" or "MyService.Entities/Save" |
{boolean} | bAsPath? | determines whether the function import is returned as a path or as an object |
- Since:
- 1.29.0
{object|string} | (the path to) the function import with the given simple name; undefined (for a path) or null (for an object) if no such function import is found |
If an array is given instead of a single name, it is consumed (via Array.prototype.shift
) piece by piece. Each element is interpreted as a property name of the current type, and the current type is replaced by that property's type. This is repeated until an element is encountered which cannot be resolved as a property name of the current type anymore; in this case, the last property found is returned and vName
contains only the remaining names, with vName[0]
being the one which was not found.
Examples:
- Get address property of business partner:
var oEntityType = oMetaModel.getODataEntityType("GWSAMPLE_BASIC.BusinessPartner"), oAddressProperty = oMetaModel.getODataProperty(oEntityType, "Address"); oAddressProperty.name === "Address"; oAddressProperty.type === "GWSAMPLE_BASIC.CT_Address";
- Get street property of address type:
var oComplexType = oMetaModel.getODataComplexType("GWSAMPLE_BASIC.CT_Address"), oStreetProperty = oMetaModel.getODataProperty(oComplexType, "Street"); oStreetProperty.name === "Street"; oStreetProperty.type === "Edm.String";
- Get address' street property directly from business partner:
var aParts = ["Address", "Street"]; oMetaModel.getODataProperty(oEntityType, aParts) === oStreetProperty; aParts.length === 0;
- Trying to get address' foo property directly from business partner:
aParts = ["Address", "foo"]; oMetaModel.getODataProperty(oEntityType, aParts) === oAddressProperty; aParts.length === 1; aParts[0] === "foo";
{object} | oType | a complex type as returned by getODataComplexType, or an entity type as returned by getODataEntityType |
{string|string[]} | vName | the name of a property within this type (e.g. "Address"), or an array of such names (e.g. ["Address", "Street"] ) in order to drill-down into complex types; BEWARE that this array is modified by removing each part which is understood! |
{boolean} | bAsPath? | determines whether the property is returned as a path or as an object |
{object|string} | (the path to) the last OData property found; undefined (for a path) or null (for an object) if no property was found at all |
Promise
which is resolved with a map representing the com.sap.vocabularies.Common.v1.ValueList
annotations of the given property or rejected with an error. The key in the map provided on successful resolution is the qualifier of the annotation or the empty string if no qualifier is defined. The value in the map is the JSON object for the annotation. The map is empty if the property has no com.sap.vocabularies.Common.v1.ValueList
annotations. {sap.ui.model.Context} | oPropertyContext | a model context for a structural property of an entity type or a complex type, as returned by getMetaContext |
- Since:
- 1.29.1
{Promise} | a Promise that gets resolved as soon as the value lists as well as the required model elements have been loaded |