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

Need to constrain functions/actions to particular paths

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Applied
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Vocabularies
    • Labels:
      None
    • Environment:

      Proposed

    • Proposal:
      Hide

      Introduce two new terms:

      RequiresExplicitBinding targets a bound action or function and specifies that the operation must be specified through an ExplicitOperationBinding to be available on a model element.

      ExplicitOperationBindings targets a model element and specifies the qualified name of explicitly bound operations that are supported through that path. These bindings are in addition to any bindings to the target type not annotated with RequiresExplicitBinding.

      <Term Name="RequiresExplicitBinding" Type="Core.Tag" DefaultValue="true" AppliesTo="Action, Function">
        <Annotation Name="Description" Edm.String="This bound action or function is only available on model elements annotated with the ExplicitOperationBinding term."/>
      </Term>
      
      <Term Name="ExplicitOperationBindings" Type="Collection(Edm.String)"> 
         <Annotation Name="Description" Edm.String="The qualified names of explicitly bound operations that are supported on the target model element. These bindings are in addition to any bindings to the type of the target model element not annotated with RequiresExplicitBinding"/> 
      </Term>
      

       

      Example usage:

      <Action Name="forward" IsBound="true" >
        <AnnotationTerm="Org.OData.Capabilities.V1.RequiresExplicitBinding"/>
        <ParameterName="bindingParameter" Type="self.email"/>
        <ParameterName="recipient" Type="Collection(self.recipent)"/>
        <ReturnTypeType="self.email" />
      </Action>
      
      <Annotations Target="self.Container/me/email">
        <Annotation Term="Org.OData.Capabilities.V1.ExplicitOperationBindings">
          <Collection>
            <String>self.forward</String>
          </Collection>
        </Annotation>
      </Annotations>
      
      Show
      Introduce two new terms: RequiresExplicitBinding targets a bound action or function and specifies that the operation must be specified through an ExplicitOperationBinding to be available on a model element. ExplicitOperationBindings targets a model element and specifies the qualified name of explicitly bound operations that are supported through that path. These bindings are in addition to any bindings to the target type not annotated with RequiresExplicitBinding. <Term Name= "RequiresExplicitBinding" Type= "Core.Tag" DefaultValue= "true" AppliesTo= "Action, Function" > <Annotation Name= "Description" Edm.String= "This bound action or function is only available on model elements annotated with the ExplicitOperationBinding term." /> </Term> <Term Name= "ExplicitOperationBindings" Type= "Collection(Edm.String)" > <Annotation Name= "Description" Edm.String= "The qualified names of explicitly bound operations that are supported on the target model element. These bindings are in addition to any bindings to the type of the target model element not annotated with RequiresExplicitBinding" /> </Term>   Example usage: <Action Name= "forward" IsBound= "true" > <AnnotationTerm= "Org.OData.Capabilities.V1.RequiresExplicitBinding" /> <ParameterName= "bindingParameter" Type= "self.email" /> <ParameterName= "recipient" Type= "Collection(self.recipent)" /> <ReturnTypeType= "self.email" /> </Action> <Annotations Target= "self.Container/me/email" > <Annotation Term= "Org.OData.Capabilities.V1.ExplicitOperationBindings" > <Collection> <String> self.forward </String> </Collection> </Annotation> </Annotations>
    • Resolution:
      Show
      Add vocabulary terms to Require Explicit Binding by mikepizzo · Pull Request #214 · oasis-tcs/odata-vocabularies (github.com)

      Description

      Today, actions and functions are bound to a type. This implies that, anywhere that type is present, the action or function can be invoked.

      There are many scenarios in which whether an action or function could be invoked is dependent upon where the instance of the type lives.

      For such scenarios, it would be nice to be able to specify exactly what usages of a type supported a particular operation.

      One option would be to introduce a BindingConstraint annotation; something like:

      <Action Name="forward" IsBound="true" >
        <AnnotationTerm="Org.OData.Core.V1.Capabilities.BindingConstraint">
           <Collection>
              <Record>
                 <PropertyValue Property="Target" ModelElementPath="/me/email"/>
              </Record>
           </Collection>
        </Annotation>
        <ParameterName="bindingParameter" Type="self.email"/>
        <ParameterName="recipient" Type="Collection(self.recipent)"/>
        <ReturnTypeType="self.email" />
      </Action>
      

      If we don't think we need to add additional properties/annotations to the path, it would be simpler to make a collection of model element paths:

      <Action Name="forward" IsBound="true" >
        <AnnotationTerm="Org.OData.Core.V1.Capabilities.BindingConstraint">
            <Collection>
               <ModelElementPath>/me/email<ModelElementPath/>
            </Collection>
        </Annotation>
        <ParameterName="bindingParameter" Type="self.email"/>
        <ParameterName="recipient" Type="Collection(self.recipent)"/>
        <ReturnTypeType="self.email" />
      </Action>
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mikep Michael Pizzo
            • Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: