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