if (callback != null) {
writer.write(callback);
writer.write("(");
}
JSONWriter jsonWriter = new JSONWriter(writer);
jsonWriter.object();
RowWritingVisitor rwv = new RowWritingVisitor(start, limit, jsonWriter, options);
JSONObject sortingJson = null;
try{
String json = request.getParameter("sorting");
sortingJson = (json == null) ? null :
ParsingUtilities.evaluateJsonStringToObject(json);
} catch (JSONException e) {
}
if (engine.getMode() == Mode.RowBased) {
FilteredRows filteredRows = engine.getAllFilteredRows();
RowVisitor visitor = rwv;
if (sortingJson != null) {
SortingRowVisitor srv = new SortingRowVisitor(visitor);
srv.initializeFromJSON(project, sortingJson);
if (srv.hasCriteria()) {
visitor = srv;
}
}
jsonWriter.key("mode"); jsonWriter.value("row-based");
jsonWriter.key("rows"); jsonWriter.array();
filteredRows.accept(project, visitor);
jsonWriter.endArray();
jsonWriter.key("filtered"); jsonWriter.value(rwv.total);
jsonWriter.key("total"); jsonWriter.value(project.rows.size());
} else {
FilteredRecords filteredRecords = engine.getFilteredRecords();
RecordVisitor visitor = rwv;
if (sortingJson != null) {
SortingRecordVisitor srv = new SortingRecordVisitor(visitor);
srv.initializeFromJSON(project, sortingJson);
if (srv.hasCriteria()) {
visitor = srv;
}
}
jsonWriter.key("mode"); jsonWriter.value("record-based");
jsonWriter.key("rows"); jsonWriter.array();
filteredRecords.accept(project, visitor);
jsonWriter.endArray();
jsonWriter.key("filtered"); jsonWriter.value(rwv.total);
jsonWriter.key("total"); jsonWriter.value(project.recordModel.getRecordCount());
}
jsonWriter.key("start"); jsonWriter.value(start);
jsonWriter.key("limit"); jsonWriter.value(limit);
jsonWriter.key("pool"); pool.write(jsonWriter, options);
jsonWriter.endObject();
if (callback != null) {
writer.write(")");
}
} catch (Exception e) {