use of com.developmentontheedge.be5.query.impl.MoreRowsGenerator in project be5 by DevelopmentOnTheEdge.
the class Document method generate.
@Override
public void generate(Request req, Response res, Injector injector) {
DocumentGenerator documentGenerator = injector.get(DocumentGenerator.class);
UserAwareMeta userAwareMeta = injector.get(UserAwareMeta.class);
String entityName = req.getNonEmpty(RestApiConstants.ENTITY);
String queryName = req.getNonEmpty(RestApiConstants.QUERY);
int sortColumn = req.getInt("order[0][column]", -1);
boolean sortDesc = "desc".equals(req.get("order[0][dir]"));
Map<String, String> parametersMap = req.getValuesFromJsonAsStrings(RestApiConstants.VALUES);
HashUrl url = new HashUrl(TABLE_ACTION, entityName, queryName).named(parametersMap);
Query query;
try {
query = userAwareMeta.getQuery(entityName, queryName);
} catch (Be5Exception e) {
sendError(req, res, url, e);
return;
}
try {
switch(req.getRequestUri()) {
case "":
JsonApiModel document = documentGenerator.getDocument(query, parametersMap, sortColumn, sortDesc);
document.setMeta(req.getDefaultMeta());
res.sendAsJson(document);
return;
case "moreRows":
res.sendAsRawJson(new MoreRowsGenerator(injector).generate(req));
return;
default:
res.sendUnknownActionError();
}
} catch (Be5Exception e) {
sendError(req, res, url, e);
} catch (Throwable e) {
sendError(req, res, url, Be5Exception.internalInQuery(e, query));
}
}
Aggregations