use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.
the class RenderReportHtmlHandler method execute.
@Override
@LogException
public CommandResult execute(RenderReportHtml cmd, User user) throws CommandException {
ReportElement model = cmd.getModel();
LOGGER.fine("Model: " + model);
// don't show the title: it will be rendered by the container
model.setTitle(null);
generator.generateElement(user, model, new Filter(), new DateRange());
StringWriter writer = new StringWriter();
try {
renderer.render(model, writer);
} catch (IOException e) {
throw new CommandException(e);
}
return new HtmlResult(writer.toString());
}
use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.
the class SearchHandler method searchAll.
/**
* Assumes the user typed a generic search term without specifying a
* dimension. Search using all possible searchers, and return a list of
* matched dimensions
*/
private void searchAll(final List<String> q, final ExecutionContext context, final AsyncCallback<SearchResult> callback) {
AllSearcher allSearcher = new AllSearcher(context.getTransaction());
allSearcher.searchAll(q, new AsyncCallback<Filter>() {
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
@Override
public void onSuccess(final Filter resultFilter) {
processFilter(context, callback, resultFilter);
}
});
}
use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.
the class SearchHandler method searchDimensions.
private void searchDimensions(QueryParser parser, final ExecutionContext context, final AsyncCallback<SearchResult> callback) {
AllSearcher allSearcher = new AllSearcher(context.getTransaction());
allSearcher.searchDimensions(parser.getUniqueDimensions(), new AsyncCallback<Filter>() {
@Override
public void onSuccess(Filter result) {
processFilter(context, callback, result);
}
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
});
}
use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.
the class ExportSitesServlet method doGet.
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
Set<Integer> activities = new HashSet<Integer>();
if (req.getParameterValues("a") != null) {
for (String activity : req.getParameterValues("a")) {
activities.add(Integer.parseInt(activity));
}
}
Filter filter = FilterUrlSerializer.fromQueryParameter(req.getParameter("filter"));
SchemaDTO schema = dispatcher.execute(new GetSchema());
SiteExporter export = new SiteExporter(dispatcher);
for (UserDatabaseDTO db : schema.getDatabases()) {
for (ActivityDTO activity : db.getActivities()) {
if (!filter.isRestricted(DimensionType.Activity) || filter.getRestrictions(DimensionType.Activity).contains(activity.getId())) {
export.export(activity, filter);
}
}
}
export.done();
resp.setContentType("application/vnd.ms-excel");
if (req.getHeader("User-Agent").indexOf("MSIE") != -1) {
resp.addHeader("Content-Disposition", "attachment; filename=ActivityInfo.xls");
} else {
resp.addHeader("Content-Disposition", "attachment; filename=" + ("ActivityInfo Export " + new Date().toString() + ".xls").replace(" ", "_"));
}
OutputStream os = resp.getOutputStream();
export.getBook().write(os);
}
use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.
the class KmlDataServlet method querySites.
private List<SiteDTO> querySites(User user, SchemaDTO schema, int activityId) {
Filter filter = new Filter();
filter.addRestriction(DimensionType.Activity, activityId);
return dispatcher.execute(new GetSites(filter)).getData();
}
Aggregations