Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formally define OData Metamodel #288

Open
ralfhandl opened this issue Mar 20, 2024 · 3 comments
Open

Formally define OData Metamodel #288

ralfhandl opened this issue Mar 20, 2024 · 3 comments

Comments

@ralfhandl
Copy link
Contributor

Various aspects of OData seem unclear or redundant. A formal UML model for the OData metamodel can be used to clarify and simplify OData.

The existing metamodel defined by 'MetadataService.xml' contains much of what is needed, but has some issues, such as:

  • The MetadataContainer element refers to metadata elements, but should be referencing instances of metadata elements (i.e. schema).
  • Various language elements are included, (eg. ne and eq)

The included proposal started from scratch out of a need to understand several concepts, including the semantics of Singletons and EntitySets. It needs to be rationalized with the existing 'MetadataService.xml' . It is preliminary and needs review and refinement. It is expressed in CSDL XML. (See https://www.oasis-open.org/apps/org/workgroup/odata/download.php/60420/OdataMetamodel.xml.) UML diagrams are provided that illustrate this proposal. (See: https://www.oasis-open.org/apps/org/workgroup/odata/download.php/60421/OdataMetamodel.pdf)

An advantage of the UML model is that it expresses the Odata metamodel in precise terms. Constraints and requirements on the various elements of the model are expressed normatively using the UML model together with UML Object Constraing Language (OCL) statements. An added Term supports this.

The various schema definition languages CSDL XML, CSDL JSON, and others should conform to the OData metamodel.

Imported from ODATA-1062

@HeikoTheissen
Copy link
Contributor

HeikoTheissen commented Mar 22, 2024

A PropertyRef does not simply refer to a structural property, because the same structural property (Name in the example) can be reached via different paths by different PropertyRefs.

<EntityType Name="Employee">
  <Key>
    <PropertyRef Name="Name"/>
  </Key>
  <Property Name="Name" Type="Edm.String" Nullable="false"/>
</EntityType>
<EntityType Name="ReportingLine">
  <Key>
    <PropertyRef Name="ReportsTo/Name" Alias="Manager"/>
    <PropertyRef Name="DirectReport/Name" Alias="Subordinate"/>
  </Key>
  <NavigationProperty Name="ReportsTo" Type="self.Employee"/>
  <NavigationProperty Name="DirectReport" Type="self.Employee"/>
</EntityType>

A PropertyRef is expressed as a sequences of references to model elements, that last of which is a structural property. Similarly, the final segment of a NavigationPropertyBinding is a navigation property, and the final segment of an external annotation target is any model element. Such references can be expressed in YAML:

$Version: '4.0'
Org.OData.Core.V1:
  Description: &Core.Description
    $Kind: Term
    $Annotations:
      - term: *Core.Description
        value: A brief description of a model element
example.StructuralProperty:
  Employee: &Employee
    $Kind: EntityType
    Name: &Name
    $Key:
      - finalSegmentStructuralProperty: *Name
  ReportingLine: &ReportingLine
    $Kind: EntityType
    ReportsTo: &ReportsTo
      $Kind: NavigationProperty
      $Type: *Employee
    DirectReport: &DirectReport
      $Kind: NavigationProperty
      $Type: *Employee
    $Key:
      - nonFinalSegments: [*ReportsTo]
        finalSegmentStructuralProperty: *Name
        alias: Manager
      - nonFinalSegments: [*DirectReport]
        finalSegmentStructuralProperty: *Name
        alias: Subordinate
  container: &container
    $Kind: EntityContainer
    Employees: &Employees
      $Collection: true
      $Type: *Employee
      $NavigationPropertyBinding:
        - finalSegmentNavigationProperty: *ReportsTo
          target: *Employees
        - finalSegmentNavigationProperty: *DirectReport
          target: *Employees
  $Annotations:
    - target: [*Employee]
      term: *Core.Description
      value: Party to a contractual agreement regarding employment
$EntityContainer: *container

Or they can be expressed in CSDL XML through additional ID attributes, see oasis-tcs/odata-openapi#291.

@chrisspre
Copy link

chrisspre commented Apr 10, 2024

About the comment from March 22.

the standard says : "The value of Name is a path expression leading to a primitive property. The names of the properties in the path are joined together by forward slashes."

the meta model would specify that it is a path starting with the containing EntityType followed by a sequence of Properties or NavigationProperties (connected via their referenced types) and ending in a PrimitiveType.

In pseudo PGQL:
(EntityType) --> (Property) [ – /Type/ -> (:EntityType|ComplexType) --> (Property) ]* – /Type/ -> (PrimititveType)

the paths are visualized in the graph visualization through colored graph-paths

image

@chrisspre
Copy link

chrisspre commented Apr 10, 2024

About the comment from March 22.

the standard says : "The value of Name is a path expression leading to a primitive property. The names of the properties in the path are joined together by forward slashes."

the meta model would specify that it is a path starting with the containing EntityType followed by a sequence of Properties or NavigationProperties (via their types) and ending in a PrimitiveType.

In pseudo PGQL:
(EntityType) --> (Property) [ – /Type/ -> (:EntityType|ComplexType) --> (Property) ]* – /Type/ -> (PrimititveType)

the paths are visualized in the graph visualization through colored graph-paths

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Open
Development

No branches or pull requests

3 participants