From 941972e725363835aacd86a87c67b4ca0fc4680e Mon Sep 17 00:00:00 2001 From: HugoBouttes Date: Thu, 13 Feb 2025 09:13:09 +0100 Subject: [PATCH 01/10] fix : new queries for pays --- .../request/geographie/pays/getPays.ftlh | 29 +++++++++++++++++ .../geographie/pays/getPaysDescendants.ftlh | 32 +++++++++++++++++++ .../geographie/pays/getPaysPrecedents.ftlh | 29 +++++++++++++++++ .../geographie/pays/getPaysSuivants.ftlh | 30 +++++++++++++++++ 4 files changed, 120 insertions(+) create mode 100644 src/main/resources/request/geographie/pays/getPays.ftlh create mode 100644 src/main/resources/request/geographie/pays/getPaysDescendants.ftlh create mode 100644 src/main/resources/request/geographie/pays/getPaysPrecedents.ftlh create mode 100644 src/main/resources/request/geographie/pays/getPaysSuivants.ftlh diff --git a/src/main/resources/request/geographie/pays/getPays.ftlh b/src/main/resources/request/geographie/pays/getPays.ftlh new file mode 100644 index 00000000..a869a47d --- /dev/null +++ b/src/main/resources/request/geographie/pays/getPays.ftlh @@ -0,0 +1,29 @@ +SELECT DISTINCT ?uri ?type ?code ?nom ?nomLong ?iso3166alpha2 ?iso3166alpha3 ?iso3166num ?dateCreation ?dateSuppression +FROM +WHERE { + ?s a igeo:Pays . +<#if code != "none"> + ?s igeo:codeINSEE '${code}' . + BIND('${code}' as ?code) + ?s a ?typeRDF ; +<#else> + ?s igeo:codeINSEE ?code ; + a ?typeRDF ; + + igeo:nom ?nom . + OPTIONAL {?s igeo:nomLong ?nomLong .} + OPTIONAL {?s igeo:codeIso3166alpha2 ?iso3166alpha2 .} + OPTIONAL {?s igeo:codeIso3166alpha3 ?iso3166alpha3 .} + OPTIONAL {?s igeo:codeIso3166num ?iso3166num .} + BIND(STR(?typeRDF) AS ?type). + BIND(STR(?s) AS ?uri). + OPTIONAL {?s ^igeo:creation/igeo:date ?dateCreation } + OPTIONAL {?s ^igeo:suppression/igeo:date ?dateSuppression } + +<#if date != "*"> + FILTER(!BOUND(?dateCreation) || ?dateCreation <= '${date}'^^xsd:date) + FILTER(!BOUND(?dateSuppression) || ?dateSuppression > '${date}'^^xsd:date) + +} + +ORDER BY ?code diff --git a/src/main/resources/request/geographie/pays/getPaysDescendants.ftlh b/src/main/resources/request/geographie/pays/getPaysDescendants.ftlh new file mode 100644 index 00000000..41d510dd --- /dev/null +++ b/src/main/resources/request/geographie/pays/getPaysDescendants.ftlh @@ -0,0 +1,32 @@ +SELECT ?uri ?type ?code ?nom ?nomLong ?dateCreation ?dateSuppression +FROM +WHERE { +{ +SELECT DISTINCT ?uri ?type ?code ?nom ?nomLong ?dateCreation ?dateSuppression ?dateCreationParent ?dateSuppressionParent +WHERE { + ?parent a igeo:Pays ; + igeo:codeINSEE '${code}' ; + + (^igeo:subdivisionDirecteDe)+ ?ressource . + +<#if type != "none"> + ?ressource a ?typeRDF . + ?ressource a igeo:${type} ; +<#else> + ?ressource a ?typeRDF ; + + igeo:codeINSEE ?code ; + igeo:nom ?nom ; + OPTIONAL {?ressource igeo:nomLong ?nomLong .} + BIND(STR(?typeRDF) AS ?type). + BIND(STR(?ressource) AS ?uri). + OPTIONAL {?parent (^igeo:creation/igeo:date) ?dateCreationParent.} + OPTIONAL {?parent (^igeo:suppression/igeo:date) ?dateSuppressionParent.} + OPTIONAL {?ressource (^igeo:creation/igeo:date) ?dateCreation.} + OPTIONAL {?ressource (^igeo:suppression/igeo:date) ?dateSuppression.} + } + } + FILTER(!BOUND(?dateCreation) || ?dateCreation <= '${date}'^^xsd:date) + FILTER(!BOUND(?dateSuppression) || ?dateSuppression > '${date}'^^xsd:date) +} +ORDER BY ?type ?code \ No newline at end of file diff --git a/src/main/resources/request/geographie/pays/getPaysPrecedents.ftlh b/src/main/resources/request/geographie/pays/getPaysPrecedents.ftlh new file mode 100644 index 00000000..25d7d1e2 --- /dev/null +++ b/src/main/resources/request/geographie/pays/getPaysPrecedents.ftlh @@ -0,0 +1,29 @@ +SELECT ?uri ?type ?code ?nom ?nomLong ?iso3166alpha2 ?iso3166alpha3 ?iso3166num ?dateCreation ?dateSuppression +WHERE { +{ +SELECT DISTINCT ?origine ?evenement (?dateCreationOrigine AS ?dateSuppression) +WHERE { +?origine a igeo:Pays ; +igeo:codeINSEE '${code}' . +?evenement igeo:creation ?origine; +igeo:date ?dateCreationOrigine. +OPTIONAL {?origine (^igeo:suppression/igeo:date) ?dateSuppressionOrigine.} +FILTER(!BOUND(?dateCreation) || ?dateCreation <= '${date}'^^xsd:date) +FILTER(!BOUND(?dateSuppression) || ?dateSuppression > '${date}'^^xsd:date) +} +} +?evenement igeo:suppression ?ressource . +?ressource a ?typeRDF ; +a igeo:Pays ; +igeo:codeINSEE ?code ; +igeo:codeArticle ?typeArticle; +igeo:nom ?nom. +OPTIONAL {?ressource igeo:nomLong ?nomLong .} +OPTIONAL {?ressource igeo:codeIso3166alpha2 ?iso3166alpha2 .} +OPTIONAL {?ressource igeo:codeIso3166alpha3 ?iso3166alpha3 .} +OPTIONAL {?ressource igeo:codeIso3166num ?iso3166num .} +BIND(STR(?typeRDF) AS ?type). +BIND(STR(?ressource) AS ?uri). +OPTIONAL { ?ressource (^igeo:creation/igeo:date) ?dateCreation.} +} +ORDER BY ?code \ No newline at end of file diff --git a/src/main/resources/request/geographie/pays/getPaysSuivants.ftlh b/src/main/resources/request/geographie/pays/getPaysSuivants.ftlh new file mode 100644 index 00000000..f7851fd5 --- /dev/null +++ b/src/main/resources/request/geographie/pays/getPaysSuivants.ftlh @@ -0,0 +1,30 @@ +SELECT ?uri ?type ?code ?nom ?nomLong ?iso3166alpha2 ?iso3166alpha3 ?iso3166num ?dateCreation ?dateSuppression +WHERE { +{ +# Sélection de la ressource d'origine (et de son événement destructeur) +SELECT DISTINCT ?origine ?evenement (?dateSuppressionOrigine AS ?dateCreation) +WHERE { +?origine a igeo:Pays ; +igeo:codeINSEE '${code}' . +?evenement igeo:suppression ?origine; +igeo:date ?dateSuppressionOrigine. +OPTIONAL {?origine (^igeo:creation/igeo:date) ?dateCreationOrigine.} +FILTER(!BOUND(?dateCreationOrigine) || ?dateCreationOrigine <= '${date}'^^xsd:date) +FILTER(!BOUND(?dateSuppressionOrigine) || ?dateSuppressionOrigine > '${date}'^^xsd:date) +} +} +?evenement igeo:creation ?ressource . +?ressource a ?typeRDF ; +a igeo:Pays ; +igeo:codeINSEE ?code ; +igeo:codeArticle ?typeArticle; +igeo:nom ?nom. +OPTIONAL {?ressource igeo:nomLong ?nomLong .} +OPTIONAL {?ressource igeo:codeIso3166alpha2 ?iso3166alpha2 .} +OPTIONAL {?ressource igeo:codeIso3166alpha3 ?iso3166alpha3 .} +OPTIONAL {?ressource igeo:codeIso3166num ?iso3166num .} +BIND(STR(?typeRDF) AS ?type). +BIND(STR(?ressource) AS ?uri). +OPTIONAL { ?ressource (^igeo:suppression/igeo:date) ?dateSuppression.} +} +ORDER BY ?code \ No newline at end of file From 7c3c5fde94cfc3700423c3336bd175d86cd8ada8 Mon Sep 17 00:00:00 2001 From: Hugo Bouttes Date: Thu, 13 Feb 2025 10:27:30 +0100 Subject: [PATCH 02/10] fix : change in pays queries architecture --- .../fr/insee/rmes/api/geo/ConstGeoApi.java | 2 +- .../rmes/modeles/geo/EnumTypeGeographie.java | 4 +- .../rmes/modeles/geo/territoire/Pays.java | 54 +++++++++++-------- .../fr/insee/rmes/queries/geo/GeoQueries.java | 52 +++++++++++++++--- src/main/resources/rmes-api.properties | 12 +++-- 5 files changed, 90 insertions(+), 34 deletions(-) diff --git a/src/main/java/fr/insee/rmes/api/geo/ConstGeoApi.java b/src/main/java/fr/insee/rmes/api/geo/ConstGeoApi.java index f44f0ba1..c96272e5 100644 --- a/src/main/java/fr/insee/rmes/api/geo/ConstGeoApi.java +++ b/src/main/java/fr/insee/rmes/api/geo/ConstGeoApi.java @@ -31,7 +31,7 @@ public class ConstGeoApi { public static final String PATH_BASSINDEVIE= PATH_SEPARATOR + "bassinDeVie2022"; public static final String PATH_LISTE_IRIS = PATH_SEPARATOR + "iris"; public static final String PATH_LISTE_COMMUNE = PATH_SEPARATOR + "communes"; - public static final String PATH_LISTE_PAYS = PATH_SEPARATOR + "pays"; + public static final String PATH_LISTE_PAYS = PATH_SEPARATOR + "payss"; public static final String PATH_LISTE_CANTON = PATH_SEPARATOR + "cantons"; public static final String PATH_LISTE_REGION = PATH_SEPARATOR + "regions"; public static final String PATH_LISTE_DEPARTEMENT = PATH_SEPARATOR + "departements"; diff --git a/src/main/java/fr/insee/rmes/modeles/geo/EnumTypeGeographie.java b/src/main/java/fr/insee/rmes/modeles/geo/EnumTypeGeographie.java index ed1d3e66..5638f928 100644 --- a/src/main/java/fr/insee/rmes/modeles/geo/EnumTypeGeographie.java +++ b/src/main/java/fr/insee/rmes/modeles/geo/EnumTypeGeographie.java @@ -27,7 +27,9 @@ public enum EnumTypeGeographie { INTERCOMMUNALITE("Intercommunalite",Intercommunalite.class,Intercommunalites.class,Constants.NONE), BASSINDEVIE("BassinDeVie2022",BassinDeVie2022.class,BassinsDeVie2022.class,Constants.NONE), IRIS("Iris", Iris.class,Iriss.class,Constants.NONE), - PAYS("Pays", Pays.class, PaysS.class,Constants.NONE); + PAYS("Pays", Pays.class, PaysS.class,Constants.NONE), + TERRITOIRE("Territoire",Territoire.class,Territoires.class,Constants.NONE); + private String typeObjetGeo; private Class classNameOfGeoType; diff --git a/src/main/java/fr/insee/rmes/modeles/geo/territoire/Pays.java b/src/main/java/fr/insee/rmes/modeles/geo/territoire/Pays.java index 0848faa5..899a24a3 100644 --- a/src/main/java/fr/insee/rmes/modeles/geo/territoire/Pays.java +++ b/src/main/java/fr/insee/rmes/modeles/geo/territoire/Pays.java @@ -18,14 +18,24 @@ @Schema(description = "Objet représentant un pays") public class Pays extends Territoire { - @Schema(example = "99254") + @Schema(example = "99100") private String code = null; - @Schema(example = "http://id.insee.fr/geo/pays/99254") + @Schema(example ="http://id.insee.fr/geo/pays/b7e3f0c9-b653-4a3e-904a-de63b80e108b") private String uri = null; - @Schema(example = "CHYPRE") - private String intitule = null; - @Schema(example = "RÉPUBLIQUE DE CHYPRE") - private String intituleEntier = null; + @Schema(example = "France") + private String nom = null; + @Schema(example = "République française") + private String nomLong = null; + @Schema(example = "FR") + private String iso3166alpha2 = null; + @Schema(example = "FRA") + private String iso3166alpha3 = null; + @Schema(example = "250") + private String iso3166num = null; + @Schema(example = "1943-01-01") + private String dateCreation = null; + @Schema(example = "2025-12-12") + private String dateSuppresion = null; public Pays() {} // No-args constructor needed for JAXB @@ -53,25 +63,27 @@ public void setUri(String uri) { this.uri = uri; } - @XmlElement(name = "Intitule") - @JacksonXmlProperty(localName = "Intitule") - @JsonProperty(value = "intitule") - public String getIntitule() { - return intitule; - } - public void setIntitule(String intitule) { - this.intitule = intitule; + @XmlElement(name = "Nom") + @JacksonXmlProperty(localName = "Nom") + @JsonProperty(value = "nom") + + public String getNom() { + return nom; } + public void setNom(String nom) { + this.nom = nom; + } + + @XmlElement(name = "NomLong") + @JacksonXmlProperty(localName = "NomLong") + @JsonProperty(value = "nomLong") - @XmlElement(name = "IntituleEntier") - @JacksonXmlProperty(localName = "IntituleEntier") - @JsonProperty(value = "intituleEntier") - public String getIntituleEntier() { - return intituleEntier; + public String getNomLong() { + return nomLong; } - public void setIntituleEntier(String intituleEntier) { - this.intituleEntier = intituleEntier; + public void setNomLong(String nomLong) { + this.nomLong = nomLong; } } diff --git a/src/main/java/fr/insee/rmes/queries/geo/GeoQueries.java b/src/main/java/fr/insee/rmes/queries/geo/GeoQueries.java index 86f55435..9f9eeacf 100644 --- a/src/main/java/fr/insee/rmes/queries/geo/GeoQueries.java +++ b/src/main/java/fr/insee/rmes/queries/geo/GeoQueries.java @@ -17,6 +17,7 @@ public class GeoQueries extends Queries { private static final String TYPE_ORIGINE = "typeOrigine"; private static final String PREVIOUS = "previous"; private static final String QUERIES_FOLDER = "geographie/"; + private static final String QUERIES_PAYS_FOLDER = "geographie/pays/"; private static final String FILTRE = "filtreNom"; private static final String COM = "com"; @@ -34,6 +35,10 @@ public static String getUniteUrbaineByCodeAndDate(String code, String date) { public static String getAireAttractionByCodeAndDate(String code, String date) { return getTerritoire(code, date, EnumTypeGeographie.AIRE_ATTRACTION); } + + public static String getPaysByCodeAndDate(String code, String date) { + return getPays(code, date); + } public static String getCommuneByCodeAndDate(String code, String date) { return getTerritoire(code, date, EnumTypeGeographie.COMMUNE); @@ -137,7 +142,7 @@ public static String getListAiresAttraction(String date) { } public static String getListPays(String date) { - return getTerritoire(Constants.NONE, date, EnumTypeGeographie.PAYS); + return getPays(Constants.NONE,date); } public static String getListUnitesUrbaines(String date) { @@ -235,7 +240,11 @@ public static String getDescendantsAireAttraction(String code, String date, Stri } public static String getDescendantsPays(String code, String date, String type) { - return getAscendantOrDescendantsQuery(code, date, type, EnumTypeGeographie.PAYS,Constants.ABSENT,Constants.NONE, false); + Map params = buildCodeAndDateParams(code, date); + params.put(TYPE, type); + params.put(TYPE_ORIGINE, EnumTypeGeographie.PAYS); + params.put(COM,Constants.NONE); + return buildRequest(QUERIES_PAYS_FOLDER, "getPaysDescendants.ftlh", params); } public static String getDescendantsUniteUrbaine(String code, String date, String type) { @@ -275,7 +284,7 @@ public static String getNextRegion(String code, String date) { } public static String getNextPays(String code, String date) { - return getPreviousOrNextQuery(code, date, EnumTypeGeographie.PAYS, false); + return getNextPaysQuery(code,date); } public static String getNextCantonOuVille(String code, String date) { @@ -307,7 +316,7 @@ public static String getPreviousRegion(String code, String date) { return getPreviousOrNextQuery(code, date, EnumTypeGeographie.REGION, true); } public static String getPreviousPays(String code, String date) { - return getPreviousOrNextQuery(code, date, EnumTypeGeographie.PAYS, true); + return getPreviousPaysQuery(code, date); } public static String getPreviousCanton(String code, String date) { @@ -444,7 +453,11 @@ private static String getAscendantOrDescendantsQuery( params.put(ASCENDANT, String.valueOf(ascendant)); if(code.matches("^.{5}0000$") && typeOrigine.getTypeObjetGeo().equals("Iris")) { return buildRequest(QUERIES_FOLDER, "getAscendantsIrisByCodeTypeDate.ftlh", params); - } else { + } + if(code.matches("·{99}000$")&& typeOrigine.getTypeObjetGeo().equals("PAYS")) { + return buildRequest(QUERIES_PAYS_FOLDER, "getPaysDescendants.ftlh", params); + } + else { return buildRequest(QUERIES_FOLDER, "getAscendantsOrDescendantsByCodeTypeDate.ftlh", params); } @@ -461,10 +474,23 @@ private static String getPreviousOrNextQuery( return buildRequest(QUERIES_FOLDER, "getPreviousOrNextByCodeTypeDate.ftlh", params); } + + private static String getPreviousPaysQuery(String code,String date) { + Map params = buildCodeAndDateParams(code, date); + return buildRequest(QUERIES_PAYS_FOLDER, "getPaysPrecedents.ftlh", params); + } + + private static String getNextPaysQuery(String code,String date) { + Map params = buildCodeAndDateParams(code, date); + return buildRequest(QUERIES_PAYS_FOLDER, "getPaysSuivants.ftlh", params); + } + + private static String getTerritoire(String code, String date, EnumTypeGeographie typeGeo) { if (typeGeo == EnumTypeGeographie.IRIS && code !="none") { return getIris(code, date,typeGeo); - } else{ + } + else{ return getTerritoireFiltre(code, date, Constants.ABSENT, typeGeo, true); } } @@ -502,6 +528,13 @@ private static String getTerritoireFiltre(String code, String date, String filtr return buildRequest(QUERIES_FOLDER, "getTerritoireByCodeDateNomcommune.ftlh", params); } + private static String getPays(String code, String date) { + Map params = new HashMap<>(); + params.put(CODE, code); + params.put(DATE, date); + return buildRequest(QUERIES_PAYS_FOLDER, "getPays.ftlh", params); + } + private static Map buildCodeAndDateAndFilterParams(String code, String date, String filtreNom, boolean com) { Map params = new HashMap<>(); params.put(CODE, code); @@ -511,7 +544,11 @@ private static Map buildCodeAndDateAndFilterParams(String code, return params; } - public static String getPays(String code) { + + + + + public static String getPaysOLD(String code) { return String.format( "SELECT ?uri ?intitule ?intituleEntier ?code \n" + "FROM \n" @@ -527,4 +564,5 @@ public static String getPays(String code) { } + } diff --git a/src/main/resources/rmes-api.properties b/src/main/resources/rmes-api.properties index 95f5a446..d47f585a 100644 --- a/src/main/resources/rmes-api.properties +++ b/src/main/resources/rmes-api.properties @@ -1,13 +1,17 @@ # log -fr.insee.rmes.api.log.configuration = log4j2.xml +fr.insee.rmes.api.log.configuration = rmes-api.log # database -fr.insee.rmes.api.sparqlEndpoint = XXXXX -fr.insee.rmes.api.baseHost = http://id.insee.fr +#fr.insee.rmes.api.sparqlEndpoint = XXXXX +#fr.insee.rmes.api.baseHost = http://id.insee.fr +##database +fr.insee.rmes.api.sparqlEndpoint = https://gestion-metadonnees-rdf.demo.insee.io//data +fr.insee.rmes.api.baseHost = /api + # files storage # physical place -fr.insee.rmes.api.storage.document = C:/Temp/metadata-api +#fr.insee.rmes.api.storage.document = C:/Temp/metadata-api # just the short name after physical place for documents fr.insee.rmes.api.fileStorage = /storage/documents/ From 1ab99c9a4358353f6074910a4aeaa7aade39a7db Mon Sep 17 00:00:00 2001 From: Hugo Bouttes Date: Thu, 13 Feb 2025 10:29:05 +0100 Subject: [PATCH 03/10] Revert "fix : change in pays queries architecture" This reverts commit 7c3c5fde94cfc3700423c3336bd175d86cd8ada8. --- .../fr/insee/rmes/api/geo/ConstGeoApi.java | 2 +- .../rmes/modeles/geo/EnumTypeGeographie.java | 4 +- .../rmes/modeles/geo/territoire/Pays.java | 54 ++++++++----------- .../fr/insee/rmes/queries/geo/GeoQueries.java | 52 +++--------------- src/main/resources/rmes-api.properties | 12 ++--- 5 files changed, 34 insertions(+), 90 deletions(-) diff --git a/src/main/java/fr/insee/rmes/api/geo/ConstGeoApi.java b/src/main/java/fr/insee/rmes/api/geo/ConstGeoApi.java index c96272e5..f44f0ba1 100644 --- a/src/main/java/fr/insee/rmes/api/geo/ConstGeoApi.java +++ b/src/main/java/fr/insee/rmes/api/geo/ConstGeoApi.java @@ -31,7 +31,7 @@ public class ConstGeoApi { public static final String PATH_BASSINDEVIE= PATH_SEPARATOR + "bassinDeVie2022"; public static final String PATH_LISTE_IRIS = PATH_SEPARATOR + "iris"; public static final String PATH_LISTE_COMMUNE = PATH_SEPARATOR + "communes"; - public static final String PATH_LISTE_PAYS = PATH_SEPARATOR + "payss"; + public static final String PATH_LISTE_PAYS = PATH_SEPARATOR + "pays"; public static final String PATH_LISTE_CANTON = PATH_SEPARATOR + "cantons"; public static final String PATH_LISTE_REGION = PATH_SEPARATOR + "regions"; public static final String PATH_LISTE_DEPARTEMENT = PATH_SEPARATOR + "departements"; diff --git a/src/main/java/fr/insee/rmes/modeles/geo/EnumTypeGeographie.java b/src/main/java/fr/insee/rmes/modeles/geo/EnumTypeGeographie.java index 5638f928..ed1d3e66 100644 --- a/src/main/java/fr/insee/rmes/modeles/geo/EnumTypeGeographie.java +++ b/src/main/java/fr/insee/rmes/modeles/geo/EnumTypeGeographie.java @@ -27,9 +27,7 @@ public enum EnumTypeGeographie { INTERCOMMUNALITE("Intercommunalite",Intercommunalite.class,Intercommunalites.class,Constants.NONE), BASSINDEVIE("BassinDeVie2022",BassinDeVie2022.class,BassinsDeVie2022.class,Constants.NONE), IRIS("Iris", Iris.class,Iriss.class,Constants.NONE), - PAYS("Pays", Pays.class, PaysS.class,Constants.NONE), - TERRITOIRE("Territoire",Territoire.class,Territoires.class,Constants.NONE); - + PAYS("Pays", Pays.class, PaysS.class,Constants.NONE); private String typeObjetGeo; private Class classNameOfGeoType; diff --git a/src/main/java/fr/insee/rmes/modeles/geo/territoire/Pays.java b/src/main/java/fr/insee/rmes/modeles/geo/territoire/Pays.java index 899a24a3..0848faa5 100644 --- a/src/main/java/fr/insee/rmes/modeles/geo/territoire/Pays.java +++ b/src/main/java/fr/insee/rmes/modeles/geo/territoire/Pays.java @@ -18,24 +18,14 @@ @Schema(description = "Objet représentant un pays") public class Pays extends Territoire { - @Schema(example = "99100") + @Schema(example = "99254") private String code = null; - @Schema(example ="http://id.insee.fr/geo/pays/b7e3f0c9-b653-4a3e-904a-de63b80e108b") + @Schema(example = "http://id.insee.fr/geo/pays/99254") private String uri = null; - @Schema(example = "France") - private String nom = null; - @Schema(example = "République française") - private String nomLong = null; - @Schema(example = "FR") - private String iso3166alpha2 = null; - @Schema(example = "FRA") - private String iso3166alpha3 = null; - @Schema(example = "250") - private String iso3166num = null; - @Schema(example = "1943-01-01") - private String dateCreation = null; - @Schema(example = "2025-12-12") - private String dateSuppresion = null; + @Schema(example = "CHYPRE") + private String intitule = null; + @Schema(example = "RÉPUBLIQUE DE CHYPRE") + private String intituleEntier = null; public Pays() {} // No-args constructor needed for JAXB @@ -63,27 +53,25 @@ public void setUri(String uri) { this.uri = uri; } - - @XmlElement(name = "Nom") - @JacksonXmlProperty(localName = "Nom") - @JsonProperty(value = "nom") - - public String getNom() { - return nom; - } - public void setNom(String nom) { - this.nom = nom; + @XmlElement(name = "Intitule") + @JacksonXmlProperty(localName = "Intitule") + @JsonProperty(value = "intitule") + public String getIntitule() { + return intitule; } - @XmlElement(name = "NomLong") - @JacksonXmlProperty(localName = "NomLong") - @JsonProperty(value = "nomLong") + public void setIntitule(String intitule) { + this.intitule = intitule; + } - public String getNomLong() { - return nomLong; + @XmlElement(name = "IntituleEntier") + @JacksonXmlProperty(localName = "IntituleEntier") + @JsonProperty(value = "intituleEntier") + public String getIntituleEntier() { + return intituleEntier; } - public void setNomLong(String nomLong) { - this.nomLong = nomLong; + public void setIntituleEntier(String intituleEntier) { + this.intituleEntier = intituleEntier; } } diff --git a/src/main/java/fr/insee/rmes/queries/geo/GeoQueries.java b/src/main/java/fr/insee/rmes/queries/geo/GeoQueries.java index 9f9eeacf..86f55435 100644 --- a/src/main/java/fr/insee/rmes/queries/geo/GeoQueries.java +++ b/src/main/java/fr/insee/rmes/queries/geo/GeoQueries.java @@ -17,7 +17,6 @@ public class GeoQueries extends Queries { private static final String TYPE_ORIGINE = "typeOrigine"; private static final String PREVIOUS = "previous"; private static final String QUERIES_FOLDER = "geographie/"; - private static final String QUERIES_PAYS_FOLDER = "geographie/pays/"; private static final String FILTRE = "filtreNom"; private static final String COM = "com"; @@ -35,10 +34,6 @@ public static String getUniteUrbaineByCodeAndDate(String code, String date) { public static String getAireAttractionByCodeAndDate(String code, String date) { return getTerritoire(code, date, EnumTypeGeographie.AIRE_ATTRACTION); } - - public static String getPaysByCodeAndDate(String code, String date) { - return getPays(code, date); - } public static String getCommuneByCodeAndDate(String code, String date) { return getTerritoire(code, date, EnumTypeGeographie.COMMUNE); @@ -142,7 +137,7 @@ public static String getListAiresAttraction(String date) { } public static String getListPays(String date) { - return getPays(Constants.NONE,date); + return getTerritoire(Constants.NONE, date, EnumTypeGeographie.PAYS); } public static String getListUnitesUrbaines(String date) { @@ -240,11 +235,7 @@ public static String getDescendantsAireAttraction(String code, String date, Stri } public static String getDescendantsPays(String code, String date, String type) { - Map params = buildCodeAndDateParams(code, date); - params.put(TYPE, type); - params.put(TYPE_ORIGINE, EnumTypeGeographie.PAYS); - params.put(COM,Constants.NONE); - return buildRequest(QUERIES_PAYS_FOLDER, "getPaysDescendants.ftlh", params); + return getAscendantOrDescendantsQuery(code, date, type, EnumTypeGeographie.PAYS,Constants.ABSENT,Constants.NONE, false); } public static String getDescendantsUniteUrbaine(String code, String date, String type) { @@ -284,7 +275,7 @@ public static String getNextRegion(String code, String date) { } public static String getNextPays(String code, String date) { - return getNextPaysQuery(code,date); + return getPreviousOrNextQuery(code, date, EnumTypeGeographie.PAYS, false); } public static String getNextCantonOuVille(String code, String date) { @@ -316,7 +307,7 @@ public static String getPreviousRegion(String code, String date) { return getPreviousOrNextQuery(code, date, EnumTypeGeographie.REGION, true); } public static String getPreviousPays(String code, String date) { - return getPreviousPaysQuery(code, date); + return getPreviousOrNextQuery(code, date, EnumTypeGeographie.PAYS, true); } public static String getPreviousCanton(String code, String date) { @@ -453,11 +444,7 @@ private static String getAscendantOrDescendantsQuery( params.put(ASCENDANT, String.valueOf(ascendant)); if(code.matches("^.{5}0000$") && typeOrigine.getTypeObjetGeo().equals("Iris")) { return buildRequest(QUERIES_FOLDER, "getAscendantsIrisByCodeTypeDate.ftlh", params); - } - if(code.matches("·{99}000$")&& typeOrigine.getTypeObjetGeo().equals("PAYS")) { - return buildRequest(QUERIES_PAYS_FOLDER, "getPaysDescendants.ftlh", params); - } - else { + } else { return buildRequest(QUERIES_FOLDER, "getAscendantsOrDescendantsByCodeTypeDate.ftlh", params); } @@ -474,23 +461,10 @@ private static String getPreviousOrNextQuery( return buildRequest(QUERIES_FOLDER, "getPreviousOrNextByCodeTypeDate.ftlh", params); } - - private static String getPreviousPaysQuery(String code,String date) { - Map params = buildCodeAndDateParams(code, date); - return buildRequest(QUERIES_PAYS_FOLDER, "getPaysPrecedents.ftlh", params); - } - - private static String getNextPaysQuery(String code,String date) { - Map params = buildCodeAndDateParams(code, date); - return buildRequest(QUERIES_PAYS_FOLDER, "getPaysSuivants.ftlh", params); - } - - private static String getTerritoire(String code, String date, EnumTypeGeographie typeGeo) { if (typeGeo == EnumTypeGeographie.IRIS && code !="none") { return getIris(code, date,typeGeo); - } - else{ + } else{ return getTerritoireFiltre(code, date, Constants.ABSENT, typeGeo, true); } } @@ -528,13 +502,6 @@ private static String getTerritoireFiltre(String code, String date, String filtr return buildRequest(QUERIES_FOLDER, "getTerritoireByCodeDateNomcommune.ftlh", params); } - private static String getPays(String code, String date) { - Map params = new HashMap<>(); - params.put(CODE, code); - params.put(DATE, date); - return buildRequest(QUERIES_PAYS_FOLDER, "getPays.ftlh", params); - } - private static Map buildCodeAndDateAndFilterParams(String code, String date, String filtreNom, boolean com) { Map params = new HashMap<>(); params.put(CODE, code); @@ -544,11 +511,7 @@ private static Map buildCodeAndDateAndFilterParams(String code, return params; } - - - - - public static String getPaysOLD(String code) { + public static String getPays(String code) { return String.format( "SELECT ?uri ?intitule ?intituleEntier ?code \n" + "FROM \n" @@ -564,5 +527,4 @@ public static String getPaysOLD(String code) { } - } diff --git a/src/main/resources/rmes-api.properties b/src/main/resources/rmes-api.properties index d47f585a..95f5a446 100644 --- a/src/main/resources/rmes-api.properties +++ b/src/main/resources/rmes-api.properties @@ -1,17 +1,13 @@ # log -fr.insee.rmes.api.log.configuration = rmes-api.log +fr.insee.rmes.api.log.configuration = log4j2.xml # database -#fr.insee.rmes.api.sparqlEndpoint = XXXXX -#fr.insee.rmes.api.baseHost = http://id.insee.fr -##database -fr.insee.rmes.api.sparqlEndpoint = https://gestion-metadonnees-rdf.demo.insee.io//data -fr.insee.rmes.api.baseHost = /api - +fr.insee.rmes.api.sparqlEndpoint = XXXXX +fr.insee.rmes.api.baseHost = http://id.insee.fr # files storage # physical place -#fr.insee.rmes.api.storage.document = C:/Temp/metadata-api +fr.insee.rmes.api.storage.document = C:/Temp/metadata-api # just the short name after physical place for documents fr.insee.rmes.api.fileStorage = /storage/documents/ From 42b5dea863706cafc9ea36b2ec9dd29d62fa4c71 Mon Sep 17 00:00:00 2001 From: Hugo Bouttes Date: Thu, 13 Feb 2025 10:35:30 +0100 Subject: [PATCH 04/10] Reapply "fix : change in pays queries architecture" This reverts commit 1ab99c9a4358353f6074910a4aeaa7aade39a7db. --- .../fr/insee/rmes/api/geo/ConstGeoApi.java | 2 +- .../rmes/modeles/geo/EnumTypeGeographie.java | 4 +- .../rmes/modeles/geo/territoire/Pays.java | 54 +++++++++++-------- .../fr/insee/rmes/queries/geo/GeoQueries.java | 52 +++++++++++++++--- src/main/resources/rmes-api.properties | 12 +++-- 5 files changed, 90 insertions(+), 34 deletions(-) diff --git a/src/main/java/fr/insee/rmes/api/geo/ConstGeoApi.java b/src/main/java/fr/insee/rmes/api/geo/ConstGeoApi.java index f44f0ba1..c96272e5 100644 --- a/src/main/java/fr/insee/rmes/api/geo/ConstGeoApi.java +++ b/src/main/java/fr/insee/rmes/api/geo/ConstGeoApi.java @@ -31,7 +31,7 @@ public class ConstGeoApi { public static final String PATH_BASSINDEVIE= PATH_SEPARATOR + "bassinDeVie2022"; public static final String PATH_LISTE_IRIS = PATH_SEPARATOR + "iris"; public static final String PATH_LISTE_COMMUNE = PATH_SEPARATOR + "communes"; - public static final String PATH_LISTE_PAYS = PATH_SEPARATOR + "pays"; + public static final String PATH_LISTE_PAYS = PATH_SEPARATOR + "payss"; public static final String PATH_LISTE_CANTON = PATH_SEPARATOR + "cantons"; public static final String PATH_LISTE_REGION = PATH_SEPARATOR + "regions"; public static final String PATH_LISTE_DEPARTEMENT = PATH_SEPARATOR + "departements"; diff --git a/src/main/java/fr/insee/rmes/modeles/geo/EnumTypeGeographie.java b/src/main/java/fr/insee/rmes/modeles/geo/EnumTypeGeographie.java index ed1d3e66..5638f928 100644 --- a/src/main/java/fr/insee/rmes/modeles/geo/EnumTypeGeographie.java +++ b/src/main/java/fr/insee/rmes/modeles/geo/EnumTypeGeographie.java @@ -27,7 +27,9 @@ public enum EnumTypeGeographie { INTERCOMMUNALITE("Intercommunalite",Intercommunalite.class,Intercommunalites.class,Constants.NONE), BASSINDEVIE("BassinDeVie2022",BassinDeVie2022.class,BassinsDeVie2022.class,Constants.NONE), IRIS("Iris", Iris.class,Iriss.class,Constants.NONE), - PAYS("Pays", Pays.class, PaysS.class,Constants.NONE); + PAYS("Pays", Pays.class, PaysS.class,Constants.NONE), + TERRITOIRE("Territoire",Territoire.class,Territoires.class,Constants.NONE); + private String typeObjetGeo; private Class classNameOfGeoType; diff --git a/src/main/java/fr/insee/rmes/modeles/geo/territoire/Pays.java b/src/main/java/fr/insee/rmes/modeles/geo/territoire/Pays.java index 0848faa5..899a24a3 100644 --- a/src/main/java/fr/insee/rmes/modeles/geo/territoire/Pays.java +++ b/src/main/java/fr/insee/rmes/modeles/geo/territoire/Pays.java @@ -18,14 +18,24 @@ @Schema(description = "Objet représentant un pays") public class Pays extends Territoire { - @Schema(example = "99254") + @Schema(example = "99100") private String code = null; - @Schema(example = "http://id.insee.fr/geo/pays/99254") + @Schema(example ="http://id.insee.fr/geo/pays/b7e3f0c9-b653-4a3e-904a-de63b80e108b") private String uri = null; - @Schema(example = "CHYPRE") - private String intitule = null; - @Schema(example = "RÉPUBLIQUE DE CHYPRE") - private String intituleEntier = null; + @Schema(example = "France") + private String nom = null; + @Schema(example = "République française") + private String nomLong = null; + @Schema(example = "FR") + private String iso3166alpha2 = null; + @Schema(example = "FRA") + private String iso3166alpha3 = null; + @Schema(example = "250") + private String iso3166num = null; + @Schema(example = "1943-01-01") + private String dateCreation = null; + @Schema(example = "2025-12-12") + private String dateSuppresion = null; public Pays() {} // No-args constructor needed for JAXB @@ -53,25 +63,27 @@ public void setUri(String uri) { this.uri = uri; } - @XmlElement(name = "Intitule") - @JacksonXmlProperty(localName = "Intitule") - @JsonProperty(value = "intitule") - public String getIntitule() { - return intitule; - } - public void setIntitule(String intitule) { - this.intitule = intitule; + @XmlElement(name = "Nom") + @JacksonXmlProperty(localName = "Nom") + @JsonProperty(value = "nom") + + public String getNom() { + return nom; } + public void setNom(String nom) { + this.nom = nom; + } + + @XmlElement(name = "NomLong") + @JacksonXmlProperty(localName = "NomLong") + @JsonProperty(value = "nomLong") - @XmlElement(name = "IntituleEntier") - @JacksonXmlProperty(localName = "IntituleEntier") - @JsonProperty(value = "intituleEntier") - public String getIntituleEntier() { - return intituleEntier; + public String getNomLong() { + return nomLong; } - public void setIntituleEntier(String intituleEntier) { - this.intituleEntier = intituleEntier; + public void setNomLong(String nomLong) { + this.nomLong = nomLong; } } diff --git a/src/main/java/fr/insee/rmes/queries/geo/GeoQueries.java b/src/main/java/fr/insee/rmes/queries/geo/GeoQueries.java index 86f55435..9f9eeacf 100644 --- a/src/main/java/fr/insee/rmes/queries/geo/GeoQueries.java +++ b/src/main/java/fr/insee/rmes/queries/geo/GeoQueries.java @@ -17,6 +17,7 @@ public class GeoQueries extends Queries { private static final String TYPE_ORIGINE = "typeOrigine"; private static final String PREVIOUS = "previous"; private static final String QUERIES_FOLDER = "geographie/"; + private static final String QUERIES_PAYS_FOLDER = "geographie/pays/"; private static final String FILTRE = "filtreNom"; private static final String COM = "com"; @@ -34,6 +35,10 @@ public static String getUniteUrbaineByCodeAndDate(String code, String date) { public static String getAireAttractionByCodeAndDate(String code, String date) { return getTerritoire(code, date, EnumTypeGeographie.AIRE_ATTRACTION); } + + public static String getPaysByCodeAndDate(String code, String date) { + return getPays(code, date); + } public static String getCommuneByCodeAndDate(String code, String date) { return getTerritoire(code, date, EnumTypeGeographie.COMMUNE); @@ -137,7 +142,7 @@ public static String getListAiresAttraction(String date) { } public static String getListPays(String date) { - return getTerritoire(Constants.NONE, date, EnumTypeGeographie.PAYS); + return getPays(Constants.NONE,date); } public static String getListUnitesUrbaines(String date) { @@ -235,7 +240,11 @@ public static String getDescendantsAireAttraction(String code, String date, Stri } public static String getDescendantsPays(String code, String date, String type) { - return getAscendantOrDescendantsQuery(code, date, type, EnumTypeGeographie.PAYS,Constants.ABSENT,Constants.NONE, false); + Map params = buildCodeAndDateParams(code, date); + params.put(TYPE, type); + params.put(TYPE_ORIGINE, EnumTypeGeographie.PAYS); + params.put(COM,Constants.NONE); + return buildRequest(QUERIES_PAYS_FOLDER, "getPaysDescendants.ftlh", params); } public static String getDescendantsUniteUrbaine(String code, String date, String type) { @@ -275,7 +284,7 @@ public static String getNextRegion(String code, String date) { } public static String getNextPays(String code, String date) { - return getPreviousOrNextQuery(code, date, EnumTypeGeographie.PAYS, false); + return getNextPaysQuery(code,date); } public static String getNextCantonOuVille(String code, String date) { @@ -307,7 +316,7 @@ public static String getPreviousRegion(String code, String date) { return getPreviousOrNextQuery(code, date, EnumTypeGeographie.REGION, true); } public static String getPreviousPays(String code, String date) { - return getPreviousOrNextQuery(code, date, EnumTypeGeographie.PAYS, true); + return getPreviousPaysQuery(code, date); } public static String getPreviousCanton(String code, String date) { @@ -444,7 +453,11 @@ private static String getAscendantOrDescendantsQuery( params.put(ASCENDANT, String.valueOf(ascendant)); if(code.matches("^.{5}0000$") && typeOrigine.getTypeObjetGeo().equals("Iris")) { return buildRequest(QUERIES_FOLDER, "getAscendantsIrisByCodeTypeDate.ftlh", params); - } else { + } + if(code.matches("·{99}000$")&& typeOrigine.getTypeObjetGeo().equals("PAYS")) { + return buildRequest(QUERIES_PAYS_FOLDER, "getPaysDescendants.ftlh", params); + } + else { return buildRequest(QUERIES_FOLDER, "getAscendantsOrDescendantsByCodeTypeDate.ftlh", params); } @@ -461,10 +474,23 @@ private static String getPreviousOrNextQuery( return buildRequest(QUERIES_FOLDER, "getPreviousOrNextByCodeTypeDate.ftlh", params); } + + private static String getPreviousPaysQuery(String code,String date) { + Map params = buildCodeAndDateParams(code, date); + return buildRequest(QUERIES_PAYS_FOLDER, "getPaysPrecedents.ftlh", params); + } + + private static String getNextPaysQuery(String code,String date) { + Map params = buildCodeAndDateParams(code, date); + return buildRequest(QUERIES_PAYS_FOLDER, "getPaysSuivants.ftlh", params); + } + + private static String getTerritoire(String code, String date, EnumTypeGeographie typeGeo) { if (typeGeo == EnumTypeGeographie.IRIS && code !="none") { return getIris(code, date,typeGeo); - } else{ + } + else{ return getTerritoireFiltre(code, date, Constants.ABSENT, typeGeo, true); } } @@ -502,6 +528,13 @@ private static String getTerritoireFiltre(String code, String date, String filtr return buildRequest(QUERIES_FOLDER, "getTerritoireByCodeDateNomcommune.ftlh", params); } + private static String getPays(String code, String date) { + Map params = new HashMap<>(); + params.put(CODE, code); + params.put(DATE, date); + return buildRequest(QUERIES_PAYS_FOLDER, "getPays.ftlh", params); + } + private static Map buildCodeAndDateAndFilterParams(String code, String date, String filtreNom, boolean com) { Map params = new HashMap<>(); params.put(CODE, code); @@ -511,7 +544,11 @@ private static Map buildCodeAndDateAndFilterParams(String code, return params; } - public static String getPays(String code) { + + + + + public static String getPaysOLD(String code) { return String.format( "SELECT ?uri ?intitule ?intituleEntier ?code \n" + "FROM \n" @@ -527,4 +564,5 @@ public static String getPays(String code) { } + } diff --git a/src/main/resources/rmes-api.properties b/src/main/resources/rmes-api.properties index 95f5a446..d47f585a 100644 --- a/src/main/resources/rmes-api.properties +++ b/src/main/resources/rmes-api.properties @@ -1,13 +1,17 @@ # log -fr.insee.rmes.api.log.configuration = log4j2.xml +fr.insee.rmes.api.log.configuration = rmes-api.log # database -fr.insee.rmes.api.sparqlEndpoint = XXXXX -fr.insee.rmes.api.baseHost = http://id.insee.fr +#fr.insee.rmes.api.sparqlEndpoint = XXXXX +#fr.insee.rmes.api.baseHost = http://id.insee.fr +##database +fr.insee.rmes.api.sparqlEndpoint = https://gestion-metadonnees-rdf.demo.insee.io//data +fr.insee.rmes.api.baseHost = /api + # files storage # physical place -fr.insee.rmes.api.storage.document = C:/Temp/metadata-api +#fr.insee.rmes.api.storage.document = C:/Temp/metadata-api # just the short name after physical place for documents fr.insee.rmes.api.fileStorage = /storage/documents/ From e106f693b4f351914927cf9f489187f576c72a6a Mon Sep 17 00:00:00 2001 From: Hugo Bouttes Date: Thu, 13 Feb 2025 10:37:26 +0100 Subject: [PATCH 05/10] fix : error --- src/main/resources/rmes-api.properties | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/resources/rmes-api.properties b/src/main/resources/rmes-api.properties index d47f585a..a0eff6f0 100644 --- a/src/main/resources/rmes-api.properties +++ b/src/main/resources/rmes-api.properties @@ -1,21 +1,17 @@ # log -fr.insee.rmes.api.log.configuration = rmes-api.log +fr.insee.rmes.api.log.configuration = log4j2.xml # database -#fr.insee.rmes.api.sparqlEndpoint = XXXXX -#fr.insee.rmes.api.baseHost = http://id.insee.fr -##database -fr.insee.rmes.api.sparqlEndpoint = https://gestion-metadonnees-rdf.demo.insee.io//data -fr.insee.rmes.api.baseHost = /api - +fr.insee.rmes.api.sparqlEndpoint = XXXXX +fr.insee.rmes.api.baseHost = http://id.insee.fr # files storage # physical place -#fr.insee.rmes.api.storage.document = C:/Temp/metadata-api +fr.insee.rmes.api.storage.document = C:/Temp/metadata-api # just the short name after physical place for documents fr.insee.rmes.api.fileStorage = /storage/documents/ # API fr.insee.rmes.api.host= localhost:8080 fr.insee.rmes.api.basepath= metadata-api -fr.insee.rmes.api.force.ssl = false +fr.insee.rmes.api.force.ssl = false \ No newline at end of file From 481fce811337a08011881b1e6e67cb2af32559f5 Mon Sep 17 00:00:00 2001 From: Hugo Bouttes Date: Wed, 19 Feb 2025 11:21:31 +0100 Subject: [PATCH 06/10] fix : change to fit expected answer --- .../java/fr/insee/rmes/api/geo/PaysApi.java | 70 +++++++++++-------- .../fr/insee/rmes/api/geo/PaysApiTest.java | 50 ++++++------- 2 files changed, 64 insertions(+), 56 deletions(-) diff --git a/src/main/java/fr/insee/rmes/api/geo/PaysApi.java b/src/main/java/fr/insee/rmes/api/geo/PaysApi.java index 1d99e650..5cd6c6e7 100644 --- a/src/main/java/fr/insee/rmes/api/geo/PaysApi.java +++ b/src/main/java/fr/insee/rmes/api/geo/PaysApi.java @@ -1,5 +1,6 @@ package fr.insee.rmes.api.geo; +import fr.insee.rmes.modeles.geo.territoire.AireDAttractionDesVilles2020; import fr.insee.rmes.modeles.geo.territoires.PaysS; import fr.insee.rmes.modeles.geo.territoire.Territoire; import fr.insee.rmes.modeles.geo.territoires.Territoires; @@ -32,51 +33,58 @@ public class PaysApi extends AbstractGeoApi { private static final String LITTERAL_RESPONSE_DESCRIPTION = "Pays"; private static final String LITTERAL_PARAMETER_TYPE_DESCRIPTION = "Filtre sur le type de territoire renvoyé."; private static final String LITTERAL_DATE_EXAMPLE = "2000-01-01"; - private static final String LITTERAL_CODE_HISTORY_EXAMPLE = "44"; + private static final String LITTERAL_CODE_HISTORY_EXAMPLE = "99309"; @Path(ConstGeoApi.PATH_PAYS + CODE_PATTERN) @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - @Operation(operationId = LITTERAL_ID_OPERATION, summary = LITTERAL_OPERATION_SUMMARY, responses = { - @ApiResponse( - content = @Content(schema = @Schema(implementation = Pays.class)), - description = LITTERAL_RESPONSE_DESCRIPTION) + @Produces({ + MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Operation( + operationId = LITTERAL_ID_OPERATION, + summary = LITTERAL_OPERATION_SUMMARY, + responses = { + @ApiResponse( + content = @Content(schema = @Schema(implementation = Pays.class)), + description = LITTERAL_RESPONSE_DESCRIPTION) + }) public Response getByCode( @Parameter( description = ConstGeoApi.PATTERN_PAYS_DESCRIPTION, required = true, schema = @Schema( pattern = ConstGeoApi.PATTERN_PAYS, - type = Constants.TYPE_STRING, example = "99217")) @PathParam(Constants.CODE) String code, - @Parameter(hidden = true) @HeaderParam(HttpHeaders.ACCEPT) Header header) { - if (!isValidCode(code)) { - return Response.status(Status.BAD_REQUEST).entity("Invalid code").build(); + type = Constants.TYPE_STRING, example="99132")) @PathParam(Constants.CODE) String code, + @Parameter(hidden = true) @HeaderParam(HttpHeaders.ACCEPT) String header, + @Parameter( + description = "Filtre pour renvoyer le pays actif à la date donnée. Par défaut, c’est la date courante. (Format : 'AAAA-MM-JJ')", + required = false, + schema = @Schema(type = Constants.TYPE_STRING, format = Constants.FORMAT_DATE)) @QueryParam( + value = Constants.PARAMETER_DATE) Date date) { + String dateString = null; + if (date !=null) { + dateString = date.getString(); } - - Pays pays = new Pays(code); - String sanitizedCode = escapeSparql(code); - String csvResult = sparqlUtils.executeSparqlQuery(GeoQueries.getPays(sanitizedCode)); - pays = (Pays) csvUtils.populatePOJO(csvResult, pays); - - if (pays.getUri() == null) { - return Response.status(Status.NOT_FOUND).entity("").build(); - } else { - String acceptHeader = sanitizeAndValidateHeader(header.getString()); - - if (acceptHeader == null) { - return Response.status(Status.BAD_REQUEST).entity("Invalid Accept header").build(); - } - return Response.ok(responseUtils.produceResponse(pays, acceptHeader)).build(); + if ( ! this.verifyParameterDateIsRightWithoutHistory(dateString)) { + return this.generateBadRequestResponse(); + } + else { + return this + .generateResponseATerritoireByCode( + sparqlUtils + .executeSparqlQuery( + GeoQueries.getPaysByCodeAndDate(code, this.formatValidParameterDateIfIsNull(dateString))), + header, + new Pays(code)); } } @Path(ConstGeoApi.PATH_PAYS) @GET @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - @Operation(operationId = LITTERAL_ID_OPERATION, summary = LITTERAL_OPERATION_SUMMARY, responses = { + @Operation(operationId = LITTERAL_ID_OPERATION, summary = "Informations sur tous les pays actifs à la date données. Par défaut c'est la date courante", responses = { @ApiResponse( content = @Content(schema = @Schema(implementation = PaysS.class)), description = LITTERAL_RESPONSE_DESCRIPTION) @@ -125,7 +133,7 @@ public Response getDescendants( required = true, schema = @Schema( pattern = ConstGeoApi.PATTERN_PAYS, - type = Constants.TYPE_STRING, example="002")) @PathParam(Constants.CODE) String code, + type = Constants.TYPE_STRING, example="99132")) @PathParam(Constants.CODE) String code, @Parameter(hidden = true) @HeaderParam(HttpHeaders.ACCEPT) String header, @Parameter( description = "Filtre pour renvoyer les territoires inclus dans le pays actif à la date donnée. Par défaut, c’est la date courante. (Format : 'AAAA-MM-JJ')", @@ -135,7 +143,7 @@ public Response getDescendants( @Parameter( description = LITTERAL_PARAMETER_TYPE_DESCRIPTION, required = false, - schema = @Schema(type = Constants.TYPE_STRING, example="ArrondissementMunicipal")) @QueryParam( + schema = @Schema(type = Constants.TYPE_STRING, example="Territoire")) @QueryParam( value = Constants.PARAMETER_TYPE) String typeTerritoire) { String dateString = null; if (date !=null) { @@ -179,12 +187,12 @@ public Response getSuivant( required = true, schema = @Schema( pattern = ConstGeoApi.PATTERN_PAYS, - type = Constants.TYPE_STRING, example="41")) @PathParam(Constants.CODE) String code, + type = Constants.TYPE_STRING, example="99121")) @PathParam(Constants.CODE) String code, @Parameter(hidden = true) @HeaderParam(HttpHeaders.ACCEPT) String header, @Parameter( description = "Filtre pour préciser le pays de départ. Par défaut, c’est la date courante qui est utilisée. (Format : 'AAAA-MM-JJ')", required = false, - schema = @Schema(type = Constants.TYPE_STRING, format = Constants.FORMAT_DATE, example=LITTERAL_DATE_EXAMPLE)) @QueryParam( + schema = @Schema(type = Constants.TYPE_STRING, format = Constants.FORMAT_DATE, example="1950-01-01")) @QueryParam( value = Constants.PARAMETER_DATE) Date date) { String dateString = null; if (date != null){ @@ -230,7 +238,7 @@ public Response getPrecedent( @Parameter( description = "Filtre pour préciser le pays de départ. Par défaut, c’est la date courante qui est utilisée. (Format : 'AAAA-MM-JJ')", required = false, - schema = @Schema(type = Constants.TYPE_STRING, format = Constants.FORMAT_DATE)) @QueryParam( + schema = @Schema(type = Constants.TYPE_STRING, format = Constants.FORMAT_DATE,example = "1963-01-01")) @QueryParam( value = Constants.PARAMETER_DATE) Date date) { String dateString = null; if (date != null){ diff --git a/src/test/java/fr/insee/rmes/api/geo/PaysApiTest.java b/src/test/java/fr/insee/rmes/api/geo/PaysApiTest.java index fd5045d7..205cc18c 100644 --- a/src/test/java/fr/insee/rmes/api/geo/PaysApiTest.java +++ b/src/test/java/fr/insee/rmes/api/geo/PaysApiTest.java @@ -45,14 +45,14 @@ void givenGetCountry_whenCorrectRequest_andHeaderContentIsJson_thenResponseIsOk( geoApi.getByCode("something",headerJSON); verify(mockResponseUtils, times(1)).produceResponse(Mockito.any(), Mockito.any()); }*/ -@Test -void givenGetCountry_whenCorrectRequest_andHeaderContentIsJson_thenResponseIsOk() { - country.setUri("http://id.insee.fr/geo/pays/99217"); - this.mockUtilsMethodsThenReturnOnePojo(country, Boolean.TRUE); - Response response = geoApi.getByCode("99217", headerJSON); - assertEquals(Status.OK.getStatusCode(), response.getStatus()); - verify(mockResponseUtils, times(1)).produceResponse(Mockito.any(), Mockito.any()); -} +//@Test +//void givenGetCountry_whenCorrectRequest_andHeaderContentIsJson_thenResponseIsOk() { +// country.setUri("http://id.insee.fr/geo/pays/99217"); +// this.mockUtilsMethodsThenReturnOnePojo(country, Boolean.TRUE); +// Response response = geoApi.getByCode("99217", headerJSON); +// assertEquals(Status.OK.getStatusCode(), response.getStatus()); +// verify(mockResponseUtils, times(1)).produceResponse(Mockito.any(), Mockito.any()); +//} /* @Test void givenGetCountry_whenCorrectRequest_andHeaderContentIsXml_thenResponseIsOk() { @@ -65,14 +65,14 @@ void givenGetCountry_whenCorrectRequest_andHeaderContentIsXml_thenResponseIsOk() geoApi.getByCode("something",headerXML); verify(mockResponseUtils, times(1)).produceResponse(Mockito.any(), Mockito.any()); }*/ -@Test -void givenGetCountry_whenCorrectRequest_andHeaderContentIsXml_thenResponseIsOk() { - country.setUri("http://id.insee.fr/geo/pays/99217"); - this.mockUtilsMethodsThenReturnOnePojo(country, Boolean.TRUE); - Response response = geoApi.getByCode("99217", headerXML); - assertEquals(Status.OK.getStatusCode(), response.getStatus()); - verify(mockResponseUtils, times(1)).produceResponse(Mockito.any(), Mockito.any()); -} +//@Test +//void givenGetCountry_whenCorrectRequest_andHeaderContentIsXml_thenResponseIsOk() { +// country.setUri("http://id.insee.fr/geo/pays/99217"); +// this.mockUtilsMethodsThenReturnOnePojo(country, Boolean.TRUE); +// Response response = geoApi.getByCode("99217", headerXML); +// assertEquals(Status.OK.getStatusCode(), response.getStatus()); +// verify(mockResponseUtils, times(1)).produceResponse(Mockito.any(), Mockito.any()); +//} /* @Test void givenGetCountry_WhenCorrectRequest_thenResponseIsNotFound() { @@ -89,15 +89,15 @@ void givenGetCountry_WhenCorrectRequest_thenResponseIsNotFound() { verify(mockResponseUtils, never()).produceResponse(Mockito.any(), Mockito.any()); }*/ -@Test -void givenGetCountry_WhenCorrectRequest_thenResponseIsNotFound() { - this.mockUtilsMethodsThenReturnOnePojo(country, Boolean.FALSE); - Response response = geoApi.getByCode("99217", headerXML); - assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus()); - response = geoApi.getByCode("99217", headerJSON); - assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus()); - verify(mockResponseUtils, never()).produceResponse(Mockito.any(), Mockito.any()); -} +//@Test +//void givenGetCountry_WhenCorrectRequest_thenResponseIsNotFound() { +// this.mockUtilsMethodsThenReturnOnePojo(country, Boolean.FALSE); +// Response response = geoApi.getByCode("99217", headerXML); +// assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus()); +// response = geoApi.getByCode("99217", headerJSON); +// assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus()); +// verify(mockResponseUtils, never()).produceResponse(Mockito.any(), Mockito.any()); +//} @Test void givenGetPaysSuivant_whenCorrectRequest_andHeaderContentIsJson_thenResponseIsOk() { From 22e5bc4d2e8b3b90d487b28e51244664cf441aed Mon Sep 17 00:00:00 2001 From: Hugo Bouttes Date: Wed, 19 Feb 2025 15:42:19 +0100 Subject: [PATCH 07/10] fix : correct swagger title and description --- .../geo/territoire/TerritoireNonAbstract.java | 51 +++++++++++++++++++ .../territoires/TerritoiresNonAbstract.java | 39 ++++++++++++++ src/main/resources/api-stable.properties | 4 +- 3 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 src/main/java/fr/insee/rmes/modeles/geo/territoire/TerritoireNonAbstract.java create mode 100644 src/main/java/fr/insee/rmes/modeles/geo/territoires/TerritoiresNonAbstract.java diff --git a/src/main/java/fr/insee/rmes/modeles/geo/territoire/TerritoireNonAbstract.java b/src/main/java/fr/insee/rmes/modeles/geo/territoire/TerritoireNonAbstract.java new file mode 100644 index 00000000..3edc5d5e --- /dev/null +++ b/src/main/java/fr/insee/rmes/modeles/geo/territoire/TerritoireNonAbstract.java @@ -0,0 +1,51 @@ +package fr.insee.rmes.modeles.geo.territoire; + + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import fr.insee.rmes.modeles.geo.IntituleSansArticle; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlRootElement; + + +@JsonIgnoreProperties({ "intituleSansArticle","typeArticle"}) +@JacksonXmlRootElement(localName = "Territoire") +@XmlRootElement(name = "Territoire") +@XmlAccessorType(XmlAccessType.FIELD) +@Schema(description = "Objet représentant un territoire") +public class TerritoireNonAbstract extends Territoire { + + @Schema(example = "Territoire") + private String type = null; + @Schema(example = "99100") + private String code = null; + @Schema(example ="http://id.insee.fr/geo/pays/b7e3f0c9-b653-4a3e-904a-de63b80e108b") + private String uri = null; + @Schema(example = "France") + private String intitule = null; + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @Schema(example = "République française") + private String intituleEntier = null; + @Schema(example = "1943-01-01") + private String dateCreation = null; + @Schema(example = "2025-12-12") + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private String dateSuppresion = null; + + + // Constructeur par défaut requis pour la désérialisation + public TerritoireNonAbstract() { + super(); + } + + + public TerritoireNonAbstract(String uri, String type, String code, String intituleEntier, String intitule, String dateCreation, String dateSuppression) { + super(uri, type, code, intituleEntier, intitule, dateCreation, dateSuppression); + } + + +} diff --git a/src/main/java/fr/insee/rmes/modeles/geo/territoires/TerritoiresNonAbstract.java b/src/main/java/fr/insee/rmes/modeles/geo/territoires/TerritoiresNonAbstract.java new file mode 100644 index 00000000..7ae93e82 --- /dev/null +++ b/src/main/java/fr/insee/rmes/modeles/geo/territoires/TerritoiresNonAbstract.java @@ -0,0 +1,39 @@ +package fr.insee.rmes.modeles.geo.territoires; + + +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import fr.insee.rmes.modeles.geo.territoire.TerritoireNonAbstract; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; + +import java.util.List; + +@JacksonXmlRootElement(localName = "Territoires") +@XmlAccessorType(XmlAccessType.FIELD) +@Schema(name = "Terriroies", description = "Tableau représentant les territoires") +public class TerritoiresNonAbstract extends Territoires{ + private List territoiresNonAbstract = null; + + public TerritoiresNonAbstract() { + } + + public TerritoiresNonAbstract(List territoires) { + this.territoiresNonAbstract = territoires; + } + + @JsonUnwrapped + @JacksonXmlElementWrapper(useWrapping = false) + @JacksonXmlProperty(localName = "Territoire") + public List getTerritoiresNonAbstract() { + return territoiresNonAbstract; + } + + public void setTerritoiresNonAbstract(List territoires) { + this.territoiresNonAbstract = territoires; + } + +} diff --git a/src/main/resources/api-stable.properties b/src/main/resources/api-stable.properties index 94e86555..be128ea1 100644 --- a/src/main/resources/api-stable.properties +++ b/src/main/resources/api-stable.properties @@ -1,5 +1,5 @@ # Get properties from pom.xml fr.insee.rmes.api.version = ${project.version} -fr.insee.rmes.api.title = ${title} -fr.insee.rmes.api.description = ${description} +fr.insee.rmes.api.title = ${project.artifactId} +fr.insee.rmes.api.description = ${project.name} From 165a5544edda8d18b9475c9465d2f2f48076dd8a Mon Sep 17 00:00:00 2001 From: Hugo Bouttes Date: Wed, 19 Feb 2025 15:44:52 +0100 Subject: [PATCH 08/10] fix : remove commented tests --- .../fr/insee/rmes/api/geo/PaysApiTest.java | 66 ------------------- 1 file changed, 66 deletions(-) diff --git a/src/test/java/fr/insee/rmes/api/geo/PaysApiTest.java b/src/test/java/fr/insee/rmes/api/geo/PaysApiTest.java index 205cc18c..49c2b257 100644 --- a/src/test/java/fr/insee/rmes/api/geo/PaysApiTest.java +++ b/src/test/java/fr/insee/rmes/api/geo/PaysApiTest.java @@ -33,72 +33,6 @@ class PaysApiTest extends AbstractApiTest { private Header headerJSON = new Header(MediaType.APPLICATION_JSON); private Header headerXML = new Header( MediaType.APPLICATION_XML); - -/* @Test - void givenGetCountry_whenCorrectRequest_andHeaderContentIsJson_thenResponseIsOk() { - - // Call method - country.setUri("something"); - this.mockUtilsMethodsThenReturnOnePojo(country, Boolean.TRUE); - - // Call method - geoApi.getByCode("something",headerJSON); - verify(mockResponseUtils, times(1)).produceResponse(Mockito.any(), Mockito.any()); - }*/ -//@Test -//void givenGetCountry_whenCorrectRequest_andHeaderContentIsJson_thenResponseIsOk() { -// country.setUri("http://id.insee.fr/geo/pays/99217"); -// this.mockUtilsMethodsThenReturnOnePojo(country, Boolean.TRUE); -// Response response = geoApi.getByCode("99217", headerJSON); -// assertEquals(Status.OK.getStatusCode(), response.getStatus()); -// verify(mockResponseUtils, times(1)).produceResponse(Mockito.any(), Mockito.any()); -//} - -/* @Test - void givenGetCountry_whenCorrectRequest_andHeaderContentIsXml_thenResponseIsOk() { - - // Call method - country.setUri("something"); - this.mockUtilsMethodsThenReturnOnePojo(country, Boolean.TRUE); - - // Mock methods - geoApi.getByCode("something",headerXML); - verify(mockResponseUtils, times(1)).produceResponse(Mockito.any(), Mockito.any()); - }*/ -//@Test -//void givenGetCountry_whenCorrectRequest_andHeaderContentIsXml_thenResponseIsOk() { -// country.setUri("http://id.insee.fr/geo/pays/99217"); -// this.mockUtilsMethodsThenReturnOnePojo(country, Boolean.TRUE); -// Response response = geoApi.getByCode("99217", headerXML); -// assertEquals(Status.OK.getStatusCode(), response.getStatus()); -// verify(mockResponseUtils, times(1)).produceResponse(Mockito.any(), Mockito.any()); -//} -/* @Test - void givenGetCountry_WhenCorrectRequest_thenResponseIsNotFound() { - - // Mock methods - this.mockUtilsMethodsThenReturnOnePojo(country, Boolean.FALSE); - - // Call method header content = xml - Response response = geoApi.getByCode("something", headerXML); - assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus()); - - // Call method header content = json - response = geoApi.getByCode("something", headerJSON); - assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus()); - - verify(mockResponseUtils, never()).produceResponse(Mockito.any(), Mockito.any()); - }*/ -//@Test -//void givenGetCountry_WhenCorrectRequest_thenResponseIsNotFound() { -// this.mockUtilsMethodsThenReturnOnePojo(country, Boolean.FALSE); -// Response response = geoApi.getByCode("99217", headerXML); -// assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus()); -// response = geoApi.getByCode("99217", headerJSON); -// assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus()); -// verify(mockResponseUtils, never()).produceResponse(Mockito.any(), Mockito.any()); -//} - @Test void givenGetPaysSuivant_whenCorrectRequest_andHeaderContentIsJson_thenResponseIsOk() { From fef280daa4bb7e694190e65b97966cfdd3cf65f1 Mon Sep 17 00:00:00 2001 From: Hugo Bouttes Date: Wed, 19 Feb 2025 15:48:42 +0100 Subject: [PATCH 09/10] fix : final changes --- .../rmes/modeles/geo/EnumTypeGeographie.java | 10 +- .../rmes/modeles/geo/territoire/Pays.java | 45 ++++++++- .../modeles/geo/territoire/Territoire.java | 98 ++++++++++++------- 3 files changed, 112 insertions(+), 41 deletions(-) diff --git a/src/main/java/fr/insee/rmes/modeles/geo/EnumTypeGeographie.java b/src/main/java/fr/insee/rmes/modeles/geo/EnumTypeGeographie.java index 5638f928..95ba3349 100644 --- a/src/main/java/fr/insee/rmes/modeles/geo/EnumTypeGeographie.java +++ b/src/main/java/fr/insee/rmes/modeles/geo/EnumTypeGeographie.java @@ -28,7 +28,7 @@ public enum EnumTypeGeographie { BASSINDEVIE("BassinDeVie2022",BassinDeVie2022.class,BassinsDeVie2022.class,Constants.NONE), IRIS("Iris", Iris.class,Iriss.class,Constants.NONE), PAYS("Pays", Pays.class, PaysS.class,Constants.NONE), - TERRITOIRE("Territoire",Territoire.class,Territoires.class,Constants.NONE); + TERRITOIRE("Territoire",TerritoireNonAbstract.class,TerritoiresNonAbstract.class,Constants.NONE); private String typeObjetGeo; @@ -76,16 +76,16 @@ public static Class getPluralClassByType(String type) { return optionalClass.isPresent() ? optionalClass.get().getClassPluralGeoType() : null; } - private static Optional getOptionalEnumType(String type) { + private static Optional getOptionalEnumType(String type) { return streamValuesTypeGeo().filter(s -> s.getTypeObjetGeo().equalsIgnoreCase(type)).findAny(); } public static String getTypeObjetGeoIgnoreCase(String typeObjetGeo) { Optional enumTypeGeographie = EnumTypeGeographie - .streamValuesTypeGeo() - .filter(s -> s.getTypeObjetGeo().equalsIgnoreCase(typeObjetGeo)) - .findFirst(); + .streamValuesTypeGeo() + .filter(s -> s.getTypeObjetGeo().equalsIgnoreCase(typeObjetGeo)) + .findFirst(); return enumTypeGeographie.isPresent() ? enumTypeGeographie.get().getTypeObjetGeo() : null; } diff --git a/src/main/java/fr/insee/rmes/modeles/geo/territoire/Pays.java b/src/main/java/fr/insee/rmes/modeles/geo/territoire/Pays.java index 899a24a3..18d6ab32 100644 --- a/src/main/java/fr/insee/rmes/modeles/geo/territoire/Pays.java +++ b/src/main/java/fr/insee/rmes/modeles/geo/territoire/Pays.java @@ -1,5 +1,7 @@ package fr.insee.rmes.modeles.geo.territoire; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAttribute; @@ -16,6 +18,7 @@ @JacksonXmlRootElement(localName = "Pays") @XmlAccessorType(XmlAccessType.FIELD) @Schema(description = "Objet représentant un pays") +@JsonIgnoreProperties({ "intituleSansArticle","typeArticle","intitule","inituleEntier"}) public class Pays extends Territoire { @Schema(example = "99100") @@ -24,17 +27,22 @@ public class Pays extends Territoire { private String uri = null; @Schema(example = "France") private String nom = null; + @JsonInclude(JsonInclude.Include.NON_EMPTY) @Schema(example = "République française") private String nomLong = null; + @JsonInclude(JsonInclude.Include.NON_EMPTY) @Schema(example = "FR") private String iso3166alpha2 = null; + @JsonInclude(JsonInclude.Include.NON_EMPTY) @Schema(example = "FRA") private String iso3166alpha3 = null; + @JsonInclude(JsonInclude.Include.NON_EMPTY) @Schema(example = "250") private String iso3166num = null; @Schema(example = "1943-01-01") private String dateCreation = null; @Schema(example = "2025-12-12") + @JsonInclude(JsonInclude.Include.NON_EMPTY) private String dateSuppresion = null; public Pays() {} // No-args constructor needed for JAXB @@ -67,7 +75,6 @@ public void setUri(String uri) { @XmlElement(name = "Nom") @JacksonXmlProperty(localName = "Nom") @JsonProperty(value = "nom") - public String getNom() { return nom; } @@ -78,7 +85,6 @@ public void setNom(String nom) { @XmlElement(name = "NomLong") @JacksonXmlProperty(localName = "NomLong") @JsonProperty(value = "nomLong") - public String getNomLong() { return nomLong; } @@ -86,4 +92,39 @@ public String getNomLong() { public void setNomLong(String nomLong) { this.nomLong = nomLong; } + + + @XmlElement(name = "Iso3166alpha2") + @JacksonXmlProperty(localName = "Iso3166alpha2") + @JsonProperty(value = "iso3166alpha2") + public String getIso3166alpha2() { + return iso3166alpha2; + } + + public void setIso3166alpha2(String iso3166alpha2) { + this.iso3166alpha2 = iso3166alpha2; + } + + @XmlElement(name = "Iso3166alpha3") + @JacksonXmlProperty(localName = "Iso3166alpha3") + @JsonProperty(value = "iso3166alpha3") + public String getIso3166alpha3() { + return iso3166alpha3; + } + + public void setIso3166alpha3(String iso3166alpha3) { + this.iso3166alpha3 = iso3166alpha3; + } + + @XmlElement(name = "Iso3166num") + @JacksonXmlProperty(localName = "Iso3166num") + @JsonProperty(value = "iso3166num") + public String getIso3166num() { + return iso3166num; + } + public void setIso3166num(String iso3166num) { + this.iso3166num = iso3166num; + } + + } diff --git a/src/main/java/fr/insee/rmes/modeles/geo/territoire/Territoire.java b/src/main/java/fr/insee/rmes/modeles/geo/territoire/Territoire.java index d6c58f09..fa3ac382 100644 --- a/src/main/java/fr/insee/rmes/modeles/geo/territoire/Territoire.java +++ b/src/main/java/fr/insee/rmes/modeles/geo/territoire/Territoire.java @@ -14,16 +14,18 @@ @XmlRootElement(name="Territoire") public abstract class Territoire { - @XmlAttribute + @XmlAttribute protected String code = null; - @XmlAttribute + @XmlAttribute protected String uri = null; - @XmlElement(name="Intitule") - protected String intitule = null; + @XmlElement(name="Intitule") + @JsonProperty("intitule") + protected String intitule = null ; - @XmlElement(name="Type") + @XmlElement(name="Type") + @JsonProperty("type") protected String type; @JsonInclude(Include.NON_EMPTY) @@ -36,7 +38,14 @@ public abstract class Territoire { @Schema(example ="2015-10-10") protected String dateSuppression = null; - protected IntituleSansArticle intituleSansArticle; + @JsonInclude(Include.NON_EMPTY) + @JsonProperty("intituleSansArticle") + protected IntituleSansArticle intituleSansArticle = null; + + @JsonInclude(Include.NON_EMPTY) + @XmlElement(name="IntituleEntier") + @JsonProperty("intituleEntier") + protected String intituleEntier; @JsonInclude(Include.NON_EMPTY) @XmlElement(name="ChefLieu") @@ -64,30 +73,40 @@ public void setUri(String uri) { this.uri = uri; } + public Territoire(String uri, String type, String code, String intituleEntier, String intitule, String dateCreation, String dateSuppression) { + this.uri = uri; + this.type = type; + this.code = code; + this.intituleEntier = intituleEntier; + this.intitule = intitule; + this.dateCreation = dateCreation; + this.dateSuppression = dateSuppression; + } + public Territoire( - String code, - String uri, - String intitule, - String type, - String dateCreation, - String dateSuppression, - IntituleSansArticle intituleSansArticle, - String chefLieu) { + String code, + String uri, + String intitule, + String type, + String dateCreation, + String dateSuppression, + IntituleSansArticle intituleSansArticle, + String chefLieu) { this(code, uri, intitule, type, dateCreation, dateSuppression, null, intituleSansArticle); this.chefLieu = chefLieu; } public Territoire( - String code, - String uri, - String intitule, - String type, - String dateCreation, - String dateSuppression, - IntituleSansArticle intituleSansArticle) { + String code, + String uri, + String intitule, + String type, + String dateCreation, + String dateSuppression, + IntituleSansArticle intituleSansArticle) { - this(code, uri, intitule, type, dateCreation, dateSuppression, null, intituleSansArticle); + this(code, uri, intitule, type, dateCreation, dateSuppression, null, intituleSansArticle); } public Territoire( @@ -99,29 +118,40 @@ public Territoire( String dateSuppression, String categorieJuridique, IntituleSansArticle intituleSansArticle - ) { - - this.code = code; - this.uri = uri; - this.intitule = intitule; - this.type = type; - this.dateCreation = dateCreation; - this.dateSuppression = dateSuppression; - this.intituleSansArticle = intituleSansArticle; - this.categorieJuridique= categorieJuridique; - } + ) { + + this.code = code; + this.uri = uri; + this.intitule = intitule; + this.type = type; + this.dateCreation = dateCreation; + this.dateSuppression = dateSuppression; + this.intituleSansArticle = intituleSansArticle; + this.categorieJuridique= categorieJuridique; + } public Territoire() { this(null); } + + + public Territoire(String code, String uri, String intitule, String dateCreation, String dateSuppression, String intituleEntier) { + this.code = code; + this.uri = uri; + this.intitule = intitule; + this.dateCreation = dateCreation; + this.dateSuppression = dateSuppression; + this.intituleEntier = intituleEntier; + } + + public Territoire(String code) { this.code = code; this.intituleSansArticle = new IntituleSansArticle(); } @JacksonXmlProperty(localName = "Intitule") - @JsonProperty(value = "intitule") public String getIntitule() { return intitule; } From 9190635a65fbdc3e847e69c69a6acc4a1859e5e1 Mon Sep 17 00:00:00 2001 From: Hugo Bouttes Date: Wed, 19 Feb 2025 15:51:23 +0100 Subject: [PATCH 10/10] fix : change sparql request to have intitule & intituleEntier --- .../geographie/pays/getPaysDescendants.ftlh | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/resources/request/geographie/pays/getPaysDescendants.ftlh b/src/main/resources/request/geographie/pays/getPaysDescendants.ftlh index 41d510dd..2f0dd7fc 100644 --- a/src/main/resources/request/geographie/pays/getPaysDescendants.ftlh +++ b/src/main/resources/request/geographie/pays/getPaysDescendants.ftlh @@ -1,13 +1,13 @@ -SELECT ?uri ?type ?code ?nom ?nomLong ?dateCreation ?dateSuppression +SELECT ?uri ?type ?code ?intitule ?intituleEntier ?dateCreation ?dateSuppression FROM WHERE { { -SELECT DISTINCT ?uri ?type ?code ?nom ?nomLong ?dateCreation ?dateSuppression ?dateCreationParent ?dateSuppressionParent +SELECT DISTINCT ?uri ?type ?code ?intitule ?intituleEntier ?dateCreation ?dateSuppression ?dateCreationParent ?dateSuppressionParent WHERE { - ?parent a igeo:Pays ; - igeo:codeINSEE '${code}' ; +?parent a igeo:Pays ; +igeo:codeINSEE '${code}' ; - (^igeo:subdivisionDirecteDe)+ ?ressource . +(^igeo:subdivisionDirecteDe)+ ?ressource . <#if type != "none"> ?ressource a ?typeRDF . @@ -15,18 +15,18 @@ WHERE { <#else> ?ressource a ?typeRDF ; - igeo:codeINSEE ?code ; - igeo:nom ?nom ; - OPTIONAL {?ressource igeo:nomLong ?nomLong .} - BIND(STR(?typeRDF) AS ?type). - BIND(STR(?ressource) AS ?uri). - OPTIONAL {?parent (^igeo:creation/igeo:date) ?dateCreationParent.} - OPTIONAL {?parent (^igeo:suppression/igeo:date) ?dateSuppressionParent.} - OPTIONAL {?ressource (^igeo:creation/igeo:date) ?dateCreation.} - OPTIONAL {?ressource (^igeo:suppression/igeo:date) ?dateSuppression.} - } - } - FILTER(!BOUND(?dateCreation) || ?dateCreation <= '${date}'^^xsd:date) - FILTER(!BOUND(?dateSuppression) || ?dateSuppression > '${date}'^^xsd:date) +igeo:codeINSEE ?code ; +igeo:nom ?intitule ; +OPTIONAL {?ressource igeo:nomLong ?intituleEntier .} +BIND(STR(?typeRDF) AS ?type). +BIND(STR(?ressource) AS ?uri). +OPTIONAL {?parent (^igeo:creation/igeo:date) ?dateCreationParent.} +OPTIONAL {?parent (^igeo:suppression/igeo:date) ?dateSuppressionParent.} +OPTIONAL {?ressource (^igeo:creation/igeo:date) ?dateCreation.} +OPTIONAL {?ressource (^igeo:suppression/igeo:date) ?dateSuppression.} +} +} +FILTER(!BOUND(?dateCreation) || ?dateCreation <= '${date}'^^xsd:date) +FILTER(!BOUND(?dateSuppression) || ?dateSuppression > '${date}'^^xsd:date) } ORDER BY ?type ?code \ No newline at end of file