String countryISO = StringUtils.trimToNull(row[countryColumnIdx]);
String currencyISO = StringUtils.trimToNull(row[currencyColumnIdx]);
Set<String> rowSubRegions = new HashSet<String>(Arrays.asList(row[subRegionsColumnIdx].split(";")));
rowSubRegions = trim(rowSubRegions);
ManageableRegion region = new ManageableRegion();
region.setClassification(classification);
region.setName(name);
region.setFullName(fullName);
if (countryISO != null) {
region.setCountry(Country.of(countryISO));
region.addExternalId(ExternalSchemes.financialRegionId(countryISO)); // TODO: looks odd
}
if (currencyISO != null) {
region.setCurrency(Currency.of(currencyISO));
}
if (sovereignity != null) {
ManageableRegion parent = regions.get(sovereignity);
if (parent == null) {
throw new OpenGammaRuntimeException("Cannot find parent '" + sovereignity + "' for '" + name + "'");
}
region.getParentRegionIds().add(parent.getUniqueId());
}
for (Entry<UniqueId, Set<String>> entry : subRegions.entrySet()) {
if (entry.getValue().remove(name)) {
region.getParentRegionIds().add(entry.getKey());
}