Skip to content

Commit

Permalink
Add Capabilities supports in OData Lib.
Browse files Browse the repository at this point in the history
Related issues: OData#37, OData#51, OData#152.
  • Loading branch information
xuzhg committed Jun 9, 2015
1 parent de553d4 commit cbf0925
Show file tree
Hide file tree
Showing 9 changed files with 1,751 additions and 37 deletions.
212 changes: 212 additions & 0 deletions src/Microsoft.OData.Edm/ExtensionMethods/ExtensionMethods.cs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Microsoft.OData.Edm/Microsoft.OData.Edm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
<Compile Include="PrimitiveValueConverters\PrimitiveValueConverterConstants.cs" />
<Compile Include="Vocabularies\CapabilitiesVocabularyConstants.cs" />
<Compile Include="Vocabularies\CapabilitiesVocabularyModel.cs" />
<Compile Include="Vocabularies\CapabilitiesNavigationType.cs" />
<Compile Include="Vocabularies\CoreVocabularyConstants.cs" />
<Compile Include="Vocabularies\CoreVocabularyModel.cs" />
<Compile Include="Vocabularis\CapabilitiesVocabularyConstants.cs" />
Expand Down
26 changes: 26 additions & 0 deletions src/Microsoft.OData.Edm/Vocabularies/CapabilitiesNavigationType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//---------------------------------------------------------------------
// <copyright file="CapabilitiesNavigationType.cs" company="Microsoft">
// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
// </copyright>
//---------------------------------------------------------------------

namespace Microsoft.OData.Edm.Vocabularies.V1
{
public enum CapabilitiesNavigationType
{
/// <summary>
/// Navigation properties can be recursively navigated.
/// </summary>
Recursive,

/// <summary>
/// Navigation properties can be navigated to a single level.
/// </summary>
Single,

/// <summary>
/// Navigation properties are not navigable.
/// </summary>
None
}
}
107 changes: 97 additions & 10 deletions src/Microsoft.OData.Edm/Vocabularies/CapabilitiesVocabularies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,104 @@
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Org.OData.Capabilities.V1" Alias="Capabilities">
<!-- Supported Preferences -->
<Term Name="ChangeTracking" Type="Capabilities.ChangeTrackingType" AppliesTo="EntityContainer EntitySet">
<Annotation Term="Core.Description" String="Change tracking capabilities of this service or entity set" />
<Annotation Term="Core.Description" String="Change tracking capabilities of this service or entity set" />
</Term>
<ComplexType Name="ChangeTrackingType">
<Property Name="Supported" Type="Edm.Boolean" DefaultValue="true">
<Annotation Term="Core.Description" String="This entity set supports the odata.track-changes preference" />
</Property>
<Property Name="FilterableProperties" Type="Collection(Edm.PropertyPath)">
<Annotation Term="Core.Description" String="Change tracking supports filters on these properties" />
</Property>
<Property Name="ExpandableProperties" Type="Collection(Edm.NavigationPropertyPath)">
<Annotation Term="Core.Description" String="Change tracking supports these properties expanded" />
</Property>
<Property Name="Supported" Type="Edm.Boolean" DefaultValue="true">
<Annotation Term="Core.Description" String="This entity set supports the odata.track-changes preference" />
</Property>
<Property Name="FilterableProperties" Type="Collection(Edm.PropertyPath)">
<Annotation Term="Core.Description" String="Change tracking supports filters on these properties" />
</Property>
<Property Name="ExpandableProperties" Type="Collection(Edm.NavigationPropertyPath)">
<Annotation Term="Core.Description" String="Change tracking supports these properties expanded" />
</Property>
</ComplexType>
<Term Name="CountRestrictions" Type="Capabilities.CountRestrictionsType" AppliesTo="EntitySet">
<Annotation Term="Core.Description" String="Restrictions on /$count path suffix and $count=true system query option" />
</Term>
<ComplexType Name="CountRestrictionsType">
<Property Name="Countable" Type="Edm.Boolean" DefaultValue="true">
<Annotation Term="Core.Description" String="Entities can be counted" />
</Property>
<Property Name="NonCountableProperties" Type="Collection(Edm.PropertyPath)">
<Annotation Term="Core.Description" String="These collection properties do not allow /$count segments" />
</Property>
<Property Name="NonCountableNavigationProperties" Type="Collection(Edm.NavigationPropertyPath)">
<Annotation Term="Core.Description" String="These navigation properties do not allow /$count segments" />
</Property>
</ComplexType>
<Term Name="NavigationRestrictions" Type="Capabilities.NavigationRestrictionsType" AppliesTo="EntitySet">
<Annotation Term="Core.Description" String="Restrictions on navigating properties according to OData URL conventions" />
</Term>
<ComplexType Name="NavigationRestrictionsType">
<Property Name="Navigability" Type="Capabilities.NavigationType">
<Annotation Term="Core.Description" String="Supported Navigability" />
</Property>
<Property Name="RestrictedProperties" Type="Collection(Capabilities.NavigationPropertyRestriction)" />
</ComplexType>
<ComplexType Name="NavigationPropertyRestriction">
<Property Name="NavigationProperty" Type="Edm.NavigationPropertyPath">
<Annotation Term="Core.Description" String="Navigation properties can be navigated" />
</Property>
<Property Name="Navigability" Type="Capabilities.NavigationType">
<Annotation Term="Core.Description" String="Navigation properties can be navigated to this level" />
</Property>
</ComplexType>
<EnumType Name="NavigationType">
<Member Name="Recursive">
<Annotation Term="Core.Description" String="Navigation properties can be recursively navigated" />
</Member>
<Member Name="Single">
<Annotation Term="Core.Description" String="Navigation properties can be navigated to a single level" />
</Member>
<Member Name="None">
<Annotation Term="Core.Description" String="Navigation properties are not navigable" />
</Member>
</EnumType>
<Term Name="FilterRestrictions" Type="Capabilities.FilterRestrictionsType" AppliesTo="EntitySet">
<Annotation Term="Core.Description" String="Restrictions on $filter expressions" />
</Term>
<ComplexType Name="FilterRestrictionsType">
<Property Name="Filterable" Type="Edm.Boolean" DefaultValue="true">
<Annotation Term="Core.Description" String="$filter is supported" />
</Property>
<Property Name="RequiresFilter" Type="Edm.Boolean" Nullable="true">
<Annotation Term="Core.Description" String="$filter is required" />
</Property>
<Property Name="RequiredProperties" Type="Collection(Edm.PropertyPath)">
<Annotation Term="Core.Description" String="These properties must be specified in the $filter clause (properties of derived types are not allowed here)" />
</Property>
<Property Name="NonFilterableProperties" Type="Collection(Edm.PropertyPath)">
<Annotation Term="Core.Description" String="These properties cannot be used in $filter expressions" />
</Property>
</ComplexType>
<Term Name="SortRestrictions" Type="Capabilities.SortRestrictionsType" AppliesTo="EntitySet">
<Annotation Term="Core.Description" String="Restrictions on $orderby expressions" />
</Term>
<ComplexType Name="SortRestrictionsType">
<Property Name="Sortable" Type="Edm.Boolean" DefaultValue="true">
<Annotation Term="Core.Description" String="$orderby is supported" />
</Property>
<Property Name="AscendingOnlyProperties" Type="Collection(Edm.PropertyPath)">
<Annotation Term="Core.Description" String="These properties can only be used for sorting in Ascending order" />
</Property>
<Property Name="DescendingOnlyProperties" Type="Collection(Edm.PropertyPath)">
<Annotation Term="Core.Description" String="These properties can only be used for sorting in Descending order" />
</Property>
<Property Name="NonSortableProperties" Type="Collection(Edm.PropertyPath)">
<Annotation Term="Core.Description" String="These properties cannot be used in $orderby expressions" />
</Property>
</ComplexType>
<Term Name="ExpandRestrictions" Type="Capabilities.ExpandRestrictionsType" AppliesTo="EntitySet">
<Annotation Term="Core.Description" String="Restrictions on $expand expressions" />
</Term>
<ComplexType Name="ExpandRestrictionsType">
<Property Name="Expandable" Type="Edm.Boolean" DefaultValue="true">
<Annotation Term="Core.Description" String="$expand is supported" />
</Property>
<Property Name="NonExpandableProperties" Type="Collection(Edm.NavigationPropertyPath)">
<Annotation Term="Core.Description" String="These properties cannot be used in $expand expressions" />
</Property>
</ComplexType>
</Schema>
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,82 @@ public static class CapabilitiesVocabularyConstants

/// <summary>Org.OData.Capabilities.V1.xml file suffix</summary>
internal const string VocabularyUrlSuffix = "/Org.OData.Capabilities.V1.xml";

#region $count
/// <summary>Org.OData.Capabilities.V1.CountRestrictions</summary>
public const string CountRestrictions = "Org.OData.Capabilities.V1.CountRestrictions";

/// <summary>Property Countable of Org.OData.Capabilities.V1.CountRestrictions</summary>
public const string CountRestrictionsCountable = "Countable";

/// <summary>Property NonCountableProperties of Org.OData.Capabilities.V1.CountRestrictions</summary>
public const string CountRestrictionsNonCountableProperties = "NonCountableProperties";

/// <summary>Property NonCountableNavigationProperties of Org.OData.Capabilities.V1.CountRestrictions</summary>
public const string CountRestrictionsNonCountableNavigationProperties = "NonCountableNavigationProperties";
#endregion

#region $select
/// <summary>Org.OData.Capabilities.V1.NavigationRestrictions</summary>
public const string NavigationRestrictions = "Org.OData.Capabilities.V1.NavigationRestrictions";

/// <summary>Property Navigability of Org.OData.Capabilities.V1.NavigationRestrictions</summary>
public const string NavigationRestrictionsNavigability = "Navigability";

/// <summary>Property RestrictedProperties of Org.OData.Capabilities.V1.NavigationRestrictions</summary>
public const string NavigationRestrictionsRestrictedProperties = "RestrictedProperties";

/// <summary>Property NavigationProperty of Org.OData.Capabilities.V1.NavigationPropertyRestriction</summary>
public const string NavigationPropertyRestrictionNavigationProperty = "NavigationProperty";

/// <summary>Org.OData.Capabilities.V1.NavigationType</summary>
public const string NavigationType = "Org.OData.Capabilities.V1.NavigationType";

#endregion

#region $filter
/// <summary>Org.OData.Capabilities.V1.FilterRestrictions</summary>
public const string FilterRestrictions = "Org.OData.Capabilities.V1.FilterRestrictions";

/// <summary>Property Filterable of Org.OData.Capabilities.V1.FilterRestrictions</summary>
public const string FilterRestrictionsFilterable = "Filterable";

/// <summary>Property RequiresFilter of Org.OData.Capabilities.V1.FilterRestrictions</summary>
public const string FilterRestrictionsRequiresFilter = "RequiresFilter";

/// <summary>Property RequiredProperties of Org.OData.Capabilities.V1.FilterRestrictions</summary>
public const string FilterRestrictionsRequiredProperties = "RequiredProperties";

/// <summary>Property NonFilterableProperties of Org.OData.Capabilities.V1.FilterRestrictions</summary>
public const string FilterRestrictionsNonFilterableProperties = "NonFilterableProperties";
#endregion

#region $orderby
/// <summary>Org.OData.Capabilities.V1.SortRestrictions</summary>
public const string SortRestrictions = "Org.OData.Capabilities.V1.SortRestrictions";

/// <summary>Property Sortable of Org.OData.Capabilities.V1.FilterRestrictions</summary>
public const string SortRestrictionsSortable = "Sortable";

/// <summary>Property AscendingOnlyProperties of Org.OData.Capabilities.V1.FilterRestrictions</summary>
public const string SortRestrictionsAscendingOnlyProperties = "AscendingOnlyProperties";

/// <summary>Property DescendingOnlyProperties of Org.OData.Capabilities.V1.FilterRestrictions</summary>
public const string SortRestrictionsDescendingOnlyProperties = "DescendingOnlyProperties";

/// <summary>Property NonSortableProperties of Org.OData.Capabilities.V1.FilterRestrictions</summary>
public const string SortRestrictionsNonSortableProperties = "NonSortableProperties";
#endregion

#region $expand
/// <summary>Org.OData.Capabilities.V1.ExpandRestrictions</summary>
public const string ExpandRestrictions = "Org.OData.Capabilities.V1.ExpandRestrictions";

/// <summary>Property Expandable of Org.OData.Capabilities.V1.ExpandRestrictions</summary>
public const string ExpandRestrictionsExpandable = "Expandable";

/// <summary>Property NonExpandableProperties of Org.OData.Capabilities.V1.ExpandRestrictions</summary>
public const string ExpandRestrictionsNonExpandableProperties = "NonExpandableProperties";
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

namespace Microsoft.OData.Edm.Vocabularies.V1
{
using System.Diagnostics.CodeAnalysis;

/// <summary>
/// Representing Capabilities Vocabulary Model.
/// </summary>
Expand All @@ -31,6 +29,36 @@ internal class CapabilitiesVocabularyModel
/// </summary>
public static readonly IEdmValueTerm ChangeTrackingTerm;

/// <summary>
/// The count restrictions term.
/// </summary>
public static readonly IEdmValueTerm CountRestrictionsTerm;

/// <summary>
/// The navigation restrictions term.
/// </summary>
public static readonly IEdmValueTerm NavigationRestrictionsTerm;

/// <summary>
/// The filter restrictions term.
/// </summary>
public static readonly IEdmValueTerm FilterRestrictionsTerm;

/// <summary>
/// The sort restrictions term.
/// </summary>
public static readonly IEdmValueTerm SortRestrictionsTerm;

/// <summary>
/// The expand restrictions term.
/// </summary>
public static readonly IEdmValueTerm ExpandRestrictionsTerm;

/// <summary>
/// The navigation type.
/// </summary>
public static readonly IEdmEnumType NavigationTypeType;

/// <summary>
/// Parse Capabilities Vocabulary Model from CapabilitiesVocabularies.xml
/// </summary>
Expand All @@ -46,6 +74,13 @@ static CapabilitiesVocabularyModel()
}

ChangeTrackingTerm = Instance.FindDeclaredValueTerm(CapabilitiesVocabularyConstants.ChangeTracking);
CountRestrictionsTerm = Instance.FindDeclaredValueTerm(CapabilitiesVocabularyConstants.CountRestrictions);
NavigationRestrictionsTerm = Instance.FindDeclaredValueTerm(CapabilitiesVocabularyConstants.NavigationRestrictions);
FilterRestrictionsTerm = Instance.FindDeclaredValueTerm(CapabilitiesVocabularyConstants.FilterRestrictions);
SortRestrictionsTerm = Instance.FindDeclaredValueTerm(CapabilitiesVocabularyConstants.SortRestrictions);
ExpandRestrictionsTerm = Instance.FindDeclaredValueTerm(CapabilitiesVocabularyConstants.ExpandRestrictions);

NavigationTypeType = (IEdmEnumType)Instance.FindDeclaredType(CapabilitiesVocabularyConstants.NavigationType);
}
}
}
Loading

0 comments on commit cbf0925

Please sign in to comment.