Search in sources :

Example 1 with PivotReportElement

use of org.activityinfo.legacy.shared.reports.model.PivotReportElement 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 2 with PivotReportElement

use of org.activityinfo.legacy.shared.reports.model.PivotReportElement 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)

Aggregations

ReportDTO (org.activityinfo.legacy.shared.model.ReportDTO)2 PivotReportElement (org.activityinfo.legacy.shared.reports.model.PivotReportElement)2 Report (org.activityinfo.legacy.shared.reports.model.Report)2 ReportElement (org.activityinfo.legacy.shared.reports.model.ReportElement)2 AuthenticatedUser (org.activityinfo.legacy.shared.AuthenticatedUser)1