use of org.activityinfo.shared.report.model.Dimension in project activityinfo by bedatadriven.
the class ReportJsonFactory method encodeDimensionList.
public JsonArray encodeDimensionList(List<Dimension> dims) {
JsonArray jsonDims = new JsonArray();
for (int i = 0; i < dims.size(); i++) {
JsonObject jsonDim = new JsonObject();
DimensionType type = dims.get(i).getType();
if (type.equals(DimensionType.Date)) {
DateDimension dim = (DateDimension) dims.get(i);
jsonDim.addProperty("type", dim.getType().toString());
jsonDim.addProperty("dateUnit", dim.getUnit().toString());
if (dim.getColor() != null) {
jsonDim.addProperty("color", dim.getColor());
}
if (!dim.getCategories().isEmpty()) {
jsonDim.add("categories", encodeCategories(dim.getCategories()));
}
} else if (type.equals(DimensionType.AdminLevel)) {
AdminDimension dim = (AdminDimension) dims.get(i);
jsonDim.addProperty("type", dim.getType().toString());
jsonDim.addProperty("level", dim.getLevelId());
if (dim.getColor() != null) {
jsonDim.addProperty("color", dim.getColor());
}
if (!dim.getCategories().isEmpty()) {
jsonDim.add("categories", encodeCategories(dim.getCategories()));
}
} else {
Dimension dim = dims.get(i);
jsonDim.addProperty("type", dim.getType().toString());
if (dim.getColor() != null) {
jsonDim.addProperty("color", dim.getColor());
}
if (!dim.getCategories().isEmpty()) {
jsonDim.add("categories", encodeCategories(dim.getCategories()));
}
}
jsonDims.add(jsonDim);
}
return jsonDims;
}
use of org.activityinfo.shared.report.model.Dimension 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.Dimension in project activityinfo by bedatadriven.
the class DimensionSelectionListView method updateStoreAfterModelChanged.
private void updateStoreAfterModelChanged(SchemaDTO schema) {
store.setFiresEvents(false);
store.removeAll();
for (Dimension dim : getSelection()) {
DimensionModel model = toModel(dim, schema);
if (model != null) {
store.add(model);
}
}
store.setFiresEvents(true);
list.refresh();
}
use of org.activityinfo.shared.report.model.Dimension in project activityinfo by bedatadriven.
the class DimensionTree method updateModelAfterCheckChange.
private void updateModelAfterCheckChange(TreePanelEvent<DimensionModel> event) {
Dimension dim = event.getItem().getDimension();
if (event.isChecked()) {
if (!model.getRowDimensions().contains(dim) && !model.getColumnDimensions().contains(dim)) {
if (model.getRowDimensions().size() > model.getColumnDimensions().size()) {
model.addColDimension(dim);
} else {
model.addRowDimension(dim);
}
}
} else {
model.getRowDimensions().remove(dim);
model.getColumnDimensions().remove(dim);
}
if (fireEvents) {
reportEventBus.fireChange();
}
}
use of org.activityinfo.shared.report.model.Dimension in project activityinfo by bedatadriven.
the class DimensionTree method isAttributeDimensionSelected.
private boolean isAttributeDimensionSelected(SchemaDTO schema, List<Dimension> dims, AttributeGroupDimension dim) {
String name = schema.getAttributeGroupNameSafe(dim.getAttributeGroupId());
for (Dimension selectedDim : dims) {
if (selectedDim instanceof AttributeGroupDimension) {
int selectedId = ((AttributeGroupDimension) selectedDim).getAttributeGroupId();
String selectedName = schema.getAttributeGroupNameSafe(selectedId);
if (selectedName.equalsIgnoreCase(name)) {
return true;
}
}
}
return false;
}
Aggregations