Geert Graat created OLINGO-1144:
-----------------------------------

             Summary: 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)

Reply via email to