Skip to content

Commit

Permalink
Merge pull request #64 from InseeFr/acceptance
Browse files Browse the repository at this point in the history
Acceptance
  • Loading branch information
JeromeMBourgeois authored Aug 10, 2022
2 parents 82aa444 + 7b6d165 commit 1d0d120
Show file tree
Hide file tree
Showing 30 changed files with 651 additions and 246 deletions.
2 changes: 1 addition & 1 deletion src/main/java/fr/insee/rmes/api/AbstractMetadataApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract class AbstractMetadataApi {

protected ResponseUtils responseUtils;

public AbstractMetadataApi() {
protected AbstractMetadataApi() {

this.sparqlUtils = new SparqlUtils();
this.csvUtils = new CSVUtils();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import javax.ws.rs.core.Response.Status;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import fr.insee.rmes.api.AbstractMetadataApi;
import fr.insee.rmes.modeles.classification.Poste;
Expand All @@ -39,7 +37,6 @@
@Tag(name = "nomenclatures", description = "Nomenclatures API")
public class ClassificationApi extends AbstractMetadataApi {

private static Logger logger = LogManager.getLogger(ClassificationApi.class);

@Hidden
@GET
Expand All @@ -53,8 +50,6 @@ public Response getClassificationByCode(
@Parameter(required = true, description = "Identifiant de la nomenclature (hors cj)", example = "nafr2") @PathParam("code") String code,
@Parameter(hidden = true) @HeaderParam(value = HttpHeaders.ACCEPT) String header) {

logger.debug("Received GET request for classification {}", code);

final String csvResult = sparqlUtils.executeSparqlQuery(ClassificationsQueries.getClassification(code));
final List<Poste> itemsList = csvUtils.populateMultiPOJO(csvResult, Poste.class);

Expand All @@ -80,7 +75,6 @@ public Response getClassificationByCode(
public Response getClassificationTreeByCode(
@Parameter(required = true, description = "Identifiant de la nomenclature (hors cj)", example = "nafr2") @PathParam("code") String code,
@Parameter(hidden = true) @HeaderParam(value = HttpHeaders.ACCEPT) String header) {
logger.debug("Received GET request for classification tree {}", code);

final String csvResult = sparqlUtils.executeSparqlQuery(ClassificationsQueries.getClassification(code));
final List<? extends Poste> itemsList = csvUtils.populateMultiPOJO(csvResult, Poste.class);
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/fr/insee/rmes/api/classifications/CodesAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.joda.time.DateTime;

import fr.insee.rmes.api.AbstractMetadataApi;
Expand Down Expand Up @@ -47,7 +45,6 @@
@Tag(name = "nomenclatures", description = "Nomenclatures API")
public class CodesAPI extends AbstractMetadataApi {

private static Logger logger = LogManager.getLogger(CodesAPI.class);

@Path("/cj/n2/{code: [0-9]{2}}")
@GET
Expand All @@ -62,7 +59,6 @@ public Response getCategorieJuridiqueNiveauII(
required = true,
description = "Identifiant de la catégorie juridique de niveau 2 (deux chiffres)", example="10") @PathParam("code") String code,
@Parameter(hidden = true) @HeaderParam("Accept") String header) {
logger.debug("Received GET request for CJ 2nd level {}", code);

CategorieJuridiqueNiveauII cjNiveau2 = new CategorieJuridiqueNiveauII(code);
String csvResult = sparqlUtils.executeSparqlQuery(CJQueries.getCategorieJuridiqueNiveauII(code));
Expand All @@ -87,7 +83,6 @@ public Response getCategorieJuridiqueNiveauIII(
required = true,
description = "Identifiant de la catégorie juridique de niveau 3 (quatre chiffres)", example="7112") @PathParam("code") String code,
@Parameter(hidden = true) @HeaderParam("Accept") String header) {
logger.debug("Received GET request for CJ 3rd level {}", code);


CategorieJuridiqueNiveauIII cjNiveau3 = new CategorieJuridiqueNiveauIII(code);
Expand Down Expand Up @@ -117,7 +112,6 @@ public Response getCategoriesJuridiques(
@Parameter(
description = "Date à laquelle la catégorie juridique est valide (Format : 'AAAA-MM-JJ' ; '*' pour obtenir tout l'historique ; paramètre absent pour la date du jour)", example="2020-05-11") @QueryParam("date") String date,
@Parameter(hidden = true) @HeaderParam("Accept") String header) {
logger.debug("Received GET request for CJ 2nd level {} date: {}", code, date);

String csvResult = "";
if (date == null) {
Expand Down Expand Up @@ -164,7 +158,6 @@ public Response getSousClasseNAF2008(
required = true,
description = "Code de la sous-classe (deux chiffres, un point, deux chiffres et une lettre majuscule)", example="33.16Z") @PathParam("code") String code,
@Parameter(hidden = true) @HeaderParam("Accept") String header) {
logger.debug("Received GET request for NAF sub-class {}", code);

SousClasseNAF2008 sousClasse = new SousClasseNAF2008(code);
String csvResult = sparqlUtils.executeSparqlQuery(Naf2008Queries.getSousClasseNAF2008(code));
Expand Down Expand Up @@ -192,7 +185,6 @@ public Response getClasseNAF2008(
required = true,
description = "Code de la classe (deux chiffres, un point, deux chiffres)", example = "46.66") @PathParam("code") String code,
@Parameter(hidden = true) @HeaderParam("Accept") String header) {
logger.debug("Received GET request for NAF rev. 2 class {}", code);

ClasseNAF2008 classe = new ClasseNAF2008(code);
String csvResult = sparqlUtils.executeSparqlQuery(Naf2008Queries.getClasseNAF2008(code));
Expand Down Expand Up @@ -221,7 +213,6 @@ public Response getClasseNAF2003(
required = true,
description = "Code de la classe (deux chiffres, un point, un chiffre, une lettre majuscule)", example = "28.1C") @PathParam("code") String code,
@Parameter(hidden = true) @HeaderParam("Accept") String header) {
logger.debug("Received GET request for NAF rev. 1 class {}", code);

ClasseNAF2003 classe = new ClasseNAF2003(code);
String csvResult = sparqlUtils.executeSparqlQuery(Naf2003Queries.getClasseNAF2003(code));
Expand Down Expand Up @@ -250,7 +241,6 @@ public Response getClasseNAF1993(
required = true,
description = "Code de la classe (deux chiffres, un point, un chiffre, une lettre majuscule)", example = "28.1C") @PathParam("code") String code,
@Parameter(hidden = true) @HeaderParam("Accept") String header) {
logger.debug("Received GET request for NAF class {}", code);

ClasseNAF1993 classe = new ClasseNAF1993(code);
String csvResult = sparqlUtils.executeSparqlQuery(Naf1993Queries.getClasseNAF1993(code));
Expand Down Expand Up @@ -279,7 +269,6 @@ public Response getGroupeNA1973(
required = true,
description = "Code du groupe (deux chiffres, un point, deux chiffres)", example="45.23") @PathParam("code") String code,
@Parameter(hidden = true) @HeaderParam("Accept") String header) {
logger.debug("Received GET request for NA 1973 group {}", code);

GroupeNA1973 groupe = new GroupeNA1973(code);
String csvResult = sparqlUtils.executeSparqlQuery(Na1973Queries.getGroupeNA1973(code));
Expand Down Expand Up @@ -308,7 +297,6 @@ public Response getActivities(
@Parameter(
description = "Date à laquelle l'activité est valide (Format : 'AAAA-MM-JJ' ; '*' pour obtenir tout l'historique ; paramètre absent pour la date du jour)") @QueryParam("date") String date,
@Parameter(hidden = true) @HeaderParam("Accept") String header) {
logger.debug("Received GET request for Activities {} date: {}", code, date);

String csvResult = "";

Expand Down
8 changes: 0 additions & 8 deletions src/main/java/fr/insee/rmes/api/concepts/ConceptsAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import javax.ws.rs.core.Response.Status;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import fr.insee.rmes.api.AbstractMetadataApi;
import fr.insee.rmes.modeles.concepts.Concept;
Expand All @@ -34,8 +32,6 @@
@Tag(name = "concepts", description = "Concepts API")
public class ConceptsAPI extends AbstractMetadataApi {

private static Logger logger = LogManager.getLogger(ConceptsAPI.class);

@Path("/definitions")
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
Expand All @@ -47,8 +43,6 @@ public Response getConcepts(
@Parameter(description = "Recherche dans les libellés", schema = @Schema(type = "string"), example = "élect") @QueryParam("libelle") String libelle,
@Parameter(hidden = true) @HeaderParam(HttpHeaders.ACCEPT) String header) {

logger.debug("Received GET request concepts");

String label = StringUtils.isEmpty(libelle) ? "" : libelle;

String csvResult = sparqlUtils.executeSparqlQuery(ConceptsQueries.getConceptsByLabel(label));
Expand Down Expand Up @@ -83,8 +77,6 @@ public Response getConceptById(
@Parameter(required = true, description = "Identifiant du concept (format : c[0-9]{4})", schema = @Schema(pattern = "c[0-9]{4}", type = "string"), example = "c2066") @PathParam("id") String id,
@Parameter(hidden = true) @HeaderParam(HttpHeaders.ACCEPT) String header) {

logger.debug("Received GET request for Concept: {}", id);

Concept concept = new Concept(id);
String csvResult = sparqlUtils.executeSparqlQuery(ConceptsQueries.getConceptById(id));
concept = (Concept) csvUtils.populatePOJO(csvResult, concept);
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/fr/insee/rmes/api/geo/PaysApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import fr.insee.rmes.modeles.geo.Country;
import fr.insee.rmes.queries.geo.GeoQueries;
import fr.insee.rmes.utils.Constants;
Expand All @@ -27,7 +24,6 @@
@Tag(name = ConstGeoApi.TAG_NAME, description = ConstGeoApi.TAG_DESCRIPTION)
public class PaysApi extends AbstractGeoApi {

private static Logger logger = LogManager.getLogger(PaysApi.class);

private static final String CODE_PATTERN = "/{code: " + ConstGeoApi.PATTERN_PAYS + "}";
private static final String LITTERAL_ID_OPERATION = "getcogpays";
Expand All @@ -54,8 +50,6 @@ public Response getByCode(
type = Constants.TYPE_STRING, example="99217")) @PathParam(Constants.CODE) String code,
@Parameter(hidden = true) @HeaderParam(HttpHeaders.ACCEPT) String header) {

logger.debug("Received GET request for country {}", code);

Country country = new Country(code);
String csvResult = sparqlUtils.executeSparqlQuery(GeoQueries.getCountry(code));
country = (Country) csvUtils.populatePOJO(csvResult, country);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import fr.insee.rmes.api.geo.AbstractGeoApi;
import fr.insee.rmes.api.geo.ConstGeoApi;
import fr.insee.rmes.modeles.geo.territoire.AireAttraction;
Expand All @@ -32,8 +29,6 @@
@Tag(name = ConstGeoApi.TAG_NAME, description = ConstGeoApi.TAG_DESCRIPTION)
public class AireAttractionApi extends AbstractGeoApi {

private static Logger logger = LogManager.getLogger(AireAttractionApi.class);

private static final String CODE_PATTERN = "/{code: " + ConstGeoApi.PATTERN_AIRE_ATTRACTION + "}";
private static final String LITTERAL_ID_OPERATION = "getcogaav";
private static final String LITTERAL_OPERATION_SUMMARY =
Expand Down Expand Up @@ -73,8 +68,6 @@ public Response getByCode(
schema = @Schema(type = Constants.TYPE_STRING, format = Constants.FORMAT_DATE)) @QueryParam(
value = Constants.PARAMETER_DATE) String date) {

logger.debug("Received GET request for aire d'attraction {}", code);

if ( ! this.verifyParameterDateIsRightWithoutHistory(date)) {
return this.generateBadRequestResponse();
}
Expand Down Expand Up @@ -121,8 +114,6 @@ public Response getDescendants(
schema = @Schema(type = Constants.TYPE_STRING, example="ArrondissementMunicipal")) @QueryParam(
value = Constants.PARAMETER_TYPE) String typeTerritoire) {

logger.debug("Received GET request for descendants of aire d'attraction {}", code);

if ( ! this.verifyParametersTypeAndDateAreValid(typeTerritoire, date)) {
return this.generateBadRequestResponse();
}
Expand Down Expand Up @@ -164,8 +155,6 @@ public Response getListe(
schema = @Schema(type = Constants.TYPE_STRING, format = Constants.FORMAT_DATE)) @QueryParam(
value = Constants.PARAMETER_DATE) String date) {

logger.debug("Received GET request for all attraction areas");

if ( ! this.verifyParameterDateIsRightWithHistory(date)) {
return this.generateBadRequestResponse();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import fr.insee.rmes.api.geo.AbstractGeoApi;
import fr.insee.rmes.api.geo.ConstGeoApi;
import fr.insee.rmes.modeles.geo.territoire.Arrondissement;
Expand All @@ -37,8 +34,6 @@ public class ArrondissementApi extends AbstractGeoApi {
private static final String LITTERAL_DATE_PROJECTION_DESCRIPTION = "Date vers laquelle est projetée l'arrondissement. Paramètre obligatoire (erreur 400 si absent, Format : 'AAAA-MM-JJ')";
private static final String LITTERAL_DATE_ORIGINE_PROJ_DESCRIPTION = "Filtre pour préciser l'arrondissement de départ. Par défaut, c’est la date courante qui est utilisée. (Format : 'AAAA-MM-JJ')";

private static Logger logger = LogManager.getLogger(ArrondissementApi.class);

private static final String CODE_PATTERN = "/{code: " + ConstGeoApi.PATTERN_ARRONDISSEMENT + "}";
private static final String LITTERAL_ID_OPERATION = "getcogarr";
private static final String LITTERAL_OPERATION_SUMMARY =
Expand Down Expand Up @@ -77,8 +72,6 @@ public Response getByCode(
schema = @Schema(type = Constants.TYPE_STRING, format = Constants.FORMAT_DATE)) @QueryParam(
value = Constants.PARAMETER_DATE) String date) {

logger.debug("Received GET request for arrondissement {}", code);

if ( ! this.verifyParameterDateIsRightWithoutHistory(date)) {
return this.generateBadRequestResponse();
}
Expand Down Expand Up @@ -126,8 +119,6 @@ public Response getAscendants(
schema = @Schema(type = Constants.TYPE_STRING)) @QueryParam(
value = Constants.PARAMETER_TYPE) String typeTerritoire) {

logger.debug("Received GET request for ascendants of arrondissement {}", code);

if ( ! this.verifyParametersTypeAndDateAreValid(typeTerritoire, date)) {
return this.generateBadRequestResponse();
}
Expand Down Expand Up @@ -179,8 +170,6 @@ public Response getDescendants(
schema = @Schema(type = Constants.TYPE_STRING), example="CommuneDeleguee") @QueryParam(
value = Constants.PARAMETER_TYPE) String typeTerritoire) {

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

if ( ! this.verifyParametersTypeAndDateAreValid(typeTerritoire, date)) {
return this.generateBadRequestResponse();
}
Expand Down Expand Up @@ -221,8 +210,6 @@ public Response getListe(
schema = @Schema(type = Constants.TYPE_STRING, format = Constants.FORMAT_DATE)) @QueryParam(
value = Constants.PARAMETER_DATE) String date) {

logger.debug("Received GET request for all arrondissements");

if ( ! this.verifyParameterDateIsRightWithHistory(date)) {
return this.generateBadRequestResponse();
}
Expand Down Expand Up @@ -266,8 +253,6 @@ public Response getSuivant(
schema = @Schema(type = Constants.TYPE_STRING, format = Constants.FORMAT_DATE, example=LITTERAL_DATE_EXAMPLE)) @QueryParam(
value = Constants.PARAMETER_DATE) String date) {

logger.debug("Received GET request for suivant arrondissement {}", code);

if ( ! this.verifyParameterDateIsRightWithoutHistory(date)) {
return this.generateBadRequestResponse();
}
Expand Down Expand Up @@ -310,8 +295,6 @@ public Response getPrecedent(
schema = @Schema(type = Constants.TYPE_STRING, format = Constants.FORMAT_DATE)) @QueryParam(
value = Constants.PARAMETER_DATE) String date) {

logger.debug("Received GET request for precedent arrondissement {}", code);

if ( ! this.verifyParameterDateIsRightWithoutHistory(date)) {
return this.generateBadRequestResponse();
}
Expand Down Expand Up @@ -359,8 +342,6 @@ public Response getProjection(
schema = @Schema(type = Constants.TYPE_STRING, format = Constants.FORMAT_DATE), example="1994-07-30") @QueryParam(
value = Constants.PARAMETER_DATE_PROJECTION) String dateProjection) {

logger.debug("Received GET request for arrondissement {} projection", code);

if ( ! this.verifyParameterDateIsRightWithoutHistory(date) || ! this.verifyParameterDateIsRightWithoutHistory(dateProjection)) {
return this.generateBadRequestResponse();
}
Expand Down Expand Up @@ -407,8 +388,6 @@ public Response getAllProjections(
schema = @Schema(type = Constants.TYPE_STRING, format = Constants.FORMAT_DATE)) @QueryParam(
value = Constants.PARAMETER_DATE_PROJECTION) String dateProjection) {

logger.debug("Received GET request for all arrondissements projections");

if ( ! this.verifyParameterDateIsRightWithoutHistory(date) || ! this.verifyParameterDateIsRightWithoutHistory(dateProjection)) {
return this.generateBadRequestResponse();
}
Expand Down
Loading

0 comments on commit 1d0d120

Please sign in to comment.