Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package fr.insee.rmes.metadata.api;

import fr.insee.rmes.metadata.api.requestprocessor.RequestProcessor;
import fr.insee.rmes.metadata.model.Commune;
import fr.insee.rmes.metadata.model.Iris;
import fr.insee.rmes.metadata.model.TerritoireTousAttributs;
import fr.insee.rmes.metadata.model.*;
import fr.insee.rmes.metadata.queries.parameters.AscendantsDescendantsRequestParametizer;
import fr.insee.rmes.metadata.queries.parameters.IrisListRequestParametizer;
import fr.insee.rmes.metadata.queries.parameters.TerritoireRequestParametizer;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.testcontainers.shaded.org.bouncycastle.crypto.engines.EthereumIESEngine;

import java.time.LocalDate;
import java.util.List;
Expand All @@ -21,6 +21,23 @@ public GeoIrisEndpoints(RequestProcessor requestProcessor) {
this.requestProcessor = requestProcessor;
}

@Override
public ResponseEntity<List<TerritoireTousAttributs>> getcogirisasc (String code, LocalDate date, TypeEnumAscendantsIris type) {
if (code.matches("^.{5}0000$")) {
return requestProcessor.queryToFindAscendantsFauxIris()
.with(new AscendantsDescendantsRequestParametizer(code, date, type, Iris.class))
.executeQuery()
.listResult(TerritoireTousAttributs.class)
.toResponseEntity();
}
else {
return requestProcessor.queryforFindAscendantsDescendants()
.with(new AscendantsDescendantsRequestParametizer(code, date, type, Iris.class))
.executeQuery()
.listResult(TerritoireTousAttributs.class)
.toResponseEntity();
}
}

@Override
public ResponseEntity<Iris> getcogiris(String code, LocalDate date) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public RequestProcessor.QueryBuilder queryToFindCommunesOfCanton() {
return new RequestProcessor.QueryBuilder(CANTON_COMMUNES, this);
}

public RequestProcessor.QueryBuilder queryToFindAscendantsFauxIris() {
return new RequestProcessor.QueryBuilder(ASCENDANTS_FAUX_IRIS, this);
}

public RequestProcessor.QueryBuilder queryforFindIrisDescendantsCommune() {
return new RequestProcessor.QueryBuilder(LIEN_COMMUNE_IRIS, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public record QueryBuilder(Configuration freemarkerConfiguration) {
// public static final String IRIS = "geographie/getIrisByCodeDate.ftlh";
public static final String IRIS = "geographie/getTerritoireByCodeDateNomCommune.ftlh";
public static final String IRIS_LIST = "geographie/getIrisList.ftlh";
public static final String ASCENDANTS_FAUX_IRIS = "geographie/getAscendantsFauxIrisByCodeTypeDate.ftlh";
public static final String LIEN_COMMUNE_IRIS = "geographie/hasIrisDescendant.ftlh";
public static final String LIEN_PAYS = "geographie/getPays.ftlh";
public static final String DESCENDANTS_PAYS = "geographie/getPaysDescendants.ftlh";
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface ParameterValueDecoder<T> {
String ENUM_DESCENDANTS_COMMUNE_CLASS = "fr.insee.rmes.metadata.model.TypeEnumDescendantsCommune";
String ENUM_ASCENDANTS_COMMUNE_CLASS = "fr.insee.rmes.metadata.model.TypeEnumAscendantsCommune";
String ENUM_DESCENDANTS_INTERCOMMUNALITE_CLASS = "fr.insee.rmes.metadata.model.TypeEnumDescendantsIntercommunalite";
String ENUM_ASCENDANTS_IRIS_CLASS = "fr.insee.rmes.metadata.model.TypeEnumAscendantsIris";
String ENUM_DESCENDANTS_PAYS_CLASS = "fr.insee.rmes.metadata.model.TypeEnumDescendantsPays";
String ENUM_DESCENDANTS_REGION_CLASS = "fr.insee.rmes.metadata.model.TypeEnumDescendantsRegion";
String ENUM_DESCENDANTS_UNITEURBAINE_CLASS = "fr.insee.rmes.metadata.model.TypeEnumDescendantsUniteUrbaine";
Expand Down Expand Up @@ -78,6 +79,8 @@ static <U> ParameterValueDecoder<U> of(Class<U> type) {
enumDepDesValue -> enumDepDesValue == null ? "none" : ((TypeEnumAscendantsDepartement) enumDepDesValue).getValue();
case ENUM_DESCENDANTS_INTERCOMMUNALITE_CLASS ->
enumIntercoValue -> enumIntercoValue == null ? "none" : ((TypeEnumDescendantsIntercommunalite) enumIntercoValue).getValue();
case ENUM_ASCENDANTS_IRIS_CLASS ->
enumIrisValue -> enumIrisValue == null ? "none" : ((TypeEnumAscendantsIris) enumIrisValue).getValue();
case ENUM_DESCENDANTS_PAYS_CLASS ->
enumPaysValue -> enumPaysValue == null ? "none" : ((TypeEnumDescendantsPays) enumPaysValue).getValue();
case ENUM_DESCENDANTS_REGION_CLASS ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package fr.insee.rmes.metadata.utils;

import fr.insee.rmes.metadata.model.TypeEnumAscendantsIris;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;


@Component
public class TypeEnumAscendantsIrisConverter implements Converter<String, TypeEnumAscendantsIris> {
@Override
public TypeEnumAscendantsIris convert(String source) {
for (TypeEnumAscendantsIris type : TypeEnumAscendantsIris.values()) {
if (type.getValue().equalsIgnoreCase(source)) {
return type;
}
}
throw new IllegalArgumentException("Invalid value for TypeEnumAscendantsIris : " + source);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
SELECT ?uri ?type ?code ?typeArticle ?intitule ?intituleSansArticle ?cheflieu ?dateCreation ?dateSuppression
SELECT ?uri (STRAFTER(STR(?typeAvecIri), "#") AS ?type) ?code ?typeArticle ?intitule ?intituleSansArticle ?cheflieu ?dateCreation ?dateSuppression
FROM <http://rdf.insee.fr/graphes/geo/cog>
WHERE {
{
SELECT DISTINCT ?uri ?type ?code ?typeArticle ?intitule ?intituleSansArticle ?cheflieu ?dateCreation ?dateSuppression
SELECT DISTINCT ?uri ?typeAvecIri ?code ?typeArticle ?intitule ?intituleSansArticle ?cheflieu ?dateCreation ?dateSuppression
WHERE {
{
?enfant a igeo:Iris ;
Expand All @@ -26,14 +27,14 @@ WHERE {
?enfant igeo:subdivisionDirecteDe* ?ressource .
}
?ressource a ?typeRDF;
<#if type != "none">
a igeo:${type} ;
<#if typeEnumAscendantsIris != "none">
a igeo:${typeEnumAscendantsIris} ;
</#if>
igeo:codeINSEE ?code ;
igeo:codeArticle ?typeArticle ;
igeo:nom ?intitule ;
igeo:nomSansArticle ?intituleSansArticle .
BIND(STR(?typeRDF) AS ?type).
BIND(STR(?typeRDF) AS ?typeAvecIri).
BIND(STR(?ressource) AS ?uri).
OPTIONAL {?enfant (^igeo:creation/igeo:date) ?dateCreationEnfant.}
OPTIONAL {?enfant (^igeo:suppression/igeo:date) ?dateSuppressionEnfant.}
Expand All @@ -46,4 +47,4 @@ WHERE {
FILTER(!BOUND(?dateCreation) || ?dateCreation <= '${date}'^^xsd:date)
FILTER(!BOUND(?dateSuppression) || ?dateSuppression > '${date}'^^xsd:date)
}
ORDER BY ?type ?code
ORDER BY ?typeAvecIri ?code
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ BIND(SUBSTR(STR(?uriTypeDIris ), STRLEN(STR(?uriTypeDIris )), 1) AS ?typeDIris)
?uri a igeo:${typeEnumDescendantsIntercommunalite} .
</#if>

<#if typeEnumAscendantsIris != "none">
?uri a igeo:${typeEnumAscendantsIris} .
</#if>

<#if typeEnumDescendantsRegion != "none">
?uri a igeo:${typeEnumDescendantsRegion} .
</#if>
Expand Down
Loading