src/main/java: Correctly map common_name and official_name

I forgot to fix these so that they map exactly to the ISO 3166-1
JSON so that GSON can deserialize them automatically.
This commit is contained in:
Alan Orth 2020-08-01 11:44:54 +03:00
parent 91a4367f38
commit 0f2081db51
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
2 changed files with 11 additions and 11 deletions

View File

@ -28,21 +28,21 @@ public class CountriesVocabulary {
class Country { class Country {
private String name; //required private String name; //required
private String commonName; //optional private String common_name; //optional
private String officialName; //optional private String official_name; //optional
private String numeric; //required Hmmmm need to cast this... private String numeric; //required Hmmmm need to cast this...
private String alpha_2; //required private String alpha_2; //required
private String alpha_3; //required private String alpha_3; //required
public Country(String name, public Country(String name,
@Nullable String commonName, @Nullable String common_name,
@Nullable String officialName, @Nullable String official_name,
String numeric, String numeric,
String alpha_2, String alpha_2,
String alpha_3) { String alpha_3) {
this.name = name; this.name = name;
this.commonName = commonName; this.common_name = common_name;
this.officialName = officialName; this.official_name = official_name;
this.numeric = numeric; // fuuuuu this is a string and we can't cast to Integer because some values are zeropadded like "004" this.numeric = numeric; // fuuuuu this is a string and we can't cast to Integer because some values are zeropadded like "004"
this.alpha_2 = alpha_2; this.alpha_2 = alpha_2;
this.alpha_3 = alpha_3; this.alpha_3 = alpha_3;
@ -56,12 +56,12 @@ public class CountriesVocabulary {
return numeric; return numeric;
} }
public String getCommonName() { public String get_common_name() {
return commonName; return common_name;
} }
public String getOfficialName() { public String get_official_name() {
return officialName; return official_name;
} }
public String getAlpha_2() { public String getAlpha_2() {

View File

@ -94,7 +94,7 @@ public class CountryCodeTagger extends AbstractCurationTask
Integer addedCodeCount = 0; Integer addedCodeCount = 0;
for (Metadatum itemCountry : itemCountries) { for (Metadatum itemCountry : itemCountries) {
for (CountriesVocabulary.Country country : isocodesCountriesJson.countries) { for (CountriesVocabulary.Country country : isocodesCountriesJson.countries) {
if (itemCountry.value.equalsIgnoreCase(country.getName()) || itemCountry.value.equalsIgnoreCase(country.getOfficialName()) || itemCountry.value.equalsIgnoreCase(country.getCommonName())) { if (itemCountry.value.equalsIgnoreCase(country.getName()) || itemCountry.value.equalsIgnoreCase(country.get_official_name()) || itemCountry.value.equalsIgnoreCase(country.get_common_name())) {
System.out.println(itemHandle + ": adding country code " + country.getAlpha_2()); System.out.println(itemHandle + ": adding country code " + country.getAlpha_2());
try { try {