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

Resolve paths in CSDL XML documents #291

Draft
wants to merge 70 commits into
base: main
Choose a base branch
from
Draft

Conversation

HeikoTheissen
Copy link

@HeikoTheissen HeikoTheissen commented Apr 12, 2024

Given an augmented CSDL XML document like

<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" id="d156aAcA" Namespace="Resolved.Paths" Alias="self">
   <EntityType id="d156aAcAa" Name="Order">
      <Key id="d156aAcAaA">
         <PropertyRef id="d156aAcAaAa" Name="ID" p1:Name="d156aAcAaB"/>
      </Key>
      <Property id="d156aAcAaB" Name="ID" Type="Edm.String"/>
      <Property id="d156aAcAaC" Name="Unit" Type="Edm.String">
         <Annotation id="d156aAcAaCa" target="d156aAcAaC" Term="Core.Immutable" p2:Term="Org.OData.Core.V1.Immutable"/>
      </Property>
      <NavigationProperty id="d156aAcAaD" Name="Items" Type="Collection(self.OrderItem)" p1:Type="d156aAcAb"/>
   </EntityType>
   <EntityType id="d156aAcAb" Name="OrderItem">
      <Key id="d156aAcAbA">
         <PropertyRef id="d156aAcAbAa" Name="ID" p1:Name="d156aAcAbB"/>
      </Key>
      <Property id="d156aAcAbB" Name="ID" Type="Edm.String" Nullable="false"/>
      <Property id="d156aAcAbC" Name="Text" Type="Edm.String"/>
      <Property id="d156aAcAbD" Name="Quantity" Type="Edm.Decimal">
         <Annotation id="d156aAcAbDa" target="d156aAcAbD" Term="Measures.Unit" p2:Term="Org.OData.Measures.V1.Unit" Path="Header/Unit" p0:Path="d156aAcAbE" p1:Path="d156aAcAaC"/>
      </Property>
      <NavigationProperty id="d156aAcAbE" Name="Header" Type="self.Order" p1:Type="d156aAcAa"/>
   </EntityType>
   <EntityContainer id="d156aAcAc" Name="Container">
      <EntitySet id="d156aAcAcA" Name="Orders" EntityType="self.Order" p1:EntityType="d156aAcAa"/>
      <EntitySet id="d156aAcAcB" Name="OrderItems" EntityType="self.OrderItem" p1:EntityType="d156aAcAb">
         <NavigationPropertyBinding id="d156aAcAcBa" Path="Header" p1:Path="d156aAcAbE" Target="Orders" p1:Target="d156aAcAcA"/>
      </EntitySet>
   </EntityContainer>
   <Annotations id="d156aAcAd" Target="self.OrderItem/ID" p0:Target="d156aAcAb" p1:Target="d156aAcAbB">
      <Annotation id="d156aAcAdA" target="d156aAcAbB" Term="Core.Description" p2:Term="Org.OData.Core.V1.Description">
         <Path id="d156aAcAdAa" p0:Path="d156aAcAbD" p2:Path="Org.OData.Measures.V1.Unit">Quantity/@Measures.Unit</Path>
      </Annotation>
   </Annotations>
</Schema>

an immutable property can still be part of the PATCH payload if it is the target of a Measures.Unit annotation, and this can be checked with an XPath expression like

@id=//edm:Annotation[@p2:Term='Org.OData.Core.V1.Immutable']/@target
and not(@id=//edm:Annotation[@p2:Term='Org.OData.Measures.V1.Unit'
or @p2:Term='Org.OData.Measures.V1.ISOCurrency']//@p1:*)

See the result here.

@HeikoTheissen HeikoTheissen marked this pull request as draft April 12, 2024 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant