Search in sources :

Example 1 with CountryDTO

use of org.activityinfo.legacy.shared.model.CountryDTO in project activityinfo by bedatadriven.

the class NewDbDetailsPage method loadCountries.

private void loadCountries() {
    loadCountries.setEnabled(false);
    countryField.setShowValidationMessage(false);
    dispatcher.execute(new GetCountries(), new AsyncCallback<CountryResult>() {

        @Override
        public void onFailure(Throwable caught) {
            loadCountries.setEnabled(true);
            countryField.showValidationMessage(I18N.CONSTANTS.failedToLoadCountries());
            loadCountries.setVisible(true);
        }

        @Override
        public void onSuccess(CountryResult result) {
            loadCountries.setVisible(false);
            for (CountryDTO countryDTO : result.getData()) {
                country.addItem(countryDTO.getName(), Integer.toString(countryDTO.getId()));
            }
            country.update();
        }
    });
}
Also used : CountryResult(org.activityinfo.legacy.shared.command.result.CountryResult) CountryDTO(org.activityinfo.legacy.shared.model.CountryDTO) GetCountries(org.activityinfo.legacy.shared.command.GetCountries)

Example 2 with CountryDTO

use of org.activityinfo.legacy.shared.model.CountryDTO in project activityinfo by bedatadriven.

the class GetCountriesHandler method mapToDtos.

private ArrayList<CountryDTO> mapToDtos(List<Country> countries) {
    ArrayList<CountryDTO> dtos = new ArrayList<CountryDTO>();
    for (Country country : countries) {
        CountryDTO dto = new CountryDTO();
        dto.setId(country.getId());
        dto.setName(country.getName());
        dto.setCodeISO(country.getCodeISO());
        dtos.add(dto);
    }
    return dtos;
}
Also used : CountryDTO(org.activityinfo.legacy.shared.model.CountryDTO) ArrayList(java.util.ArrayList) Country(org.activityinfo.server.database.hibernate.entity.Country)

Example 3 with CountryDTO

use of org.activityinfo.legacy.shared.model.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.legacy.shared.command.CreateEntity) UserDatabaseDTO(org.activityinfo.legacy.shared.model.UserDatabaseDTO) CountryDTO(org.activityinfo.legacy.shared.model.CountryDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) Capture(org.easymock.Capture) Test(org.junit.Test)

Aggregations

CountryDTO (org.activityinfo.legacy.shared.model.CountryDTO)3 ArrayList (java.util.ArrayList)1 CreateEntity (org.activityinfo.legacy.shared.command.CreateEntity)1 GetCountries (org.activityinfo.legacy.shared.command.GetCountries)1 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)1 CountryResult (org.activityinfo.legacy.shared.command.result.CountryResult)1 UserDatabaseDTO (org.activityinfo.legacy.shared.model.UserDatabaseDTO)1 Country (org.activityinfo.server.database.hibernate.entity.Country)1 Capture (org.easymock.Capture)1 Test (org.junit.Test)1