Namespace sap.ui.model.odata.ODataUtilsModule: sap/ui/model/odata/ODataUtils


Method Summary
sap.ui.model.odata.ODataUtils.compare(vValue1, vValue2, bAsDecimal?)Compares the given OData values based on their type.
sap.ui.model.odata.ODataUtils.formatValue(vValue, sType)Formats a JavaScript value according to the given EDM type.
sap.ui.model.odata.ODataUtils.getComparator(sEdmType)Returns a comparator function optimized for the given EDM type.
sap.ui.model.odata.ODataUtils.setOrigin(sServiceURL, vParameters)Adds an origin to the given service URL.
Method Detail
sap.ui.model.odata.ODataUtils.compare(vValue1, vValue2, bAsDecimal?): int
Compares the given OData values based on their type. All date and time types can also be compared with a number. This number is then interpreted as the number of milliseconds that the corresponding date or time object should hold.
Parameters:
{any}vValue1 the first value to compare
{any}vValue2 the second value to compare
{string}bAsDecimal? if true, the string values vValue1 and vValue2 are compared as a decimal number (only sign, integer and fraction digits; no exponential format). Otherwise they are recognized by looking at their types.
Since:
1.29.1
Returns:
{int} the result of the compare: 0 if the values are equal, -1 if the first value is smaller, 1 if the first value is larger, NaN if they cannot be compared
sap.ui.model.odata.ODataUtils.formatValue(vValue, sType): string
Formats a JavaScript value according to the given EDM type.
Parameters:
{any}vValue the value to format
{string}sType the EDM type (e.g. Edm.Decimal)
Returns:
{string} the formatted value
sap.ui.model.odata.ODataUtils.getComparator(sEdmType): function
Returns a comparator function optimized for the given EDM type.
Parameters:
{string}sEdmType the EDM type
Since:
1.29.1
Returns:
{function} the comparator function taking two values of the given type and returning 0 if the values are equal, -1 if the first value is smaller, 1 if the first value is larger and NaN if they cannot be compared (e.g. one value is null or undefined)
sap.ui.model.odata.ODataUtils.setOrigin(sServiceURL, vParameters): string
Adds an origin to the given service URL. If an origin is already present, it will only be replaced if the parameters object contains the flag "force: true". In case the URL already contains URL parameters, these will be kept. As a parameter, a sole alias is sufficient. The parameters vParameters.system and vParameters.client however have to be given in pairs. In case all three origin specifying parameters are given (system/client/alias), the alias has precedence.

Examples: setOrigin("/backend/service/url/", "DEMO_123"); - result: /backend/service/url;o=DEMO_123/

setOrigin("/backend/service/url;o=OTHERSYS8?myUrlParam=true&x=4", {alias: "DEMO_123", force: true}); - result /backend/service/url;o=DEMO_123?myUrlParam=true&x=4

setOrigin("/backend/service/url/", {system: "DEMO", client: 134}); - result /backend/service/url;o=sid(DEMO.134)/

Parameters:
{string}sServiceURL the URL which will be enriched with an origin
{object|string}vParameters if string then it is asumed its the system alias, else if the argument is an object then additional Parameters can be given
{string}vParameters.alias the system alias which will be used as the origin
{string}vParameters.system the system id which will be used as the origin
{string}vParameters.client the system's client
{string}vParameters.force setting this flag to 'true' overrides the already existing origin
Since:
1.30.7
Returns:
{string} the service URL with the added origin.