Skip to content

Commit

Permalink
Merge pull request #212 from EmmanuelDemey/acceptance
Browse files Browse the repository at this point in the history
fix: rewrite getcomponent sparql query
  • Loading branch information
alicela authored Mar 11, 2022
2 parents 5c0e970 + 34a736d commit c5930cb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ public String getComponent(String id) throws RmesException {
JSONObject concept = new JSONObject();
concept.put("uri", component.getString("uriConcept"));
concept.put("id", component.getString("idConcept"));
this.addCloseMatch(concept);
component.put("concept", concept);
component.remove("uriConcept");
component.remove("idConcept");
Expand Down Expand Up @@ -291,6 +292,25 @@ public String getComponent(String id) throws RmesException {
return component.toString();
}

private void addCloseMatch(JSONObject concept) throws RmesException {
HashMap<String, Object> params = new HashMap<>();
params.put("CONCEPTS_GRAPH", Config.CONCEPTS_GRAPH);
params.put("CONCEPT_ID", concept.getString("id"));
JSONArray closeMatch = repoGestion.getResponseAsArray(buildRequest("getCloseMatch.ftlh", params));
if(closeMatch.length() > 0){
JSONArray formattedCloseMatchArray = new JSONArray();
for(int i = 0; i < closeMatch.length(); i++){
String iri = ((JSONObject) closeMatch.get(i)).getString("closeMatch").replace("urn:sdmx:org.sdmx.infomodel.conceptscheme.Concept=", "");;
JSONObject relation = new JSONObject();
relation.put("agence", iri.substring(0, iri.indexOf(":")));
relation.put("id", iri.substring(iri.lastIndexOf(".") + 1));
formattedCloseMatchArray.put(relation);
}
concept.put("conceptsSdmx", formattedCloseMatchArray);
}

}

private void getStructureComponents(String id, JSONObject structure) throws RmesException {
HashMap<String, Object> params = new HashMap<>();
params.put("STRUCTURES_GRAPH", Config.STRUCTURES_GRAPH);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SELECT ?closeMatch
FROM <${CONCEPTS_GRAPH}>
WHERE {
?concept skos:notation "${CONCEPT_ID}" .
?concept skos:closeMatch ?closeMatch .
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ WHERE {
OPTIONAL {
?uriComposant qb:codeList ?uriListeCode .
?uriListeCode skos:notation ?idListeCode .
}
OPTIONAL {
?uriListeCode prov:wasDerivedFrom ?uriParentListCode .
?uriParentListCode skos:notation ?idParentListCode .
}

OPTIONAL {
?uriComposant pav:version ?version .
}
Expand Down

0 comments on commit c5930cb

Please sign in to comment.