Skip to content

Commit 6224dd1

Browse files
authored
Merge pull request #151 from microsoftgraph/removeduplicateItem
Add the `microsoft.graph.user/joinedGroups` annotations otherwise modify it if exists
2 parents cec3e44 + ca8e83a commit 6224dd1

3 files changed

Lines changed: 160 additions & 93 deletions

File tree

transforms/csdl/preprocess_csdl.xsl

Lines changed: 65 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,25 @@
570570
</xsl:element>
571571
</xsl:element>
572572
</xsl:template>
573+
<xsl:template name="NavigationRestrictionsTemplate">
574+
<xsl:param name = "navigable" />
575+
<xsl:element name="Annotation">
576+
<xsl:attribute name="Term">Org.OData.Capabilities.V1.NavigationRestrictions</xsl:attribute>
577+
<xsl:element name="Record" namespace="{namespace-uri()}">
578+
<xsl:element name="PropertyValue">
579+
<xsl:attribute name="Property">RestrictedProperties</xsl:attribute>
580+
<xsl:element name="Collection">
581+
<xsl:element name="Record">
582+
<xsl:element name="PropertyValue">
583+
<xsl:attribute name="Property">IndexableByKey</xsl:attribute>
584+
<xsl:attribute name="Bool"><xsl:value-of select = "$navigable" /></xsl:attribute>
585+
</xsl:element>
586+
</xsl:element>
587+
</xsl:element>
588+
</xsl:element>
589+
</xsl:element>
590+
</xsl:element>
591+
</xsl:template>
573592

574593
<!-- Add Navigation Restrictions Annotations -->
575594
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']">
@@ -620,66 +639,43 @@
620639
</xsl:element>
621640
</xsl:element>
622641
</xsl:element>
642+
623643
<!-- Remove indexability for joinedGroups navigation property -->
624-
<xsl:element name="Annotations">
625-
<xsl:attribute name="Target">microsoft.graph.user/joinedGroups</xsl:attribute>
626-
<xsl:element name="Annotation">
627-
<xsl:attribute name="Term">Org.OData.Capabilities.V1.NavigationRestrictions</xsl:attribute>
628-
<xsl:element name="Record" namespace="{namespace-uri()}">
629-
<xsl:element name="PropertyValue">
630-
<xsl:attribute name="Property">RestrictedProperties</xsl:attribute>
631-
<xsl:element name="Collection">
632-
<xsl:element name="Record">
633-
<xsl:element name="PropertyValue">
634-
<xsl:attribute name="Property">IndexableByKey</xsl:attribute>
635-
<xsl:attribute name="Bool">false</xsl:attribute>
636-
</xsl:element>
637-
</xsl:element>
638-
</xsl:element>
639-
</xsl:element>
644+
<!-- Add the parent "Annotations" tag if it doesn't exists -->
645+
<xsl:choose>
646+
<xsl:when test="not(edm:Annotations[@Target='microsoft.graph.user/joinedGroups'])">
647+
<xsl:element name="Annotations">
648+
<xsl:attribute name="Target">microsoft.graph.user/joinedGroups</xsl:attribute>
649+
<xsl:call-template name="NavigationRestrictionsTemplate">
650+
<xsl:with-param name="navigable">false</xsl:with-param>
651+
</xsl:call-template>
640652
</xsl:element>
641-
</xsl:element>
642-
</xsl:element>
653+
</xsl:when>
654+
</xsl:choose>
643655
<!-- Remove indexability for users navigation property -->
644-
<xsl:element name="Annotations">
645-
<xsl:attribute name="Target">microsoft.graph.managedDevice/users</xsl:attribute>
646-
<xsl:element name="Annotation">
647-
<xsl:attribute name="Term">Org.OData.Capabilities.V1.NavigationRestrictions</xsl:attribute>
648-
<xsl:element name="Record" namespace="{namespace-uri()}">
649-
<xsl:element name="PropertyValue">
650-
<xsl:attribute name="Property">RestrictedProperties</xsl:attribute>
651-
<xsl:element name="Collection">
652-
<xsl:element name="Record">
653-
<xsl:element name="PropertyValue">
654-
<xsl:attribute name="Property">IndexableByKey</xsl:attribute>
655-
<xsl:attribute name="Bool">false</xsl:attribute>
656-
</xsl:element>
657-
</xsl:element>
658-
</xsl:element>
659-
</xsl:element>
656+
<!-- Add the parent "Annotations" tag if it doesn't exists -->
657+
<xsl:choose>
658+
<xsl:when test="not(edm:Annotations[@Target='microsoft.graph.managedDevice/users'])">
659+
<xsl:element name="Annotations">
660+
<xsl:attribute name="Target">microsoft.graph.managedDevice/users</xsl:attribute>
661+
<xsl:call-template name="NavigationRestrictionsTemplate">
662+
<xsl:with-param name="navigable">false</xsl:with-param>
663+
</xsl:call-template>
660664
</xsl:element>
661-
</xsl:element>
662-
</xsl:element>
665+
</xsl:when>
666+
</xsl:choose>
663667
<!-- Remove indexability for activities navigation property -->
664-
<xsl:element name="Annotations">
665-
<xsl:attribute name="Target">microsoft.graph.list/activities</xsl:attribute>
666-
<xsl:element name="Annotation">
667-
<xsl:attribute name="Term">Org.OData.Capabilities.V1.NavigationRestrictions</xsl:attribute>
668-
<xsl:element name="Record" namespace="{namespace-uri()}">
669-
<xsl:element name="PropertyValue">
670-
<xsl:attribute name="Property">RestrictedProperties</xsl:attribute>
671-
<xsl:element name="Collection">
672-
<xsl:element name="Record">
673-
<xsl:element name="PropertyValue">
674-
<xsl:attribute name="Property">IndexableByKey</xsl:attribute>
675-
<xsl:attribute name="Bool">false</xsl:attribute>
676-
</xsl:element>
677-
</xsl:element>
678-
</xsl:element>
679-
</xsl:element>
668+
<!-- Add the parent "Annotations" tag if it doesn't exists -->
669+
<xsl:choose>
670+
<xsl:when test="not(edm:Annotations[@Target='microsoft.graph.list/activities'])">
671+
<xsl:element name="Annotations">
672+
<xsl:attribute name="Target">microsoft.graph.list/activities</xsl:attribute>
673+
<xsl:call-template name="NavigationRestrictionsTemplate">
674+
<xsl:with-param name="navigable">false</xsl:with-param>
675+
</xsl:call-template>
680676
</xsl:element>
681-
</xsl:element>
682-
</xsl:element>
677+
</xsl:when>
678+
</xsl:choose>
683679
<!-- Remove deletability -->
684680
<xsl:element name="Annotations">
685681
<xsl:attribute name="Target">microsoft.graph.security/alerts</xsl:attribute>
@@ -708,6 +704,21 @@
708704
</xsl:copy>
709705
</xsl:template>
710706

707+
<!-- If the parent "Annotations" tag already exists modify it -->
708+
<!-- Remove indexability for joinedGroups navigation property -->
709+
<!-- Remove indexability for activities navigation property -->
710+
<!-- Remove indexability for users navigation property -->
711+
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:Annotations[@Target='microsoft.graph.user/joinedGroups'] |
712+
edm:Schema[@Namespace='microsoft.graph']/edm:Annotations[@Target='microsoft.graph.managedDevice/users'] |
713+
edm:Schema[@Namespace='microsoft.graph']/edm:Annotations[@Target='microsoft.graph.list/activities'] ">
714+
<xsl:copy>
715+
<xsl:copy-of select="@*|node()"/>
716+
<xsl:call-template name="NavigationRestrictionsTemplate">
717+
<xsl:with-param name="navigable">false</xsl:with-param>
718+
</xsl:call-template>
719+
</xsl:copy>
720+
</xsl:template>
721+
711722
<!-- Remove directoryObject Capability Annotations -->
712723
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:Annotations[@Target='microsoft.graph.directoryObject']/*[starts-with(@Term, 'Org.OData.Capabilities')]"/>
713724

transforms/csdl/preprocess_csdl_test_input.xml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,37 @@
4242
<EntityType Name="directoryObject" BaseType="graph.entity" OpenType="true">
4343
<Property Name="deletedDateTime" Type="Edm.DateTimeOffset" />
4444
</EntityType>
45+
<Annotations Target="microsoft.graph.user/joinedGroups">
46+
<Annotation Term="Org.OData.Capabilities.V1.ChangeTracking">
47+
<Record>
48+
<PropertyValue Property="Supported" Bool="false"/>
49+
</Record>
50+
</Annotation>
51+
<Annotation Term="Org.OData.Capabilities.V1.DeleteRestrictions">
52+
<Record>
53+
<PropertyValue Property="Deletable" Bool="false"/>
54+
</Record>
55+
</Annotation>
56+
<Annotation Term="Org.OData.Capabilities.V1.ExpandRestrictions">
57+
<Record>
58+
<PropertyValue Property="Expandable" Bool="false"/>
59+
</Record>
60+
</Annotation>
61+
</Annotations>
62+
<Annotations Target="microsoft.graph.managedDevice/users">
63+
<Annotation Term="Org.OData.Capabilities.V1.ChangeTracking">
64+
<Record>
65+
<PropertyValue Property="Supported" Bool="false"/>
66+
</Record>
67+
</Annotation>
68+
</Annotations>
69+
<Annotations Target="microsoft.graph.list/activities">
70+
<Annotation Term="Org.OData.Capabilities.V1.ChangeTracking">
71+
<Record>
72+
<PropertyValue Property="Supported" Bool="false"/>
73+
</Record>
74+
</Annotation>
75+
</Annotations>
4576
<Annotations Target="graph.activityHistoryItem">
4677
<Annotation Term="Org.OData.Capabilities.V1.SelectRestrictions">
4778
<Record>

transforms/csdl/preprocess_csdl_test_output.xml

Lines changed: 64 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,70 @@
5151
<EntityType Name="directoryObject" BaseType="graph.entity" OpenType="true">
5252
<Property Name="deletedDateTime" Type="Edm.DateTimeOffset" />
5353
</EntityType>
54+
<Annotations Target="microsoft.graph.user/joinedGroups">
55+
<Annotation Term="Org.OData.Capabilities.V1.ChangeTracking">
56+
<Record>
57+
<PropertyValue Property="Supported" Bool="false" />
58+
</Record>
59+
</Annotation>
60+
<Annotation Term="Org.OData.Capabilities.V1.DeleteRestrictions">
61+
<Record>
62+
<PropertyValue Property="Deletable" Bool="false" />
63+
</Record>
64+
</Annotation>
65+
<Annotation Term="Org.OData.Capabilities.V1.ExpandRestrictions">
66+
<Record>
67+
<PropertyValue Property="Expandable" Bool="false" />
68+
</Record>
69+
</Annotation>
70+
<Annotation Term="Org.OData.Capabilities.V1.NavigationRestrictions">
71+
<Record>
72+
<PropertyValue Property="RestrictedProperties">
73+
<Collection>
74+
<Record>
75+
<PropertyValue Property="IndexableByKey" Bool="false" />
76+
</Record>
77+
</Collection>
78+
</PropertyValue>
79+
</Record>
80+
</Annotation>
81+
</Annotations>
82+
<Annotations Target="microsoft.graph.managedDevice/users">
83+
<Annotation Term="Org.OData.Capabilities.V1.ChangeTracking">
84+
<Record>
85+
<PropertyValue Property="Supported" Bool="false" />
86+
</Record>
87+
</Annotation>
88+
<Annotation Term="Org.OData.Capabilities.V1.NavigationRestrictions">
89+
<Record>
90+
<PropertyValue Property="RestrictedProperties">
91+
<Collection>
92+
<Record>
93+
<PropertyValue Property="IndexableByKey" Bool="false" />
94+
</Record>
95+
</Collection>
96+
</PropertyValue>
97+
</Record>
98+
</Annotation>
99+
</Annotations>
100+
<Annotations Target="microsoft.graph.list/activities">
101+
<Annotation Term="Org.OData.Capabilities.V1.ChangeTracking">
102+
<Record>
103+
<PropertyValue Property="Supported" Bool="false" />
104+
</Record>
105+
</Annotation>
106+
<Annotation Term="Org.OData.Capabilities.V1.NavigationRestrictions">
107+
<Record>
108+
<PropertyValue Property="RestrictedProperties">
109+
<Collection>
110+
<Record>
111+
<PropertyValue Property="IndexableByKey" Bool="false" />
112+
</Record>
113+
</Collection>
114+
</PropertyValue>
115+
</Record>
116+
</Annotation>
117+
</Annotations>
54118
<Annotations Target="graph.activityHistoryItem">
55119
<Annotation Term="Org.OData.Core.V1.Computed" Bool="true" />
56120
</Annotations>
@@ -361,45 +425,6 @@
361425
</Record>
362426
</Annotation>
363427
</Annotations>
364-
<Annotations Target="microsoft.graph.user/joinedGroups">
365-
<Annotation Term="Org.OData.Capabilities.V1.NavigationRestrictions">
366-
<Record>
367-
<PropertyValue Property="RestrictedProperties">
368-
<Collection>
369-
<Record>
370-
<PropertyValue Property="IndexableByKey" Bool="false" />
371-
</Record>
372-
</Collection>
373-
</PropertyValue>
374-
</Record>
375-
</Annotation>
376-
</Annotations>
377-
<Annotations Target="microsoft.graph.managedDevice/users">
378-
<Annotation Term="Org.OData.Capabilities.V1.NavigationRestrictions">
379-
<Record>
380-
<PropertyValue Property="RestrictedProperties">
381-
<Collection>
382-
<Record>
383-
<PropertyValue Property="IndexableByKey" Bool="false" />
384-
</Record>
385-
</Collection>
386-
</PropertyValue>
387-
</Record>
388-
</Annotation>
389-
</Annotations>
390-
<Annotations Target="microsoft.graph.list/activities">
391-
<Annotation Term="Org.OData.Capabilities.V1.NavigationRestrictions">
392-
<Record>
393-
<PropertyValue Property="RestrictedProperties">
394-
<Collection>
395-
<Record>
396-
<PropertyValue Property="IndexableByKey" Bool="false" />
397-
</Record>
398-
</Collection>
399-
</PropertyValue>
400-
</Record>
401-
</Annotation>
402-
</Annotations>
403428
<Annotations Target="microsoft.graph.security/alerts">
404429
<Annotation Term="Org.OData.Capabilities.V1.DeleteRestrictions">
405430
<Record>

0 commit comments

Comments
 (0)