Uploaded image for project: 'OASIS Open Data Protocol (OData) TC'
  1. OASIS Open Data Protocol (OData) TC
  2. ODATA-696

Support "interfaces" for casting entities to multiple different types

    XMLWordPrintable

    Details

    • Proposal:
      Hide

      Services MAY support casting any entity type, complex type, primitive type, or type definition to a type outside of the type hierarchy, following standard cast semantics including path constructs in URLs. If an instance of the type doesn't support the cast, a null is returned.

      The target type of the cast may have some or no properties in common with the source type, and properties with the same name may have different values and even different types.

      If casting to an entity type, the entity type may have an entity key which may or may not match the entity key of the type that implements it.

      A new term is added to the Core vocabulary to advertise the set of types outside of the type hierarchy that a type may be cast to:

      <Term Name="MayImplement" Type="Collection(Edm.String)">
      <Annotation Term="Core.Description"
      String="A collection of types that this type may be cast to."/>
      </Term>

      Services MUST support casting instances of the annotated type to the target type(s) using existing cast segments and semantics. If an instance of the type doesn't support the cast, the cast results in a null value.

      Opened ODATA-953 to consider structural casting

      Show
      Services MAY support casting any entity type, complex type, primitive type, or type definition to a type outside of the type hierarchy, following standard cast semantics including path constructs in URLs. If an instance of the type doesn't support the cast, a null is returned. The target type of the cast may have some or no properties in common with the source type, and properties with the same name may have different values and even different types. If casting to an entity type, the entity type may have an entity key which may or may not match the entity key of the type that implements it. A new term is added to the Core vocabulary to advertise the set of types outside of the type hierarchy that a type may be cast to: <Term Name="MayImplement" Type="Collection(Edm.String)"> <Annotation Term="Core.Description" String="A collection of types that this type may be cast to."/> </Term> Services MUST support casting instances of the annotated type to the target type(s) using existing cast segments and semantics. If an instance of the type doesn't support the cast, the cast results in a null value. Opened ODATA-953 to consider structural casting
    • Resolution:
      Show
      https://www.oasis-open.org/apps/org/workgroup/odata/download.php/59028/odata-v4.01-wd01-part1-protocol.docx https://www.oasis-open.org/apps/org/workgroup/odata/download.php/59029/odata-v4.01-wd01-part2-url-conventions.docx https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/4.01%20spec/vocabularies/Org.OData.Core.V1.xml

      Description

      OData's single-inheritance type model works well for many types of ontologies where new types are specializations of existing types, and maps well to class definitions in popular programming languages. However, single inheritance does not describe the fact that an instance of a type can play multiple different roles.

      Vocabularies were introduced to OData in order to enable the definition of common schemas that could be shared across a particular industry or enterprise. Vocabularies allow the ability to share semantic information, such as the fact that a particular instance represents some generic concept.

      Entity models can use these shared schema in defining a data model, for example through derivation, or can map properties of a defined entity to properties of an entity from a shared model. However, we don't have a common way for a service to specify that an entity can be treated (i.e., cast) to another entity outside of the single-inheritance hierarchy, and requiring inheritance to model ontologies is overly restrictive in many cases. Also, some ontologies (like schema.org) make use of multiple inheritance, making it difficult for an entity to derive, for example, from both an individual and an organization.

      Odata defines clear semantics for casting entities of one type to a different type in requests urls, filters, etc. Services can support casting instances to any type, but can currently only advertise the ability to cast to a single (derived) type.

      Adding a new "implements" annotation term to the Core vocabulary allows a service to advertise the fact that one type can be cast to one or more other types using existing cast rules. This rule is entirely backward compatible; it doesn't introduce any incompatible behavior and is entirely safe for a client to ignore.

        Attachments

          Activity

            People

            • Assignee:
              mikep Michael Pizzo (Inactive)
              Reporter:
              mikep Michael Pizzo (Inactive)
            • Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: