Class sap.ui.model.odata.v4.ODataMetaModelModule: sap/ui/model/odata/v4/ODataMetaModel

extends MetaModel

Implementation of an OData meta data model which offers access to OData V4 meta data. The meta model does not support any public events; attaching an event handler leads to an error.

This model is read-only.

Constructor Summary
new sap.ui.model.odata.v4.ODataMetaModel(oRequestor, sUrl)Do NOT call this private constructor for a new ODataMetaModel, but rather use getMetaModel instead.
Method Summary
sap.ui.model.odata.v4.ODataMetaModel.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.model.odata.v4.ODataMetaModel with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.model.odata.v4.ODataMetaModel.getMetadata()Returns a metadata object for class sap.ui.model.odata.v4.ODataMetaModel.
bindList(sPath, oContext?, aSorters?, aFilters?)Creates a list binding for this meta data model which iterates content from the given path (relative to the given context), sorted and filtered as indicated.
bindTree()Method not supported
getMetaContext(sPath)Returns the OData meta data model context corresponding to the given OData data model path.
getObject(sPath, oContext?)Returns the meta data object for the given path relative to the given context.
getOriginalProperty()Method not supported
getUI5Type(sPath)Returns the UI5 type for the given property path that formats and parses corresponding to the property's EDM type and constraints.
isList()Method not supported
refresh()Method not supported
requestObject(sPath, oContext?)Requests the meta data value for the given path relative to the given context (see resolve on how this resolution happens and how slashes are inserted as a separator).
requestUI5Type(sPath)Requests the UI5 type for the given property path that formats and parses corresponding to the property's EDM type and constraints.
setLegacySyntax()Method not supported
toString()Returns a string representation of this object including the URL to the $metadata document of the service.
Methods borrowed from class sap.ui.base.Object
Constructor Detail
new sap.ui.model.odata.v4.ODataMetaModel(oRequestor, sUrl)
Do NOT call this private constructor for a new ODataMetaModel, but rather use getMetaModel instead.
Parameters:
{sap.ui.model.odata.v4.lib._MetadataRequestor}oRequestor The meta data requestor
{string}sUrl The URL to the $metadata document of the service
Method Detail
sap.ui.model.odata.v4.ODataMetaModel.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.model.odata.v4.ODataMetaModel with name 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.

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.model.odata.v4.ODataMetaModel.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.model.odata.v4.ODataMetaModel.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
bindList(sPath, oContext?, aSorters?, aFilters?): sap.ui.model.ListBinding
Creates a list binding for this meta data model which iterates content from the given path (relative to the given context), sorted and filtered as indicated.

By default, OData names are iterated and a trailing slash is implicitly added to the path (see requestObject for the effects this has); technical properties and inline annotations are filtered out.

A path which ends with an "@" segment can be used to iterate all inline or external targeting annotations; no trailing slash is added implicitly; technical properties and OData names are filtered out.

Parameters:
{string}sPath A relative or absolute path within the meta data model, for example "/EMPLOYEES"
{sap.ui.model.Context}oContext? The context to be used as a starting point in case of a relative path
{sap.ui.model.Sorter|sap.ui.model.Sorter[]}aSorters? Initial sort order, see sort
{sap.ui.model.Filter|sap.ui.model.Filter[]}aFilters? Initial application filter(s), see filter
Since:
1.37.0
Returns:
{sap.ui.model.ListBinding} A list binding for this meta data model
See:
#requestObject
sap.ui.model.Model#bindList
bindTree()
Method not supported
Since:
1.37.0
Exceptions:
{Error}
See:
sap.ui.model.Model#bindTree
getMetaContext(sPath): sap.ui.model.Context
Returns the OData meta data model context corresponding to the given OData data model path.
Parameters:
{string}sPath An absolute data path within the OData data model, for example "/EMPLOYEES/0/ENTRYDATE"
Since:
1.37.0
Returns:
{sap.ui.model.Context} The corresponding meta data context within the OData meta data model, for example with meta data path "/EMPLOYEES/ENTRYDATE"
getObject(sPath, oContext?): any
Returns the meta data object for the given path relative to the given context. Returns undefined in case the meta data is not (yet) available. Use requestObject for asynchronous access.
Parameters:
{string}sPath A relative or absolute path within the meta data model
{sap.ui.model.Context}oContext? The context to be used as a starting point in case of a relative path
Since:
1.37.0
Returns:
{any} The requested meta data object if it is already available, or undefined
See:
#requestObject
sap.ui.model.Model#getObject
getOriginalProperty()
Method not supported
Since:
1.37.0
Exceptions:
{Error}
See:
sap.ui.model.Model#getOriginalProperty
Returns the UI5 type for the given property path that formats and parses corresponding to the property's EDM type and constraints. The property's type must be a primitive type. Use requestUI5Type for asynchronous access.
Parameters:
{string}sPath An absolute path to an OData property within the OData data model
Since:
1.37.0
Exceptions:
{Error} If the UI5 type cannot be determined synchronously (due to a pending meta data request) or cannot be determined at all (due to a wrong data path)
Returns:
{sap.ui.model.odata.type.ODataType} The corresponding UI5 type from sap.ui.model.odata.type, if all required meta data to calculate this type is already available; if no specific type can be determined, a warning is logged and sap.ui.model.odata.type.Raw is used
See:
#requestUI5Type
isList()
Method not supported
Since:
1.37.0
Exceptions:
{Error}
See:
sap.ui.model.Model#isList
refresh()
Method not supported
Since:
1.37.0
Exceptions:
{Error}
See:
sap.ui.model.Model#refresh
requestObject(sPath, oContext?): Promise
Requests the meta data value for the given path relative to the given context (see resolve on how this resolution happens and how slashes are inserted as a separator). Returns a Promise which is resolved with the requested meta data value or rejected with an error (only in case meta data cannot be loaded). An invalid path leads to an undefined result and a warning is logged. Use getObject for synchronous access.

The basic idea is that every path described in "14.2.1 Attribute Target" in specification "OData Version 4.0 Part 3: Common Schema Definition Language" is a valid absolute path within the meta data model if a leading slash is added; for example "/" + "MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyNavigationProperty". Also, every path described in "14.5.2 Expression edm:AnnotationPath", "14.5.11 Expression edm:NavigationPropertyPath", "14.5.12 Expression edm:Path", and "14.5.13 Expression edm:PropertyPath" is a valid relative path within the meta data model if a suitable prefix is added which addresses an entity container, entity set, singleton, complex type, entity type, or property; for example "/MySchema.MyEntityType/MyProperty" + "@vCard.Address#work/FullName".

The absolute path is split into segments and followed step-by-step, starting at the global scope of all known qualified OData names. There are two technical properties there: "$Version" (typically "4.0") and "$EntityContainer" with the name of the single entity container for this meta data model's service.

An empty segment in between is invalid. An empty segment at the end caused by a trailing slash differentiates between a name and the object it refers to. This way, "/$EntityContainer" refers to the name of the single entity container and "/$EntityContainer/" refers to the single entity container as an object.

The segment "@sapui.name" refers back to the last OData name (simple identifier or qualified name) or annotation name encountered during path traversal immediately before "@sapui.name":

  • "/EMPLOYEES@sapui.name" results in "EMPLOYEES" and "/EMPLOYEES/@sapui.name" results in the same as "/EMPLOYEES/$Type", that is, the qualified name of the entity set's type (see below how "$Type" is inserted implicitly). Note how the separating slash again makes a difference here.
  • "/EMPLOYEES/@com.sap.vocabularies.Common.v1.Label@sapui.name" results in "@com.sap.vocabularies.Common.v1.Label" and a slash does not make any difference as long as the annotation does not have a "$Type" property.
  • A technical property (that is, a numerical segment or one starting with a "$") immediately before "@sapui.name" is invalid, for example "/$EntityContainer@sapui.name".
The path must not continue after "@sapui.name".

If the current object is a string value, that string value is treated as a relative path and followed step-by-step before the next segment is processed. Except for this, a path must not continue if it comes across a non-object value. Such a string value can be a qualified name (example path "/$EntityContainer/..."), a simple identifier (example path "/TEAMS/$NavigationPropertyBinding/TEAM_2_EMPLOYEES/...") or even a path according to "14.5.12 Expression edm:Path" etc. (example path "/TEAMS/$Type/@com.sap.vocabularies.UI.v1.LineItem/0/Value/$Path/...").

Segments starting with an "@" character, for example "@com.sap.vocabularies.Common.v1.Label", address annotations at the current object. As the first segment, they refer to the single entity container. For objects which can only be annotated inline (see "14.3 Element edm:Annotation" minus "14.2.1 Attribute Target"), the object already contains the annotations as a property. For objects which can (only or also) be annotated via external targeting, the object does not contain any annotation as a property. Such annotations MUST be accessed via a path. BEWARE of a special case: Actions, functions and their parameters can be annotated inline for a single overload or via external targeting for all overloads at the same time. In this case, the object contains all annotations for the single overload as a property, but annotations MUST nevertheless be accessed via a path in order to include also annotations for all overloads at the same time.

Segments starting with an OData name followed by an "@" character, for example "/TEAMS@Org.OData.Capabilities.V1.TopSupported", address annotations at an entity set, singleton, or property, not at the corresponding type. In contrast, "/TEAMS/@com.sap.vocabularies.Common.v1.Deletable" (note the separating slash) addresses an annotation at the entity set's type. This is in line with the special rule of "14.5.12 Expression edm:Path" regarding annotations at a navigation property itself.

"@" can be used as a segment to address a map of all annotations of the current object. This is useful for iteration, for example via <template:repeat list="{entityType>@}" ...>.

Annotations of an annotation are addressed not by two separate segments, but by a single segment like "@com.sap.vocabularies.Common.v1.Text@com.sap.vocabularies.Common.v1.TextArrangement". Each annotation can have a qualifier, for example "@first#foo@second#bar". Note: If the first annotation's value is a record, a separate segment addresses an annotation of that record, not an annotation of the first annotation itself. In a similar way, annotations of "7.2 Element edm:ReferentialConstraint", "7.3 Element edm:OnDelete", "10.2 Element edm:Member" and "14.5.14.2 Element edm:PropertyValue" are addressed by segments like "<7.2.1 Attribute Property>@...", "$OnDelete@...", "<10.2.1 Attribute Name>@..." and "<14.5.14.2.1 Attribute Property>@..." (where angle brackets denote a variable part and sections refer to specification "OData Version 4.0 Part 3: Common Schema Definition Language").

A segment which represents an OData qualified name is looked up in the global scope ("scope lookup") and thus determines a schema child which is used later on. Unknown qualified names are invalid. This way, "/acme.DefaultContainer/EMPLOYEES" addresses the "EMPLOYEES" child of the schema child named "acme.DefaultContainer". This also works indirectly ("/$EntityContainer/EMPLOYEES") and implicitly ("/EMPLOYEES", see below).

A segment which represents an OData simple identifier needs special preparations. The same applies to the empty segment after a trailing slash.

  1. If the current object has a "$Action", "$Function" or "$Type" property, it is used for scope lookup first. This way, "/EMPLOYEES/ENTRYDATE" addresses the same object as "/EMPLOYEES/$Type/ENTRYDATE", namely the "ENTRYDATE" child of the entity type corresponding to the "EMPLOYEES" child of the entity container. The other cases jump from an action or function import to the corresponding action or function overloads.
  2. Else if the segment is the first one within its path, the last schema child addressed via scope lookup is used instead of the current object. This can only happen indirectly as in "/TEAMS/$NavigationPropertyBinding/TEAM_2_EMPLOYEES/..." where the schema child is the entity container and the navigation property binding can contain the simple identifier of another entity set within the same container.

    If the segment is the first one overall, "$EntityContainer" is inserted into the path implicitly. In other words, the entity container is used as the initial schema child. This way, "/EMPLOYEES" addresses the same object as "/$EntityContainer/EMPLOYEES", namely the "EMPLOYEES" child of the entity container.

  3. Afterwards, if the current object is an array, it represents overloads for an action or function. Multiple overloads are invalid. The overload's "$ReturnType/$Type" is used for scope lookup. This way, "/GetOldestWorker/AGE" addresses the same object as "/GetOldestWorker/0/$ReturnType/$Type/AGE". For primitive return types, the special segment "value" can be used to refer to the return type itself (see sap.ui.model.odata.v4.ODataContextBinding#execute). This way, "/GetOldestAge/value" addresses the same object as "/GetOldestAge/0/$ReturnType" (which is needed for automatic type determination, see requestUI5Type).

A trailing slash can be used to continue a path and thus force scope lookup or OData simple identifier preparations, but then stay at the current object. This way, "/EMPLOYEES/$Type/" addresses the entity type itself corresponding to the "EMPLOYEES" child of the entity container. Although the empty segment is not an OData simple identifier, it can be used as a placeholder for one. In this way, "/EMPLOYEES/" addresses the same entity type as "/EMPLOYEES/$Type/". That entity type in turn is a map of all its OData children (that is, structural and navigation properties) and determines the set of possible child names that might be used after the trailing slash.

Any other segment, including an OData simple identifier, is looked up as a property of the current object.

Parameters:
{string}sPath A relative or absolute path within the meta data model
{sap.ui.model.Context}oContext? The context to be used as a starting point in case of a relative path, see resolve
Since:
1.37.0
Returns:
{Promise} A promise which is resolved with the requested meta data value as soon as it is available
See:
#getObject
requestUI5Type(sPath): Promise
Requests the UI5 type for the given property path that formats and parses corresponding to the property's EDM type and constraints. The property's type must be a primitive type. Use getUI5Type for synchronous access.
Parameters:
{string}sPath An absolute path to an OData property within the OData data model
Since:
1.37.0
Returns:
{Promise} A promise that gets resolved with the corresponding UI5 type from sap.ui.model.odata.type or rejected with an error; if no specific type can be determined, a warning is logged and sap.ui.model.odata.type.Raw is used
See:
#getUI5Type
setLegacySyntax()
Method not supported
Since:
1.37.0
Exceptions:
{Error}
See:
sap.ui.model.Model#setLegacySyntax
toString(): string
Returns a string representation of this object including the URL to the $metadata document of the service.
Since:
1.37.0
Returns:
{string} A string description of this model
getProperty()
Deprecated:
Use getObject.
Since:
1.37.0
See:
sap.ui.model.Model#getProperty