BasicDemographicInfo Retrieval

Feb 16, 2011 at 5:50 PM
Edited Feb 16, 2011 at 5:52 PM

Rob,

I am looking to retrieve BasicDemographicInfo from the GetThingsResponse object. I see in the debug logs that BasicDemoGraphicInfo is returned in the response. However, I do not get the data in the thing object. Here is the code I am using.

List<Thing> things = gtResponse.getGroup().get(0).getThing();

Iterator<Thing> iterator = things.iterator();

while(iterator.hasNext()) {

Thing thing = iterator.next();

thing.getData(); --------------> This returns null.

}

should I use thing.getDataXml(); instead? Can you post some sample code as to how I can access the Basic object from the dataxml? Finally, I also had a question on the version of the GetThingsRequest that I should use - should I use GetThings3Request instead?

Please let me know when you get a chance.

Thanks Shyam

Coordinator
Feb 16, 2011 at 8:31 PM

Good catch.  Those types were missing from the type mapping.  They are checked in now.

--Rob

Feb 16, 2011 at 10:48 PM

Rob,

Before I pull the latest version, just wanted to find out if the same problem exists with PersonalDemographicInfo as well?

Thanks for the quick updates.

Shyam

Coordinator
Feb 17, 2011 at 6:33 AM

Personal Demographic Info has always been there and works fine.

--Rob

Jun 19, 2012 at 7:31 AM

Hi Rob,

I have downloaded the latest version of java sdk version R1.3.1. But still i am getting NullPointer at 

PeakFlow peakFlow = (PeakFlow)thing.getData();

getData() method in this case returns null. Do i need to any other methods. How i can get the Object from this.

I am, putting my sample code below

	List <PeakFlow> peakFlowList = new ArrayList<PeakFlow>(); 
    	try{
    		GetThingsResponse gtResponse = (GetThingsResponse)requestTemplate.makeRequest(info,getPersonInfo());
    		List<Thing> pfList = gtResponse.getGroup().get(0).getThing();
    		logger.info("pfList.size() == "+pfList.size()); // It returns size 5 for example
    		Iterator<Thing> iterator = pfList.iterator();
    		while ( iterator.hasNext() ){
    			Thing thing = (Thing)iterator.next();
    			PeakFlow peakFlow = (PeakFlow)thing.getData(); // --> Here comes NullPointer when accessing getData()
    			logger.info("peakFlow thing = "+peakFlow); //--> peakFlow object is null here
    			peakFlowList.add(peakFlow);
    		}
	}catch (Exception e) {
    		e.printStackTrace();
    	}

Any reply from you will be helpful to us.

Thanks

Hasan

Coordinator
Jun 21, 2012 at 11:18 PM

Hi Hasan, I answered your question on your thread.