From 416e983e1ab692bb1846d94711c9bd5babb4e9ab Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Wed, 18 Aug 2021 13:27:41 +0200 Subject: [PATCH 01/14] refactor: move concepts queries to a FTLH file --- .../sparql_queries/concepts/ConceptsQueries.java | 16 ++++------------ .../resources/request/concepts/getConcepts.ftlh | 13 +++++++++++++ 2 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 src/main/resources/request/concepts/getConcepts.ftlh diff --git a/src/main/java/fr/insee/rmes/persistance/sparql_queries/concepts/ConceptsQueries.java b/src/main/java/fr/insee/rmes/persistance/sparql_queries/concepts/ConceptsQueries.java index d86fee600..725979303 100644 --- a/src/main/java/fr/insee/rmes/persistance/sparql_queries/concepts/ConceptsQueries.java +++ b/src/main/java/fr/insee/rmes/persistance/sparql_queries/concepts/ConceptsQueries.java @@ -27,18 +27,10 @@ public static String lastConceptID() { } - public static String conceptsQuery() { - return "SELECT DISTINCT ?id ?label (group_concat(?altLabelLg1;separator=' || ') as ?altLabel) \n" - + "WHERE { GRAPH <"+Config.CONCEPTS_GRAPH+"> { \n" - + "?concept skos:notation ?notation . \n" - + "BIND (STR(?notation) AS ?id) \n" - + "?concept skos:prefLabel ?label . \n" - + "FILTER (lang(?label) = '" + Config.LG1 + "') \n" - + "OPTIONAL{?concept skos:altLabel ?altLabelLg1 . \n" - + "FILTER (lang(?altLabelLg1) = '" + Config.LG1 + "')} \n" - + "}} \n" - + "GROUP BY ?id ?label \n" - + "ORDER BY ?label "; + public static String conceptsQuery() throws RmesException { + if (params==null) {initParams();} + params.put("CONCEPTS_GRAPH", Config.CONCEPTS_GRAPH); + return buildConceptRequest("getConcepts.ftlh", params); } public static String conceptsSearchQuery() { diff --git a/src/main/resources/request/concepts/getConcepts.ftlh b/src/main/resources/request/concepts/getConcepts.ftlh new file mode 100644 index 000000000..96805bf6d --- /dev/null +++ b/src/main/resources/request/concepts/getConcepts.ftlh @@ -0,0 +1,13 @@ +SELECT DISTINCT ?id ?label (group_concat(?altLabelLg1;separator=' || ') as ?altLabel) +WHERE { + GRAPH <${CONCEPTS_GRAPH}> { + ?concept skos:notation ?notation . + BIND (STR(?notation) AS ?id) + ?concept skos:prefLabel ?label . + FILTER (lang(?label) = '${LG1}') + OPTIONAL{?concept skos:altLabel ?altLabelLg1 . + FILTER (lang(?altLabelLg1) = '${LG1}')} + } +} +GROUP BY ?id ?label +ORDER BY ?label \ No newline at end of file From 263bb49d56748818538fdec33b2f23ef3d73616d Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Thu, 19 Aug 2021 16:32:26 +0200 Subject: [PATCH 02/14] fix: remove useless sysout --- src/main/java/fr/insee/rmes/webservice/StructureResources.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/fr/insee/rmes/webservice/StructureResources.java b/src/main/java/fr/insee/rmes/webservice/StructureResources.java index bd2c5833e..b0ed7656a 100644 --- a/src/main/java/fr/insee/rmes/webservice/StructureResources.java +++ b/src/main/java/fr/insee/rmes/webservice/StructureResources.java @@ -108,8 +108,6 @@ public Response publishStructureById(@PathParam(Constants.ID) String id) { jsonResultat = structureService.publishStructureById(id); } catch (RmesException e) { return Response.status(e.getStatus()).entity(e.getDetails()).type(MediaType.TEXT_PLAIN).build(); - } catch( Exception e ) { - System.out.println(e); } return Response.status(HttpStatus.SC_OK).entity(jsonResultat).build(); } From 48565366dfaaf85dd9904ed1fa9cf92d25e50626 Mon Sep 17 00:00:00 2001 From: Alice Lambois Date: Mon, 23 Aug 2021 10:41:24 +0200 Subject: [PATCH 03/14] Fix issue with "Not a valid (absolute) URI" --- .../documentations/documents/DocumentsUtils.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/operations/documentations/documents/DocumentsUtils.java b/src/main/java/fr/insee/rmes/bauhaus_services/operations/documentations/documents/DocumentsUtils.java index 5bf5c8654..cb46617a5 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/operations/documentations/documents/DocumentsUtils.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/operations/documentations/documents/DocumentsUtils.java @@ -441,11 +441,16 @@ public String changeFile(String docId, InputStream documentFile, String document uploadFile(documentFile, documentName, newUrl, false); // Update document's url - changeDocumentsURL(docId, docUrl, newUrl); + changeDocumentsURL(docId, addSchemeFile(docUrl), addSchemeFile(newUrl)); } return newUrl; } + + private String addSchemeFile(String url) { + if (url.startsWith(SCHEME_FILE))return url; + return SCHEME_FILE+url; + } private void uploadFile(InputStream documentFile, String documentName, String url, Boolean sameName) throws RmesUnauthorizedException { @@ -531,7 +536,7 @@ private String createFileUrl(String name) throws RmesException { if (m.find()) {// absolute URL return url; } - return SCHEME_FILE + url; + return addSchemeFile(url); } /** From 12b9f7ca3f90775fc6b1678a15c4a6643d3a196f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Aug 2021 20:38:50 +0000 Subject: [PATCH 04/14] Bump jsoup from 1.7.2 to 1.14.2 Bumps [jsoup](https://github.com/jhy/jsoup) from 1.7.2 to 1.14.2. - [Release notes](https://github.com/jhy/jsoup/releases) - [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES) - [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.7.2...jsoup-1.14.2) --- updated-dependencies: - dependency-name: org.jsoup:jsoup dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7c3e52f6b..85d7aac2f 100644 --- a/pom.xml +++ b/pom.xml @@ -414,7 +414,7 @@ org.jsoup jsoup - 1.7.2 + 1.14.2 From afa7c986b78723f3692877db02499fb0f07064c1 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Tue, 5 Oct 2021 21:52:44 +0200 Subject: [PATCH 05/14] feat: improve consultation --- .../ConsultationGestionServiceImpl.java | 61 ++++++++++++++++++- .../consultation-gestion/getComponent.ftlh | 7 ++- .../getComponentChildren.ftlh | 8 +++ .../consultation-gestion/getStructure.ftlh | 7 ++- 4 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/request/consultation-gestion/getComponentChildren.ftlh diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/consutation_gestion/ConsultationGestionServiceImpl.java b/src/main/java/fr/insee/rmes/bauhaus_services/consutation_gestion/ConsultationGestionServiceImpl.java index 7b4d8261b..0d168d39e 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/consutation_gestion/ConsultationGestionServiceImpl.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/consutation_gestion/ConsultationGestionServiceImpl.java @@ -133,6 +133,12 @@ public String getStructure(String id) throws RmesException { structure.remove("prefLabelLg1"); structure.remove("prefLabelLg2"); + if(structure.has("idParent")){ + String idParent = structure.getString("idParent"); + JSONObject parent = new JSONObject(); + parent.put("id", idParent); + structure.put("parent", parent); + } if(structure.has("statutValidation")){ String validationState = structure.getString("statutValidation"); structure.put("statutValidation", this.getValidationState(validationState)); @@ -180,10 +186,61 @@ public String getComponent(String id) throws RmesException { component.remove("prefLabelLg1"); component.remove("prefLabelLg2"); + if(component.has("uriComponentParentId")){ + JSONObject parent = new JSONObject(); + parent.put("id", component.getString("uriComponentParentId")); + component.remove("uriComponentParentId"); + component.put("parent", parent); + } + + JSONArray flatChildren = repoGestion.getResponseAsArray(buildRequest("getComponentChildren.ftlh", params)); + + JSONArray children = new JSONArray(); + for (int i = 0; i < flatChildren.length(); i++) { + String childrenId = flatChildren.getJSONObject(i).getString("uriComponentChildId"); + children.put(new JSONObject().put("id", childrenId)); + } + if(children.length() > 0) { + component.put("children", children); + } + if(component.has("statutValidation")){ String validationState = component.getString("statutValidation"); component.put("statutValidation", this.getValidationState(validationState)); } + + if(component.has("uriListeCode")){ + component.put("representation", "liste de code"); + + JSONArray codes = getCodes(component.getString("idListeCode")); + JSONObject listCode = new JSONObject(); + listCode.put("uri", component.getString("uriListeCode")); + listCode.put("id", component.getString("idListeCode")); + listCode.put("codes", codes); + component.put("listeCode", listCode); + component.remove("uriListeCode"); + component.remove("idListeCode"); + } + + if(component.has("uriConcept")){ + + JSONObject concept = new JSONObject(); + concept.put("uri", component.getString("uriConcept")); + concept.put("id", component.getString("idConcept")); + component.put("concept", concept); + component.remove("uriConcept"); + component.remove("idConcept"); + } + + if(component.has("representation")){ + if(component.getString("representation").endsWith("date")){ + component.put("representation", "date"); + } else if(component.getString("representation").endsWith("int")){ + component.put("representation", "entier"); + } else if(component.getString("representation").endsWith("float")){ + component.put("representation", "décimal"); + } + } return component.toString(); } @@ -213,9 +270,11 @@ private void getStructureComponents(String id, JSONObject structure) throws Rmes if(component.has("listeCodeUri")){ component.put("representation", "liste de code"); + JSONArray codes = getCodes(component.getString("listeCodeNotation")); JSONObject listCode = new JSONObject(); listCode.put("uri", component.getString("listeCodeUri")); listCode.put("id", component.getString("listeCodeNotation")); + listCode.put("codes", codes); component.put("listeCode", listCode); component.remove("listeCodeUri"); component.remove("listeCodeNotation"); @@ -242,7 +301,7 @@ private void getStructureComponents(String id, JSONObject structure) throws Rmes } String idComponent = component.getString("id"); - component.remove("id"); + if(idComponent.startsWith("a")){ attributes.put(component); } diff --git a/src/main/resources/request/consultation-gestion/getComponent.ftlh b/src/main/resources/request/consultation-gestion/getComponent.ftlh index 9f5cc2502..4e32fd6af 100644 --- a/src/main/resources/request/consultation-gestion/getComponent.ftlh +++ b/src/main/resources/request/consultation-gestion/getComponent.ftlh @@ -1,7 +1,7 @@ SELECT ?id (?uriComposant as ?uri) ?type ?notation ?dateMiseAJour ?statutValidation ?prefLabelLg1 ?prefLabelLg2 ?uriConcept ?idConcept ?representation - ?uriListeCode ?idListeCode ?version + ?uriListeCode ?idListeCode ?version ?uriComponentParentId FROM <${STRUCTURES_COMPONENTS_GRAPH}> FROM <${CODELIST_GRAPH}> WHERE { @@ -31,6 +31,11 @@ WHERE { ?uriComposant rdfs:label ?prefLabelLg2 . FILTER (lang(?prefLabelLg2) = '${LG2}') . + OPTIONAL { + ?uriComposant skos:broader ?uriComponentParent . + ?uriComponentParent dcterms:identifier ?uriComponentParentId . + } + OPTIONAL { ?uriComposant qb:concept ?uriConcept . BIND(STRAFTER(STR(?uriConcept), "${CONCEPTS_BASE_URI}/") AS ?idConcept) diff --git a/src/main/resources/request/consultation-gestion/getComponentChildren.ftlh b/src/main/resources/request/consultation-gestion/getComponentChildren.ftlh new file mode 100644 index 000000000..8f70dd393 --- /dev/null +++ b/src/main/resources/request/consultation-gestion/getComponentChildren.ftlh @@ -0,0 +1,8 @@ +SELECT ?uriComponentChildId +FROM <${STRUCTURES_COMPONENTS_GRAPH}> +FROM <${CODELIST_GRAPH}> +WHERE { + ?uriComposant dcterms:identifier "${ID}" ; + skos:narrower ?uriComponentChild . + ?uriComponentChild dcterms:identifier ?uriComponentChildId . +} \ No newline at end of file diff --git a/src/main/resources/request/consultation-gestion/getStructure.ftlh b/src/main/resources/request/consultation-gestion/getStructure.ftlh index 2f2f4cc12..3cda8efb7 100644 --- a/src/main/resources/request/consultation-gestion/getStructure.ftlh +++ b/src/main/resources/request/consultation-gestion/getStructure.ftlh @@ -1,10 +1,10 @@ -SELECT ?uri ?id ?notation ?prefLabelLg1 ?prefLabelLg2 ?dateCréation ?dateMiseAJour ?dateFinValidité ?statutValidation ?version +SELECT ?uri ?id ?notation ?prefLabelLg1 ?prefLabelLg2 ?dateCréation ?dateMiseAJour ?dateFinValidité ?statutValidation ?version ?idParent FROM <${STRUCTURES_GRAPH}> WHERE { ?uri rdf:type qb:DataStructureDefinition . ?uri dcterms:identifier "${STRUCTURE_ID}" . BIND("${STRUCTURE_ID}" AS ?id) . - ?uri skos:notation ?notation . + OPTIONAL { ?uri skos:notation ?notation . } ?uri rdfs:label ?prefLabelLg1 . FILTER (lang(?prefLabelLg1) = '${LG1}') . ?uri rdfs:label ?prefLabelLg2 . @@ -12,6 +12,7 @@ WHERE { ?uri dcterms:created ?dateCréation . ?uri dcterms:modified ?dateMiseAJour . OPTIONAL {?uri dcterms:valid ?dateFinValidité . } - ?uri insee:validationState ?statutValidation . + OPTIONAL { ?uri insee:validationState ?statutValidation . } OPTIONAL {?uri pav:version ?version . } + OPTIONAL { ?uri dcterms:relation ?idParent } } \ No newline at end of file From bc08fa4811bb2a51454b59a1c6fd0f3597a7037d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Bourgeois?= Date: Mon, 11 Oct 2021 16:22:26 +0200 Subject: [PATCH 06/14] update to fix the problem of exporting indicators in odt --- .../insee/rmes/model/operations/Indicator.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/insee/rmes/model/operations/Indicator.java b/src/main/java/fr/insee/rmes/model/operations/Indicator.java index 8e5890f95..15289c907 100644 --- a/src/main/java/fr/insee/rmes/model/operations/Indicator.java +++ b/src/main/java/fr/insee/rmes/model/operations/Indicator.java @@ -73,6 +73,9 @@ public class Indicator { @Schema(description="Id of Sims documentation") public String idSims; + @Schema(description = "validationState") + public String validationState; + public Indicator(String id) { this.id=id; } @@ -174,6 +177,14 @@ public List getCreators() { return creators; } + public String getValidationState() { + return validationState; + } + + public void setValidationState(String validationState) { + this.validationState = validationState; + } + public void setPublishers(List publishers) { this.publishers = publishers; } @@ -254,7 +265,7 @@ public void setId(String id) { public int hashCode() { return Objects.hash(abstractLg1, abstractLg2, accrualPeriodicityCode, accrualPeriodicityList, altLabelLg1, altLabelLg2, contributors, creators, historyNoteLg1, historyNoteLg2, id, idSims, isReplacedBy, - prefLabelLg1, prefLabelLg2, publishers, replaces, seeAlso, wasGeneratedBy); + prefLabelLg1, prefLabelLg2, publishers, replaces, seeAlso, wasGeneratedBy,validationState); } @Override @@ -276,7 +287,8 @@ public boolean equals(Object obj) { && Objects.equals(idSims, other.idSims) && Objects.equals(isReplacedBy, other.isReplacedBy) && Objects.equals(prefLabelLg1, other.prefLabelLg1) && Objects.equals(prefLabelLg2, other.prefLabelLg2) && Objects.equals(publishers, other.publishers) && Objects.equals(replaces, other.replaces) - && Objects.equals(seeAlso, other.seeAlso) && Objects.equals(wasGeneratedBy, other.wasGeneratedBy); + && Objects.equals(seeAlso, other.seeAlso) && Objects.equals(wasGeneratedBy, other.wasGeneratedBy) + && Objects.equals(validationState, other.validationState); } From 7317e86a496ac4275f6eeeca92438ef80c9e2ef0 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Wed, 13 Oct 2021 14:03:56 +0200 Subject: [PATCH 07/14] fix: review consultation API for components --- .../ConsultationGestionServiceImpl.java | 12 ++++-------- .../request/consultation-gestion/getComponent.ftlh | 3 ++- .../consultation-gestion/getComponentChildren.ftlh | 5 +++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/consutation_gestion/ConsultationGestionServiceImpl.java b/src/main/java/fr/insee/rmes/bauhaus_services/consutation_gestion/ConsultationGestionServiceImpl.java index 0d168d39e..905658df1 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/consutation_gestion/ConsultationGestionServiceImpl.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/consutation_gestion/ConsultationGestionServiceImpl.java @@ -189,19 +189,15 @@ public String getComponent(String id) throws RmesException { if(component.has("uriComponentParentId")){ JSONObject parent = new JSONObject(); parent.put("id", component.getString("uriComponentParentId")); + parent.put("notation", component.getString("uriComponentParentNotation")); component.remove("uriComponentParentId"); + component.remove("uriComponentParentNotation"); component.put("parent", parent); } JSONArray flatChildren = repoGestion.getResponseAsArray(buildRequest("getComponentChildren.ftlh", params)); - - JSONArray children = new JSONArray(); - for (int i = 0; i < flatChildren.length(); i++) { - String childrenId = flatChildren.getJSONObject(i).getString("uriComponentChildId"); - children.put(new JSONObject().put("id", childrenId)); - } - if(children.length() > 0) { - component.put("children", children); + if(flatChildren.length() > 0) { + component.put("enfants", flatChildren); } if(component.has("statutValidation")){ diff --git a/src/main/resources/request/consultation-gestion/getComponent.ftlh b/src/main/resources/request/consultation-gestion/getComponent.ftlh index 4e32fd6af..e8cdd7f54 100644 --- a/src/main/resources/request/consultation-gestion/getComponent.ftlh +++ b/src/main/resources/request/consultation-gestion/getComponent.ftlh @@ -1,7 +1,7 @@ SELECT ?id (?uriComposant as ?uri) ?type ?notation ?dateMiseAJour ?statutValidation ?prefLabelLg1 ?prefLabelLg2 ?uriConcept ?idConcept ?representation - ?uriListeCode ?idListeCode ?version ?uriComponentParentId + ?uriListeCode ?idListeCode ?version ?uriComponentParentId ?uriComponentParentNotation FROM <${STRUCTURES_COMPONENTS_GRAPH}> FROM <${CODELIST_GRAPH}> WHERE { @@ -34,6 +34,7 @@ WHERE { OPTIONAL { ?uriComposant skos:broader ?uriComponentParent . ?uriComponentParent dcterms:identifier ?uriComponentParentId . + ?uriComponentParent skos:notation ?uriComponentParentNotation . } OPTIONAL { diff --git a/src/main/resources/request/consultation-gestion/getComponentChildren.ftlh b/src/main/resources/request/consultation-gestion/getComponentChildren.ftlh index 8f70dd393..09c562271 100644 --- a/src/main/resources/request/consultation-gestion/getComponentChildren.ftlh +++ b/src/main/resources/request/consultation-gestion/getComponentChildren.ftlh @@ -1,8 +1,9 @@ -SELECT ?uriComponentChildId +SELECT ?id ?notation FROM <${STRUCTURES_COMPONENTS_GRAPH}> FROM <${CODELIST_GRAPH}> WHERE { ?uriComposant dcterms:identifier "${ID}" ; skos:narrower ?uriComponentChild . - ?uriComponentChild dcterms:identifier ?uriComponentChildId . + ?uriComponentChild dcterms:identifier ?id . + ?uriComponentChild skos:notation ?notation . } \ No newline at end of file From 3806839742966c223c5d5b50ddcc3dd55a361cbb Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Thu, 14 Oct 2021 21:48:28 +0200 Subject: [PATCH 08/14] feat: finish geography --- .../geography/GeographyServiceImpl.java | 19 ++++++++++++++----- .../rmes/model/geography/GeoFeature.java | 6 +++--- .../rmes/persistance/ontologies/GEO.java | 10 +++++++--- .../rmes/persistance/ontologies/IGEO.java | 4 +++- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/geography/GeographyServiceImpl.java b/src/main/java/fr/insee/rmes/bauhaus_services/geography/GeographyServiceImpl.java index ad5fce884..91a307692 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/geography/GeographyServiceImpl.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/geography/GeographyServiceImpl.java @@ -11,6 +11,7 @@ import org.eclipse.rdf4j.model.impl.LinkedHashModel; import org.eclipse.rdf4j.model.vocabulary.DCTERMS; import org.eclipse.rdf4j.model.vocabulary.RDF; +import org.eclipse.rdf4j.model.vocabulary.SKOS; import org.json.JSONArray; import org.json.JSONObject; import org.springframework.stereotype.Service; @@ -102,7 +103,7 @@ private void addUnionsAndDifferenceToJsonObject(JSONObject feature) throws RmesE String uriFeature = feature.getString(Constants.URI); JSONArray unions = repoGestion.getResponseAsArray(GeoQueries.getUnionsForAFeatureQuery(uriFeature)); feature.put("unions", unions); - JSONObject diff = repoGestion.getResponseAsObject(GeoQueries.getDifferenceForAFeatureQuery(uriFeature)); + JSONArray diff = repoGestion.getResponseAsArray(GeoQueries.getDifferenceForAFeatureQuery(uriFeature)); feature.put("difference", diff); } @@ -139,15 +140,23 @@ public void createRdfGeoFeature(GeoFeature geoFeature) throws RmesException { } IRI geoIRI = RdfUtils.objectIRI(ObjectType.GEO_STAT_TERRITORY, geoFeature.getId()); /*Const*/ - model.add(geoIRI, RDF.TYPE, GEO.FEATURE, RdfUtils.simsGeographyGraph()); + model.add(geoIRI, RDF.TYPE, IGEO.TERRITOIRE_STATISTIQUE, RdfUtils.simsGeographyGraph()); /*Required*/ - model.add(geoIRI, IGEO.NOM, RdfUtils.setLiteralString(geoFeature.getLabelLg1(), Config.LG1), RdfUtils.simsGeographyGraph()); - model.add(geoIRI, IGEO.CODE_INSEE, RdfUtils.setLiteralString(geoFeature.getCode()), RdfUtils.simsGeographyGraph()); + model.add(geoIRI, SKOS.PREF_LABEL, RdfUtils.setLiteralString(geoFeature.getLabelLg1(), Config.LG1), RdfUtils.simsGeographyGraph()); + /*Optional*/ RdfUtils.addTripleString(geoIRI, IGEO.NOM, geoFeature.getLabelLg2(), Config.LG2, model, RdfUtils.simsGeographyGraph()); RdfUtils.addTripleStringMdToXhtml(geoIRI, DCTERMS.ABSTRACT, geoFeature.getDescriptionLg1(), Config.LG1, model, RdfUtils.simsGeographyGraph()); RdfUtils.addTripleStringMdToXhtml(geoIRI, DCTERMS.ABSTRACT, geoFeature.getDescriptionLg2(), Config.LG2, model, RdfUtils.simsGeographyGraph()); - + + + geoFeature.getUnions().forEach(feature -> { + RdfUtils.addTripleUri(geoIRI, GEO.UNION, feature.getUri(), model, RdfUtils.simsGeographyGraph()); + + }); + geoFeature.getDifference().forEach(feature -> { + RdfUtils.addTripleUri(geoIRI, GEO.DIFFERENCE, feature.getUri(), model, RdfUtils.simsGeographyGraph()); + }); repoGestion.loadSimpleObject(geoIRI, model); } diff --git a/src/main/java/fr/insee/rmes/model/geography/GeoFeature.java b/src/main/java/fr/insee/rmes/model/geography/GeoFeature.java index c1456599d..8bb7a3a16 100644 --- a/src/main/java/fr/insee/rmes/model/geography/GeoFeature.java +++ b/src/main/java/fr/insee/rmes/model/geography/GeoFeature.java @@ -8,7 +8,7 @@ public class GeoFeature { private String labelLg1; private String labelLg2; private List unions; - private GeoFeature difference; + private List difference; private String code; private String uri; private String descriptionLg1; @@ -38,10 +38,10 @@ public List getUnions() { public void setUnions(List unions) { this.unions = unions; } - public GeoFeature getDifference() { + public List getDifference() { return difference; } - public void setDifference(GeoFeature difference) { + public void setDifference(List difference) { this.difference = difference; } diff --git a/src/main/java/fr/insee/rmes/persistance/ontologies/GEO.java b/src/main/java/fr/insee/rmes/persistance/ontologies/GEO.java index 91171bf7e..bdbd91c25 100644 --- a/src/main/java/fr/insee/rmes/persistance/ontologies/GEO.java +++ b/src/main/java/fr/insee/rmes/persistance/ontologies/GEO.java @@ -18,14 +18,18 @@ private GEO() { public static final String PREFIX = "geo"; public static final Namespace NS = new SimpleNamespace(PREFIX, NAMESPACE); - + public static final IRI FEATURE; - + public static final IRI DIFFERENCE; + public static final IRI UNION; + static { final ValueFactory f = SimpleValueFactory.getInstance(); FEATURE = f.createIRI(NAMESPACE, "Feature"); - + DIFFERENCE = f.createIRI(NAMESPACE, "difference"); + UNION = f.createIRI(NAMESPACE, "union"); + } } diff --git a/src/main/java/fr/insee/rmes/persistance/ontologies/IGEO.java b/src/main/java/fr/insee/rmes/persistance/ontologies/IGEO.java index ffafb075a..a60268ede 100644 --- a/src/main/java/fr/insee/rmes/persistance/ontologies/IGEO.java +++ b/src/main/java/fr/insee/rmes/persistance/ontologies/IGEO.java @@ -21,6 +21,7 @@ private IGEO() { public static final IRI NOM; public static final IRI CODE_INSEE; + public static final IRI TERRITOIRE_STATISTIQUE; static { @@ -28,7 +29,8 @@ private IGEO() { NOM = f.createIRI(NAMESPACE, "nom"); CODE_INSEE = f.createIRI(NAMESPACE, "codeINSEE"); - + TERRITOIRE_STATISTIQUE = f.createIRI(NAMESPACE, "TerritoireStatistique"); + } } From f9dc7de5fd206c07f5f5903c3f7bf30fec54ee62 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Mon, 18 Oct 2021 21:48:37 +0200 Subject: [PATCH 09/14] feat: add skos:Collection codelist --- .../consultation-gestion/getCodes.ftlh | 52 +++++++++++++------ .../consultation-gestion/getCodesList.ftlh | 41 ++++++++++----- 2 files changed, 64 insertions(+), 29 deletions(-) diff --git a/src/main/resources/request/consultation-gestion/getCodes.ftlh b/src/main/resources/request/consultation-gestion/getCodes.ftlh index 9c78242df..1cc6c912a 100644 --- a/src/main/resources/request/consultation-gestion/getCodes.ftlh +++ b/src/main/resources/request/consultation-gestion/getCodes.ftlh @@ -1,22 +1,40 @@ SELECT ?uri ?code ?prefLabelLg1 ?prefLabelLg2 ?parents ?ordre FROM <${CODELIST_GRAPH}> WHERE { - ?uriListe rdf:type skos:ConceptScheme . - ?uriListe skos:notation "${NOTATION}" . - ?uri rdf:type skos:Concept . - ?uri skos:inScheme ?uriListe . - ?uri skos:notation ?code . - ?uri skos:prefLabel ?prefLabelLg1 . - FILTER (lang(?prefLabelLg1) = '${LG1}') . - ?uri skos:prefLabel ?prefLabelLg2 . - FILTER (lang(?prefLabelLg2) = '${LG2}') . - OPTIONAL { - ?uri skos:broader ?parentsParent . - ?parentsParent skos:notation ?parents - } . - OPTIONAL { - ?uriListe ?predicatRdfSeq ?uri . - filter(contains(str(?predicatRdfSeq), "http://www.w3.org/1999/02/22-rdf-syntax-ns#_" )) . - bind(strafter(str(?predicatRdfSeq),"http://www.w3.org/1999/02/22-rdf-syntax-ns#_") as ?ordre) . + { + ?uriListe rdf:type skos:ConceptScheme . + ?uriListe skos:notation "${NOTATION}" . + ?uri rdf:type skos:Concept . + ?uri skos:inScheme ?uriListe . + ?uri skos:notation ?code . + ?uri skos:prefLabel ?prefLabelLg1 . + FILTER (lang(?prefLabelLg1) = '${LG1}') . + ?uri skos:prefLabel ?prefLabelLg2 . + FILTER (lang(?prefLabelLg2) = '${LG2}') . + OPTIONAL { + ?uri skos:broader ?parentsParent . + ?parentsParent skos:notation ?parents + } . + OPTIONAL { + ?uriListe ?predicatRdfSeq ?uri . + filter(contains(str(?predicatRdfSeq), "http://www.w3.org/1999/02/22-rdf-syntax-ns#_" )) . + bind(strafter(str(?predicatRdfSeq),"http://www.w3.org/1999/02/22-rdf-syntax-ns#_") as ?ordre) . + } + } + UNION + { + ?uriListe rdf:type skos:Collection . + ?uriListe skos:notation "${NOTATION}" . + ?uriListe skos:member ?uri . + ?uri skos:notation ?code . + ?uri skos:prefLabel ?prefLabelLg1 . + FILTER (lang(?prefLabelLg1) = '${LG1}') . + ?uri skos:prefLabel ?prefLabelLg2 . + FILTER (lang(?prefLabelLg2) = '${LG2}') . + ?uri rdf:type skos:Concept . + OPTIONAL { + ?uri skos:broader ?parentsParent . + ?parentsParent skos:notation ?parents + } . } } \ No newline at end of file diff --git a/src/main/resources/request/consultation-gestion/getCodesList.ftlh b/src/main/resources/request/consultation-gestion/getCodesList.ftlh index c70402b48..503a82522 100644 --- a/src/main/resources/request/consultation-gestion/getCodesList.ftlh +++ b/src/main/resources/request/consultation-gestion/getCodesList.ftlh @@ -1,16 +1,33 @@ SELECT ?uri ?id ?prefLabelLg1 ?prefLabelLg2 ?dateCréation ?dateMiseAJour ?dateFinValidité ?statutValidation ?version FROM <${CODELIST_GRAPH}> WHERE { - ?uri rdf:type skos:ConceptScheme . - ?uri skos:notation "${NOTATION}" . - BIND("${NOTATION}" AS ?id) . - ?uri skos:prefLabel ?prefLabelLg1 . - FILTER (lang(?prefLabelLg1) = '${LG1}') . - ?uri skos:prefLabel ?prefLabelLg2 . - FILTER (lang(?prefLabelLg2) = '${LG2}') . - OPTIONAL {?uri dcterms:created ?dateCréation . } - OPTIONAL {?uri dcterms:modified ?dateMiseAJour . } - OPTIONAL {?uri dcterms:valid ?dateFinValidité . } - OPTIONAL {?uri insee:validationState ?statutValidation . } - OPTIONAL { ?uri pav:version ?version . } + { + ?uri rdf:type skos:ConceptScheme . + ?uri skos:notation "${NOTATION}" . + BIND("${NOTATION}" AS ?id) . + ?uri skos:prefLabel ?prefLabelLg1 . + FILTER (lang(?prefLabelLg1) = '${LG1}') . + ?uri skos:prefLabel ?prefLabelLg2 . + FILTER (lang(?prefLabelLg2) = '${LG2}') . + OPTIONAL {?uri dcterms:created ?dateCréation . } + OPTIONAL {?uri dcterms:modified ?dateMiseAJour . } + OPTIONAL {?uri dcterms:valid ?dateFinValidité . } + OPTIONAL {?uri insee:validationState ?statutValidation . } + OPTIONAL { ?uri pav:version ?version . } + } + UNION + { + ?uri rdf:type skos:Collection . + ?uri skos:notation "${NOTATION}" . + BIND("${NOTATION}" AS ?id) . + ?uri skos:prefLabel ?prefLabelLg1 . + FILTER (lang(?prefLabelLg1) = '${LG1}') . + ?uri skos:prefLabel ?prefLabelLg2 . + FILTER (lang(?prefLabelLg2) = '${LG2}') . + OPTIONAL {?uri dcterms:created ?dateCréation . } + OPTIONAL {?uri dcterms:modified ?dateMiseAJour . } + OPTIONAL {?uri dcterms:valid ?dateFinValidité . } + OPTIONAL {?uri insee:validationState ?statutValidation . } + OPTIONAL { ?uri pav:version ?version . } + } } \ No newline at end of file From 9a972c0666d8322078f0b9c158160605111311cf Mon Sep 17 00:00:00 2001 From: BulotF Date: Tue, 19 Oct 2021 09:48:22 +0200 Subject: [PATCH 10/14] Update rmesPatternContent.xml --- .../xslTransformerFiles/simsRmes/rmesPatternContent.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/xslTransformerFiles/simsRmes/rmesPatternContent.xml b/src/main/resources/xslTransformerFiles/simsRmes/rmesPatternContent.xml index 138b92af1..942ae0a1e 100644 --- a/src/main/resources/xslTransformerFiles/simsRmes/rmesPatternContent.xml +++ b/src/main/resources/xslTransformerFiles/simsRmes/rmesPatternContent.xml @@ -519,7 +519,7 @@ Organismes responsables - #list(${indicator/publishers},'L1') + #list(${indicator/publishers/labelLg1},'L1') @@ -531,7 +531,7 @@ Partenaires - #list(${indicator/contributors},'L1') + #list(${indicator/contributors/labelLg1},'L1') From 444196f854a71245456a862a19a0c905104fb32f Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Wed, 20 Oct 2021 23:48:32 +0200 Subject: [PATCH 11/14] fix: get serie creator when fetching sims of an operation --- .../series/getSeriesCreatorsByUriQuery.ftlh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/resources/request/operations/series/getSeriesCreatorsByUriQuery.ftlh b/src/main/resources/request/operations/series/getSeriesCreatorsByUriQuery.ftlh index 1892dd947..941a23ff1 100644 --- a/src/main/resources/request/operations/series/getSeriesCreatorsByUriQuery.ftlh +++ b/src/main/resources/request/operations/series/getSeriesCreatorsByUriQuery.ftlh @@ -1,6 +1,13 @@ SELECT ?creators FROM <${OPERATIONS_GRAPH}> - WHERE { - ?series dc:creator ?creators . - VALUES ?series { <${URI_SERIES}>} + WHERE { + { + ?series dc:creator ?creators . + VALUES ?series { <${URI_SERIES}>} + } + UNION + { + ?series dc:creator ?creators . + ?series dcterms:hasPart <${URI_SERIES}> + } } \ No newline at end of file From 163f2a45db67630d4c9cd46f3cd0db6f0073f4e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Bourgeois?= Date: Thu, 21 Oct 2021 13:21:02 +0200 Subject: [PATCH 12/14] Fix : Recovery of "France" in "Geo\Pays" Fix to respect the updated ontology "GEO" : "France" is now a "Country" and not a "FrenchTerritory" anymore. --- .../resources/request/geography/getGeoFeatures.ftlh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/resources/request/geography/getGeoFeatures.ftlh b/src/main/resources/request/geography/getGeoFeatures.ftlh index f248754fd..1188860c5 100644 --- a/src/main/resources/request/geography/getGeoFeatures.ftlh +++ b/src/main/resources/request/geography/getGeoFeatures.ftlh @@ -37,7 +37,15 @@ FROM <${GEO_SIMS_GRAPH}> ?uri a igeo:TerritoireFrancais . BIND("Territoire Français" AS ?typeTerritory) - } + } + UNION + + { + ?uri rdfs:label ?labelLg1 . + ?uri a igeo:Pays . + BIND("pays" AS ?typeTerritory) + + } BIND(REPLACE( STR(?uri) , '(.*/)(\\w.*$)', '$2' ) AS ?id) From 6dbff7a8ded664171590abebbf764ed915b5dbc2 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Tue, 26 Oct 2021 09:29:50 +0200 Subject: [PATCH 13/14] fix: return uri when creating a new geography --- .../bauhaus_services/geography/GeographyServiceImpl.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/geography/GeographyServiceImpl.java b/src/main/java/fr/insee/rmes/bauhaus_services/geography/GeographyServiceImpl.java index 91a307692..afeeb95cb 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/geography/GeographyServiceImpl.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/geography/GeographyServiceImpl.java @@ -125,12 +125,12 @@ public String createFeature(String body) throws RmesException { } catch (IOException e) { logger.error(e.getMessage()); } - createRdfGeoFeature(geoFeature); + String iri = createRdfGeoFeature(geoFeature); logger.info("Create geofeature : {} - {}", id , geoFeature.getLabelLg1()); - return id.toString(); + return iri; } - public void createRdfGeoFeature(GeoFeature geoFeature) throws RmesException { + public String createRdfGeoFeature(GeoFeature geoFeature) throws RmesException { Model model = new LinkedHashModel(); if (geoFeature == null || StringUtils.isEmpty(geoFeature.getId())) { throw new RmesNotFoundException(ErrorCodes.GEOFEATURE_UNKNOWN, "No uri found", CAN_T_READ_REQUEST_BODY); @@ -158,6 +158,8 @@ public void createRdfGeoFeature(GeoFeature geoFeature) throws RmesException { RdfUtils.addTripleUri(geoIRI, GEO.DIFFERENCE, feature.getUri(), model, RdfUtils.simsGeographyGraph()); }); repoGestion.loadSimpleObject(geoIRI, model); + + return geoIRI.toString(); } } From e88159fe8c023f1fcfaf98b22db7c60c59d85034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Bourgeois?= Date: Thu, 4 Nov 2021 11:18:54 +0100 Subject: [PATCH 14/14] release3.0.9 --- bauhaus-back-changeLog.txt | 5 +++++ pom.xml | 2 +- .../java/fr/insee/rmes/config/swagger/SwaggerConfig.java | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bauhaus-back-changeLog.txt b/bauhaus-back-changeLog.txt index 995b1a4a8..015c41e89 100644 --- a/bauhaus-back-changeLog.txt +++ b/bauhaus-back-changeLog.txt @@ -1,3 +1,8 @@ +3.0.9 : - Amélioration de la consultation: Ajout des parents/enfants + - Fin des développements pour "Géographie" + - Correction d'un bug lors de l'exportation des indicateurs en odt + - Récupération du créateur de la série lors de l'appel depuis une de ses opérations + - Prise en compte du changement de l'ontologie "Géographie" pour "France" (GEO\Pays) 3.0.8 : - Suppression de la page blanche à la première connexion - Titres spécifiques aux pages (pour l'historique des navigateurs notamment) - Améliorations des sims : diff --git a/pom.xml b/pom.xml index c089ce43b..7e91a8a91 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ fr.insee.rmes Bauhaus-BO war - 3.0.8 + 3.0.9 Bauhaus-Back-Office Back-office services for Bauhaus https://github.com/InseeFr/Bauhaus-Back-Office diff --git a/src/main/java/fr/insee/rmes/config/swagger/SwaggerConfig.java b/src/main/java/fr/insee/rmes/config/swagger/SwaggerConfig.java index bb78d47aa..109223c2b 100644 --- a/src/main/java/fr/insee/rmes/config/swagger/SwaggerConfig.java +++ b/src/main/java/fr/insee/rmes/config/swagger/SwaggerConfig.java @@ -30,7 +30,7 @@ public SwaggerConfig(@Context ServletConfig servletConfig) { super(); OpenAPI openApi = new OpenAPI(); - Info info = new Info().title("Bauhaus API").version("3.0.8").description("Rest Endpoints and services Integration used by Bauhaus"); + Info info = new Info().title("Bauhaus API").version("3.0.9").description("Rest Endpoints and services Integration used by Bauhaus"); openApi.info(info); Server server = new Server();