Search in sources :

Example 1 with ReportElement

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

the class ReportPortlet method onModelLoad.

private void onModelLoad(ReportDTO dto) {
    Report report = dto.getReport();
    if (report.getElements().isEmpty()) {
        removeAll();
        add(new Label("The report is empty"));
        return;
    }
    final ReportElement element = report.getElement(0);
    final ReportView view = createView(element);
    if (view == null) {
        removeAll();
        add(new Label("Unsupport report type"));
        layout();
        return;
    }
    dispatcher.execute(new GenerateElement<Content>(element), new AsyncCallback<Content>() {

        @Override
        public void onFailure(Throwable caught) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onSuccess(Content result) {
            element.setContent(result);
            view.show(element);
            removeAll();
            add(view.asComponent());
            layout();
        }
    });
}
Also used : Report(org.activityinfo.shared.report.model.Report) Content(org.activityinfo.shared.report.content.Content) Label(com.extjs.gxt.ui.client.widget.Label) MapReportView(org.activityinfo.client.report.view.MapReportView) ReportView(org.activityinfo.client.report.view.ReportView) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) ReportElement(org.activityinfo.shared.report.model.ReportElement)

Example 2 with ReportElement

use of org.activityinfo.shared.report.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.shared.report.model.ReportElement) Component(com.extjs.gxt.ui.client.widget.Component)

Example 3 with ReportElement

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

the class ReportJsonFactory method decodeElements.

private List<ReportElement> decodeElements(JsonArray elements) {
    List<ReportElement> reportElements = new ArrayList<ReportElement>();
    for (int i = 0; i < elements.size(); i++) {
        JsonObject element = (JsonObject) elements.get(i);
        String type = element.get("elementType").getAsString();
        if ("pivotTable".equals(type)) {
            reportElements.add(decodePivotTableReportElement(element));
        } else if ("pivotChart".equals(type)) {
            reportElements.add(decodePivotChartReportElement(element));
        } else if ("map".equals(type)) {
            reportElements.add(decodeMapReportElement(element));
        }
    }
    return reportElements;
}
Also used : ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) ReportElement(org.activityinfo.shared.report.model.ReportElement)

Example 4 with ReportElement

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

the class ReportJsonFactory method serialize.

@Override
public String serialize(Report report) {
    JsonObject jsonReport = new JsonObject();
    // write custom maker
    jsonReport.addProperty("id", report.getId());
    if (report.getTitle() != null) {
        jsonReport.addProperty("title", report.getTitle());
    }
    if (report.getSheetTitle() != null) {
        jsonReport.addProperty("sheetTitle", report.getSheetTitle());
    }
    if (report.getDescription() != null) {
        jsonReport.addProperty("description", report.getDescription());
    }
    if (report.getFileName() != null) {
        jsonReport.addProperty("fileName", report.getFileName());
    }
    jsonReport.add("filter", encodeFilter(report.getFilter()));
    if (report.getElements() != null) {
        List<ReportElement> reportElements = report.getElements();
        JsonArray jsonElements = new JsonArray();
        for (int i = 0; i < reportElements.size(); i++) {
            ReportElement rp = report.getElement(i);
            if (rp instanceof PivotTableReportElement) {
                jsonElements.add(encodePivotTableReportElement((PivotTableReportElement) rp));
            } else if (rp instanceof PivotChartReportElement) {
                jsonElements.add(encodePivotChartReportElement((PivotChartReportElement) rp));
            } else if (rp instanceof MapReportElement) {
                jsonElements.add(encodeMapReportElement((MapReportElement) rp));
            }
        }
        jsonReport.add("elements", jsonElements);
    }
    return jsonReport.toString();
}
Also used : JsonArray(com.google.gson.JsonArray) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) JsonObject(com.google.gson.JsonObject) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) ReportElement(org.activityinfo.shared.report.model.ReportElement) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement)

Example 5 with ReportElement

use of org.activityinfo.shared.report.model.ReportElement 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)

Aggregations

ReportElement (org.activityinfo.shared.report.model.ReportElement)9 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)7 PivotChartReportElement (org.activityinfo.shared.report.model.PivotChartReportElement)6 PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)5 Report (org.activityinfo.shared.report.model.Report)4 JsonObject (com.google.gson.JsonObject)2 Filter (org.activityinfo.shared.command.Filter)2 TextReportElement (org.activityinfo.shared.report.model.TextReportElement)2 Component (com.extjs.gxt.ui.client.widget.Component)1 Label (com.extjs.gxt.ui.client.widget.Label)1 JsonArray (com.google.gson.JsonArray)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 MapReportView (org.activityinfo.client.report.view.MapReportView)1 ReportView (org.activityinfo.client.report.view.ReportView)1 LogException (org.activityinfo.server.util.logging.LogException)1 HtmlResult (org.activityinfo.shared.command.result.HtmlResult)1 CommandException (org.activityinfo.shared.exception.CommandException)1 Content (org.activityinfo.shared.report.content.Content)1