← Back to team overview

dhis2-devs team mailing list archive

Re: Sync Anonymous Event Data along with coordinates code fix

 

Sorry Morten,  executeAnonymousEventPush which we build for pushing
anonymous event data, When we are getting events(which does not have valid
and coordinateString field ) and when we are passing that to <ObjectMapper>
to write to request, at the time this payload was building.


Any idea why are we getting those field when we  writeValue using
ObjectMapper


Here is the code:

Events result = eventService.getEventValuesLastUpdatedAfter( lastSuccessTime );
ObjectMapper mapper = new ObjectMapper();
mapper.writeValue( request.getBody(), result );


OutPut

result = Events{program='null', programInstance='null',
events=[Event{event='p6lrkXRw14W', status=ACTIVE,
program='YJ4AHPlFTrf', programStage='UpHRvs3KcyL',
orgUnit='y2mjbcN29en', trackedEntityInstance='null',
eventDate='2016-06-15T18:30:00.000+0000', dueDate='null',
storedBy='null', coordinate=Coordinate{latitude=14.093957177836236,
longitude=46.175537109375}, dataValues=[DataValue{value='12345',
dataElement='YKz99vMMKpg', providedElsewhere=false,
storedBy='Srikanth'}], attributeCategoryOptions=xYerKDKCefk,
completedBy=null, completedDate=null}]}

After we are mapping we are getting previous payload




On Thu, Jun 16, 2016 at 4:32 PM, Anilkumar Kodi <anilkumk@xxxxxxxxxxxxxxxx>
wrote:

> It got added when we are serializing and sending request in the
> executeAnonymousEventPush.
>
> On Thu, Jun 16, 2016 at 3:34 PM, Morten Olav Hansen <morten@xxxxxxxxx>
> wrote:
>
>> Right, but I don't see why you have valid in the payload to start with?
>> normal event export will not include this
>>
>> --
>> Morten Olav Hansen
>> Senior Engineer, DHIS 2
>> University of Oslo
>> http://www.dhis2.org
>>
>> On Thu, Jun 16, 2016 at 4:52 PM, Anilkumar Kodi <
>> anilkumk@xxxxxxxxxxxxxxxx> wrote:
>>
>>> Hi Morten
>>>
>>> This is related to the coordinate value itself.
>>> Please see this event payload thats getting posted to /api/events
>>> (POST).
>>>
>>>
>>> {"program":null,"programInstance":null,"events":[{"event":"tiqYSyQER6a","status":"ACTIVE","program":"MR7cTxF25lM","programStage":"f8hc3X0zYQ7","enrollment":null,"enrollmentStatus":null,"orgUnit":"y2mjbcN29en","orgUnitName":null,"trackedEntityInstance":null,"eventDate":"2016-06-15T18:30:00.000+0000","dueDate":null,"storedBy":null,"coordinate":{"latitude":16.867633616803847,"longitude":50.28167724609375,"valid":true,"coordinateString":"[50.28167724609375,16.867633616803847]"},"dataValues":[{"created":"2016-06-16T06:11:29.707+0000","lastUpdated":"2016-06-16T06:11:29.707+0000","value":"123456789","dataElement":"YKz99vMMKpg","providedElsewhere":false,"storedBy":"admin"}],"notes":[],"followup":null,"created":null,"lastUpdated":null,"attributeCategoryOptions":"xYerKDKCefk","completedBy":null,"completedDate":null,"href":null}],"metaData":null,"pager":null}
>>>
>>> *And the underlying exception is this:*
>>>
>>> com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:
>>> Unrecognized field "valid" (class
>>> org.hisp.dhis.dxf2.events.event.Coordinate), not marked as ignorable (2
>>> known properties: "latitude", "longitude"])
>>>  at [Source:
>>> {"program":null,"programInstance":null,"events":[{"event":"tiqYSyQER6a","status":"ACTIVE","program":"MR7cTxF25lM","programStage":"f8hc3X0zYQ7","enrollment":null,"enrollmentStatus":null,"orgUnit":"y2mjbcN29en","orgUnitName":null,"trackedEntityInstance":null,"eventDate":"2016-06-15T18:30:00.000+0000","dueDate":null,"storedBy":null,"coordinate":{"latitude":16.867633616803847,"longitude":50.28167724609375,"valid":true,"coordinateString":"[50.28167724609375,16.867633616803847]"},"dataValues":[{"created":"2016-06-16T06:11:29.707+0000","lastUpdated":"2016-06-16T06:11:29.707+0000","value":"123456789","dataElement":"YKz99vMMKpg","providedElsewhere":false,"storedBy":"admin"}],"notes":[],"followup":null,"created":null,"lastUpdated":null,"attributeCategoryOptions":"xYerKDKCefk","completedBy":null,"completedDate":null,"href":null}],"metaData":null,"pager":null}
>>> ; line: 1, column: 418] (through reference chain:
>>> org.hisp.dhis.dxf2.events.event.Events["events"]->java.util.ArrayList[0]->org.hisp.dhis.dxf2.events.event.Event["coordinate"]->org.hisp.dhis.dxf2.events.event.Coordinate["valid"])
>>>
>>> Please let us know what you think.
>>>
>>> Regards
>>> Anil
>>>
>>> On Thu, Jun 16, 2016 at 7:30 AM, Morten Olav Hansen <morten@xxxxxxxxx>
>>> wrote:
>>>
>>>> Hi
>>>>
>>>> Could you show me the payload you are sending? this API is in use by
>>>> several clients without any issues.
>>>>
>>>> Also, it says `Unrecognized field "programInstance"` are you sure this
>>>> is really related to `@JsonIgnore` on the `Coordinate` class?
>>>>
>>>> It would be easier to debug if you can share the event you are sending.
>>>>
>>>> --
>>>> Morten Olav Hansen
>>>> Senior Engineer, DHIS 2
>>>> University of Oslo
>>>> http://www.dhis2.org
>>>>
>>>> On Wed, Jun 15, 2016 at 7:46 PM, Anilkumar Kodi <
>>>> anilkumk@xxxxxxxxxxxxxxxx> wrote:
>>>>
>>>>> Hi Morten,
>>>>>
>>>>> This is still looking for other 2 properties to map while
>>>>> deserializing, we are getting exception like
>>>>>
>>>>> com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:
>>>>> Unrecognized field "programInstance" (class
>>>>> org.hisp.dhis.dxf2.events.event.Event), not marked as ignorable (22 known
>>>>> properties: "notes", "trackedEntityInstance", "program", "lastUpdated",
>>>>> "orgUnit", "href", "dataValues", "status", "orgUnitName",
>>>>> "enrollmentStatus", "coordinate", "completedDate", "event", "dueDate",
>>>>> "enrollment", "eventDate", "followup", "programStage", "storedBy",
>>>>> "created", "attributeCategoryOptions", "completedBy"])
>>>>>  at [Source:
>>>>> {"program":null,"programInstance":null,"events":[{"event":"EcHeh9roBlf","status":"ACTIVE","program":"KKZTIFe5sf5","programStage":"lQgBMyAgzae","enrollment":null,"enrollmentStatus":null,"orgUnit":"fxXno3Zm20F","orgUnitName":null,"trackedEntityInstance":null,"eventDate":"2016-06-06T18:30:00.000+0000","dueDate":null,"storedBy":null,"coordinate":{"latitude":11.587669416896203,"longitude":41.66839599609375,"valid":true,"coordinateString":"[41.66839599609375,11.587669416896203]"},"dataValues":[{"created":"2016-06-14T07:21:30.781+0000","lastUpdated":"2016-06-14T07:21:30.782+0000","value":"7","dataElement":"gKGoK7Vb2yK","providedElsewhere":false,"storedBy":"Anil"}],"notes":[],"followup":null,"created":null,"lastUpdated":null,"attributeCategoryOptions":"xYerKDKCefk","completedBy":null,"completedDate":null,"href":null}],"metaData":null,"pager":null};
>>>>> line: 1, column: 39] (through reference chain:
>>>>> org.hisp.dhis.dxf2.events.event.Event["programInstance"])
>>>>> at
>>>>> com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:51)
>>>>>
>>>>>
>>>>> Although, we see this working when we add  @JsonIgnore on getters.
>>>>>
>>>>> @JsonIgnore
>>>>> public boolean isValid()
>>>>>
>>>>> @JsonIgnore
>>>>>
>>>>> public String getCoordinateString()
>>>>>
>>>>>
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Anil
>>>>>
>>>>>
>>>>>
>>>>> On Wed, Jun 15, 2016 at 10:48 AM, Morten Olav Hansen <morten@xxxxxxxxx
>>>>> > wrote:
>>>>>
>>>>>> Already done :)
>>>>>>
>>>>>> --
>>>>>> Morten Olav Hansen
>>>>>> Senior Engineer, DHIS 2
>>>>>> University of Oslo
>>>>>> http://www.dhis2.org
>>>>>>
>>>>>> On Wed, Jun 15, 2016 at 11:50 AM, Vanya Seth <vanyas@xxxxxxxxxxxxxxxx
>>>>>> > wrote:
>>>>>>
>>>>>>> Hi Morten
>>>>>>>
>>>>>>> That would be great. Please let us know when you commit the changes.
>>>>>>> We ll take a merge from the trunk.
>>>>>>>
>>>>>>> Regards
>>>>>>> Vanya
>>>>>>>
>>>>>>> On Wed, Jun 15, 2016 at 9:01 AM, Morten Olav Hansen <
>>>>>>> morten@xxxxxxxxx> wrote:
>>>>>>>
>>>>>>>> Hi
>>>>>>>>
>>>>>>>> We usually turn off most of that Jackson auto discovery magic, I
>>>>>>>> see we haven't done that properly in Jackson*<tracker object classes>, I
>>>>>>>> will add that now (so it follows JacksonUtils, RenderService etc)
>>>>>>>>
>>>>>>>> --
>>>>>>>> Morten Olav Hansen
>>>>>>>> Senior Engineer, DHIS 2
>>>>>>>> University of Oslo
>>>>>>>> http://www.dhis2.org
>>>>>>>>
>>>>>>>> On Tue, Jun 14, 2016 at 8:41 PM, Anilkumar Kodi <
>>>>>>>> anilkumk@xxxxxxxxxxxxxxxx> wrote:
>>>>>>>>
>>>>>>>>> Hi Morten,
>>>>>>>>>
>>>>>>>>> We are doing Anonymous Event data push. As part of that we are
>>>>>>>>> also sending coordinates.
>>>>>>>>>
>>>>>>>>> Coordinate object has 4 public properties which are listed below
>>>>>>>>>
>>>>>>>>> @JsonProperty( required = true )
>>>>>>>>> @JacksonXmlProperty( isAttribute = true )
>>>>>>>>> public Double getLatitude()
>>>>>>>>>
>>>>>>>>> @JsonProperty( required = true )
>>>>>>>>> @JacksonXmlProperty( isAttribute = true )
>>>>>>>>> public Double getLongitude()
>>>>>>>>>
>>>>>>>>> public boolean isValid()
>>>>>>>>>
>>>>>>>>> public String getCoordinateString()
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> We don't have @JsonIgnore/@JsonProperty on the Other 2 properties.
>>>>>>>>>
>>>>>>>>> Because of this we are getting Error while Deserializing.
>>>>>>>>>
>>>>>>>>> Moreover, the JSON Mapper for the class <JacksonEventService>  has configuration FAIL_ON_UNKNOWN_PROPERTIES  set to *true*
>>>>>>>>>
>>>>>>>>> We have fixed this by adding @JsonIgnore on those properties.
>>>>>>>>>
>>>>>>>>> We Would like to know if you see any downstream issues with this minor change.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>>
>>>>>>>>> Anil Kumar & Srikanth
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Mailing list: https://launchpad.net/~dhis2-devs
>>>>>>>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>>>>>>>> Unsubscribe : https://launchpad.net/~dhis2-devs
>>>>>>>> More help   : https://help.launchpad.net/ListHelp
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> With Regards
>>>>>>> ThoughtWorks Technologies
>>>>>>> Hyderabad
>>>>>>>
>>>>>>> --Stay Hungry Stay Foolish!!
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

Follow ups

References