Skip to content

Commit

Permalink
Merge pull request #1068 from okauppinen/sotka-parser-skip
Browse files Browse the repository at this point in the history
SotkaIndicatorParser skip faulty indicators
  • Loading branch information
ZakarFin authored Aug 27, 2024
2 parents 725da88 + 3b217df commit c72091c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ public void update() {
JSONArray responseJSON = new JSONArray(data);
SotkaIndicatorParser parser = new SotkaIndicatorParser(config);
LOG.info("Parsing indicator response of length: " + responseJSON.length());
int parsedIndicators = 0;
for (int i = 0; i < responseJSON.length(); i++) {
StatisticalIndicator indicator = parser.parse(responseJSON.getJSONObject(i), sotkaToLayerMappings);
if(indicator != null) {
parsedIndicators++;
onIndicatorProcessed(indicator);
}
}
LOG.info("Parsed indicator response.");
LOG.info("Updated datasource:", config.getUrl(), "with parsed", parsedIndicators, "of", responseJSON.length(), "indicators.");
} catch (JSONException e) {
LOG.error("Error in mapping Sotka Indicators response to Oskari model: " + e.getMessage(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ StatisticalIndicator createIndicator(JSONObject json, Map<String, Long> sotkaLay
ind.setSource(toLocalizationMap(json.getJSONObject("organization").getJSONObject("title")));

return setupMetadata(ind, sotkaLayersToOskariLayers);
} catch (JSONException e) {
} catch (Exception e) {
LOG.error(e, "Could not read data from Sotka Indicator JSON.");
return null;
}
Expand Down Expand Up @@ -340,6 +340,7 @@ private StatisticalIndicator setupMetadata(StatisticalIndicator ind, Map<String,
if (ind.getLayers().isEmpty()) {
// we can't show this indicator since it doesn't link to any region set
// if at this point we don't have layers -> ignore the indicator by returning null
LOG.debug("Indicator:", ind.getId(), "doesn't have any of regionsets linked to datasource, ignoring");
return null;
}

Expand Down

0 comments on commit c72091c

Please sign in to comment.