Search in sources :

Example 11 with Filter

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());
}
Also used : DateRange(org.activityinfo.shared.report.model.DateRange) StringWriter(java.io.StringWriter) Filter(org.activityinfo.shared.command.Filter) HtmlResult(org.activityinfo.shared.command.result.HtmlResult) ReportElement(org.activityinfo.shared.report.model.ReportElement) IOException(java.io.IOException) CommandException(org.activityinfo.shared.exception.CommandException) LogException(org.activityinfo.server.util.logging.LogException)

Example 12 with Filter

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);
        }
    });
}
Also used : Filter(org.activityinfo.shared.command.Filter) AllSearcher(org.activityinfo.shared.command.handler.search.AllSearcher)

Example 13 with Filter

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);
        }
    });
}
Also used : Filter(org.activityinfo.shared.command.Filter) AllSearcher(org.activityinfo.shared.command.handler.search.AllSearcher)

Example 14 with Filter

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);
}
Also used : Filter(org.activityinfo.shared.command.Filter) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) OutputStream(java.io.OutputStream) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Date(java.util.Date) HashSet(java.util.HashSet)

Example 15 with Filter

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();
}
Also used : Filter(org.activityinfo.shared.command.Filter) GetSites(org.activityinfo.shared.command.GetSites)

Aggregations

Filter (org.activityinfo.shared.command.Filter)59 GetSites (org.activityinfo.shared.command.GetSites)8 Test (org.junit.Test)8 GetSchema (org.activityinfo.shared.command.GetSchema)5 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)5 DimensionType (org.activityinfo.shared.report.model.DimensionType)5 ArrayList (java.util.ArrayList)4 SiteDTO (org.activityinfo.shared.dto.SiteDTO)4 DateRange (org.activityinfo.shared.report.model.DateRange)4 StringWriter (java.io.StringWriter)3 Indicator (org.activityinfo.server.database.hibernate.entity.Indicator)3 SiteResult (org.activityinfo.shared.command.result.SiteResult)3 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)3 UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)3 Margins (com.extjs.gxt.ui.client.util.Margins)2 BorderLayoutData (com.extjs.gxt.ui.client.widget.layout.BorderLayoutData)2 JsonElement (com.google.gson.JsonElement)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 List (java.util.List)2