Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/geography lang #418

Merged
merged 2 commits into from
Nov 3, 2023
Merged
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,16 +1,11 @@
package fr.insee.rmes.bauhaus_services;

import fr.insee.rmes.exceptions.RmesException;
import org.eclipse.rdf4j.model.IRI;
import org.json.JSONObject;

import fr.insee.rmes.exceptions.RmesException;

public interface GeographyService {

/******************************************************************************************
* COG
* *******************************************************************************************/

String getGeoFeatures() throws RmesException;

JSONObject getGeoFeatureById(String id) throws RmesException;
Expand All @@ -19,6 +14,5 @@ public interface GeographyService {

JSONObject getGeoFeature(IRI uri) throws RmesException;


void updateFeature(String id, String body) throws RmesException;
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
package fr.insee.rmes.bauhaus_services.geography;

import java.io.IOException;
import java.util.UUID;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.Model;
import org.eclipse.rdf4j.model.impl.LinkedHashModel;
import org.eclipse.rdf4j.model.vocabulary.DCTERMS;
import org.eclipse.rdf4j.model.vocabulary.RDF;
import org.eclipse.rdf4j.model.vocabulary.SKOS;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

import fr.insee.rmes.bauhaus_services.Constants;
import fr.insee.rmes.bauhaus_services.GeographyService;
import fr.insee.rmes.bauhaus_services.rdf_utils.ObjectType;
Expand All @@ -33,6 +16,21 @@
import fr.insee.rmes.persistance.ontologies.GEO;
import fr.insee.rmes.persistance.ontologies.IGEO;
import fr.insee.rmes.persistance.sparql_queries.geography.GeoQueries;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.Model;
import org.eclipse.rdf4j.model.impl.LinkedHashModel;
import org.eclipse.rdf4j.model.vocabulary.DCTERMS;
import org.eclipse.rdf4j.model.vocabulary.RDF;
import org.eclipse.rdf4j.model.vocabulary.SKOS;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.UUID;

@Service
public class GeographyServiceImpl extends RdfService implements GeographyService {
Expand Down Expand Up @@ -173,6 +171,7 @@ public String createRdfGeoFeature(GeoFeature geoFeature) throws RmesException {
model.add(geoIRI, SKOS.PREF_LABEL, RdfUtils.setLiteralString(geoFeature.getLabelLg1(), config.getLg1()), RdfUtils.simsGeographyGraph());

/*Optional*/
RdfUtils.addTripleString(geoIRI, SKOS.PREF_LABEL, geoFeature.getLabelLg2(), config.getLg2(), model, RdfUtils.simsGeographyGraph());
RdfUtils.addTripleString(geoIRI, IGEO.NOM, geoFeature.getLabelLg2(), config.getLg2(), model, RdfUtils.simsGeographyGraph());
RdfUtils.addTripleStringMdToXhtml(geoIRI, DCTERMS.ABSTRACT, geoFeature.getDescriptionLg1(), config.getLg1(), model, RdfUtils.simsGeographyGraph());
RdfUtils.addTripleStringMdToXhtml(geoIRI, DCTERMS.ABSTRACT, geoFeature.getDescriptionLg2(), config.getLg2(), model, RdfUtils.simsGeographyGraph());
Expand Down
17 changes: 14 additions & 3 deletions src/main/resources/request/geography/getGeoFeatures.ftlh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
SELECT DISTINCT ?id ?uri ?labelLg1 ?labelLg2 ?code ?typeTerritory
?dateCreation ?dateSuppression ?hasComposition
SELECT DISTINCT ?id ?uri ?labelLg1 ?labelLg2 ?code ?typeTerritory ?dateCreation ?dateSuppression ?hasComposition
FROM <${COG_GRAPH}>
FROM <${GEO_SIMS_GRAPH}>
WHERE {
{ ?uri igeo:nom ?labelLg1 .
?uri igeo:nom ?labelLg2 .
?uri igeo:codeINSEE ?code .

OPTIONAL {
Expand All @@ -25,7 +25,16 @@ FROM <${GEO_SIMS_GRAPH}>
UNION

{
?uri skos:prefLabel ?labelLg1 .
OPTIONAL {
?uri skos:prefLabel ?labelLg1 .
FILTER (lang(?labelLg1) = '${LG1}')
}

OPTIONAL {
?uri skos:prefLabel ?labelLg2 .
FILTER (lang(?labelLg2) = '${LG2}')
}

?uri a igeo:TerritoireStatistique .
BIND("Territoire Statistique" AS ?typeTerritory)

Expand All @@ -34,6 +43,7 @@ FROM <${GEO_SIMS_GRAPH}>

{
?uri rdfs:label ?labelLg1 .
?uri rdfs:label ?labelLg2 .
?uri a igeo:TerritoireFrancais .
BIND("Territoire Français" AS ?typeTerritory)

Expand All @@ -42,6 +52,7 @@ FROM <${GEO_SIMS_GRAPH}>

{
?uri rdfs:label ?labelLg1 .
?uri rdfs:label ?labelLg2 .
?uri a igeo:Pays .
BIND("pays" AS ?typeTerritory)

Expand Down