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

Add capabilities vocabulary annotation support. #405

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
5 participants
@xuzhg
Copy link
Member

commented Jun 17, 2015

To support the following capabilities vocabulary annotation:

• NonFilterable / NotFilterable -- $filter
• NotCountable -- $count
• NotExpandable -- $expand
• NotNavigable -- $select
• NotSortable / Unsortable -- $orderby

@congysu congysu added this to the v5.7 milestone Jun 24, 2015

@xuzhg xuzhg force-pushed the xuzhg:VocabularySupport branch from 87db0e0 to 99ff45a Jun 25, 2015

/// Enumerates the navigation type can apply on navigation restrictions.
/// </summary>
public enum CapabilitiesNavigationType
{

This comment has been minimized.

Copy link
@karataliu

karataliu Jun 25, 2015

Contributor

make internal?

This comment has been minimized.

Copy link
@xuzhg

xuzhg Jun 25, 2015

Author Member

I agree.

/// Constant values for Capabilities Vocabulary
/// </summary>
public static class CapabilitiesVocabularyConstants
{

This comment has been minimized.

Copy link
@karataliu

karataliu Jun 25, 2015

Contributor

make internal?

This comment has been minimized.

Copy link
@xuzhg

xuzhg Jun 25, 2015

Author Member

Agree.

/// Contains extension methods for <see cref="EdmModel"/> to set the query capabilities vocabulary.
/// </summary>
public static class CapabilitiesVocabularyExtensionMethods
{

This comment has been minimized.

Copy link
@karataliu

karataliu Jun 25, 2015

Contributor

make internal?

This comment has been minimized.

Copy link
@xuzhg

xuzhg Jun 25, 2015

Author Member

Partial agree. What about the un-type scenario?

/// </summary>
public static class CapabilitiesVocabularyExtensionMethods
{
private static readonly IEnumerable<IEdmStructuralProperty> EmptyStructuralProperties = new Collection<IEdmStructuralProperty>();

This comment has been minimized.

Copy link
@karataliu

karataliu Jun 25, 2015

Contributor

Enumerable.Empty<>

This comment has been minimized.

Copy link
@xuzhg

xuzhg Jun 25, 2015

Author Member

modified

throw Error.ArgumentNull("target");
}

IEdmEnumType navigationType = model.FindType(CapabilitiesVocabularyConstants.NavigationType) as IEdmEnumType;

This comment has been minimized.

Copy link
@karataliu

karataliu Jun 25, 2015

Contributor

use capabilitymodel directly, or cache the type.

This comment has been minimized.

Copy link
@xuzhg

xuzhg Jun 25, 2015

Author Member

I add a private method to do it.

/// <param name="restrictedProperties">These properties have navigation restrictions on.</param>
public static void SetNavigationRestrictionsAnnotation(this EdmModel model, IEdmEntitySet target,
CapabilitiesNavigationType navigability,
IEnumerable<Tuple<IEdmNavigationProperty, CapabilitiesNavigationType>> restrictedProperties)

This comment has been minimized.

Copy link
@karataliu

karataliu Jun 25, 2015

Contributor

why not IDictionary, the key should be unique?

This comment has been minimized.

Copy link
@xuzhg

xuzhg Jun 25, 2015

Author Member

No limit to let the same IEdmNavigationProperty has difference NavigationType.

Contract.Assert(model != null);
Contract.Assert(target != null);

IEdmValueTerm term = model.FindValueTerm(qualifiedName);

This comment has been minimized.

Copy link
@karataliu

karataliu Jun 25, 2015

Contributor

better cache term-s in model.

This comment has been minimized.

Copy link
@xuzhg

xuzhg Jun 25, 2015

Author Member

It's internal model in ODL.

internal class CapabilitiesVocabularyModel

This comment has been minimized.

Copy link
@xuzhg

xuzhg Jun 25, 2015

Author Member

It's only used in model builder. Is there any bad performance?

/// <param name="nonCountableNavigationProperties">These navigation properties do not allow /$count segments.</param>
public static void SetCountRestrictionsAnnotation(this EdmModel model, IEdmEntitySet target, bool isCountable,
IEnumerable<IEdmProperty> nonCountableProperties,
IEnumerable<IEdmNavigationProperty> nonCountableNavigationProperties)

This comment has been minimized.

Copy link
@karataliu

karataliu Jun 25, 2015

Contributor

consider pass IEnumerable here, to resolve complex type case : 'Address/Zip'

This comment has been minimized.

Copy link
@xuzhg

xuzhg Jun 25, 2015

Author Member

Not in scope

@xuzhg xuzhg force-pushed the xuzhg:VocabularySupport branch from 99ff45a to 3bd8782 Jun 25, 2015

xuzhg added a commit that referenced this pull request Jun 25, 2015

@xuzhg

This comment has been minimized.

Copy link
Member Author

commented Jun 25, 2015

Merged.

@xuzhg xuzhg closed this Jun 25, 2015

namespace System.Web.OData.Builder
{
/// <summary>
/// Constant values for Capabilities Vocabulary

This comment has been minimized.

Copy link
@congysu

congysu Jul 6, 2015

Contributor

nit: Add a trailing .

nonCountableProperties = nonCountableProperties ?? EmptyStructuralProperties;
nonCountableNavigationProperties = nonCountableNavigationProperties ?? EmptyNavigationProperties;

IList<IEdmPropertyConstructor> properties = new List<IEdmPropertyConstructor>

This comment has been minimized.

Copy link
@congysu

congysu Jul 6, 2015

Contributor

var. Not for this change: We shall update the StyleCop.

new EdmEnumMemberReferenceExpression(navigationType.Members.Single(m => m.Name == name)))
});
});

This comment has been minimized.

Copy link
@congysu

congysu Jul 6, 2015

Contributor

remove one empty line.

foreach (NavigationSourceAndAnnotations source in entitySets)
{
IEdmEntitySet entitySet = source.NavigationSource as IEdmEntitySet;
if (entitySet == null)

This comment has been minimized.

Copy link
@congysu

congysu Jul 7, 2015

Contributor

Use OfType to enumerate, instead of as in a for loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.