olingo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geert Graat (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OLINGO-1144) How to use the FilterFactory to create a valid URI for filtering on a ComplexValue in a collection?
Date Wed, 20 Dec 2017 10:13:00 GMT

    [ https://issues.apache.org/jira/browse/OLINGO-1144?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16298216#comment-16298216

Geert Graat commented on OLINGO-1144:

Hi Ramya,

Thank you for this fix, this will definitely work for us! We actually created a custom FilterLambda
implementation to circumvent this problem, with has exactly the same implementation as the
FilterLambda in your fix. So with this code we can remove our custom code and just use the
Olingo library for this.

Looking forward to a new release with this fix and thanks again for your help.

> How to use the FilterFactory to create a valid URI for filtering on a ComplexValue in
a collection?
> ---------------------------------------------------------------------------------------------------
>                 Key: OLINGO-1144
>                 URL: https://issues.apache.org/jira/browse/OLINGO-1144
>             Project: Olingo
>          Issue Type: Question
>          Components: odata4-client
>    Affects Versions: (Java) V4 4.3.0
>            Reporter: Geert Graat
> Hi,
> We use the Olingo client library to call an OData service (which also uses the Olingo
library). We are implementing filtering using the {{FilterFactory}}. The problem we are facing
is how we can build a valid URIFilter to filter on the values of a ComplexType that is inside
a collection.
> Below is a simplified version of or metadata document:
> {code}
> <?xml version='1.0' encoding='UTF-8'?>
> <edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
> 	<edmx:DataServices>
> 		<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="example">
> 			<EntityType Name="Entity">
> 				<Property Name="values" Type="Collection(example.Value)"/>
> 			</EntityType>
> 			<ComplexType Name="Value">
> 				<Property Name="name" Type="Edm.String"/>
> 				<Property Name="type" Type="Edm.String"/>
> 			</ComplexType>
> 			<EntityContainer Name="Container">
> 				<EntitySet Name="Entities" EntityType="example.Entity"/>
> 			</EntityContainer>
> 		</Schema>
> 	</edmx:DataServices>
> </edmx:Edmx>
> {code}
> What we want is for instance to filter on an Entity that has a Value with name 'example'.
For this we need to construct the following URI:
> {code}$filter=values/any(v:v/name eq 'example'){code}
> We need to use the {{any}} function because as you can see from the metadata model an
{{Entity}} can contain multiple {{Value}} complex types in the collection property {{values}}.
> The problem is the definition of the lambda variable ({{v}} in the example above). If
we use the {{FilterFactory}}, we can get a {{FilterArgFactory}} that has an {{any}} function.
This creates a {{FilterLambda}} with the following arguments:
> * collection: the property that contains the collection, in our case {{values}}
> * operator: the operator, in our case {{any}}
> * expression: the expression to filter on our collection, in our case {{v/name eq 'example'}}
> So where does the declaration of the lambda variable go? We have searched the entire
library, but cannot find it. Can you please help with an example?

This message was sent by Atlassian JIRA

View raw message