Search in sources :

Example 1 with CountryIsoEntity

use of org.orcid.persistence.jpa.entities.CountryIsoEntity in project ORCID-Source by ORCID.

the class CountryManagerImpl method retrieveCountriesAndIsoCodes.

@Override
@Cacheable("iso-countries")
public Map<String, String> retrieveCountriesAndIsoCodes() {
    List<CountryIsoEntity> countries = isoCountryReferenceDataDao.getAll();
    Collections.sort(countries, new Comparator<CountryIsoEntity>() {

        public int compare(CountryIsoEntity country1, CountryIsoEntity country2) {
            return ((String) country1.getCountryName()).compareToIgnoreCase((String) country2.getCountryName());
        }
    });
    Map<String, String> countriesMap = new LinkedHashMap<String, String>();
    for (CountryIsoEntity country : countries) {
        countriesMap.put(country.getCountryIsoCode(), country.getCountryName());
    }
    return countriesMap;
}
Also used : CountryIsoEntity(org.orcid.persistence.jpa.entities.CountryIsoEntity) LinkedHashMap(java.util.LinkedHashMap) Cacheable(org.springframework.cache.annotation.Cacheable)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)1 CountryIsoEntity (org.orcid.persistence.jpa.entities.CountryIsoEntity)1 Cacheable (org.springframework.cache.annotation.Cacheable)1