Monday, June 25, 2018

Week 6

Hi folks,

Like I said in the preceding week my machine was down. Actually I purchased another machine. I'm struggling with my dev environment setup and adopting to a new platform that's OSx.

Today I had a physical meetup with my mentor( Senkomago Stephen) at Kololo Uganda. We had lunch together, he advised  me on better/recommended development practices as required by GSoC. I have loved this guy, he is very motivating and resourceful.

Project Progress

To be honest, for this week I have done less as expected by last week's objectives. The module currently downloads/exports data but I started with the Patient domain as a Resource. I also tried to implement the import part of it. Just like you know in development, we always hit upon bugs. There is this logical bug that took me almost 2 days to hunt down and understand. I use the gson library for serialization and de-serialization of data. Serialization is quite straight obvious. I love all the magic with this library. But as data goes complex, de-serialization is quite complicated That when your dealing with generic Classes/domains.
public interface Resource {
    // Some logic goes here

public class Patient implements Resource {
    //Patient Resource logic

public class Location implements Resource {
    //Location Resource logic

public void dummyTest() {
Patient patient = new Patient();
Location location = new Location();

//Add the Resources to a Collection
HashMap resourceMap = new HashMap();
resourceMap.add("Patient", patient);
resourceMap.add("Location", location);

String data = gson.toJson(resourceMap); // Works fine

HashMap deserializedObj = gson.fromJson(data, HashMap.class);

//Attempt getting a Patient object.
Object patientResource = deserializedObj.get("Patient");
Patient patient = (Patient) patientResource; //Ooopppss, this throws an //Exception."ClassCastException : gson.internal.LinkedTreeMap cannot be cast to Patient.class"


That's basically my current blocker. I googled around it and I'm planning to implement manual handlers. I you have a better and quick work around, feel free comment it here or get me on talk and ping me (@samuel34) . We could resolve this an the module would start working at all ends. Then I work on  the Configuration part of it.


Samuel Male.

No comments:

Post a Comment