@Test public void testIndicatorData() throws JSONException { Map<String, IndicatorValue> valuesByRegion = UnsdDataParser.parseIndicatorData(dataResponseUnlimited); assertFalse("Did not parse any data from response.", valuesByRegion.isEmpty()); }
protected static Map<String, IndicatorValue> parseIndicatorData(JSONObject response) throws JSONException { Map<String, IndicatorValue> results = new HashMap<>(); JSONArray dataArray = response.getJSONArray("data"); for (int i = 0; i < dataArray.length(); i++) { JSONObject data = dataArray.getJSONObject(i); String valueType = data.optString(VALUE_TYPE_KEY); if(dataObjectValueTypeIsSupported(valueType)){ results.put(data.getString(GEO_AREA_CODE_KEY), new IndicatorValueFloat(data.getDouble("value"))); } else { LOG.error(String.format("Not supported valueType %s received.",valueType)); } } return results; }
UnsdDataParser { protected static Map<String, IndicatorValue> parseIndicatorData(JSONObject response) throws JSONException { Map<String, IndicatorValue> results = new HashMap<>(); JSONArray dataArray = response.getJSONArray("data"); for (int i = 0; i < dataArray.length(); i++) { JSONObject data = dataArray.getJSONObject(i); String valueType = data.optString(VALUE_TYPE_KEY); if(dataObjectValueTypeIsSupported(valueType)){ results.put(data.getString(GEO_AREA_CODE_KEY), new IndicatorValueFloat(data.getDouble("value"))); } else { LOG.error(String.format("Not supported valueType %s received.",valueType)); } } return results; } }
UnsdDataParser { protected static Map<String, IndicatorValue> parseIndicatorData(JSONObject response) throws JSONException { Map<String, IndicatorValue> results = new HashMap<>(); JSONArray dataArray = response.getJSONArray("data"); for (int i = 0; i < dataArray.length(); i++) { JSONObject data = dataArray.getJSONObject(i); String valueType = data.optString(VALUE_TYPE_KEY); if(dataObjectValueTypeIsSupported(valueType)){ results.put(data.getString(GEO_AREA_CODE_KEY), new IndicatorValueFloat(data.getDouble("value"))); } else { LOG.error(String.format("Not supported valueType %s received.",valueType)); } } return results; } UnsdDataParser(UnsdConfig config); }
UnsdDataParser { protected static Map<String, IndicatorValue> parseIndicatorData(JSONObject response) throws JSONException { Map<String, IndicatorValue> results = new HashMap<>(); JSONArray dataArray = response.getJSONArray("data"); for (int i = 0; i < dataArray.length(); i++) { JSONObject data = dataArray.getJSONObject(i); String valueType = data.optString(VALUE_TYPE_KEY); if(dataObjectValueTypeIsSupported(valueType)){ results.put(data.getString(GEO_AREA_CODE_KEY), new IndicatorValueFloat(data.getDouble("value"))); } else { LOG.error(String.format("Not supported valueType %s received.",valueType)); } } return results; } UnsdDataParser(UnsdConfig config); Map<String, IndicatorValue> get(StatisticalIndicatorDataModel selectors, String indicator, String[] areaCodes); StatisticalIndicatorDataDimension getTimeperiodDimensionFromIndicatorData(String timePeriodDimensionId,
            String indicator, String[] areaCodes); static void parseTimePeriod(Map<Integer, Set<Integer>> geoAreaCodesForYears, JSONObject response); static List<IdNamePair> getSortedListOfYearsThatBelongToSeveralGeoAreas(
            Map<Integer,  Set<Integer>> countOfAreaCodesForYear); }
UnsdDataParser { protected static Map<String, IndicatorValue> parseIndicatorData(JSONObject response) throws JSONException { Map<String, IndicatorValue> results = new HashMap<>(); JSONArray dataArray = response.getJSONArray("data"); for (int i = 0; i < dataArray.length(); i++) { JSONObject data = dataArray.getJSONObject(i); String valueType = data.optString(VALUE_TYPE_KEY); if(dataObjectValueTypeIsSupported(valueType)){ results.put(data.getString(GEO_AREA_CODE_KEY), new IndicatorValueFloat(data.getDouble("value"))); } else { LOG.error(String.format("Not supported valueType %s received.",valueType)); } } return results; } UnsdDataParser(UnsdConfig config); Map<String, IndicatorValue> get(StatisticalIndicatorDataModel selectors, String indicator, String[] areaCodes); StatisticalIndicatorDataDimension getTimeperiodDimensionFromIndicatorData(String timePeriodDimensionId,
            String indicator, String[] areaCodes); static void parseTimePeriod(Map<Integer, Set<Integer>> geoAreaCodesForYears, JSONObject response); static List<IdNamePair> getSortedListOfYearsThatBelongToSeveralGeoAreas(
            Map<Integer,  Set<Integer>> countOfAreaCodesForYear);  }