use of org.alfresco.rest.api.search.model.TupleEntry in project alfresco-remote-api by Alfresco.
the class ResultMapper method toCollectionWithPagingInfo.
public CollectionWithPagingInfo<TupleList> toCollectionWithPagingInfo(JSONArray docs, SearchSQLQuery searchQuery) throws JSONException {
if (docs == null) {
throw new RuntimeException("Solr response is required instead of JSONArray docs was null");
}
if (searchQuery == null) {
throw new RuntimeException("SearchSQLQuery is required");
}
List<TupleList> entries = new ArrayList<TupleList>();
for (int i = 0; i < docs.length() - 1; i++) {
List<TupleEntry> row = new ArrayList<TupleEntry>();
JSONObject docObj = (JSONObject) docs.get(i);
docObj.keys().forEachRemaining(action -> {
try {
String value = docObj.get(action.toString()).toString();
row.add(new TupleEntry(action.toString(), value));
} catch (JSONException e) {
throw new RuntimeException("Unable to parse SQL response. " + e);
}
});
entries.add(new TupleList(row));
}
Paging paging = Paging.valueOf(0, searchQuery.getItemLimit());
return CollectionWithPagingInfo.asPaged(paging, entries);
}
Aggregations