Commit ba6fe73e authored by Matija Obreza's avatar Matija Obreza
Browse files

Use the new FAO WIEWS export_c.zip with ISO country code

parent 99269891
...@@ -49,7 +49,7 @@ import au.com.bytecode.opencsv.CSVReader; ...@@ -49,7 +49,7 @@ import au.com.bytecode.opencsv.CSVReader;
@Component @Component
public class InstituteUpdater { public class InstituteUpdater {
public static final String WIEWS_EXPORT_URL = "http://apps3.fao.org/wiews/export.zip"; public static final String WIEWS_EXPORT_URL = "http://apps3.fao.org/wiews/export_c.zip";
public static final Log LOG = LogFactory.getLog(InstituteUpdater.class); public static final Log LOG = LogFactory.getLog(InstituteUpdater.class);
...@@ -98,9 +98,9 @@ public class InstituteUpdater { ...@@ -98,9 +98,9 @@ public class InstituteUpdater {
instream = new ZipInputStream(entity.getContent()); instream = new ZipInputStream(entity.getContent());
final ZipEntry zipEntry = instream.getNextEntry(); final ZipEntry zipEntry = instream.getNextEntry();
LOG.debug("Got entry: " + zipEntry.getName()); LOG.debug("Got entry: " + zipEntry.getName());
if (!zipEntry.getName().equals("export.txt")) { if (!zipEntry.getName().equals("export_c.txt")) {
LOG.warn("Expected export.txt, not " + zipEntry.getName()); LOG.warn("Expected export_c, not " + zipEntry.getName());
throw new IOException("Missing export.txt"); throw new IOException("Missing export_c");
} }
final InputStreamReader inreader = new InputStreamReader(instream, "UTF-8"); final InputStreamReader inreader = new InputStreamReader(instream, "UTF-8");
...@@ -219,6 +219,7 @@ public class InstituteUpdater { ...@@ -219,6 +219,7 @@ public class InstituteUpdater {
// final String updatedOn = line[17]; // final String updatedOn = line[17];
// V_INSTCODE === New instcode? // V_INSTCODE === New instcode?
final String vInstCode = line[18]; final String vInstCode = line[18];
final String isoCountry = line[19];
if (faoInstitute.getCode() == null) { if (faoInstitute.getCode() == null) {
faoInstitute.setCode(instCode); faoInstitute.setCode(instCode);
...@@ -242,7 +243,7 @@ public class InstituteUpdater { ...@@ -242,7 +243,7 @@ public class InstituteUpdater {
// Update institute country if null or when not matching the // Update institute country if null or when not matching the
// code // code
faoInstitute.setCountry(geoService.getCurrentCountry(faoInstitute.getCode().substring(0, 3))); faoInstitute.setCountry(geoService.getCurrentCountry(isoCountry));
return true; return true;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment