Search in sources :

Example 1 with DimensionCategory

use of org.activityinfo.legacy.shared.reports.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.legacy.shared.reports.content.DimensionCategory) Dimension(org.activityinfo.legacy.shared.reports.model.Dimension)

Example 2 with DimensionCategory

use of org.activityinfo.legacy.shared.reports.content.DimensionCategory in project activityinfo by bedatadriven.

the class PivotAdapter method bucketKey.

private Map<Dimension, DimensionCategory> bucketKey(int rowIndex, DimensionCategory[][] categories, @Nullable DimensionCategory indicatorCategory) {
    Map<Dimension, DimensionCategory> key = new HashMap<>();
    // Only include indicator as dimension if we are pivoting on dimension
    if (indicatorCategory != null) {
        key.put(indicatorDimension.get().getModel(), indicatorCategory);
    }
    for (int j = 0; j < groupBy.size(); j++) {
        Dimension dimension = groupBy.get(j).getModel();
        DimensionCategory category = categories[j][rowIndex];
        if (category != null) {
            key.put(dimension, category);
        }
    }
    return key;
}
Also used : DimensionCategory(org.activityinfo.legacy.shared.reports.content.DimensionCategory) Dimension(org.activityinfo.legacy.shared.reports.model.Dimension) AdminDimension(org.activityinfo.legacy.shared.reports.model.AdminDimension) AttributeGroupDimension(org.activityinfo.legacy.shared.reports.model.AttributeGroupDimension) DateDimension(org.activityinfo.legacy.shared.reports.model.DateDimension)

Example 3 with DimensionCategory

use of org.activityinfo.legacy.shared.reports.content.DimensionCategory in project activityinfo by bedatadriven.

the class AdminDimBinding method extractCategories.

@Override
public DimensionCategory[] extractCategories(Activity activity, ColumnSet columnSet) {
    DimensionCategory[] c = new DimensionCategory[columnSet.getNumRows()];
    if (columnSet.getColumns().containsKey(labelColumn)) {
        ColumnView idView = columnSet.getColumnView(idColumn);
        ColumnView labelView = columnSet.getColumnView(labelColumn);
        for (int i = 0; i < columnSet.getNumRows(); i++) {
            String id = idView.getString(i);
            if (id != null) {
                int entityId = getLegacyIdFromCuid(id);
                String label = labelView.getString(i);
                c[i] = new EntityCategory(entityId, label);
            }
        }
    }
    return c;
}
Also used : DimensionCategory(org.activityinfo.legacy.shared.reports.content.DimensionCategory) ColumnView(org.activityinfo.model.query.ColumnView) EntityCategory(org.activityinfo.legacy.shared.reports.content.EntityCategory)

Example 4 with DimensionCategory

use of org.activityinfo.legacy.shared.reports.content.DimensionCategory in project activityinfo by bedatadriven.

the class SiteDimBinding method extractCategories.

@Override
public DimensionCategory[] extractCategories(Activity activity, ColumnSet columnSet) {
    ColumnView id = columnSet.getColumnView(ID_COLUMN);
    ColumnView label = columnSet.getColumnView(LABEL_COLUMN);
    int numRows = columnSet.getNumRows();
    DimensionCategory[] categories = new DimensionCategory[numRows];
    for (int i = 0; i < numRows; i++) {
        String idString = id.getString(i);
        String labelString = label.getString(i);
        // Note that we try to gracefully handle an empty location label because not all forms
        // will have a location in the new data model
        // Legacy activities with "nullary" location types, when represented in the new data model,
        // have *no* location field, so we just have to treat it as a blank.
        categories[i] = new EntityCategory(CuidAdapter.getLegacyIdFromCuid(idString), Strings.nullToEmpty(labelString));
    }
    return categories;
}
Also used : DimensionCategory(org.activityinfo.legacy.shared.reports.content.DimensionCategory) ColumnView(org.activityinfo.model.query.ColumnView) EntityCategory(org.activityinfo.legacy.shared.reports.content.EntityCategory)

Example 5 with DimensionCategory

use of org.activityinfo.legacy.shared.reports.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.legacy.shared.reports.content.DimensionCategory) PivotTableData(org.activityinfo.legacy.shared.reports.content.PivotTableData) Dimension(org.activityinfo.legacy.shared.reports.model.Dimension)

Aggregations

DimensionCategory (org.activityinfo.legacy.shared.reports.content.DimensionCategory)10 ColumnView (org.activityinfo.model.query.ColumnView)5 Nullable (javax.annotation.Nullable)4 ColumnModel (org.activityinfo.model.query.ColumnModel)4 ColumnSet (org.activityinfo.model.query.ColumnSet)4 QueryModel (org.activityinfo.model.query.QueryModel)4 Dimension (org.activityinfo.legacy.shared.reports.model.Dimension)3 FormTree (org.activityinfo.model.formTree.FormTree)3 EntityCategory (org.activityinfo.legacy.shared.reports.content.EntityCategory)2 ActivityField (org.activityinfo.store.mysql.metadata.ActivityField)2 PivotTableData (org.activityinfo.legacy.shared.reports.content.PivotTableData)1 AdminDimension (org.activityinfo.legacy.shared.reports.model.AdminDimension)1 AttributeGroupDimension (org.activityinfo.legacy.shared.reports.model.AttributeGroupDimension)1 DateDimension (org.activityinfo.legacy.shared.reports.model.DateDimension)1 ResourceId (org.activityinfo.model.resource.ResourceId)1 QueryFilter (org.activityinfo.server.command.QueryFilter)1 Activity (org.activityinfo.store.mysql.metadata.Activity)1 LinkedActivity (org.activityinfo.store.mysql.metadata.LinkedActivity)1