[
https://issues.apache.org/jira/browse/OLINGO-1144?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16294713#comment-16294713
]
Ramya edited comment on OLINGO-1144 at 12/18/17 9:42 AM:
---------------------------------------------------------
Hi Geert,
I have fixed this as part of the commit
https://git-wip-us.apache.org/repos/asf?p=olingo-odata4.git;a=commit;h=ee919d812d7168541734079f7a01633311ff23b5
I have added a new API which can take lambda variable as a parameter.
E.g:
ODataClient client = ODataClientFactory.getClient();
FilterFactory filterFactory = client.getFilterFactory();
FilterArgFactory filterArgFactory = filterFactory.getArgFactory();
URIFilter andFilExp = filterFactory.and(filterFactory.eq("v/name", "example"),
filterFactory.eq("v/type", "type"));
final URIFilter filter = filterFactory.match(
filterArgFactory.any(filterArgFactory.property("values"), "v",
andFilExp));
filter.build() gives "values/any(v: ((v/name eq 'example') and (v/type eq
'type')))"
Kindly verify this fix and get back if you find any issues.
Regards,
Ramya
was (Author: ramya.vasanth):
Hi Geert,
I have fixed this as part of the commit
https://git-wip-us.apache.org/repos/asf?p=olingo-odata4.git;a=commit;h=ee919d812d7168541734079f7a01633311ff23b5
I have added a new API which can take lambda variable as a parameter.
E.g:
ODataClient client = ODataClientFactory.getClient();
FilterFactory filterFactory = client.getFilterFactory();
FilterArgFactory filterArgFactory = filterFactory.getArgFactory();
URIFilter andFilExp = filterFactory.and(filterFactory.eq("v/name", "example"),
filterFactory.eq("v/type", "type"));
final URIFilter filter = filterFactory.match(
filterArgFactory.any(filterArgFactory.property("values"), "v",
andFilExp));
filter.build() gives "values/any(v:((v/name eq 'example') and (v/type eq
'type')))"
Kindly verify this fix and get back if you find any issues.
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)