Search in sources :

Example 1 with CountryDTO

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)));
}
Also used : CreateEntity(org.activityinfo.shared.command.CreateEntity) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) CountryDTO(org.activityinfo.shared.dto.CountryDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Capture(org.easymock.Capture) Test(org.junit.Test)

Example 2 with CountryDTO

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"));
}
Also used : CountryDTO(org.activityinfo.shared.dto.CountryDTO) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) SiteResult(org.activityinfo.shared.command.result.SiteResult) Filter(org.activityinfo.shared.command.Filter) LocationTypeDTO(org.activityinfo.shared.dto.LocationTypeDTO) SiteDTO(org.activityinfo.shared.dto.SiteDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) DispatcherSync(org.activityinfo.server.command.DispatcherSync) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) Test(org.junit.Test)

Example 3 with CountryDTO

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();
}
Also used : AdministrativeLevelClustering(org.activityinfo.shared.report.model.clustering.AdministrativeLevelClustering) RadioGroup(com.extjs.gxt.ui.client.widget.form.RadioGroup) CountryDTO(org.activityinfo.shared.dto.CountryDTO) AdminLevelDTO(org.activityinfo.shared.dto.AdminLevelDTO) FieldEvent(com.extjs.gxt.ui.client.event.FieldEvent) NoClustering(org.activityinfo.shared.report.model.clustering.NoClustering) AutomaticClustering(org.activityinfo.shared.report.model.clustering.AutomaticClustering)

Example 4 with CountryDTO

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;
}
Also used : CountryDTO(org.activityinfo.shared.dto.CountryDTO) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO)

Example 5 with CountryDTO

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();
    }
}
Also used : CountryDTO(org.activityinfo.shared.dto.CountryDTO) AdminLevelDTO(org.activityinfo.shared.dto.AdminLevelDTO)

Aggregations

CountryDTO (org.activityinfo.shared.dto.CountryDTO)6 UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)3 AdminLevelDTO (org.activityinfo.shared.dto.AdminLevelDTO)2 Test (org.junit.Test)2 FieldEvent (com.extjs.gxt.ui.client.event.FieldEvent)1 RadioGroup (com.extjs.gxt.ui.client.widget.form.RadioGroup)1 DispatcherSync (org.activityinfo.server.command.DispatcherSync)1 CreateEntity (org.activityinfo.shared.command.CreateEntity)1 Filter (org.activityinfo.shared.command.Filter)1 GetSchema (org.activityinfo.shared.command.GetSchema)1 SiteResult (org.activityinfo.shared.command.result.SiteResult)1 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)1 LocationTypeDTO (org.activityinfo.shared.dto.LocationTypeDTO)1 SiteDTO (org.activityinfo.shared.dto.SiteDTO)1 AdministrativeLevelClustering (org.activityinfo.shared.report.model.clustering.AdministrativeLevelClustering)1 AutomaticClustering (org.activityinfo.shared.report.model.clustering.AutomaticClustering)1 NoClustering (org.activityinfo.shared.report.model.clustering.NoClustering)1 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)1 Capture (org.easymock.Capture)1