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

Bugfix: variables/groups API when data cannot be found in DB

parent 91b9a1a3
No related branches found
No related tags found
No related merge requests found
......@@ -56,12 +56,13 @@ public class GroupsApi {
String sqlQuery = String.format(
"SELECT * FROM meta_variables where target_table='%s'", featuresMainTable.toUpperCase());
SqlRowSet data = metaJdbcTemplate.queryForRowSet(sqlQuery);
data.next();
String json = ((PGobject) data.getObject("hierarchy")).getValue();
JsonObject root = gson.fromJson(json, JsonObject.class);
removeVariablesRecursive(root);
JsonObject root = new JsonObject();
if (data.next()) {
String json = ((PGobject) data.getObject("hierarchy")).getValue();
root = gson.fromJson(json, JsonObject.class);
removeVariablesRecursive(root);
}
return gson.toJson(root);
}
......
......@@ -140,13 +140,13 @@ public class VariablesApi {
String sqlQuery = String.format(
"SELECT * FROM meta_variables where upper(target_table)='%s'", featuresMainTable.toUpperCase());
SqlRowSet data = metaJdbcTemplate.queryForRowSet(sqlQuery);
data.next();
String json = ((PGobject) data.getObject("hierarchy")).getValue();
JsonObject root = gson.fromJson(json, JsonObject.class);
List<String> variables = new LinkedList<>();
extractVariablesRecursive(root, variables);
if (data.next()) {
String json = ((PGobject) data.getObject("hierarchy")).getValue();
JsonObject root = gson.fromJson(json, JsonObject.class);
extractVariablesRecursive(root, variables);
}
return variables;
}
......
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