From 0c6177d5bfc09ada964d1adbe6b655a23440a207 Mon Sep 17 00:00:00 2001 From: Emmanuel Demey Date: Wed, 29 Jul 2020 21:07:51 +0200 Subject: [PATCH 1/2] fix: use good grap and baseUri for structures --- .../rmes/bauhaus_services/rdf_utils/ObjectType.java | 8 ++++---- .../insee/rmes/bauhaus_services/rdf_utils/RdfUtils.java | 9 +++++---- .../structures/utils/StructureComponentUtils.java | 6 +++--- src/main/java/fr/insee/rmes/config/Config.java | 6 ++++-- .../sparql_queries/structures/StructureQueries.java | 2 +- src/main/resources/bauhaus-core.properties | 8 ++++---- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/rdf_utils/ObjectType.java b/src/main/java/fr/insee/rmes/bauhaus_services/rdf_utils/ObjectType.java index 5f5efe8b2..c6ec61ae7 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/rdf_utils/ObjectType.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/rdf_utils/ObjectType.java @@ -27,11 +27,11 @@ public enum ObjectType { LINK("link", FOAF.DOCUMENT, Config.LINKS_BASE_URI ), GEOFEATURE("geoFeature", GEO.FEATURE, Config.DOCUMENTATIONS_GEO_BASE_URI), ORGANIZATION("organization",ORG.ORGANIZATION, ""), - STRUCTURE("structure", QB.DATA_STRUCTURE_DEFINITION, Config.STRUCTURES_COMPONENTS_GRAPH), + STRUCTURE("structure", QB.DATA_STRUCTURE_DEFINITION, Config.STRUCTURES_BASE_URI), - MEASURE_PROPERTY("measureProperty", QB.MEASURE_PROPERTY, Config.BASE_URI_GESTION + "mesures"), - ATTRIBUTE_PROPERTY("attributeProperty", QB.ATTRIBUTE_PROPERTY, Config.BASE_URI_GESTION + "attributs"), - DIMENSION_PROPERTY("dimensionProperty", QB.DIMENSION_PROPERTY, Config.BASE_URI_GESTION + "dimensions"), + MEASURE_PROPERTY("measureProperty", QB.MEASURE_PROPERTY, Config.STRUCTURES_COMPONENTS_BASE_URI + "mesure"), + ATTRIBUTE_PROPERTY("attributeProperty", QB.ATTRIBUTE_PROPERTY, Config.STRUCTURES_COMPONENTS_BASE_URI + "attribut"), + DIMENSION_PROPERTY("dimensionProperty", QB.DIMENSION_PROPERTY, Config.STRUCTURES_COMPONENTS_BASE_URI + "dimension"), UNDEFINED("undefined",null, ""); diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/rdf_utils/RdfUtils.java b/src/main/java/fr/insee/rmes/bauhaus_services/rdf_utils/RdfUtils.java index 2b2018026..dd17de0be 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/rdf_utils/RdfUtils.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/rdf_utils/RdfUtils.java @@ -84,17 +84,18 @@ public static IRI objectIRIPublication(ObjectType objType, String id) { } public static IRI structureComponentAttributeIRI(String id) { - return factory.createIRI(ObjectType.getBaseUri("attributeProperty") + "/", id); + return objectIRI(ObjectType.ATTRIBUTE_PROPERTY, id); } public static IRI structureComponentDimensionIRI(String id) { - return factory.createIRI(ObjectType.getBaseUri("dimensionProperty") + "/", id); + return objectIRI(ObjectType.DIMENSION_PROPERTY, id); } public static IRI structureComponentMeasureIRI(String id) { - return factory.createIRI(ObjectType.getBaseUri("measureProperty") + "/", id); + return objectIRI(ObjectType.MEASURE_PROPERTY, id); } + public static IRI structureComponentDefinitionIRI(String structureIRI, String componentDefinitionID) { - return factory.createIRI(structureIRI + "/components/", componentDefinitionID); + return factory.createIRI(structureIRI + "/composants/", componentDefinitionID); } public static IRI conceptIRI(String id) { diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/structures/utils/StructureComponentUtils.java b/src/main/java/fr/insee/rmes/bauhaus_services/structures/utils/StructureComponentUtils.java index dddc7430d..5e00eb816 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/structures/utils/StructureComponentUtils.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/structures/utils/StructureComponentUtils.java @@ -156,12 +156,12 @@ private void createRDFForComponent(MutualizedComponent component, Resource resou private String generateNextId(String type) throws RmesException { if (type.equals(QB.ATTRIBUTE_PROPERTY.toString())) { - return generateNextId("a", "attributs", QB.ATTRIBUTE_PROPERTY); + return generateNextId("a", "attribut", QB.ATTRIBUTE_PROPERTY); } if (type.equals(QB.MEASURE_PROPERTY.toString())) { - return generateNextId("m", "mesures", QB.MEASURE_PROPERTY); + return generateNextId("m", "mesure", QB.MEASURE_PROPERTY); } - return generateNextId("d", "dimensions", QB.DIMENSION_PROPERTY); + return generateNextId("d", "dimension", QB.DIMENSION_PROPERTY); } diff --git a/src/main/java/fr/insee/rmes/config/Config.java b/src/main/java/fr/insee/rmes/config/Config.java index f9d710539..bf6f5af07 100644 --- a/src/main/java/fr/insee/rmes/config/Config.java +++ b/src/main/java/fr/insee/rmes/config/Config.java @@ -58,8 +58,9 @@ public class Config { public static String STRUCTURES_GRAPH = ""; public static String STRUCTURES_BASE_URI = ""; public static String STRUCTURES_COMPONENTS_GRAPH = ""; - - + public static String STRUCTURES_COMPONENTS_BASE_URI = ""; + + public static String CODELIST_GRAPH = ""; public static String ORGANIZATIONS_GRAPH = ""; @@ -222,5 +223,6 @@ private static void readConfigForStructures(Environment env) { Config.STRUCTURES_GRAPH = BASE_GRAPH + env.getProperty("fr.insee.rmes.bauhaus.structures.graph"); Config.STRUCTURES_BASE_URI = env.getProperty("fr.insee.rmes.bauhaus.structures.baseURI"); Config.STRUCTURES_COMPONENTS_GRAPH = BASE_GRAPH + env.getProperty("fr.insee.rmes.bauhaus.structures.components.graph"); + Config.STRUCTURES_COMPONENTS_BASE_URI = env.getProperty("fr.insee.rmes.bauhaus.structures.components.baseURI"); } } \ No newline at end of file diff --git a/src/main/java/fr/insee/rmes/persistance/sparql_queries/structures/StructureQueries.java b/src/main/java/fr/insee/rmes/persistance/sparql_queries/structures/StructureQueries.java index 108419d63..8553593c0 100644 --- a/src/main/java/fr/insee/rmes/persistance/sparql_queries/structures/StructureQueries.java +++ b/src/main/java/fr/insee/rmes/persistance/sparql_queries/structures/StructureQueries.java @@ -8,7 +8,7 @@ public class StructureQueries { - public static String getStructures() throws RmesException { + public static String getStructures() throws RmesException { HashMap params = initParams(); return buildRequest("getStructures.ftlh", params); } diff --git a/src/main/resources/bauhaus-core.properties b/src/main/resources/bauhaus-core.properties index b4d1af580..34718361a 100644 --- a/src/main/resources/bauhaus-core.properties +++ b/src/main/resources/bauhaus-core.properties @@ -51,10 +51,10 @@ fr.insee.rmes.bauhaus.products.baseURI = produits/indicateur ############################### #STRUCTURES ############################### -fr.insee.rmes.bauhaus.structures.graph = -fr.insee.rmes.bauhaus.structures.baseURI = structures -fr.insee.rmes.bauhaus.structures.components.graph = components -fr.insee.rmes.bauhaus.structures.components.baseURI = components +fr.insee.rmes.bauhaus.structures.graph = structures +fr.insee.rmes.bauhaus.structures.baseURI = structuresDeDonnees/structure/ +fr.insee.rmes.bauhaus.structures.components.graph = composants +fr.insee.rmes.bauhaus.structures.components.baseURI = structuresDeDonnees/composants/ ############################### From ce49e7ec2dd976f7851d9e186b6e267e3daa4c39 Mon Sep 17 00:00:00 2001 From: Emmanuel Demey Date: Fri, 31 Jul 2020 11:29:21 +0200 Subject: [PATCH 2/2] fix: add creators to advanced search --- .../operations/series/SeriesUtils.java | 6 ++-- .../structures/utils/StructureUtilsTest.java | 30 ++----------------- 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/operations/series/SeriesUtils.java b/src/main/java/fr/insee/rmes/bauhaus_services/operations/series/SeriesUtils.java index 2d0deac1f..65b396110 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/operations/series/SeriesUtils.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/operations/series/SeriesUtils.java @@ -10,10 +10,7 @@ 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.RDFS; -import org.eclipse.rdf4j.model.vocabulary.SKOS; +import org.eclipse.rdf4j.model.vocabulary.*; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -89,6 +86,7 @@ public String getSeriesForSearch() throws RmesException { for (int i = 0; i < resQuery.length(); i++) { JSONObject series = resQuery.getJSONObject(i); addOneOrganizationLink(series.get(Constants.ID).toString(), series, INSEE.DATA_COLLECTOR); + addOneOrganizationLink(series.get(Constants.ID).toString(), series, DCTERMS.CREATOR); result.put(series); } return QueryUtils.correctEmptyGroupConcat(result.toString()); diff --git a/src/test/java/fr/insee/rmes/bauhaus_services/structures/utils/StructureUtilsTest.java b/src/test/java/fr/insee/rmes/bauhaus_services/structures/utils/StructureUtilsTest.java index 773e64155..d2be9ef1d 100644 --- a/src/test/java/fr/insee/rmes/bauhaus_services/structures/utils/StructureUtilsTest.java +++ b/src/test/java/fr/insee/rmes/bauhaus_services/structures/utils/StructureUtilsTest.java @@ -10,6 +10,7 @@ import java.util.ArrayList; import java.util.List; +import fr.insee.rmes.config.Config; import org.eclipse.rdf4j.model.IRI; import org.eclipse.rdf4j.model.Model; import org.eclipse.rdf4j.model.Resource; @@ -17,10 +18,7 @@ import org.eclipse.rdf4j.model.impl.SimpleValueFactory; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.mockito.Spy; +import org.mockito.*; import fr.insee.rmes.bauhaus_services.rdf_utils.RepositoryGestion; import fr.insee.rmes.exceptions.RmesException; @@ -28,6 +26,7 @@ import fr.insee.rmes.model.structures.MutualizedComponent; import fr.insee.rmes.model.structures.Structure; import fr.insee.rmes.utils.DateUtils; +import org.springframework.core.env.Environment; class StructureUtilsTest { @@ -43,29 +42,6 @@ public void init() { MockitoAnnotations.initMocks(this); } - @Test - void shouldCallCreateRdfComponentSpecifications() throws RmesException { - - String currentDate = DateUtils.getCurrentDate(); - doNothing().when(structureUtils).createRdfComponentSpecifications(any(), anyList(), any(), any()); - doNothing().when(repoGestion).loadSimpleObject(any(), any(), any()); - doReturn(1).when(structureUtils).getNextComponentSpecificationID(); - - IRI structureIRI = SimpleValueFactory.getInstance().createIRI("http://structure"); - - Structure structure = new Structure(); - structure.setId("id"); - structure.setLabelLg1("labelLg1"); - structure.setLabelLg2("labelLg2"); - structure.setUpdated(currentDate); - structure.setCreated(currentDate); - structure.setComponentDefinitions(new ArrayList<>()); - - structureUtils.createRdfStructure(structure, "id", structureIRI, null); - verify(structureUtils, times(1)).createRdfComponentSpecifications(any(), anyList(), any(), any()); - - } - @Test void shouldCallCreateComponentSpecificationForEachComponents() throws RmesException { Resource graph = null;