Search in sources :

Example 1 with ReportElement

use of org.activityinfo.legacy.shared.reports.model.ReportElement in project activityinfo by bedatadriven.

the class RenderReportHtmlHandler method execute.

@Override
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.legacy.shared.reports.model.DateRange) StringWriter(java.io.StringWriter) Filter(org.activityinfo.legacy.shared.command.Filter) HtmlResult(org.activityinfo.legacy.shared.command.result.HtmlResult) ReportElement(org.activityinfo.legacy.shared.reports.model.ReportElement) IOException(java.io.IOException) CommandException(org.activityinfo.legacy.shared.exception.CommandException)

Example 2 with ReportElement

use of org.activityinfo.legacy.shared.reports.model.ReportElement in project activityinfo by bedatadriven.

the class PivotTestResource method get.

@GET
@Path("report")
@Produces(MediaType.APPLICATION_JSON)
public List<PivotSites.PivotResult> get(@QueryParam("reportId") int reportId, @QueryParam("userId") int userId, @QueryParam("new") boolean newEngine, @QueryParam("details") boolean showDetails) {
    assertRunningInLocalDevelopmentEnvironment();
    authProvider.set(new AuthenticatedUser("XYZ", userId, "user@user.org"));
    ReportDTO report = dispatcher.execute(new GetReportModel(reportId));
    Report model = report.getReport();
    List<PivotSites.PivotResult> results = Lists.newArrayList();
    for (ReportElement element : model.getElements()) {
        if (element instanceof PivotReportElement) {
            PivotSites command = command(model, (PivotReportElement) element, newEngine, showDetails);
            if (!command.isTooBroad()) {
                results.add(dispatcher.execute(command));
            } else {
                results.add(new PivotSites.PivotResult());
            }
        }
    }
    return results;
}
Also used : Report(org.activityinfo.legacy.shared.reports.model.Report) PivotReportElement(org.activityinfo.legacy.shared.reports.model.PivotReportElement) ReportDTO(org.activityinfo.legacy.shared.model.ReportDTO) PivotReportElement(org.activityinfo.legacy.shared.reports.model.PivotReportElement) ReportElement(org.activityinfo.legacy.shared.reports.model.ReportElement) AuthenticatedUser(org.activityinfo.legacy.shared.AuthenticatedUser)

Example 3 with ReportElement

use of org.activityinfo.legacy.shared.reports.model.ReportElement in project activityinfo by bedatadriven.

the class PivotTestResource method show.

@GET
@Path("show")
@Produces(MediaType.TEXT_PLAIN)
public String show(@QueryParam("reportId") int reportId) {
    assertRunningInLocalDevelopmentEnvironment();
    ReportDTO report = dispatcher.execute(new GetReportModel(reportId));
    Report model = report.getReport();
    StringBuilder text = new StringBuilder();
    text.append(model.getTitle()).append("\n");
    text.append("Filter: " + model.getFilter()).append("\n");
    for (ReportElement element : model.getElements()) {
        text.append("-- " + element.getClass().getSimpleName() + ": " + element.getTitle()).append("\n");
        text.append("   Filter: " + element.getFilter()).append("\n");
        if (element instanceof PivotReportElement) {
            text.append("   Dimensions: " + ((PivotReportElement) element).allDimensions()).append("\n");
        }
    }
    return text.toString();
}
Also used : Report(org.activityinfo.legacy.shared.reports.model.Report) PivotReportElement(org.activityinfo.legacy.shared.reports.model.PivotReportElement) ReportDTO(org.activityinfo.legacy.shared.model.ReportDTO) PivotReportElement(org.activityinfo.legacy.shared.reports.model.PivotReportElement) ReportElement(org.activityinfo.legacy.shared.reports.model.ReportElement)

Example 4 with ReportElement

use of org.activityinfo.legacy.shared.reports.model.ReportElement in project activityinfo by bedatadriven.

the class CompositeEditor2 method bind.

@Override
public void bind(Report model) {
    this.model = model;
    for (Component child : page.getItems()) {
        if (child != addPanel) {
            page.remove(child);
        }
    }
    for (ReportElement element : model.getElements()) {
        addElementWidget(element);
    }
    page.layout();
}
Also used : ReportElement(org.activityinfo.legacy.shared.reports.model.ReportElement) Component(com.extjs.gxt.ui.client.widget.Component)

Example 5 with ReportElement

use of org.activityinfo.legacy.shared.reports.model.ReportElement in project activityinfo by bedatadriven.

the class GenerateDashboardElementHandler method execute.

@Override
public CommandResult execute(GenerateDashboardElement cmd, User user) throws CommandException {
    ReportDTO report = dispatcher.execute(new GetReportModel(cmd.getReportId()));
    if (report.getReport().getElements().isEmpty()) {
        return new TextReportElement("The report is empty");
    } else {
        ReportElement element = report.getReport().getElements().get(0);
        element.setContent(generator.generateElement(user, element, null, new DateRange()));
        return element;
    }
}
Also used : DateRange(org.activityinfo.legacy.shared.reports.model.DateRange) GetReportModel(org.activityinfo.legacy.shared.command.GetReportModel) ReportDTO(org.activityinfo.legacy.shared.model.ReportDTO) ReportElement(org.activityinfo.legacy.shared.reports.model.ReportElement) TextReportElement(org.activityinfo.legacy.shared.reports.model.TextReportElement) TextReportElement(org.activityinfo.legacy.shared.reports.model.TextReportElement)

Aggregations

ReportElement (org.activityinfo.legacy.shared.reports.model.ReportElement)5 ReportDTO (org.activityinfo.legacy.shared.model.ReportDTO)3 DateRange (org.activityinfo.legacy.shared.reports.model.DateRange)2 PivotReportElement (org.activityinfo.legacy.shared.reports.model.PivotReportElement)2 Report (org.activityinfo.legacy.shared.reports.model.Report)2 Component (com.extjs.gxt.ui.client.widget.Component)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 AuthenticatedUser (org.activityinfo.legacy.shared.AuthenticatedUser)1 Filter (org.activityinfo.legacy.shared.command.Filter)1 GetReportModel (org.activityinfo.legacy.shared.command.GetReportModel)1 HtmlResult (org.activityinfo.legacy.shared.command.result.HtmlResult)1 CommandException (org.activityinfo.legacy.shared.exception.CommandException)1 TextReportElement (org.activityinfo.legacy.shared.reports.model.TextReportElement)1