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();
}
});
}
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();
}
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;
}
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();
}
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());
}
Aggregations