You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by Anil G <gv...@gmail.com> on 2015/05/20 15:09:37 UTC

DateTimeOffset in Olingo

Hi,

I have a DateTimeOffset property defined for my type. But when I am
serializing data, it fails with the following Error Message

   - message: "Wrong value for property!"


I tried writing data in string (ISO 8601 format), date, calendar but all
fails.

Is this a bug or am I doing something wrong? I saw the source code but
could not find any serialization logic for Date/Time fields.

Thanks & Regards
Anil

Re: DateTimeOffset in Olingo

Posted by Anil G <gv...@gmail.com>.
6.2.3 Attribute Precision

A datetime-with-offset, decimal, duration, or time-of-day property MAY
define a value for the Precision attribute.


So, if I don't it shouldn't fail but ignore the time skew. No?



On Wed, May 20, 2015 at 7:22 PM, Anil G <gv...@gmail.com> wrote:

> Thanks Fred.
>
> Spec says that is optional. So it should work even if I do not define
> Precision. But it fails. The below code in EdmDateTimeOffset class throws
> the exception. Even if I had defined a precision of 2, it failed because
> the digits value came out as 3 for my data set (probably because I am
> debugging?)
>
> But why throw IllegalArgumentException when Precision < digits?
>
> /* 257 */     *int* digits = milliseconds % 10 == 0 ? 2 : milliseconds %
> 100 == 0 ? 1 : milliseconds % 1000 == 0 ? 0 : 3;
>
> /* 258 */     *if* (digits > 0) {
>
> /* 259 */       *if* ((precision == *null*) || (precision.intValue() <
> digits)) {
>
> */* 260 */         throw new IllegalArgumentException();*
>
> /*     */       }
>
>
>
> On Wed, May 20, 2015 at 7:18 PM, Frédéric SOUCHU <
> Frederic.SOUCHU@ingenico.com> wrote:
>
>>  Correct, it must be defined in the EDM.
>>
>>
>>
>> *From:* Anil G [mailto:gvnanils@gmail.com]
>> *Sent:* 20 May 2015 15:41
>> *To:* user@olingo.apache.org
>> *Subject:* Re: DateTimeOffset in Olingo
>>
>>
>>
>> as i debug the code, it looks like the precision is mandatory and
>> probably comes from metadata!
>>
>> will come back with my findings.
>>
>>
>>
>> On Wed, May 20, 2015 at 6:52 PM, Anil G <gv...@gmail.com> wrote:
>>
>> Hi Frederic,
>>
>>
>>
>> Thanks for a quick response.
>>
>> I don't see a setPrecision() method in Property class? I am using Beta03
>> in OData V4.
>>
>>
>>
>>
>>
>> On Wed, May 20, 2015 at 6:45 PM, Frédéric SOUCHU <
>> Frederic.SOUCHU@ingenico.com> wrote:
>>
>> You need to specify a 'precision', ex:
>>
>>
>>
>> new Property()
>>
>> .setName("OrderDate") // any datetime/timestamp field
>>
>> .setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName())
>>
>> .setPrecision(2)
>>
>>
>>
>> It should really be optional (as per OData spec)…
>>
>>
>>
>> Frederic
>>
>>
>>
>> *From:* Anil G [mailto:gvnanils@gmail.com]
>> *Sent:* 20 May 2015 15:10
>> *To:* user@olingo.apache.org
>> *Subject:* DateTimeOffset in Olingo
>>
>>
>>
>> Hi,
>>
>>
>>
>> I have a DateTimeOffset property defined for my type. But when I am
>> serializing data, it fails with the following Error Message
>>
>> ·         *message*: "Wrong value for property!"
>>
>>
>>
>> I tried writing data in string (ISO 8601 format), date, calendar but all
>> fails.
>>
>>
>>
>> Is this a bug or am I doing something wrong? I saw the source code but
>> could not find any serialization logic for Date/Time fields.
>>
>>
>>
>> Thanks & Regards
>>
>> Anil
>>
>>
>>
>>
>>
>
>

RE: DateTimeOffset in Olingo

Posted by "Amend, Christian" <ch...@sap.com>.
Hi Frédéric,

As far as I understand it the specification is referring to fractions of a second. But since the standard Java Calendar format also has milli seconds you get the exception. There is also a nasty side effect to this: For example if you have 1 millisecond you need a precision of 3 because the resulting string would look like “<seconds>.001” but if you have 100 milliseconds you only need a precision of 1 because the resulting string would look like “<seconds>.1”

We also throw the exception because when you transform a Calendar object into a String because you lose information and this could cause errors later on. So for now I would like to keep the exception. Setting a default precision of 3  could be a very good idea to prevent every developer to think about this issue. But I would rather have the specification to be more lenient and then adopt the Olingo library accordingly. WDYT?

Best Regards,
Christian

From: Frédéric SOUCHU [mailto:Frederic.SOUCHU@ingenico.com]
Sent: Mittwoch, 20. Mai 2015 17:40
To: user@olingo.apache.org
Subject: RE: DateTimeOffset in Olingo

Hi Christian,
Is the spec referring to fractions of a second or whole seconds? Not clear to me…

And anyway, having an exception raised on such basic types is certainly not helping.
Can't the implementation sets at least a default that would accept standard date/datetimes?

From: Amend, Christian [mailto:christian.amend@sap.com]
Sent: 20 May 2015 16:11
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: RE: DateTimeOffset in Olingo

Hi,

the important part unfortunately comes with the second paragraph:
For a temporal property the value of this attribute specifies the number of decimal places allowed in the seconds portion of the property’s value; it MUST be a non-negative integer between zero and twelve. If no value is specified, the temporal property has a precision of zero.

Thus if you give no precision the default is 0 and any number of digits for seconds must lead to an exception. I think this leads to exceptions easily but I don`t think we should relax this behavior as it is specified.

Best Regards,
Christian


From: Frédéric SOUCHU [mailto:Frederic.SOUCHU@ingenico.com]
Sent: Mittwoch, 20. Mai 2015 16:06
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: RE: DateTimeOffset in Olingo

Same question and findings I got a couple of month ago – see:
http://mail-archives.apache.org/mod_mbox/olingo-user/201503.mbox/%3C4C79C9168A5B9543AA23E3C669025A625035A38B@COSNADEXC13.usr.ingenico.loc%3E

It should be filled as a bug IMHO.

From: Anil G [mailto:gvnanils@gmail.com]
Sent: 20 May 2015 15:53
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: Re: DateTimeOffset in Olingo

Thanks Fred.

Spec says that is optional. So it should work even if I do not define Precision. But it fails. The below code in EdmDateTimeOffset class throws the exception. Even if I had defined a precision of 2, it failed because the digits value came out as 3 for my data set (probably because I am debugging?)

But why throw IllegalArgumentException when Precision < digits?

/* 257 */     int digits = milliseconds % 10 == 0 ? 2 : milliseconds % 100 == 0 ? 1 : milliseconds % 1000 == 0 ? 0 : 3;
/* 258 */     if (digits > 0) {
/* 259 */       if ((precision == null) || (precision.intValue() < digits)) {
/* 260 */         throw new IllegalArgumentException();
/*     */       }


On Wed, May 20, 2015 at 7:18 PM, Frédéric SOUCHU <Fr...@ingenico.com>> wrote:
Correct, it must be defined in the EDM.

From: Anil G [mailto:gvnanils@gmail.com<ma...@gmail.com>]
Sent: 20 May 2015 15:41
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: Re: DateTimeOffset in Olingo

as i debug the code, it looks like the precision is mandatory and probably comes from metadata!
will come back with my findings.

On Wed, May 20, 2015 at 6:52 PM, Anil G <gv...@gmail.com>> wrote:
Hi Frederic,

Thanks for a quick response.
I don't see a setPrecision() method in Property class? I am using Beta03 in OData V4.


On Wed, May 20, 2015 at 6:45 PM, Frédéric SOUCHU <Fr...@ingenico.com>> wrote:
You need to specify a 'precision', ex:

new Property()
.setName("OrderDate") // any datetime/timestamp field
.setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName())
.setPrecision(2)

It should really be optional (as per OData spec)…

Frederic

From: Anil G [mailto:gvnanils@gmail.com<ma...@gmail.com>]
Sent: 20 May 2015 15:10
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: DateTimeOffset in Olingo

Hi,

I have a DateTimeOffset property defined for my type. But when I am serializing data, it fails with the following Error Message
•         message: "Wrong value for property!"

I tried writing data in string (ISO 8601 format), date, calendar but all fails.

Is this a bug or am I doing something wrong? I saw the source code but could not find any serialization logic for Date/Time fields.

Thanks & Regards
Anil




RE: DateTimeOffset in Olingo

Posted by Frédéric SOUCHU <Fr...@ingenico.com>.
Hi Christian,
Is the spec referring to fractions of a second or whole seconds? Not clear to me…

And anyway, having an exception raised on such basic types is certainly not helping.
Can't the implementation sets at least a default that would accept standard date/datetimes?

From: Amend, Christian [mailto:christian.amend@sap.com]
Sent: 20 May 2015 16:11
To: user@olingo.apache.org
Subject: RE: DateTimeOffset in Olingo

Hi,

the important part unfortunately comes with the second paragraph:
For a temporal property the value of this attribute specifies the number of decimal places allowed in the seconds portion of the property’s value; it MUST be a non-negative integer between zero and twelve. If no value is specified, the temporal property has a precision of zero.

Thus if you give no precision the default is 0 and any number of digits for seconds must lead to an exception. I think this leads to exceptions easily but I don`t think we should relax this behavior as it is specified.

Best Regards,
Christian


From: Frédéric SOUCHU [mailto:Frederic.SOUCHU@ingenico.com]
Sent: Mittwoch, 20. Mai 2015 16:06
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: RE: DateTimeOffset in Olingo

Same question and findings I got a couple of month ago – see:
http://mail-archives.apache.org/mod_mbox/olingo-user/201503.mbox/%3C4C79C9168A5B9543AA23E3C669025A625035A38B@COSNADEXC13.usr.ingenico.loc%3E

It should be filled as a bug IMHO.

From: Anil G [mailto:gvnanils@gmail.com]
Sent: 20 May 2015 15:53
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: Re: DateTimeOffset in Olingo

Thanks Fred.

Spec says that is optional. So it should work even if I do not define Precision. But it fails. The below code in EdmDateTimeOffset class throws the exception. Even if I had defined a precision of 2, it failed because the digits value came out as 3 for my data set (probably because I am debugging?)

But why throw IllegalArgumentException when Precision < digits?

/* 257 */     int digits = milliseconds % 10 == 0 ? 2 : milliseconds % 100 == 0 ? 1 : milliseconds % 1000 == 0 ? 0 : 3;
/* 258 */     if (digits > 0) {
/* 259 */       if ((precision == null) || (precision.intValue() < digits)) {
/* 260 */         throw new IllegalArgumentException();
/*     */       }


On Wed, May 20, 2015 at 7:18 PM, Frédéric SOUCHU <Fr...@ingenico.com>> wrote:
Correct, it must be defined in the EDM.

From: Anil G [mailto:gvnanils@gmail.com<ma...@gmail.com>]
Sent: 20 May 2015 15:41
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: Re: DateTimeOffset in Olingo

as i debug the code, it looks like the precision is mandatory and probably comes from metadata!
will come back with my findings.

On Wed, May 20, 2015 at 6:52 PM, Anil G <gv...@gmail.com>> wrote:
Hi Frederic,

Thanks for a quick response.
I don't see a setPrecision() method in Property class? I am using Beta03 in OData V4.


On Wed, May 20, 2015 at 6:45 PM, Frédéric SOUCHU <Fr...@ingenico.com>> wrote:
You need to specify a 'precision', ex:

new Property()
.setName("OrderDate") // any datetime/timestamp field
.setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName())
.setPrecision(2)

It should really be optional (as per OData spec)…

Frederic

From: Anil G [mailto:gvnanils@gmail.com<ma...@gmail.com>]
Sent: 20 May 2015 15:10
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: DateTimeOffset in Olingo

Hi,

I have a DateTimeOffset property defined for my type. But when I am serializing data, it fails with the following Error Message
•         message: "Wrong value for property!"

I tried writing data in string (ISO 8601 format), date, calendar but all fails.

Is this a bug or am I doing something wrong? I saw the source code but could not find any serialization logic for Date/Time fields.

Thanks & Regards
Anil




Re: DateTimeOffset in Olingo

Posted by Anil G <gv...@gmail.com>.
Thanks for the clarification Christian.

Can you please help me on my "null" values query. Is there a way I can tell
serializer to ignore nulls and not write null values in json?

On Wed, May 20, 2015 at 7:41 PM, Amend, Christian <ch...@sap.com>
wrote:

>  Hi,
>
>
>
> the important part unfortunately comes with the second paragraph:
>
> *For a temporal property the value of this attribute specifies the number
> of decimal places allowed in the seconds portion of the property’s value;
> it MUST be a non-negative integer between zero and twelve. If no value is
> specified, the temporal property has a precision of zero.*
>
>
>
> Thus if you give no precision the default is 0 and any number of digits
> for seconds must lead to an exception. I think this leads to exceptions
> easily but I don`t think we should relax this behavior as it is specified.
>
>
>
> Best Regards,
>
> Christian
>
>
>
>
>
> *From:* Frédéric SOUCHU [mailto:Frederic.SOUCHU@ingenico.com]
> *Sent:* Mittwoch, 20. Mai 2015 16:06
> *To:* user@olingo.apache.org
> *Subject:* RE: DateTimeOffset in Olingo
>
>
>
> Same question and findings I got a couple of month ago – see:
>
>
> http://mail-archives.apache.org/mod_mbox/olingo-user/201503.mbox/%3C4C79C9168A5B9543AA23E3C669025A625035A38B@COSNADEXC13.usr.ingenico.loc%3E
>
>
>
> It should be filled as a bug IMHO.
>
>
>
> *From:* Anil G [mailto:gvnanils@gmail.com <gv...@gmail.com>]
> *Sent:* 20 May 2015 15:53
> *To:* user@olingo.apache.org
> *Subject:* Re: DateTimeOffset in Olingo
>
>
>
> Thanks Fred.
>
>
>
> Spec says that is optional. So it should work even if I do not define
> Precision. But it fails. The below code in EdmDateTimeOffset class throws
> the exception. Even if I had defined a precision of 2, it failed because
> the digits value came out as 3 for my data set (probably because I am
> debugging?)
>
>
>
> But why throw IllegalArgumentException when Precision < digits?
>
>
>
> /* 257 */     *int* digits = milliseconds % 10 == 0 ? 2 : milliseconds %
> 100 == 0 ? 1 : milliseconds % 1000 == 0 ? 0 : 3;
>
> /* 258 */     *if* (digits > 0) {
>
> /* 259 */       *if* ((precision == *null*) || (precision.intValue() <
> digits)) {
>
> */* 260 */         throw new IllegalArgumentException();*
>
> /*     */       }
>
>
>
>
>
> On Wed, May 20, 2015 at 7:18 PM, Frédéric SOUCHU <
> Frederic.SOUCHU@ingenico.com> wrote:
>
> Correct, it must be defined in the EDM.
>
>
>
> *From:* Anil G [mailto:gvnanils@gmail.com]
> *Sent:* 20 May 2015 15:41
> *To:* user@olingo.apache.org
> *Subject:* Re: DateTimeOffset in Olingo
>
>
>
> as i debug the code, it looks like the precision is mandatory and probably
> comes from metadata!
>
> will come back with my findings.
>
>
>
> On Wed, May 20, 2015 at 6:52 PM, Anil G <gv...@gmail.com> wrote:
>
> Hi Frederic,
>
>
>
> Thanks for a quick response.
>
> I don't see a setPrecision() method in Property class? I am using Beta03
> in OData V4.
>
>
>
>
>
> On Wed, May 20, 2015 at 6:45 PM, Frédéric SOUCHU <
> Frederic.SOUCHU@ingenico.com> wrote:
>
> You need to specify a 'precision', ex:
>
>
>
> new Property()
>
> .setName("OrderDate") // any datetime/timestamp field
>
> .setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName())
>
> .setPrecision(2)
>
>
>
> It should really be optional (as per OData spec)…
>
>
>
> Frederic
>
>
>
> *From:* Anil G [mailto:gvnanils@gmail.com]
> *Sent:* 20 May 2015 15:10
> *To:* user@olingo.apache.org
> *Subject:* DateTimeOffset in Olingo
>
>
>
> Hi,
>
>
>
> I have a DateTimeOffset property defined for my type. But when I am
> serializing data, it fails with the following Error Message
>
> ·         *message*: "Wrong value for property!"
>
>
>
> I tried writing data in string (ISO 8601 format), date, calendar but all
> fails.
>
>
>
> Is this a bug or am I doing something wrong? I saw the source code but
> could not find any serialization logic for Date/Time fields.
>
>
>
> Thanks & Regards
>
> Anil
>
>
>
>
>
>
>

RE: DateTimeOffset in Olingo

Posted by "Amend, Christian" <ch...@sap.com>.
Hi,

the important part unfortunately comes with the second paragraph:
For a temporal property the value of this attribute specifies the number of decimal places allowed in the seconds portion of the property’s value; it MUST be a non-negative integer between zero and twelve. If no value is specified, the temporal property has a precision of zero.

Thus if you give no precision the default is 0 and any number of digits for seconds must lead to an exception. I think this leads to exceptions easily but I don`t think we should relax this behavior as it is specified.

Best Regards,
Christian


From: Frédéric SOUCHU [mailto:Frederic.SOUCHU@ingenico.com]
Sent: Mittwoch, 20. Mai 2015 16:06
To: user@olingo.apache.org
Subject: RE: DateTimeOffset in Olingo

Same question and findings I got a couple of month ago – see:
http://mail-archives.apache.org/mod_mbox/olingo-user/201503.mbox/%3C4C79C9168A5B9543AA23E3C669025A625035A38B@COSNADEXC13.usr.ingenico.loc%3E

It should be filled as a bug IMHO.

From: Anil G [mailto:gvnanils@gmail.com]
Sent: 20 May 2015 15:53
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: Re: DateTimeOffset in Olingo

Thanks Fred.

Spec says that is optional. So it should work even if I do not define Precision. But it fails. The below code in EdmDateTimeOffset class throws the exception. Even if I had defined a precision of 2, it failed because the digits value came out as 3 for my data set (probably because I am debugging?)

But why throw IllegalArgumentException when Precision < digits?

/* 257 */     int digits = milliseconds % 10 == 0 ? 2 : milliseconds % 100 == 0 ? 1 : milliseconds % 1000 == 0 ? 0 : 3;
/* 258 */     if (digits > 0) {
/* 259 */       if ((precision == null) || (precision.intValue() < digits)) {
/* 260 */         throw new IllegalArgumentException();
/*     */       }


On Wed, May 20, 2015 at 7:18 PM, Frédéric SOUCHU <Fr...@ingenico.com>> wrote:
Correct, it must be defined in the EDM.

From: Anil G [mailto:gvnanils@gmail.com<ma...@gmail.com>]
Sent: 20 May 2015 15:41
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: Re: DateTimeOffset in Olingo

as i debug the code, it looks like the precision is mandatory and probably comes from metadata!
will come back with my findings.

On Wed, May 20, 2015 at 6:52 PM, Anil G <gv...@gmail.com>> wrote:
Hi Frederic,

Thanks for a quick response.
I don't see a setPrecision() method in Property class? I am using Beta03 in OData V4.


On Wed, May 20, 2015 at 6:45 PM, Frédéric SOUCHU <Fr...@ingenico.com>> wrote:
You need to specify a 'precision', ex:

new Property()
.setName("OrderDate") // any datetime/timestamp field
.setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName())
.setPrecision(2)

It should really be optional (as per OData spec)…

Frederic

From: Anil G [mailto:gvnanils@gmail.com<ma...@gmail.com>]
Sent: 20 May 2015 15:10
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: DateTimeOffset in Olingo

Hi,

I have a DateTimeOffset property defined for my type. But when I am serializing data, it fails with the following Error Message
•         message: "Wrong value for property!"

I tried writing data in string (ISO 8601 format), date, calendar but all fails.

Is this a bug or am I doing something wrong? I saw the source code but could not find any serialization logic for Date/Time fields.

Thanks & Regards
Anil




RE: DateTimeOffset in Olingo

Posted by "Amend, Christian" <ch...@sap.com>.
Hi,

for your previous issue please refer to my last mail. Any feedback on how you see this would be appreciated.

As for hiding null properties: The specification does not talk about a feature like that so we did not implement this. I also don`t know if it would be wise to exclude null properties when sending a response from the server to a generic client as the client then would not know about the properties at all if it doesn`t have access to the metadata. For custom clients which know the metadata this might be another story. There you could open a feature request in our JIRA.

Technically you can achieve this behavior by specifying a selected list of properties at the SerializerOptions you pass to the entity serializer. This might not be convenient as of now but it would achieve the required effect.

Best Regards,
Christian

From: Anil G [mailto:gvnanils@gmail.com]
Sent: Mittwoch, 20. Mai 2015 16:11
To: user@olingo.apache.org
Subject: Re: DateTimeOffset in Olingo

Agreed :)

On a side note, do you know how I can hide "null" values/make serializer ignore nulls in my json response. Nullable = true is not helping. The response json is full of 'null' values which could be simply hidden!

On Wed, May 20, 2015 at 7:35 PM, Frédéric SOUCHU <Fr...@ingenico.com>> wrote:
Same question and findings I got a couple of month ago – see:
http://mail-archives.apache.org/mod_mbox/olingo-user/201503.mbox/%3C4C79C9168A5B9543AA23E3C669025A625035A38B@COSNADEXC13.usr.ingenico.loc%3E

It should be filled as a bug IMHO.

From: Anil G [mailto:gvnanils@gmail.com<ma...@gmail.com>]
Sent: 20 May 2015 15:53

To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: Re: DateTimeOffset in Olingo

Thanks Fred.

Spec says that is optional. So it should work even if I do not define Precision. But it fails. The below code in EdmDateTimeOffset class throws the exception. Even if I had defined a precision of 2, it failed because the digits value came out as 3 for my data set (probably because I am debugging?)

But why throw IllegalArgumentException when Precision < digits?

/* 257 */     int digits = milliseconds % 10 == 0 ? 2 : milliseconds % 100 == 0 ? 1 : milliseconds % 1000 == 0 ? 0 : 3;
/* 258 */     if (digits > 0) {
/* 259 */       if ((precision == null) || (precision.intValue() < digits)) {
/* 260 */         throw new IllegalArgumentException();
/*     */       }


On Wed, May 20, 2015 at 7:18 PM, Frédéric SOUCHU <Fr...@ingenico.com>> wrote:
Correct, it must be defined in the EDM.

From: Anil G [mailto:gvnanils@gmail.com<ma...@gmail.com>]
Sent: 20 May 2015 15:41
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: Re: DateTimeOffset in Olingo

as i debug the code, it looks like the precision is mandatory and probably comes from metadata!
will come back with my findings.

On Wed, May 20, 2015 at 6:52 PM, Anil G <gv...@gmail.com>> wrote:
Hi Frederic,

Thanks for a quick response.
I don't see a setPrecision() method in Property class? I am using Beta03 in OData V4.


On Wed, May 20, 2015 at 6:45 PM, Frédéric SOUCHU <Fr...@ingenico.com>> wrote:
You need to specify a 'precision', ex:

new Property()
.setName("OrderDate") // any datetime/timestamp field
.setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName())
.setPrecision(2)

It should really be optional (as per OData spec)…

Frederic

From: Anil G [mailto:gvnanils@gmail.com<ma...@gmail.com>]
Sent: 20 May 2015 15:10
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: DateTimeOffset in Olingo

Hi,

I have a DateTimeOffset property defined for my type. But when I am serializing data, it fails with the following Error Message
•         message: "Wrong value for property!"

I tried writing data in string (ISO 8601 format), date, calendar but all fails.

Is this a bug or am I doing something wrong? I saw the source code but could not find any serialization logic for Date/Time fields.

Thanks & Regards
Anil





Re: DateTimeOffset in Olingo

Posted by Anil G <gv...@gmail.com>.
Agreed :)

On a side note, do you know how I can hide "null" values/make serializer
ignore nulls in my json response. Nullable = true is not helping. The
response json is full of 'null' values which could be simply hidden!

On Wed, May 20, 2015 at 7:35 PM, Frédéric SOUCHU <
Frederic.SOUCHU@ingenico.com> wrote:

>  Same question and findings I got a couple of month ago – see:
>
>
> http://mail-archives.apache.org/mod_mbox/olingo-user/201503.mbox/%3C4C79C9168A5B9543AA23E3C669025A625035A38B@COSNADEXC13.usr.ingenico.loc%3E
>
>
>
> It should be filled as a bug IMHO.
>
>
>
> *From:* Anil G [mailto:gvnanils@gmail.com]
> *Sent:* 20 May 2015 15:53
>
> *To:* user@olingo.apache.org
> *Subject:* Re: DateTimeOffset in Olingo
>
>
>
> Thanks Fred.
>
>
>
> Spec says that is optional. So it should work even if I do not define
> Precision. But it fails. The below code in EdmDateTimeOffset class throws
> the exception. Even if I had defined a precision of 2, it failed because
> the digits value came out as 3 for my data set (probably because I am
> debugging?)
>
>
>
> But why throw IllegalArgumentException when Precision < digits?
>
>
>
> /* 257 */     *int* digits = milliseconds % 10 == 0 ? 2 : milliseconds %
> 100 == 0 ? 1 : milliseconds % 1000 == 0 ? 0 : 3;
>
> /* 258 */     *if* (digits > 0) {
>
> /* 259 */       *if* ((precision == *null*) || (precision.intValue() <
> digits)) {
>
> */* 260 */         throw new IllegalArgumentException();*
>
> /*     */       }
>
>
>
>
>
> On Wed, May 20, 2015 at 7:18 PM, Frédéric SOUCHU <
> Frederic.SOUCHU@ingenico.com> wrote:
>
> Correct, it must be defined in the EDM.
>
>
>
> *From:* Anil G [mailto:gvnanils@gmail.com]
> *Sent:* 20 May 2015 15:41
> *To:* user@olingo.apache.org
> *Subject:* Re: DateTimeOffset in Olingo
>
>
>
> as i debug the code, it looks like the precision is mandatory and probably
> comes from metadata!
>
> will come back with my findings.
>
>
>
> On Wed, May 20, 2015 at 6:52 PM, Anil G <gv...@gmail.com> wrote:
>
> Hi Frederic,
>
>
>
> Thanks for a quick response.
>
> I don't see a setPrecision() method in Property class? I am using Beta03
> in OData V4.
>
>
>
>
>
> On Wed, May 20, 2015 at 6:45 PM, Frédéric SOUCHU <
> Frederic.SOUCHU@ingenico.com> wrote:
>
> You need to specify a 'precision', ex:
>
>
>
> new Property()
>
> .setName("OrderDate") // any datetime/timestamp field
>
> .setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName())
>
> .setPrecision(2)
>
>
>
> It should really be optional (as per OData spec)…
>
>
>
> Frederic
>
>
>
> *From:* Anil G [mailto:gvnanils@gmail.com]
> *Sent:* 20 May 2015 15:10
> *To:* user@olingo.apache.org
> *Subject:* DateTimeOffset in Olingo
>
>
>
> Hi,
>
>
>
> I have a DateTimeOffset property defined for my type. But when I am
> serializing data, it fails with the following Error Message
>
> ·         *message*: "Wrong value for property!"
>
>
>
> I tried writing data in string (ISO 8601 format), date, calendar but all
> fails.
>
>
>
> Is this a bug or am I doing something wrong? I saw the source code but
> could not find any serialization logic for Date/Time fields.
>
>
>
> Thanks & Regards
>
> Anil
>
>
>
>
>
>
>

RE: DateTimeOffset in Olingo

Posted by Frédéric SOUCHU <Fr...@ingenico.com>.
Same question and findings I got a couple of month ago – see:
http://mail-archives.apache.org/mod_mbox/olingo-user/201503.mbox/%3C4C79C9168A5B9543AA23E3C669025A625035A38B@COSNADEXC13.usr.ingenico.loc%3E

It should be filled as a bug IMHO.

From: Anil G [mailto:gvnanils@gmail.com]
Sent: 20 May 2015 15:53
To: user@olingo.apache.org
Subject: Re: DateTimeOffset in Olingo

Thanks Fred.

Spec says that is optional. So it should work even if I do not define Precision. But it fails. The below code in EdmDateTimeOffset class throws the exception. Even if I had defined a precision of 2, it failed because the digits value came out as 3 for my data set (probably because I am debugging?)

But why throw IllegalArgumentException when Precision < digits?

/* 257 */     int digits = milliseconds % 10 == 0 ? 2 : milliseconds % 100 == 0 ? 1 : milliseconds % 1000 == 0 ? 0 : 3;
/* 258 */     if (digits > 0) {
/* 259 */       if ((precision == null) || (precision.intValue() < digits)) {
/* 260 */         throw new IllegalArgumentException();
/*     */       }


On Wed, May 20, 2015 at 7:18 PM, Frédéric SOUCHU <Fr...@ingenico.com>> wrote:
Correct, it must be defined in the EDM.

From: Anil G [mailto:gvnanils@gmail.com<ma...@gmail.com>]
Sent: 20 May 2015 15:41
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: Re: DateTimeOffset in Olingo

as i debug the code, it looks like the precision is mandatory and probably comes from metadata!
will come back with my findings.

On Wed, May 20, 2015 at 6:52 PM, Anil G <gv...@gmail.com>> wrote:
Hi Frederic,

Thanks for a quick response.
I don't see a setPrecision() method in Property class? I am using Beta03 in OData V4.


On Wed, May 20, 2015 at 6:45 PM, Frédéric SOUCHU <Fr...@ingenico.com>> wrote:
You need to specify a 'precision', ex:

new Property()
.setName("OrderDate") // any datetime/timestamp field
.setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName())
.setPrecision(2)

It should really be optional (as per OData spec)…

Frederic

From: Anil G [mailto:gvnanils@gmail.com<ma...@gmail.com>]
Sent: 20 May 2015 15:10
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: DateTimeOffset in Olingo

Hi,

I have a DateTimeOffset property defined for my type. But when I am serializing data, it fails with the following Error Message
•         message: "Wrong value for property!"

I tried writing data in string (ISO 8601 format), date, calendar but all fails.

Is this a bug or am I doing something wrong? I saw the source code but could not find any serialization logic for Date/Time fields.

Thanks & Regards
Anil




Re: DateTimeOffset in Olingo

Posted by Anil G <gv...@gmail.com>.
Thanks Fred.

Spec says that is optional. So it should work even if I do not define
Precision. But it fails. The below code in EdmDateTimeOffset class throws
the exception. Even if I had defined a precision of 2, it failed because
the digits value came out as 3 for my data set (probably because I am
debugging?)

But why throw IllegalArgumentException when Precision < digits?

/* 257 */     *int* digits = milliseconds % 10 == 0 ? 2 : milliseconds %
100 == 0 ? 1 : milliseconds % 1000 == 0 ? 0 : 3;

/* 258 */     *if* (digits > 0) {

/* 259 */       *if* ((precision == *null*) || (precision.intValue() <
digits)) {

*/* 260 */         throw new IllegalArgumentException();*

/*     */       }



On Wed, May 20, 2015 at 7:18 PM, Frédéric SOUCHU <
Frederic.SOUCHU@ingenico.com> wrote:

>  Correct, it must be defined in the EDM.
>
>
>
> *From:* Anil G [mailto:gvnanils@gmail.com]
> *Sent:* 20 May 2015 15:41
> *To:* user@olingo.apache.org
> *Subject:* Re: DateTimeOffset in Olingo
>
>
>
> as i debug the code, it looks like the precision is mandatory and probably
> comes from metadata!
>
> will come back with my findings.
>
>
>
> On Wed, May 20, 2015 at 6:52 PM, Anil G <gv...@gmail.com> wrote:
>
> Hi Frederic,
>
>
>
> Thanks for a quick response.
>
> I don't see a setPrecision() method in Property class? I am using Beta03
> in OData V4.
>
>
>
>
>
> On Wed, May 20, 2015 at 6:45 PM, Frédéric SOUCHU <
> Frederic.SOUCHU@ingenico.com> wrote:
>
> You need to specify a 'precision', ex:
>
>
>
> new Property()
>
> .setName("OrderDate") // any datetime/timestamp field
>
> .setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName())
>
> .setPrecision(2)
>
>
>
> It should really be optional (as per OData spec)…
>
>
>
> Frederic
>
>
>
> *From:* Anil G [mailto:gvnanils@gmail.com]
> *Sent:* 20 May 2015 15:10
> *To:* user@olingo.apache.org
> *Subject:* DateTimeOffset in Olingo
>
>
>
> Hi,
>
>
>
> I have a DateTimeOffset property defined for my type. But when I am
> serializing data, it fails with the following Error Message
>
> ·         *message*: "Wrong value for property!"
>
>
>
> I tried writing data in string (ISO 8601 format), date, calendar but all
> fails.
>
>
>
> Is this a bug or am I doing something wrong? I saw the source code but
> could not find any serialization logic for Date/Time fields.
>
>
>
> Thanks & Regards
>
> Anil
>
>
>
>
>

RE: DateTimeOffset in Olingo

Posted by Frédéric SOUCHU <Fr...@ingenico.com>.
Correct, it must be defined in the EDM.

From: Anil G [mailto:gvnanils@gmail.com]
Sent: 20 May 2015 15:41
To: user@olingo.apache.org
Subject: Re: DateTimeOffset in Olingo

as i debug the code, it looks like the precision is mandatory and probably comes from metadata!
will come back with my findings.

On Wed, May 20, 2015 at 6:52 PM, Anil G <gv...@gmail.com>> wrote:
Hi Frederic,

Thanks for a quick response.
I don't see a setPrecision() method in Property class? I am using Beta03 in OData V4.


On Wed, May 20, 2015 at 6:45 PM, Frédéric SOUCHU <Fr...@ingenico.com>> wrote:
You need to specify a 'precision', ex:

new Property()
.setName("OrderDate") // any datetime/timestamp field
.setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName())
.setPrecision(2)

It should really be optional (as per OData spec)…

Frederic

From: Anil G [mailto:gvnanils@gmail.com<ma...@gmail.com>]
Sent: 20 May 2015 15:10
To: user@olingo.apache.org<ma...@olingo.apache.org>
Subject: DateTimeOffset in Olingo

Hi,

I have a DateTimeOffset property defined for my type. But when I am serializing data, it fails with the following Error Message
•         message: "Wrong value for property!"

I tried writing data in string (ISO 8601 format), date, calendar but all fails.

Is this a bug or am I doing something wrong? I saw the source code but could not find any serialization logic for Date/Time fields.

Thanks & Regards
Anil



Re: DateTimeOffset in Olingo

Posted by Anil G <gv...@gmail.com>.
as i debug the code, it looks like the precision is mandatory and probably
comes from metadata!
will come back with my findings.

On Wed, May 20, 2015 at 6:52 PM, Anil G <gv...@gmail.com> wrote:

> Hi Frederic,
>
> Thanks for a quick response.
> I don't see a setPrecision() method in Property class? I am using Beta03
> in OData V4.
>
>
> On Wed, May 20, 2015 at 6:45 PM, Frédéric SOUCHU <
> Frederic.SOUCHU@ingenico.com> wrote:
>
>>  You need to specify a 'precision', ex:
>>
>>
>>
>> new Property()
>>
>> .setName("OrderDate") // any datetime/timestamp field
>>
>> .setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName())
>>
>> .setPrecision(2)
>>
>>
>>
>> It should really be optional (as per OData spec)…
>>
>>
>>
>> Frederic
>>
>>
>>
>> *From:* Anil G [mailto:gvnanils@gmail.com]
>> *Sent:* 20 May 2015 15:10
>> *To:* user@olingo.apache.org
>> *Subject:* DateTimeOffset in Olingo
>>
>>
>>
>> Hi,
>>
>>
>>
>> I have a DateTimeOffset property defined for my type. But when I am
>> serializing data, it fails with the following Error Message
>>
>> ·         *message*: "Wrong value for property!"
>>
>>
>>
>> I tried writing data in string (ISO 8601 format), date, calendar but all
>> fails.
>>
>>
>>
>> Is this a bug or am I doing something wrong? I saw the source code but
>> could not find any serialization logic for Date/Time fields.
>>
>>
>>
>> Thanks & Regards
>>
>> Anil
>>
>
>

Re: DateTimeOffset in Olingo

Posted by Anil G <gv...@gmail.com>.
Hi Frederic,

Thanks for a quick response.
I don't see a setPrecision() method in Property class? I am using Beta03 in
OData V4.


On Wed, May 20, 2015 at 6:45 PM, Frédéric SOUCHU <
Frederic.SOUCHU@ingenico.com> wrote:

>  You need to specify a 'precision', ex:
>
>
>
> new Property()
>
> .setName("OrderDate") // any datetime/timestamp field
>
> .setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName())
>
> .setPrecision(2)
>
>
>
> It should really be optional (as per OData spec)…
>
>
>
> Frederic
>
>
>
> *From:* Anil G [mailto:gvnanils@gmail.com]
> *Sent:* 20 May 2015 15:10
> *To:* user@olingo.apache.org
> *Subject:* DateTimeOffset in Olingo
>
>
>
> Hi,
>
>
>
> I have a DateTimeOffset property defined for my type. But when I am
> serializing data, it fails with the following Error Message
>
> ·         *message*: "Wrong value for property!"
>
>
>
> I tried writing data in string (ISO 8601 format), date, calendar but all
> fails.
>
>
>
> Is this a bug or am I doing something wrong? I saw the source code but
> could not find any serialization logic for Date/Time fields.
>
>
>
> Thanks & Regards
>
> Anil
>

RE: DateTimeOffset in Olingo

Posted by Frédéric SOUCHU <Fr...@ingenico.com>.
You need to specify a 'precision', ex:

new Property()
.setName("OrderDate") // any datetime/timestamp field
.setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName())
.setPrecision(2)

It should really be optional (as per OData spec)…

Frederic

From: Anil G [mailto:gvnanils@gmail.com]
Sent: 20 May 2015 15:10
To: user@olingo.apache.org
Subject: DateTimeOffset in Olingo

Hi,

I have a DateTimeOffset property defined for my type. But when I am serializing data, it fails with the following Error Message
·         message: "Wrong value for property!"

I tried writing data in string (ISO 8601 format), date, calendar but all fails.

Is this a bug or am I doing something wrong? I saw the source code but could not find any serialization logic for Date/Time fields.

Thanks & Regards
Anil