Search in sources :

Example 1 with Dimension

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;
}
Also used : JsonArray(com.google.gson.JsonArray) DimensionType(org.activityinfo.shared.report.model.DimensionType) JsonObject(com.google.gson.JsonObject) Dimension(org.activityinfo.shared.report.model.Dimension) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) DateDimension(org.activityinfo.shared.report.model.DateDimension) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) DateDimension(org.activityinfo.shared.report.model.DateDimension)

Example 2 with Dimension

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

Example 3 with Dimension

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();
}
Also used : 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 Dimension

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

Example 5 with Dimension

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

Aggregations

Dimension (org.activityinfo.shared.report.model.Dimension)46 AdminDimension (org.activityinfo.shared.report.model.AdminDimension)31 AttributeGroupDimension (org.activityinfo.shared.report.model.AttributeGroupDimension)29 DateDimension (org.activityinfo.shared.report.model.DateDimension)28 Test (org.junit.Test)23 Bucket (org.activityinfo.shared.command.result.Bucket)11 OnDataSet (org.activityinfo.server.database.OnDataSet)10 PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)10 EntityCategory (org.activityinfo.shared.report.content.EntityCategory)9 ArrayList (java.util.ArrayList)6 PivotSites (org.activityinfo.shared.command.PivotSites)6 PivotTableData (org.activityinfo.shared.report.content.PivotTableData)4 Comparator (java.util.Comparator)3 DispatcherSync (org.activityinfo.server.command.DispatcherSync)3 User (org.activityinfo.server.database.hibernate.entity.User)3 DimensionCategory (org.activityinfo.shared.report.content.DimensionCategory)3 LocalDate (com.bedatadriven.rebar.time.calendar.LocalDate)2 JsonObject (com.google.gson.JsonObject)2 List (java.util.List)2 ReportChangeEvent (org.activityinfo.client.page.report.ReportChangeEvent)2