Skip to content

Commit

Permalink
Merge pull request #173 from JeromeMBourgeois/release3.0.9
Browse files Browse the repository at this point in the history
Release3.0.9
  • Loading branch information
BulotF authored Nov 4, 2021
2 parents 5916924 + e88159f commit 977350e
Show file tree
Hide file tree
Showing 21 changed files with 241 additions and 77 deletions.
5 changes: 5 additions & 0 deletions bauhaus-back-changeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
3.0.9 : - Amélioration de la consultation: Ajout des parents/enfants
- Fin des développements pour "Géographie"
- Correction d'un bug lors de l'exportation des indicateurs en odt
- Récupération du créateur de la série lors de l'appel depuis une de ses opérations
- Prise en compte du changement de l'ontologie "Géographie" pour "France" (GEO\Pays)
3.0.8 : - Suppression de la page blanche à la première connexion
- Titres spécifiques aux pages (pour l'historique des navigateurs notamment)
- Améliorations des sims :
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>fr.insee.rmes</groupId>
<artifactId>Bauhaus-BO</artifactId>
<packaging>war</packaging>
<version>3.0.8</version>
<version>3.0.9</version>
<name>Bauhaus-Back-Office</name>
<description>Back-office services for Bauhaus</description>
<url>https://github.com/InseeFr/Bauhaus-Back-Office</url>
Expand Down Expand Up @@ -414,7 +414,7 @@
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.7.2</version>
<version>1.14.2</version>
</dependency>

<!-- https://mvnrepository.com/artifact/jaxen/jaxen -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ public String getStructure(String id) throws RmesException {
structure.remove("prefLabelLg1");
structure.remove("prefLabelLg2");


if(structure.has("idParent")){
String idParent = structure.getString("idParent");
JSONObject parent = new JSONObject();
parent.put("id", idParent);
structure.put("parent", parent);
}
if(structure.has(Constants.STATUT_VALIDATION)){
String validationState = structure.getString(Constants.STATUT_VALIDATION);
structure.put(Constants.STATUT_VALIDATION, this.getValidationState(validationState));
Expand Down Expand Up @@ -182,10 +189,57 @@ public String getComponent(String id) throws RmesException {
component.remove("prefLabelLg1");
component.remove("prefLabelLg2");

if(component.has("uriComponentParentId")){
JSONObject parent = new JSONObject();
parent.put("id", component.getString("uriComponentParentId"));
parent.put("notation", component.getString("uriComponentParentNotation"));
component.remove("uriComponentParentId");
component.remove("uriComponentParentNotation");
component.put("parent", parent);
}

JSONArray flatChildren = repoGestion.getResponseAsArray(buildRequest("getComponentChildren.ftlh", params));
if(flatChildren.length() > 0) {
component.put("enfants", flatChildren);
}

if(component.has("statutValidation")){
String validationState = component.getString("statutValidation");
component.put("statutValidation", this.getValidationState(validationState));
}

if(component.has("uriListeCode")){
component.put("representation", "liste de code");

JSONArray codes = getCodes(component.getString("idListeCode"));
JSONObject listCode = new JSONObject();
listCode.put("uri", component.getString("uriListeCode"));
listCode.put("id", component.getString("idListeCode"));
listCode.put("codes", codes);
component.put("listeCode", listCode);
component.remove("uriListeCode");
component.remove("idListeCode");
}

if(component.has("uriConcept")){

JSONObject concept = new JSONObject();
concept.put("uri", component.getString("uriConcept"));
concept.put("id", component.getString("idConcept"));
component.put("concept", concept);
component.remove("uriConcept");
component.remove("idConcept");
}

if(component.has("representation")){
if(component.getString("representation").endsWith("date")){
component.put("representation", "date");
} else if(component.getString("representation").endsWith("int")){
component.put("representation", "entier");
} else if(component.getString("representation").endsWith("float")){
component.put("representation", "décimal");
}
}
return component.toString();
}

Expand Down Expand Up @@ -215,9 +269,11 @@ private void getStructureComponents(String id, JSONObject structure) throws Rmes
if(component.has("listeCodeUri")){
component.put("representation", "liste de code");

JSONArray codes = getCodes(component.getString("listeCodeNotation"));
JSONObject listCode = new JSONObject();
listCode.put("uri", component.getString("listeCodeUri"));
listCode.put("id", component.getString("listeCodeNotation"));
listCode.put("codes", codes);
component.put("listeCode", listCode);
component.remove("listeCodeUri");
component.remove("listeCodeNotation");
Expand All @@ -244,7 +300,7 @@ private void getStructureComponents(String id, JSONObject structure) throws Rmes
}

String idComponent = component.getString("id");
component.remove("id");

if(idComponent.startsWith("a")){
attributes.put(component);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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;
Expand Down Expand Up @@ -102,7 +103,7 @@ private void addUnionsAndDifferenceToJsonObject(JSONObject feature) throws RmesE
String uriFeature = feature.getString(Constants.URI);
JSONArray unions = repoGestion.getResponseAsArray(GeoQueries.getUnionsForAFeatureQuery(uriFeature));
feature.put("unions", unions);
JSONObject diff = repoGestion.getResponseAsObject(GeoQueries.getDifferenceForAFeatureQuery(uriFeature));
JSONArray diff = repoGestion.getResponseAsArray(GeoQueries.getDifferenceForAFeatureQuery(uriFeature));
feature.put("difference", diff);
}

Expand All @@ -124,12 +125,12 @@ public String createFeature(String body) throws RmesException {
} catch (IOException e) {
logger.error(e.getMessage());
}
createRdfGeoFeature(geoFeature);
String iri = createRdfGeoFeature(geoFeature);
logger.info("Create geofeature : {} - {}", id , geoFeature.getLabelLg1());
return id.toString();
return iri;
}

public void createRdfGeoFeature(GeoFeature geoFeature) throws RmesException {
public String createRdfGeoFeature(GeoFeature geoFeature) throws RmesException {
Model model = new LinkedHashModel();
if (geoFeature == null || StringUtils.isEmpty(geoFeature.getId())) {
throw new RmesNotFoundException(ErrorCodes.GEOFEATURE_UNKNOWN, "No uri found", CAN_T_READ_REQUEST_BODY);
Expand All @@ -139,16 +140,26 @@ public void createRdfGeoFeature(GeoFeature geoFeature) throws RmesException {
}
IRI geoIRI = RdfUtils.objectIRI(ObjectType.GEO_STAT_TERRITORY, geoFeature.getId());
/*Const*/
model.add(geoIRI, RDF.TYPE, GEO.FEATURE, RdfUtils.simsGeographyGraph());
model.add(geoIRI, RDF.TYPE, IGEO.TERRITOIRE_STATISTIQUE, RdfUtils.simsGeographyGraph());
/*Required*/
model.add(geoIRI, IGEO.NOM, RdfUtils.setLiteralString(geoFeature.getLabelLg1(), Config.LG1), RdfUtils.simsGeographyGraph());
model.add(geoIRI, IGEO.CODE_INSEE, RdfUtils.setLiteralString(geoFeature.getCode()), RdfUtils.simsGeographyGraph());
model.add(geoIRI, SKOS.PREF_LABEL, RdfUtils.setLiteralString(geoFeature.getLabelLg1(), Config.LG1), RdfUtils.simsGeographyGraph());

/*Optional*/
RdfUtils.addTripleString(geoIRI, IGEO.NOM, geoFeature.getLabelLg2(), Config.LG2, model, RdfUtils.simsGeographyGraph());
RdfUtils.addTripleStringMdToXhtml(geoIRI, DCTERMS.ABSTRACT, geoFeature.getDescriptionLg1(), Config.LG1, model, RdfUtils.simsGeographyGraph());
RdfUtils.addTripleStringMdToXhtml(geoIRI, DCTERMS.ABSTRACT, geoFeature.getDescriptionLg2(), Config.LG2, model, RdfUtils.simsGeographyGraph());



geoFeature.getUnions().forEach(feature -> {
RdfUtils.addTripleUri(geoIRI, GEO.UNION, feature.getUri(), model, RdfUtils.simsGeographyGraph());

});
geoFeature.getDifference().forEach(feature -> {
RdfUtils.addTripleUri(geoIRI, GEO.DIFFERENCE, feature.getUri(), model, RdfUtils.simsGeographyGraph());
});
repoGestion.loadSimpleObject(geoIRI, model);

return geoIRI.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,16 @@ public String changeFile(String docId, InputStream documentFile, String document
uploadFile(documentFile, documentName, newUrl, false);

// Update document's url
changeDocumentsURL(docId, docUrl, newUrl);
changeDocumentsURL(docId, addSchemeFile(docUrl), addSchemeFile(newUrl));
}

return newUrl;
}

private String addSchemeFile(String url) {
if (url.startsWith(SCHEME_FILE))return url;
return SCHEME_FILE+url;
}

private void uploadFile(InputStream documentFile, String documentName, String url, Boolean sameName)
throws RmesUnauthorizedException {
Expand Down Expand Up @@ -531,7 +536,7 @@ private String createFileUrl(String name) throws RmesException {
if (m.find()) {// absolute URL
return url;
}
return SCHEME_FILE + url;
return addSchemeFile(url);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public SwaggerConfig(@Context ServletConfig servletConfig) {
super();
OpenAPI openApi = new OpenAPI();

Info info = new Info().title("Bauhaus API").version("3.0.8").description("Rest Endpoints and services Integration used by Bauhaus");
Info info = new Info().title("Bauhaus API").version("3.0.9").description("Rest Endpoints and services Integration used by Bauhaus");
openApi.info(info);

Server server = new Server();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/fr/insee/rmes/model/geography/GeoFeature.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class GeoFeature {
private String labelLg1;
private String labelLg2;
private List<GeoFeature> unions;
private GeoFeature difference;
private List<GeoFeature> difference;
private String code;
private String uri;
private String descriptionLg1;
Expand Down Expand Up @@ -38,10 +38,10 @@ public List<GeoFeature> getUnions() {
public void setUnions(List<GeoFeature> unions) {
this.unions = unions;
}
public GeoFeature getDifference() {
public List<GeoFeature> getDifference() {
return difference;
}
public void setDifference(GeoFeature difference) {
public void setDifference(List<GeoFeature> difference) {
this.difference = difference;
}

Expand Down
16 changes: 14 additions & 2 deletions src/main/java/fr/insee/rmes/model/operations/Indicator.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public class Indicator {
@Schema(description="Id of Sims documentation")
public String idSims;

@Schema(description = "validationState")
public String validationState;

public Indicator(String id) {
this.id=id;
}
Expand Down Expand Up @@ -174,6 +177,14 @@ public List<String> getCreators() {
return creators;
}

public String getValidationState() {
return validationState;
}

public void setValidationState(String validationState) {
this.validationState = validationState;
}

public void setPublishers(List<OperationsLink> publishers) {
this.publishers = publishers;
}
Expand Down Expand Up @@ -254,7 +265,7 @@ public void setId(String id) {
public int hashCode() {
return Objects.hash(abstractLg1, abstractLg2, accrualPeriodicityCode, accrualPeriodicityList, altLabelLg1,
altLabelLg2, contributors, creators, historyNoteLg1, historyNoteLg2, id, idSims, isReplacedBy,
prefLabelLg1, prefLabelLg2, publishers, replaces, seeAlso, wasGeneratedBy);
prefLabelLg1, prefLabelLg2, publishers, replaces, seeAlso, wasGeneratedBy,validationState);
}

@Override
Expand All @@ -276,7 +287,8 @@ public boolean equals(Object obj) {
&& Objects.equals(idSims, other.idSims) && Objects.equals(isReplacedBy, other.isReplacedBy)
&& Objects.equals(prefLabelLg1, other.prefLabelLg1) && Objects.equals(prefLabelLg2, other.prefLabelLg2)
&& Objects.equals(publishers, other.publishers) && Objects.equals(replaces, other.replaces)
&& Objects.equals(seeAlso, other.seeAlso) && Objects.equals(wasGeneratedBy, other.wasGeneratedBy);
&& Objects.equals(seeAlso, other.seeAlso) && Objects.equals(wasGeneratedBy, other.wasGeneratedBy)
&& Objects.equals(validationState, other.validationState);
}


Expand Down
10 changes: 7 additions & 3 deletions src/main/java/fr/insee/rmes/persistance/ontologies/GEO.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ private GEO() {
public static final String PREFIX = "geo";

public static final Namespace NS = new SimpleNamespace(PREFIX, NAMESPACE);

public static final IRI FEATURE;

public static final IRI DIFFERENCE;
public static final IRI UNION;

static {
final ValueFactory f = SimpleValueFactory.getInstance();

FEATURE = f.createIRI(NAMESPACE, "Feature");

DIFFERENCE = f.createIRI(NAMESPACE, "difference");
UNION = f.createIRI(NAMESPACE, "union");

}

}
4 changes: 3 additions & 1 deletion src/main/java/fr/insee/rmes/persistance/ontologies/IGEO.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ private IGEO() {

public static final IRI NOM;
public static final IRI CODE_INSEE;
public static final IRI TERRITOIRE_STATISTIQUE;


static {
final ValueFactory f = SimpleValueFactory.getInstance();

NOM = f.createIRI(NAMESPACE, "nom");
CODE_INSEE = f.createIRI(NAMESPACE, "codeINSEE");

TERRITOIRE_STATISTIQUE = f.createIRI(NAMESPACE, "TerritoireStatistique");

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,10 @@ public static String lastConceptID() {
}


public static String conceptsQuery() {
return "SELECT DISTINCT ?id ?label (group_concat(?altLabelLg1;separator=' || ') as ?altLabel) \n"
+ "WHERE { GRAPH <"+Config.CONCEPTS_GRAPH+"> { \n"
+ "?concept skos:notation ?notation . \n"
+ "BIND (STR(?notation) AS ?id) \n"
+ "?concept skos:prefLabel ?label . \n"
+ "FILTER (lang(?label) = '" + Config.LG1 + "') \n"
+ "OPTIONAL{?concept skos:altLabel ?altLabelLg1 . \n"
+ "FILTER (lang(?altLabelLg1) = '" + Config.LG1 + "')} \n"
+ "}} \n"
+ "GROUP BY ?id ?label \n"
+ "ORDER BY ?label ";
public static String conceptsQuery() throws RmesException {
if (params==null) {initParams();}
params.put("CONCEPTS_GRAPH", Config.CONCEPTS_GRAPH);
return buildConceptRequest("getConcepts.ftlh", params);
}

public static String conceptsSearchQuery() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ public Response publishStructureById(@PathParam(Constants.ID) String id) {
jsonResultat = structureService.publishStructureById(id);
} catch (RmesException e) {
return Response.status(e.getStatus()).entity(e.getDetails()).type(MediaType.TEXT_PLAIN).build();
} catch( Exception e ) {
logger.error(e);
}
}
return Response.status(HttpStatus.SC_OK).entity(jsonResultat).build();
}

Expand Down
13 changes: 13 additions & 0 deletions src/main/resources/request/concepts/getConcepts.ftlh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SELECT DISTINCT ?id ?label (group_concat(?altLabelLg1;separator=' || ') as ?altLabel)
WHERE {
GRAPH <${CONCEPTS_GRAPH}> {
?concept skos:notation ?notation .
BIND (STR(?notation) AS ?id)
?concept skos:prefLabel ?label .
FILTER (lang(?label) = '${LG1}')
OPTIONAL{?concept skos:altLabel ?altLabelLg1 .
FILTER (lang(?altLabelLg1) = '${LG1}')}
}
}
GROUP BY ?id ?label
ORDER BY ?label
Loading

0 comments on commit 977350e

Please sign in to comment.