[
https://issues.apache.org/jira/browse/OLINGO-1144?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16290353#comment-16290353
]
Ramya commented on OLINGO-1144:
-------------------------------
Hi,
You need to use the API's as below
ODataClient client = ODataClientFactory.getClient();
FilterFactory filterFactory = client.getFilterFactory();
FilterArgFactory filterArgFactory = filterFactory.getArgFactory();
URIFilter filter =
filterFactory.match(filterArgFactory.any(getFilterArgFactory().property("values"),
filterFactory.eq("d:d/name", 'example')));
This returns url of the form values/any(d:d/name eq 'example')
Regards,
Ramya
> 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
(v6.4.14#64029)