use of com.helger.masterdata.locale.EContinent in project ph-masterdata by phax.
the class MainReadCountry2Continent method main.
public static void main(final String[] args) {
final IReadableResource aRes = new ClassPathResource("country2continent.xlsx");
final Workbook aWB = ExcelReadHelper.readWorkbookFromInputStream(aRes);
final Sheet aSheet = aWB.getSheetAt(0);
// Skip one row
int nRow = 1;
int nNotFound = 0;
final ICommonsNavigableMap<Locale, EContinent> aMap = new CommonsTreeMap<>(IComparator.getComparatorCollating(Locale::getCountry, LOC));
while (true) {
final Row aRow = aSheet.getRow(nRow);
if (aRow == null)
break;
final String sContinent = ExcelReadHelper.getCellValueString(aRow.getCell(0));
if (StringHelper.hasNoText(sContinent))
break;
final EContinent eContinent = _findContinent(sContinent);
final String sCountryName = ExcelReadHelper.getCellValueString(aRow.getCell(1));
final Locale aCountry = _findCountryComplex(sCountryName);
if (aCountry == null) {
LOGGER.info("No such country: '" + sCountryName + "'");
++nNotFound;
} else {
final EContinent eOld = aMap.put(aCountry, eContinent);
if (eOld != null)
LOGGER.info("Country " + aCountry.getDisplayCountry(LOC) + " is assigned to " + eContinent.getDisplayText(LOC) + " and " + eOld.getDisplayText(LOC));
}
++nRow;
}
LOGGER.info("Countries not found: " + nNotFound);
for (final Map.Entry<Locale, EContinent> e : aMap.entrySet()) {
LOGGER.info("s_aMap.put (CountryCache.getCountry (\"" + e.getKey().getCountry() + "\"), EContinent." + e.getValue().name() + "),");
}
}
Aggregations