-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support annotating common expressions as sort order of entity sets (#333
) This proposal addresses the requirement to use a common expression in the sort order annotated to an entity set. For this purpose, this proposal extends the structure type of term `Common.SortOrder`. **Rationale for this extension**: In the concrete use case of this requirement, EDMX is used to as an _interface definition language_ (a.k.a. _service provider interface (SPI)_) to describe the sort behavior a service implementation compliant with the API definition must offer for the annotated entity set. Allowing the use of an expression for a sort item mirrors the expressiveness of the protocol ABNF and leads to a self-contained API description that can be confidently published on the SAP Business Accelerator Hub (that is, no need for an out-of-band textual description). **Discussion needed**: The type of term `Common.SortOrder` is reused in `UI.PresentationVariant`. If there are concerns that this proposal adds to much freedom for services and makes it hard for UIs to interpret `Common.SortOrder` annotations because they lack a common expression parser, an **alternative design** would be to keep the term `Common.SortOrder` as it is today and create a new term `Common.SortOrderExpressions` with a type derived from `Common.SortOrderType` adding the expression to this structure. Example from the use case of the SAP Build Work Zone product: Sort instances of the `entities` entity set such that instances with `identification/entityType = "Site"` are returned before all other instances ```xml <Annotations Target="entities"> <Annotation Term="Common.SortOrder"> <Collection> <Record> <PropertyValue Property="Expression"> <Eq> <Path>identification/entityType</Path> <String>Site</String> </Eq> </PropertyValue> </Record> <Collection> </Annotation> </Annotations> … </Annotations> ``` --------- Co-authored-by: Ralf Handl <[email protected]> Co-authored-by: Heiko Theißen <[email protected]>
- Loading branch information
1 parent
7d3115c
commit 555792a
Showing
5 changed files
with
81 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"$Version": "4.0", | ||
"$Reference": { | ||
"https://sap.github.io/odata-vocabularies/vocabularies/Common.json": { | ||
"$Include": [{ "$Namespace": "com.sap.vocabularies.Common.v1", "$Alias": "Common" }] | ||
} | ||
}, | ||
"sortorder.sample": { | ||
"WorkerTimeSheet": { | ||
"$Kind": "EntityType", | ||
"ClockInDateTime": { "$Type": "Edm.DateTimeOffset", "$Nullable": true, "$Precision": 0 }, | ||
"ClockOutDateTime": { "$Type": "Edm.DateTimeOffset", "$Nullable": true, "$Precision": 0 } | ||
}, | ||
"$Annotations": { | ||
"timezone.sample.WorkerTimeSheet": { | ||
"@Common.SortOrder#HeroesOfLabor": [ | ||
{ | ||
"Expression": { "$Sub": [{ "$Path": "ClockOutDateTime" }, { "$Path": "ClockInDateTime" }] }, | ||
"Descending": true | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"> | ||
<edmx:Reference Uri="https://sap.github.io/odata-vocabularies/vocabularies/Common.xml"> | ||
<edmx:Include Namespace="com.sap.vocabularies.Common.v1" Alias="Common" /> | ||
</edmx:Reference> | ||
<edmx:DataServices> | ||
<Schema Namespace="sortorder.sample" xmlns="http://docs.oasis-open.org/odata/ns/edm"> | ||
<EntityType Name="WorkerTimeSheet"> | ||
<Property Name="ClockInDateTime" Type="Edm.DateTimeOffset" /> | ||
<Property Name="ClockOutDateTime" Type="Edm.DateTimeOffset" /> | ||
</EntityType> | ||
<Annotations Target="timezone.sample.WorkerTimeSheet"> | ||
<Annotation Term="Common.SortOrder" Qualifier="HeroesOfLabor"> | ||
<Collection> | ||
<Record> | ||
<PropertyValue Property="Expression"> | ||
<Sub> | ||
<Path>ClockOutDateTime</Path> | ||
<Path>ClockInDateTime</Path> | ||
</Sub> | ||
</PropertyValue> | ||
<PropertyValue Property="Descending" Bool="true"/> | ||
</Record> | ||
</Collection> | ||
</Annotation> | ||
</Annotations> | ||
</Schema> | ||
</edmx:DataServices> | ||
</edmx:Edmx> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters