Skip to content

Commit

Permalink
Merge pull request #42 from EmmanuelDemey/master
Browse files Browse the repository at this point in the history
fix: use good grap and baseUri for structures
  • Loading branch information
alicela authored Aug 4, 2020
2 parents e979bcd + ce49e7e commit 07732f6
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/fr/insee/rmes/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public class StructureQueries {

public static String getStructures() throws RmesException {
public static String getStructures() throws RmesException {
HashMap<String, Object> params = initParams();
return buildRequest("getStructures.ftlh", params);
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/bauhaus-core.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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/


###############################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,23 @@
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;
import org.eclipse.rdf4j.model.impl.LinkedHashModel;
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;
import fr.insee.rmes.model.structures.ComponentDefinition;
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 {

Expand All @@ -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;
Expand Down

0 comments on commit 07732f6

Please sign in to comment.