// date range
String from = form.getFirstValue("from");
String to = form.getFirstValue("to");
MonitorQuery q = new MonitorQuery().between(
from != null ? Converters.convert(from, Date.class) : null,
to != null ? Converters.convert(to, Date.class) : null);
//sorting
String sortBy;
SortOrder sortOrder;
String order = form.getFirstValue("order");
if (order != null) {
int semi = order.indexOf(';');
if (semi != -1) {
String[] split = order.split(";");
sortBy = split[0];
sortOrder = SortOrder.valueOf(split[1]);
}
else {
sortBy = order;
sortOrder = SortOrder.ASC;
}
q.sort(sortBy, sortOrder);
}
//limit offset
String offset = form.getFirstValue("offset");
String count = form.getFirstValue("count");
q.page(offset != null ? Long.parseLong(offset) : null,
count != null ? Long.parseLong(count) : null);
//live?
String live = form.getFirstValue("live");
if (live != null) {
if ("yes".equalsIgnoreCase(live) || "true".equalsIgnoreCase(live)) {
q.filter("status", Arrays.asList(
org.geoserver.monitor.RequestData.Status.RUNNING,
org.geoserver.monitor.RequestData.Status.WAITING,
org.geoserver.monitor.RequestData.Status.CANCELLING), Comparison.IN);
}
else {
q.filter("status", Arrays.asList(
org.geoserver.monitor.RequestData.Status.FINISHED,
org.geoserver.monitor.RequestData.Status.FAILED), Comparison.IN);
}
}