use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.
the class GetSitePointsHandler method execute.
@Override
public void execute(GetSitePoints command, ExecutionContext context, final AsyncCallback<SitePointList> callback) {
Filter filter = new Filter();
if (command.getActivityId() != 0) {
filter.addRestriction(DimensionType.Activity, command.getActivityId());
}
context.execute(new GetSites(filter), new AsyncCallback<SiteResult>() {
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
@Override
public void onSuccess(SiteResult result) {
callback.onSuccess(toPointList(result.getData()));
}
});
}
use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.
the class QueryParser method createFilter.
private void createFilter() {
Filter filter = new Filter();
for (String dimensionString : preciseDimensions.keySet()) {
DimensionType dimension;
try {
dimension = fromString(dimensionString);
} catch (Exception e) {
// Ruthlessly ignore nonparseable string
continue;
}
List<Integer> ids = new ArrayList<Integer>();
for (String idString : preciseDimensions.get(dimensionString)) {
try {
int id = Integer.parseInt(idString);
ids.add(id);
} catch (Exception ex) {
// Ruthlessly ignore nonparseable string
continue;
}
}
if (ids.size() > 0 && isSupportedDimension(dimension)) {
filter.addRestriction(dimension, ids);
}
}
this.filter = filter;
}
use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.
the class DataEntryPlaceParserTest method activityFiltered.
@Test
public void activityFiltered() {
Filter filter = new Filter();
filter.addRestriction(DimensionType.Activity, 33);
verifyCorrectSerde(new DataEntryPlace(filter));
}
use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.
the class GetSitesTest method filterByIndicator.
@Test
public void filterByIndicator() throws CommandException {
setUser(1);
Filter filter = new Filter();
filter.addRestriction(DimensionType.Indicator, 5);
SiteResult result = execute(new GetSites(filter));
assertThat(result.getData().size(), equalTo(1));
assertThat(result.getData().get(0).getId(), equalTo(9));
}
use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.
the class SiteExporterTest method sheetNameTest.
@Test
public void sheetNameTest() {
LocaleProxy.initialize();
CountryDTO somalia = new CountryDTO(1, "Somalia");
somalia.getLocationTypes().add(new LocationTypeDTO(1, "Village"));
UserDatabaseDTO syli = new UserDatabaseDTO();
syli.setName("SYLI");
syli.setCountry(somalia);
ActivityDTO activity = new ActivityDTO();
activity.setId(1);
activity.setDatabase(syli);
activity.setName("Construction/Rehabilitation of Sec. Schools");
activity.setLocationTypeId(1);
ActivityDTO activity2 = new ActivityDTO();
activity2.setId(2);
activity2.setDatabase(syli);
activity2.setName("Construction/Rehabilitation of Primary Schools");
activity2.setLocationTypeId(1);
ActivityDTO activity3 = new ActivityDTO();
activity3.setId(3);
activity3.setDatabase(syli);
activity3.setName("Construction Rehabil (2)");
activity3.setLocationTypeId(1);
DispatcherSync dispatcher = createMock(DispatcherSync.class);
expect(dispatcher.execute(isA(GetSites.class))).andReturn(new SiteResult(new ArrayList<SiteDTO>())).anyTimes();
replay(dispatcher);
Filter filter = new Filter();
SiteExporter exporter = new SiteExporter(dispatcher);
exporter.export(activity, filter);
exporter.export(activity2, filter);
exporter.export(activity3, filter);
HSSFWorkbook book = exporter.getBook();
assertThat(book.getSheetAt(0).getSheetName(), equalTo("SYLI - Construction Rehabilitat"));
assertThat(book.getSheetAt(1).getSheetName(), equalTo("SYLI - Construction Rehabil (2)"));
assertThat(book.getSheetAt(2).getSheetName(), equalTo("SYLI - Construction Rehabil 2"));
}
Aggregations