Search in sources :

Example 16 with DimensionType

use of org.activityinfo.shared.report.model.DimensionType in project activityinfo by bedatadriven.

the class FilterUrlSerializer method fromUrlFragment.

public static Filter fromUrlFragment(String fragment) {
    Filter filter = new Filter();
    String[] dimensions = fragment.split("\\-");
    for (String dim : dimensions) {
        String[] elements = dim.split("\\+");
        if (elements[0].equals("date")) {
            filter.getDateRange().setMinDate(parseDate(elements[1]));
            filter.getDateRange().setMaxDate(parseDate(elements[2]));
        } else {
            DimensionType dimType = DimensionType.valueOf(elements[0]);
            for (int i = 1; i < elements.length; ++i) {
                filter.addRestriction(dimType, Integer.parseInt(elements[i]));
            }
        }
    }
    return filter;
}
Also used : DimensionType(org.activityinfo.shared.report.model.DimensionType)

Example 17 with DimensionType

use of org.activityinfo.shared.report.model.DimensionType in project activityinfo by bedatadriven.

the class GetDimensionLabelsHandlerTest method labelsTest.

@Test
public void labelsTest() throws CommandException {
    Filter filter = new Filter();
    filter.addRestriction(DimensionType.Activity, Arrays.asList(1, 2, 3, 4, 5));
    filter.addRestriction(DimensionType.AdminLevel, Arrays.asList(1, 2, 3, 4, 5));
    filter.addRestriction(DimensionType.Partner, Arrays.asList(1, 2, 3, 4, 5));
    filter.addRestriction(DimensionType.Project, Arrays.asList(1, 2, 3, 4, 5));
    filter.addRestriction(DimensionType.Database, Arrays.asList(1, 2, 3, 4, 5));
    filter.addRestriction(DimensionType.Indicator, Arrays.asList(1, 2, 3, 4, 5));
    for (DimensionType dimension : filter.getRestrictedDimensions()) {
        Map<Integer, String> labels = execute(filter, dimension);
        // We don't make assumptions about the data, only about that there
        // should be data (working query)
        assertTrue("Expected at least one label for entity " + dimension.toString(), labels.size() != 0);
    }
}
Also used : DimensionType(org.activityinfo.shared.report.model.DimensionType) Test(org.junit.Test)

Aggregations

DimensionType (org.activityinfo.shared.report.model.DimensionType)17 Filter (org.activityinfo.shared.command.Filter)5 ArrayList (java.util.ArrayList)4 SqlQuery (com.bedatadriven.rebar.sql.client.query.SqlQuery)2 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 Set (java.util.Set)2 FilterDescription (org.activityinfo.shared.report.content.FilterDescription)2 SqlResultSet (com.bedatadriven.rebar.sql.client.SqlResultSet)1 LocalDate (com.bedatadriven.rebar.time.calendar.LocalDate)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Indicator (org.activityinfo.server.database.hibernate.entity.Indicator)1 BubbleLayerGenerator (org.activityinfo.server.report.generator.map.BubbleLayerGenerator)1 IconLayerGenerator (org.activityinfo.server.report.generator.map.IconLayerGenerator)1 LayerGenerator (org.activityinfo.server.report.generator.map.LayerGenerator)1 Margins (org.activityinfo.server.report.generator.map.Margins)1