else if(results!=null)
{
int i=0;
for(QueryRow qr:results) {
i++;
JSONObject jo = new JSONObject();
jo.put("uri", qr.getValue(results.getVariables().get(0)).toString());
jo.put("type",qr.getValue(results.getVariables().get(1)).toString());
jo.put("label", qr.getLiteralValue(results.getVariables().get(2)));
try {
jo.put("content", qr.getLiteralValue(results.getVariables().get(3)));
} catch(Exception e) {
jo.put("content", null);
}
try {
jo.put("creator", qr.getValue(results.getVariables().get(4)).toString());
} catch (Exception e){
jo.put("creator", null);
}
jo.put("group",entry.getURI().toString());
resultJson.add(jo);
}
//and now the taxonomies
if(i>0)
{
JSONObject concept = new JSONObject();
concept.put("uri", entry.getURI().toString());
concept.put("name", entry.getLabel());
concept.put("type", entry.getContext().getLabel());//taxonomy
List<TaxonomyEntry> path = entry.getPathFromRoot();
path.remove(entry);
StringBuilder sb = new StringBuilder();
for(TaxonomyEntry te:path) {
sb.append(te.getLabel());
sb.append(" > ");
}
if(sb.length()>=3) {
sb.insert(0, "Parents: "); //TODO: i18n or move to js.
sb.delete(sb.length()-2, sb.length());
}
concept.put("mean", sb.toString());
concept.put("count", i);
groupsJson.add(concept);
}
}
}
//3. present results