Search in sources :

Example 1 with DimensionCategory

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;
    }
}
Also used : DimensionCategory(org.activityinfo.shared.report.content.DimensionCategory) PivotTableData(org.activityinfo.shared.report.content.PivotTableData) Dimension(org.activityinfo.shared.report.model.Dimension)

Example 2 with DimensionCategory

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();
}
Also used : DimensionCategory(org.activityinfo.shared.report.content.DimensionCategory) Dimension(org.activityinfo.shared.report.model.Dimension)

Example 3 with DimensionCategory

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");
}
Also used : DimensionCategory(org.activityinfo.shared.report.content.DimensionCategory) Bucket(org.activityinfo.shared.command.result.Bucket) CommandException(org.activityinfo.shared.exception.CommandException) Dimension(org.activityinfo.shared.report.model.Dimension) AttributeGroupDimension(org.activityinfo.shared.report.model.AttributeGroupDimension) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) DateDimension(org.activityinfo.shared.report.model.DateDimension)

Example 4 with DimensionCategory

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;
}
Also used : DimensionCategory(org.activityinfo.shared.report.content.DimensionCategory) JsonArray(com.google.gson.JsonArray) CategoryProperties(org.activityinfo.shared.report.model.CategoryProperties) HashMap(java.util.HashMap) JsonElement(com.google.gson.JsonElement)

Example 5 with DimensionCategory

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;
}
Also used : JsonArray(com.google.gson.JsonArray) DimensionCategory(org.activityinfo.shared.report.content.DimensionCategory) CategoryProperties(org.activityinfo.shared.report.model.CategoryProperties) JsonObject(com.google.gson.JsonObject)

Aggregations

DimensionCategory (org.activityinfo.shared.report.content.DimensionCategory)6 Dimension (org.activityinfo.shared.report.model.Dimension)3 JsonArray (com.google.gson.JsonArray)2 HashMap (java.util.HashMap)2 CategoryProperties (org.activityinfo.shared.report.model.CategoryProperties)2 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 Bucket (org.activityinfo.shared.command.result.Bucket)1 CommandException (org.activityinfo.shared.exception.CommandException)1 PieMapMarker (org.activityinfo.shared.report.content.PieMapMarker)1 PivotTableData (org.activityinfo.shared.report.content.PivotTableData)1 AdminDimension (org.activityinfo.shared.report.model.AdminDimension)1 AttributeGroupDimension (org.activityinfo.shared.report.model.AttributeGroupDimension)1 DateDimension (org.activityinfo.shared.report.model.DateDimension)1 PointValue (org.activityinfo.shared.report.model.PointValue)1