Skip to content

Commit c069dc7

Browse files
Merge pull request #56 from InseeFr/acceptance
Version 3.1.0
2 parents 5351589 + e13cf18 commit c069dc7

29 files changed

Lines changed: 973 additions & 77 deletions

metadataapi-changeLog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
3.1.0 : Ajout des services des collectivités d'Outre-mer (Geo)
2+
3.0.5 : Montée de version log4J
3+
3.0.4 : Montée de version log4J
14
3.0.3 : Correction des régressions sur l'encodage des retours XML (documentation sims notamment)
25
3.0.2 : Correction de l'encodage des retours XML (documentation sims notamment) et logs
36
3.0.1 : Changement des properties pour correspondre à ce qui a été défini en production

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<packaging>war</packaging>
88
<name>Implementation of the RMéS metadata API</name>
99

10-
<version>3.0.5</version>
10+
<version>3.1.0</version>
1111

1212
<properties>
1313
<title>API RM\u00e9S</title>
@@ -19,7 +19,7 @@
1919
<jersey.version>2.29.1</jersey.version>
2020
<jackson.version>2.10.1</jackson.version>
2121
<jakarta.version>4.0.3</jakarta.version>
22-
<log.version>2.17.0</log.version>
22+
<log.version>2.17.1</log.version>
2323
<swagger.version>2.0.10</swagger.version>
2424
<junit.version>5.7.0</junit.version>
2525
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>

src/main/java/fr/insee/rmes/api/geo/AbstractGeoApi.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ protected boolean verifyParameterDateIsRightWithHistory(String date) {
8080
protected String formatValidParameterDateIfIsNull(String date) {
8181
return (date != null) ? date : DateUtils.getDateTodayStringFormat();
8282
}
83+
84+
protected String formatValidParameterFiltreIfIsNull(String filtreNom) {
85+
return (filtreNom != null) ? filtreNom : "*";
86+
}
87+
88+
protected Boolean formatValidParameterBooleanIfIsNull(Boolean bool) {
89+
return (bool != null) ? bool : false;
90+
}
91+
92+
8393

8494
protected Response generateStatusResponse(boolean objectIsFound, Object o, String header) {
8595
if (objectIsFound) {

src/main/java/fr/insee/rmes/api/geo/ConstGeoApi.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public class ConstGeoApi {
1919
public static final String PATH_COMMUNE_ASSOCIEE = PATH_SEPARATOR + "communeAssociee";
2020
public static final String PATH_COMMUNE_DELEGUEE = PATH_SEPARATOR + "communeDeleguee";
2121
public static final String PATH_ARRONDISSEMENT_MUNICIPAL = PATH_SEPARATOR + "arrondissementMunicipal";
22+
public static final String PATH_COM= PATH_SEPARATOR + "collectiviteDOutreMer";
23+
public static final String PATH_DISTRICT= PATH_SEPARATOR + "district";
24+
public static final String PATH_LISTE_COM= PATH_SEPARATOR +"collectivitesDOutreMer";
2225

2326
public static final String PATH_LISTE_COMMUNE = PATH_SEPARATOR + "communes";
2427
public static final String PATH_LISTE_PAYS = PATH_SEPARATOR + "pays";
@@ -31,7 +34,7 @@ public class ConstGeoApi {
3134
public static final String PATH_LISTE_ZONE_EMPLOI = PATH_SEPARATOR + "zonesDEmploi2020";
3235
public static final String PATH_LISTE_AIRE_ATTRACTION = PATH_SEPARATOR + "airesDAttractionDesVilles2020";
3336
public static final String PATH_LISTE_UNITE_URBAINE = PATH_SEPARATOR + "unitesUrbaines2020";
34-
37+
public static final String PATH_LISTE_DISTRICT = PATH_SEPARATOR + "districts";
3538

3639
public static final String PATH_ASCENDANT = PATH_SEPARATOR + "ascendants";
3740
public static final String PATH_DESCENDANT = PATH_SEPARATOR + "descendants";
@@ -41,6 +44,8 @@ public class ConstGeoApi {
4144

4245

4346
public static final String PATTERN_COMMUNE = "[0-9][0-9AB][0-9]{3}";
47+
public static final String PATTERN_COM ="9[78][1-9]";
48+
public static final String PATTERN_DISTRICT ="9[78][1-9]{3}";
4449
public static final String PATTERN_PAYS = "99[0-9]{3}";
4550
public static final String PATTERN_REGION = "[0-9]{2}";
4651
public static final String PATTERN_ZONE_EMPLOI = "[0-9]{4}";
@@ -51,8 +56,10 @@ public class ConstGeoApi {
5156
public static final String PATTERN_ARRONDISSEMENT_MUNICIPAL = "";
5257

5358
public static final String PATTERN_COMMUNE_DESCRIPTION = "Code de la commune (cinq caractères)";
59+
public static final String PATTERN_COM_DESCRIPTION= "Code de la collectivité d'outre-mer (trois caractères)";
5460
public static final String PATTERN_COMMUNE_ASSOCIEE_DESCRIPTION = "Code de la commune associée (cinq caractères)";
5561
public static final String PATTERN_COMMUNE_DELEGUEE_DESCRIPTION = "Code de la commune déléguée (cinq caractères)";
62+
public static final String PATTERN_DISTRICT_DESCRIPTION = "Code du district (cinq caractères)";
5663
public static final String PATTERN_ZONE_EMPLOI_DESCRIPTION = "Code de la zone d'emploi (quatre chiffres)";
5764
public static final String PATTERN_UNITE_URBAINE_DESCRIPTION = "Code de l'unité urbaine (cinq chiffres)";
5865
public static final String PATTERN_AIRE_ATTRACTION_DESCRIPTION = "Code de l'aire d'attraction (trois chiffres)";

src/main/java/fr/insee/rmes/api/geo/territoire/AireAttractionApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public Response getDescendants(
108108
required = true,
109109
schema = @Schema(
110110
pattern = ConstGeoApi.PATTERN_AIRE_ATTRACTION,
111-
type = Constants.TYPE_STRING, example="062")) @PathParam(Constants.CODE) String code,
111+
type = Constants.TYPE_STRING, example="002")) @PathParam(Constants.CODE) String code,
112112
@Parameter(hidden = true) @HeaderParam(HttpHeaders.ACCEPT) String header,
113113
@Parameter(
114114
description = "Filtre pour renvoyer les territoires inclus dans l'aire d'attraction active à la date donnée. Par défaut, c’est la date courante. (Format : 'AAAA-MM-JJ')",
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
package fr.insee.rmes.api.geo.territoire;
2+
3+
import javax.ws.rs.GET;
4+
import javax.ws.rs.HeaderParam;
5+
import javax.ws.rs.Path;
6+
import javax.ws.rs.PathParam;
7+
import javax.ws.rs.Produces;
8+
import javax.ws.rs.QueryParam;
9+
import javax.ws.rs.core.HttpHeaders;
10+
import javax.ws.rs.core.MediaType;
11+
import javax.ws.rs.core.Response;
12+
import org.apache.logging.log4j.LogManager;
13+
import org.apache.logging.log4j.Logger;
14+
import fr.insee.rmes.api.geo.AbstractGeoApi;
15+
import fr.insee.rmes.api.geo.ConstGeoApi;
16+
import fr.insee.rmes.modeles.geo.territoire.CollectiviteDOutreMer;
17+
import fr.insee.rmes.modeles.geo.territoire.Commune;
18+
import fr.insee.rmes.modeles.geo.territoire.Territoire;
19+
import fr.insee.rmes.modeles.geo.territoires.CollectivitesDOutreMer;
20+
import fr.insee.rmes.modeles.geo.territoires.Territoires;
21+
import fr.insee.rmes.queries.geo.GeoQueries;
22+
import fr.insee.rmes.utils.Constants;
23+
import io.swagger.v3.oas.annotations.Operation;
24+
import io.swagger.v3.oas.annotations.Parameter;
25+
import io.swagger.v3.oas.annotations.media.Content;
26+
import io.swagger.v3.oas.annotations.media.Schema;
27+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
28+
import io.swagger.v3.oas.annotations.tags.Tag;
29+
30+
31+
@Path(ConstGeoApi.PATH_GEO)
32+
@Tag(name = ConstGeoApi.TAG_NAME, description = ConstGeoApi.TAG_DESCRIPTION)
33+
34+
public class CollectivitesDOutreMerAPI extends AbstractGeoApi {
35+
36+
37+
38+
private static Logger logger = LogManager.getLogger(CollectivitesDOutreMerAPI.class);
39+
private static final String CODE_PATTERNCOM = "/{code: " + ConstGeoApi.PATTERN_COM + "}";
40+
private static final String LITTERAL_ID_OPERATION = "getcogcom";
41+
private static final String LITTERAL_OPERATION_SUMMARY =
42+
"Informations sur une collectivité d'outre-mer identifiée par son code (cinq caractères)";
43+
private static final String LITTERAL_RESPONSE_DESCRIPTION = "collectivité d'outre-mer";
44+
private static final String LITTERAL_PARAMETER_DATE_DESCRIPTION =
45+
"Filtre pour renvoyer la collectivite d'outre-mer active à la date donnée. Par défaut, c’est la date courante. (Format : 'AAAA-MM-JJ')";
46+
private static final String LITTERAL_PARAMETER_TYPE_DESCRIPTION = "Filtre sur le type de territoire renvoyé.";
47+
private static final String LITTERAL_CODE_EXAMPLE = "988";
48+
49+
50+
51+
@Path(ConstGeoApi.PATH_LISTE_COM)
52+
@GET
53+
@Produces({
54+
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML
55+
})
56+
57+
@Operation(
58+
operationId = LITTERAL_ID_OPERATION + ConstGeoApi.ID_OPERATION_LISTE,
59+
summary = "Informations sur toutes les collectivités d'outre-mer actives à la date donnée. Par défaut, c’est la date courante.",
60+
responses = {
61+
@ApiResponse(
62+
content = @Content(schema = @Schema(type = ARRAY, implementation = Commune.class)),
63+
description = LITTERAL_RESPONSE_DESCRIPTION)
64+
})
65+
66+
public Response getListe(
67+
@Parameter(hidden = true) @HeaderParam(HttpHeaders.ACCEPT) String header,
68+
@Parameter(
69+
description = "Filtre pour renvoyer les collectivités d'outre-mer actives à la date donnée. Par défaut, c’est la date courante. (Format : 'AAAA-MM-JJ')" + LITTERAL_PARAMETER_DATE_WITH_HISTORY,
70+
required = false,
71+
schema = @Schema(type = Constants.TYPE_STRING, format = Constants.FORMAT_DATE)) @QueryParam(
72+
value = Constants.PARAMETER_DATE) String date)
73+
74+
{
75+
76+
logger.debug("Received GET request for all collectivités d'outre-mer");
77+
78+
if ( ! this.verifyParameterDateIsRightWithHistory(date)) {
79+
return this.generateBadRequestResponse();
80+
}
81+
else {
82+
return this
83+
.generateResponseListOfTerritoire(
84+
sparqlUtils.executeSparqlQuery(GeoQueries.getListCollectivitesDOutreMer(this.formatValidParameterDateIfIsNull(date))),
85+
header,
86+
CollectivitesDOutreMer.class,
87+
CollectiviteDOutreMer.class );
88+
}
89+
}
90+
91+
92+
@Path(ConstGeoApi.PATH_COM + CODE_PATTERNCOM)
93+
@GET
94+
@Produces({
95+
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML
96+
})
97+
@Operation(
98+
operationId = LITTERAL_ID_OPERATION,
99+
summary = LITTERAL_OPERATION_SUMMARY,
100+
responses = {
101+
@ApiResponse(
102+
content = @Content(schema = @Schema(implementation = CollectiviteDOutreMer.class)),
103+
description = LITTERAL_RESPONSE_DESCRIPTION)
104+
})
105+
public Response getByCode(
106+
@Parameter(
107+
description = ConstGeoApi.PATTERN_COM_DESCRIPTION,
108+
required = true,
109+
schema = @Schema(
110+
pattern = ConstGeoApi.PATTERN_COM,
111+
type = Constants.TYPE_STRING, example=LITTERAL_CODE_EXAMPLE)) @PathParam(Constants.CODE) String code,
112+
@Parameter(hidden = true) @HeaderParam(HttpHeaders.ACCEPT) String header,
113+
@Parameter(
114+
description = LITTERAL_PARAMETER_DATE_DESCRIPTION,
115+
required = false,
116+
schema = @Schema(type = Constants.TYPE_STRING, format = Constants.FORMAT_DATE)) @QueryParam(
117+
value = Constants.PARAMETER_DATE) String date) {
118+
119+
logger.debug("Received GET request for collectivite d'outre-mer {}", code);
120+
121+
if ( ! this.verifyParameterDateIsRightWithoutHistory(date)) {
122+
return this.generateBadRequestResponse();
123+
}
124+
else {
125+
return this
126+
.generateResponseATerritoireByCode(
127+
sparqlUtils
128+
.executeSparqlQuery(
129+
GeoQueries.getCollectiviteDOutreMerByCodeAndDate(code, this.formatValidParameterDateIfIsNull(date))),
130+
header,
131+
new CollectiviteDOutreMer(code));
132+
}
133+
}
134+
135+
136+
@Path(ConstGeoApi.PATH_COM + CODE_PATTERNCOM + ConstGeoApi.PATH_DESCENDANT)
137+
@GET
138+
@Produces({
139+
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML
140+
})
141+
@Operation(
142+
operationId = LITTERAL_ID_OPERATION + ConstGeoApi.ID_OPERATION_DESCENDANTS,
143+
summary = "Informations concernant les territoires inclus dans la collectivite d'outre-mer",
144+
responses = {
145+
@ApiResponse(
146+
content = @Content(schema = @Schema(type = ARRAY, implementation = Territoire.class)),
147+
description = LITTERAL_RESPONSE_DESCRIPTION)
148+
})
149+
public Response getDescendants(
150+
@Parameter(
151+
description = "code de la collectivité d'outre-mer (3 caractères)",
152+
required = true,
153+
schema = @Schema(
154+
pattern = ConstGeoApi.PATTERN_COM,
155+
type = Constants.TYPE_STRING, example=LITTERAL_CODE_EXAMPLE)) @PathParam(Constants.CODE) String code,
156+
@Parameter(hidden = true) @HeaderParam(HttpHeaders.ACCEPT) String header,
157+
@Parameter(
158+
description ="Filtre pour renvoyer les territoires inclus dans la collectivité d'outre-mer active à la date donnée. Par défaut, c’est la date courante. (Format : 'AAAA-MM-JJ')",
159+
required = false,
160+
schema = @Schema(type = Constants.TYPE_STRING, format = Constants.FORMAT_DATE)) @QueryParam(
161+
value = Constants.PARAMETER_DATE) String date,
162+
@Parameter(
163+
description = LITTERAL_PARAMETER_TYPE_DESCRIPTION+ "(Commune ou District)",
164+
required = false,
165+
schema = @Schema(type = Constants.TYPE_STRING)) @QueryParam(
166+
value = Constants.PARAMETER_TYPE) String typeTerritoire,
167+
@Parameter(
168+
description = "Filtre sur le nom du ou des territoires renvoyés",
169+
required = false,
170+
schema = @Schema(type = Constants.TYPE_STRING)) @QueryParam(
171+
value = Constants.PARAMETER_FILTRE) String filtreNom) {
172+
173+
logger.debug("Received GET request for descendants of collectivite d'outre-mer {}", code);
174+
175+
if ( ! this.verifyParametersTypeAndDateAreValid(typeTerritoire, date)) {
176+
return this.generateBadRequestResponse();
177+
}
178+
else {
179+
return this.generateResponseListOfTerritoire(
180+
sparqlUtils.executeSparqlQuery(GeoQueries.getDescendantsCollectiviteDOutreMer(code,
181+
this.formatValidParameterDateIfIsNull(date),
182+
this.formatValidParametertypeTerritoireIfIsNull(typeTerritoire),
183+
this.formatValidParameterFiltreIfIsNull(filtreNom))),
184+
header, Territoires.class, Territoire.class);
185+
}
186+
}
187+
188+
}

src/main/java/fr/insee/rmes/api/geo/territoire/CommuneApi.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public class CommuneApi extends AbstractGeoApi {
4646
private static final String LITTERAL_PARAMETER_DATE_DESCRIPTION =
4747
"Filtre pour renvoyer la commune active à la date donnée. Par défaut, c’est la date courante. (Format : 'AAAA-MM-JJ')";
4848
private static final String LITTERAL_PARAMETER_TYPE_DESCRIPTION = "Filtre sur le type de territoire renvoyé.";
49-
49+
private static final String LITTERAL_PARAMETER_NAME_DESCRIPTION = "Filtre sur le nom de la commune" ;
5050
private static final String LITTERAL_CODE_EXAMPLE = "14475";
51-
51+
private static final String LITTERAL_PARAMETER_COM_DESCRIPTION="Sélectionner \"true\" pour inclure les collectivités d’outre-mer";
5252

5353
@Path(ConstGeoApi.PATH_COMMUNE + CODE_PATTERN)
5454
@GET
@@ -112,7 +112,7 @@ public Response getAscendants(
112112
required = true,
113113
schema = @Schema(
114114
pattern = ConstGeoApi.PATTERN_COMMUNE,
115-
type = Constants.TYPE_STRING, example=LITTERAL_CODE_EXAMPLE)) @PathParam(Constants.CODE) String code,
115+
type = Constants.TYPE_STRING, example="73035")) @PathParam(Constants.CODE) String code,
116116
@Parameter(hidden = true) @HeaderParam(HttpHeaders.ACCEPT) String header,
117117
@Parameter(
118118
description = "Filtre pour renvoyer les territoires contenant la commune active à la date donnée. Par défaut, c’est la date courante. (Format : 'AAAA-MM-JJ')",
@@ -218,7 +218,19 @@ public Response getListe(
218218
description = "Filtre pour renvoyer les communes actives à la date donnée. Par défaut, c’est la date courante. (Format : 'AAAA-MM-JJ')" + LITTERAL_PARAMETER_DATE_WITH_HISTORY,
219219
required = false,
220220
schema = @Schema(type = Constants.TYPE_STRING, format = Constants.FORMAT_DATE)) @QueryParam(
221-
value = Constants.PARAMETER_DATE) String date) {
221+
value = Constants.PARAMETER_DATE) String date,
222+
@Parameter(
223+
description = LITTERAL_PARAMETER_NAME_DESCRIPTION,
224+
required = false,
225+
schema = @Schema(type = Constants.TYPE_STRING, example="Bonnay")) @QueryParam(
226+
value = Constants.PARAMETER_FILTRE) String filtreNom,
227+
@Parameter(description = LITTERAL_PARAMETER_COM_DESCRIPTION,
228+
required = false,
229+
schema = @Schema(type = Constants.TYPE_BOOLEAN, allowableValues = {"true","false"},example="false", defaultValue = "false"))
230+
@QueryParam(
231+
value = Constants.PARAMETER_STRING) Boolean com
232+
)
233+
{
222234

223235
logger.debug("Received GET request for all communes");
224236

@@ -229,7 +241,7 @@ public Response getListe(
229241
return this
230242
.generateResponseListOfTerritoire(
231243
sparqlUtils
232-
.executeSparqlQuery(GeoQueries.getListCommunes(this.formatValidParameterDateIfIsNull(date))),
244+
.executeSparqlQuery(GeoQueries.getListCommunes(this.formatValidParameterDateIfIsNull(date), this.formatValidParameterFiltreIfIsNull(filtreNom),this.formatValidParameterBooleanIfIsNull(com))),
233245
header,
234246
Communes.class,
235247
Commune.class);

src/main/java/fr/insee/rmes/api/geo/territoire/DepartementApi.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class DepartementApi extends AbstractGeoApi {
4242
"Informations sur un departement identifié par son code (deux ou trois caractères)";
4343
private static final String LITTERAL_RESPONSE_DESCRIPTION = "Departement";
4444
private static final String LITTERAL_PARAMETER_TYPE_DESCRIPTION = "Filtre sur le type de territoire renvoyé.";
45-
45+
private static final String LITTERAL_PARAMETER_NAME_DESCRIPTION = "Filtre sur le nom des territoires renvoyés" ;
4646
private static final String LITTERAL_CODE_EXAMPLE = "22";
4747
private static final String LITTERAL_DATE_EXAMPLE = "1950-01-01";
4848

@@ -170,7 +170,12 @@ public Response getDescendants(
170170
description = LITTERAL_PARAMETER_TYPE_DESCRIPTION,
171171
required = false,
172172
schema = @Schema(type = Constants.TYPE_STRING)) @QueryParam(
173-
value = Constants.PARAMETER_TYPE) String typeTerritoire) {
173+
value = Constants.PARAMETER_TYPE) String typeTerritoire,
174+
@Parameter(
175+
description = LITTERAL_PARAMETER_NAME_DESCRIPTION,
176+
required = false,
177+
schema = @Schema(type = Constants.TYPE_STRING)) @QueryParam(
178+
value = Constants.PARAMETER_FILTRE) String filtreNom) {
174179

175180
logger.debug("Received GET request for descendants of departement {}", code);
176181

@@ -186,7 +191,7 @@ public Response getDescendants(
186191
.getDescendantsDepartement(
187192
code,
188193
this.formatValidParameterDateIfIsNull(date),
189-
this.formatValidParametertypeTerritoireIfIsNull(typeTerritoire))),
194+
this.formatValidParametertypeTerritoireIfIsNull(typeTerritoire),this.formatValidParameterFiltreIfIsNull(filtreNom))),
190195
header,
191196
Territoires.class,
192197
Territoire.class);

0 commit comments

Comments
 (0)