use of org.activityinfo.shared.report.model.PivotTableReportElement 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.PivotTableReportElement in project activityinfo by bedatadriven.
the class ReportJsonFactory method decodePivotTableReportElement.
public PivotTableReportElement decodePivotTableReportElement(JsonObject element) {
PivotTableReportElement pivotTableElement = new PivotTableReportElement();
JsonElement title = element.get("title");
if (title != null) {
pivotTableElement.setTitle(title.getAsString());
}
JsonElement sheetTitle = element.get("sheetTitle");
if (sheetTitle != null) {
pivotTableElement.setSheetTitle(sheetTitle.getAsString());
}
JsonObject filter = element.get("filter").getAsJsonObject();
pivotTableElement.setFilter(decodeFilter(filter));
JsonArray colDims = element.get("columnDimensions").getAsJsonArray();
if (colDims.size() > 0) {
pivotTableElement.setColumnDimensions(decodeDimensionList(colDims));
}
JsonArray rowDims = element.get("rowDimensions").getAsJsonArray();
if (rowDims.size() > 0) {
pivotTableElement.setRowDimensions(decodeDimensionList(rowDims));
}
return pivotTableElement;
}
use of org.activityinfo.shared.report.model.PivotTableReportElement in project activityinfo by bedatadriven.
the class PivotTableTemplate method createElement.
@Override
public void createElement(AsyncCallback<ReportElement> callback) {
PivotTableReportElement table = new PivotTableReportElement();
table.addColDimension(new DateDimension(DateUnit.YEAR));
table.addColDimension(new DateDimension(DateUnit.MONTH));
table.addRowDimension(new Dimension(DimensionType.Partner));
callback.onSuccess(table);
}
use of org.activityinfo.shared.report.model.PivotTableReportElement in project activityinfo by bedatadriven.
the class SearchHandler method processFilter.
private void processFilter(final ExecutionContext context, final AsyncCallback<SearchResult> callback, final Filter resultFilter) {
final SearchResult searchResult = new SearchResult();
if (resultFilter.getRestrictedDimensions().size() > 0) {
// pivot data query
final PivotTableReportElement pivotTable = createSearchPivotTableElement();
pivotTable.setFilter(resultFilter);
GenerateElement<PivotContent> zmd = new GenerateElement<PivotContent>(pivotTable);
context.execute(zmd, new AsyncCallback<PivotContent>() {
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
@Override
public void onSuccess(PivotContent content) {
content.setEffectiveFilter(resultFilter);
searchResult.setPivotTabelData(content);
// recent sites query
GetSites getSites = createGetSitesCommand(resultFilter);
context.execute(getSites, new AsyncCallback<SiteResult>() {
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
@Override
public void onSuccess(SiteResult resultSites) {
searchResult.setRecentAdditions(resultSites.getData());
callback.onSuccess(searchResult);
}
});
}
});
} else {
// Return empty searchresult when no filtered entities found
callback.onSuccess(searchResult);
}
}
use of org.activityinfo.shared.report.model.PivotTableReportElement in project activityinfo by bedatadriven.
the class SearchHandler method createSearchPivotTableElement.
private PivotTableReportElement createSearchPivotTableElement() {
final PivotTableReportElement pivotTable = new PivotTableReportElement();
pivotTable.addRowDimension(new Dimension(DimensionType.Database));
pivotTable.addRowDimension(new Dimension(DimensionType.Activity));
pivotTable.addRowDimension(new Dimension(DimensionType.Indicator));
return pivotTable;
}
Aggregations