GeoRegionService.java
package org.genesys.server.service;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import org.genesys.server.model.impl.Country;
import org.genesys.server.model.impl.GeoRegion;
import org.xml.sax.SAXException;
public interface GeoRegionService {
GeoRegion find(String regionIsoCode);
void save(GeoRegion geoRegion);
void delete(GeoRegion geoRegion);
List<GeoRegion> findAll();
List<GeoRegion> findAll(Locale locale);
void updateGeoRegionData() throws IOException, ParserConfigurationException, SAXException;
GeoRegion getRegion(Country country);
GeoRegion get(long id);
List<GeoRegion> getGeoRegionsForFilter();
List<GeoRegion> conversionToSubRegionsList(GeoRegion parentGeo);
List<GeoRegion> getChildren(String regionIsoCode);
/**
* Get all ISO3 country codes for specified region codes
*
* @param regionCodes set of region codes
* @return a set of ISO3 country codes of countries in all specified regions
*/
Collection<String> countryCodesFor(Set<String> regionCodes);
RegionDetails getDetails(String isoCode);
public static class RegionDetails implements Serializable {
private static final long serialVersionUID = -8652090344263391432L;
@JsonUnwrapped
public GeoRegion region;
public List<GeoRegion> subRegions;
public List<Country> countries;
public static RegionDetails from(GeoRegion region, List<GeoRegion> subRegions) {
RegionDetails regionDetails = new RegionDetails();
regionDetails.region = region;
regionDetails.subRegions = subRegions;
regionDetails.countries = region.getCountries();
return regionDetails;
}
}
}