use of org.activityinfo.shared.dto.CountryDTO in project activityinfo by bedatadriven.
the class DbListPresenterTest method commandShouldBePreparedProperly.
@Test
public void commandShouldBePreparedProperly() {
Capture<CreateEntity> cmd = new Capture<CreateEntity>();
expectDispatch(new GetSchema(), schema);
captureDispatch(cmd);
replay(dispatcher);
UserDatabaseDTO newDb = new UserDatabaseDTO();
newDb.setCountry(new CountryDTO(31, "Haiti"));
newDb.setName("My Db");
createPresenter();
presenter.save(newDb, niceFormDialogMock());
assertTrue("command was dispatched", cmd.hasCaptured());
assertThat((Integer) cmd.getValue().getProperties().get("countryId"), is(equalTo(31)));
}
use of org.activityinfo.shared.dto.CountryDTO 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"));
}
use of org.activityinfo.shared.dto.CountryDTO in project activityinfo by bedatadriven.
the class ClusteringOptionsWidget method buildForm.
private void buildForm(Set<CountryDTO> countries) {
radios = Lists.newArrayList();
radios.add(new ClusteringRadio(I18N.CONSTANTS.none(), new NoClustering()));
radios.add(new ClusteringRadio(I18N.CONSTANTS.automatic(), new AutomaticClustering()));
if (countries.size() == 1) {
CountryDTO country = countries.iterator().next();
for (AdminLevelDTO level : country.getAdminLevels()) {
AdministrativeLevelClustering clustering = new AdministrativeLevelClustering();
clustering.getAdminLevels().add(level.getId());
radios.add(new ClusteringRadio(level.getName(), clustering));
}
}
radioGroup = new RadioGroup();
radioGroup.setOrientation(Orientation.VERTICAL);
radioGroup.setStyleAttribute("padding", "5px");
for (ClusteringRadio radio : radios) {
radioGroup.add(radio);
if (radio.getClustering().equals(value)) {
radioGroup.setValue(radio);
}
}
add(radioGroup);
radioGroup.addListener(Events.Change, new Listener<FieldEvent>() {
@Override
public void handleEvent(FieldEvent be) {
ClusteringRadio radio = (ClusteringRadio) radioGroup.getValue();
setValue(radio.getClustering(), true);
}
});
layout();
// unmask();
}
use of org.activityinfo.shared.dto.CountryDTO in project activityinfo by bedatadriven.
the class ClusteringOptionsWidget method countriesForLayer.
private Set<CountryDTO> countriesForLayer(SchemaDTO schema, MapLayer layer) {
Set<Integer> indicatorIds = Sets.newHashSet(layer.getIndicatorIds());
Set<CountryDTO> countries = Sets.newHashSet();
for (UserDatabaseDTO database : schema.getDatabases()) {
if (databaseContainsIndicatorId(database, indicatorIds)) {
countries.add(database.getCountry());
}
}
return countries;
}
use of org.activityinfo.shared.dto.CountryDTO in project activityinfo by bedatadriven.
the class DimensionTree method addGeography.
private void addGeography(SchemaDTO schema) {
Set<CountryDTO> countries = schema.getCountriesForIndicators(model.getIndicators());
store.removeAll(geographyRoot);
if (countries.size() == 1) {
CountryDTO country = countries.iterator().next();
for (AdminLevelDTO level : country.getAdminLevels()) {
store.add(geographyRoot, new DimensionModel(level), false);
}
addLocationDimension();
}
}
Aggregations