use of org.activityinfo.shared.report.content.DimensionCategory in project activityinfo by bedatadriven.
the class PivotTableDataBuilder method find.
protected PivotTableData.Axis find(PivotTableData.Axis axis, Iterator<Dimension> dimensionIterator, Map<Dimension, Comparator<PivotTableData.Axis>> comparators, Bucket result) {
Dimension childDimension = dimensionIterator.next();
DimensionCategory category = result.getCategory(childDimension);
PivotTableData.Axis child = null;
child = axis.getChild(category);
if (child == null) {
String categoryLabel;
if (category == null) {
categoryLabel = I18N.CONSTANTS.emptyDimensionCategory();
} else {
categoryLabel = childDimension.getLabel(category);
if (categoryLabel == null) {
categoryLabel = category.getLabel();
}
}
child = axis.addChild(childDimension, result.getCategory(childDimension), categoryLabel, comparators.get(childDimension));
}
if (dimensionIterator.hasNext()) {
return find(child, dimensionIterator, comparators, result);
} else {
return child;
}
}
use of org.activityinfo.shared.report.content.DimensionCategory in project activityinfo by bedatadriven.
the class Bucket method toString.
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(" { Value: ").append(doubleValue());
for (Dimension dim : dimensions()) {
DimensionCategory cat = getCategory(dim);
sb.append("\n ").append(dim.toString()).append(": ");
sb.append(cat.toString());
}
sb.append("\n }");
return sb.toString();
}
use of org.activityinfo.shared.report.content.DimensionCategory in project activityinfo by bedatadriven.
the class PivotSitesHandlerTest method execute.
private void execute() {
setUser(OWNER_USER_ID);
try {
PivotSites pivot = new PivotSites(dimensions, filter);
pivot.setValueType(valueType);
pivot.setPointRequested(pointsRequested);
buckets = execute(pivot).getBuckets();
} catch (CommandException e) {
throw new RuntimeException(e);
}
System.out.println("Buckets = [");
for (Bucket bucket : buckets) {
System.out.print(" { Value: " + bucket.doubleValue());
for (Dimension dim : bucket.dimensions()) {
DimensionCategory cat = bucket.getCategory(dim);
System.out.print("\n " + dim.toString() + ": ");
System.out.print(cat.toString());
}
System.out.println("\n }");
}
System.out.print("]\n");
}
use of org.activityinfo.shared.report.content.DimensionCategory in project activityinfo by bedatadriven.
the class ReportJsonFactory method decodeCategories.
public Map<DimensionCategory, CategoryProperties> decodeCategories(JsonElement categories) {
Map<DimensionCategory, CategoryProperties> cats = new HashMap<DimensionCategory, CategoryProperties>();
JsonArray jsonCats = (JsonArray) parser.parse(categories.getAsString());
Iterator<JsonElement> it = jsonCats.iterator();
while (it.hasNext()) {
it.next().getAsJsonObject();
}
return cats;
}
use of org.activityinfo.shared.report.content.DimensionCategory in project activityinfo by bedatadriven.
the class ReportJsonFactory method encodeCategories.
public JsonArray encodeCategories(Map<DimensionCategory, CategoryProperties> categories) {
JsonArray jsonCats = new JsonArray();
for (Entry<DimensionCategory, CategoryProperties> entry : categories.entrySet()) {
JsonObject jsonEntry = new JsonObject();
jsonEntry.addProperty("dimensionCategory", entry.getKey().toString());
jsonEntry.addProperty("categoryProperties", entry.getValue().toString());
jsonCats.add(jsonEntry);
}
return jsonCats;
}
Aggregations