예제 #1
0
  @SuppressWarnings("unchecked")
  @Override
  public List<Country> getCountries(Language language) throws ServiceException {

    List<Country> countries = null;
    try {

      // CacheUtils cacheUtils = CacheUtils.getInstance();

      countries = (List<Country>) cache.getFromCache("COUNTRIES_" + language.getCode());

      if (countries == null) {

        countries = countryDao.listByLanguage(language);

        // set names
        for (Country country : countries) {

          CountryDescription description = country.getDescriptions().get(0);
          country.setName(description.getName());
        }

        cache.putInCache(countries, "COUNTRIES_" + language.getCode());
      }

    } catch (Exception e) {
      LOGGER.error("getCountries()", e);
    }

    return countries;
  }
예제 #2
0
  @Override
  public Map<String, Country> getCountriesMap(Language language) throws ServiceException {

    List<Country> countries = this.getCountries(language);

    Map<String, Country> returnMap = new LinkedHashMap<String, Country>();

    for (Country country : countries) {
      returnMap.put(country.getIsoCode(), country);
    }

    return returnMap;
  }
예제 #3
0
 @Override
 public List<Country> getCountries(final List<String> isoCodes, final Language language)
     throws ServiceException {
   List<Country> countryList = getCountries(language);
   List<Country> requestedCountryList = new ArrayList<Country>();
   if (!CollectionUtils.isEmpty(countryList)) {
     for (Country c : countryList) {
       if (isoCodes.contains(c.getIsoCode())) {
         requestedCountryList.add(c);
       }
     }
   }
   return requestedCountryList;
 }
예제 #4
0
 @Override
 public void addCountryDescription(Country country, CountryDescription description)
     throws ServiceException {
   country.getDescriptions().add(description);
   description.setCountry(country);
   update(country);
 }