Skip to content

Commit

Permalink
Get classification obj just once
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakarFin committed Nov 17, 2023
1 parent 866e1e5 commit 7ff92cb
Showing 1 changed file with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ StatisticalIndicator createIndicator(JSONObject json, Map<String, Long> sotkaLay
ind.setId(indicatorId);

// parse layers first since if none match -> we don't need to parse the rest
if (!json.getJSONObject("classifications").has("region")) {
JSONObject classificationObj = json.optJSONObject("classifications");
if (classificationObj == null || !classificationObj.has("region")) {
LOG.error("Region missing from indicator: " + indicatorId + ": " + String.valueOf(ind.getName()));
return null;
}
List<String> sotkaRegionsets = getDeclaredRegionsets(json.optJSONObject("classifications"));
List<String> sotkaRegionsets = getDeclaredRegionsets(classificationObj);
if (sotkaRegionsets.isEmpty()) {
// if sotkanet doesn't specify any region set to have data -> assume it has data for all
// new indicators don't seem to have this defined anymore
Expand Down Expand Up @@ -115,17 +116,30 @@ StatisticalIndicator createIndicator(JSONObject json, Map<String, Long> sotkaLay
}
return ind;
}

/**
* Get values under classification.region.values:
"classifications": {
"sex": {
"values": ["male", "female", "total"]
},
"region": {
"title: {
"fi": "Kunta, seutukunta, maakunta, hyvinvointialue, sairaanhoitopiiri, yhteistyöalue, aluehallintoviraston alue, suuralue, Manner-Suomi/Ahvenanmaa, erityisvastuualue, koko maa",
...
},
"values": ["Kunta", "Maakunta", "Erva", "Aluehallintovirasto", "Sairaanhoitopiiri", "Maa", "Suuralue", "Seutukunta", "Nuts1"]
}
},
...
}
OR use title if values is empty?
"classifications": {
"region": {
"title: {
"fi": "Hyvinvointialue",
...
},
"values": []
}
}
* @param indicatorClassification
* @return
*/
Expand Down

0 comments on commit 7ff92cb

Please sign in to comment.