Search in sources :

Example 1 with Country

use of org.activityinfo.server.database.hibernate.entity.Country in project activityinfo by bedatadriven.

the class UserDatabasePolicy method findCountry.

private Country findCountry(PropertyMap properties) {
    int countryId;
    if (properties.containsKey("countryId")) {
        countryId = properties.get("countryId");
    } else {
        // this was the default
        countryId = 1;
    }
    Country country = countryDAO.findById(countryId);
    if (country == null) {
        throw new CommandException(String.format("No country exists with id %d", countryId));
    }
    return country;
}
Also used : Country(org.activityinfo.server.database.hibernate.entity.Country) CommandException(org.activityinfo.legacy.shared.exception.CommandException)

Example 2 with Country

use of org.activityinfo.server.database.hibernate.entity.Country 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)

Aggregations

Country (org.activityinfo.server.database.hibernate.entity.Country)2 ArrayList (java.util.ArrayList)1 CommandException (org.activityinfo.legacy.shared.exception.CommandException)1 CountryDTO (org.activityinfo.legacy.shared.model.CountryDTO)1