Geert Graat created OLINGO-1145:
-----------------------------------

             Summary: How to create a valid URI with a date(time) literal using 
the FilterArgFactory?
                 Key: OLINGO-1145
                 URL: https://issues.apache.org/jira/browse/OLINGO-1145
             Project: Olingo
          Issue Type: Question
            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}} and 
{{FilterArgFactory}}. We want to filter on a property that is of type 
{{Edm.Date}} (and also {{Edm.DateTimeOffset}}), for instance for a date that 
equals 2017-07-04, e.g.

{code}
$filter=date eq 2017-07-04
{code}

Note that we do not use the {{date()}} function, is this is not implemented in 
the OData service that we call. That being said, the {{date()}} function also 
needs a {{FilterArg}}, so it has the same problem.

The problem is that we cannot find how to use the {{FilterArgFactory}} to 
create such a valid date literal. If we use the {{literal()}} method, the date 
value is surrounded with quotes, leading the OData service to interpret the 
value as a String which is inconsistent with our model, so it fails. We need to 
create a {{FilterArg}} with the date literal as a String value, without quotes. 
The only way to achieve this is to "disguise" it as a property, like the code 
below. That works, but it is clearly not the way it should be in the end.

{code}
FilterFactory filterFactory = new FilterFactoryImpl();
Date dateValue = <a valid date>;
String dateString = EdmDate.getInstance().valueToString(dateValue, null, null, 
null, null, null);
return filterFactory.getArgFactory().property(dateString);
{code}

Can you show an example how this should be done?



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to