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