Skip to content
Snippets Groups Projects
Commit f5a975b2 authored by Mirco Nasuti's avatar Mirco Nasuti
Browse files

data field in request API response is working

parent 8cb1d332
No related branches found
No related tags found
No related merge requests found
...@@ -54,7 +54,7 @@ public class RequestsApi { ...@@ -54,7 +54,7 @@ public class RequestsApi {
List<String> variables = new LinkedList<>(); List<String> variables = new LinkedList<>();
List<String> groupings = new LinkedList<>(); List<String> groupings = new LinkedList<>();
List<String> covariables = new LinkedList<>(); List<String> covariables = new LinkedList<>();
Map<String, LinkedList<Object>> data = new HashMap<>(); Map<String, List<Object>> data = new HashMap<>();
Gson gson = new Gson(); Gson gson = new Gson();
JsonObject q = gson.fromJson(gson.toJson(query, Query.class), JsonObject.class); JsonObject q = gson.fromJson(gson.toJson(query, Query.class), JsonObject.class);
...@@ -85,11 +85,19 @@ public class RequestsApi { ...@@ -85,11 +85,19 @@ public class RequestsApi {
for(String varCode : allVars) for(String varCode : allVars)
{ {
List<Object> currentVarData = new LinkedList<>();
String sqlQuery = "SELECT " + varCode + " FROM adni_merge"; String sqlQuery = "SELECT " + varCode + " FROM adni_merge";
for (Map resultMap : jdbcTemplate.queryForList(sqlQuery)) for (Map resultMap : jdbcTemplate.queryForList(sqlQuery))
{ {
resultMap.get(varCode); String strValue = String.valueOf(resultMap.get(varCode));
try {
Double numValue = Double.parseDouble(strValue);
currentVarData.add(numValue);
} catch (NumberFormatException e2) {
currentVarData.add(strValue);
}
} }
data.put(varCode, currentVarData);
} }
dataset.addProperty("code", code); dataset.addProperty("code", code);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment