diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/concepts/collections/CollectionExportBuilder.java b/src/main/java/fr/insee/rmes/bauhaus_services/concepts/collections/CollectionExportBuilder.java index e378e70a4..b0eadb761 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/concepts/collections/CollectionExportBuilder.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/concepts/collections/CollectionExportBuilder.java @@ -38,14 +38,14 @@ public class CollectionExportBuilder extends RdfService { @Autowired ExportUtils exportUtils; - private final String xslFile = "/xslTransformerFiles/rmes2odt.xsl"; - private final String xmlPattern = "/xslTransformerFiles/collection/collectionPatternContent.xml"; - private final String zip = "/xslTransformerFiles/collection/toZipForCollection.zip"; - private final String zipold = "/xslTransformerFiles/collection/toZipForCollectionOld.zip"; - private final String xmlPatternFR = "/xslTransformerFiles/collection/collectionFrPatternContent.xml"; - private final String xmlPatternEN = "/xslTransformerFiles/collection/collectionEnPatternContent.xml"; - private final String xmlPatternODS = "/xslTransformerFiles/collection/collectionOdsPatternContent.xml"; - private final String zipODS = "/xslTransformerFiles/collection/toZipForCollectionOds.zip"; + private static final String xslFile = "/xslTransformerFiles/rmes2odt.xsl"; + private static final String xmlPattern = "/xslTransformerFiles/collection/collectionPatternContent.xml"; + private static final String zip = "/xslTransformerFiles/collection/toZipForCollection.zip"; + private static final String zipold = "/xslTransformerFiles/collection/toZipForCollectionOld.zip"; + private static final String xmlPatternFR = "/xslTransformerFiles/collection/collectionFrPatternContent.xml"; + private static final String xmlPatternEN = "/xslTransformerFiles/collection/collectionEnPatternContent.xml"; + private static final String xmlPatternODS = "/xslTransformerFiles/collection/collectionOdsPatternContent.xml"; + private static final String zipODS = "/xslTransformerFiles/collection/toZipForCollectionOds.zip"; final Collator instance = Collator.getInstance(); diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/operations/indicators/IndicatorsUtils.java b/src/main/java/fr/insee/rmes/bauhaus_services/operations/indicators/IndicatorsUtils.java index 156e436ea..a69a51ea3 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/operations/indicators/IndicatorsUtils.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/operations/indicators/IndicatorsUtils.java @@ -16,7 +16,6 @@ import fr.insee.rmes.model.links.OperationsLink; import fr.insee.rmes.model.operations.Indicator; import fr.insee.rmes.persistance.ontologies.INSEE; -import fr.insee.rmes.persistance.ontologies.PROV; import fr.insee.rmes.persistance.sparql_queries.operations.indicators.IndicatorsQueries; import fr.insee.rmes.utils.DateUtils; import fr.insee.rmes.utils.XMLUtils; 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 155d5a0c2..09996a39b 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 @@ -1,11 +1,15 @@ package fr.insee.rmes.bauhaus_services.rdf_utils; import fr.insee.rmes.bauhaus_services.Constants; -import fr.insee.rmes.persistance.ontologies.*; +import fr.insee.rmes.persistance.ontologies.GEO; +import fr.insee.rmes.persistance.ontologies.INSEE; +import fr.insee.rmes.persistance.ontologies.QB; +import fr.insee.rmes.persistance.ontologies.SDMX_MM; import jakarta.validation.constraints.NotNull; import org.eclipse.rdf4j.model.IRI; import org.eclipse.rdf4j.model.vocabulary.DCAT; import org.eclipse.rdf4j.model.vocabulary.FOAF; +import org.eclipse.rdf4j.model.vocabulary.ORG; import org.eclipse.rdf4j.model.vocabulary.SKOS; import java.util.Arrays; diff --git a/src/main/java/fr/insee/rmes/model/operations/documentations/RangeType.java b/src/main/java/fr/insee/rmes/model/operations/documentations/RangeType.java index 817e0fafc..24f907e1e 100644 --- a/src/main/java/fr/insee/rmes/model/operations/documentations/RangeType.java +++ b/src/main/java/fr/insee/rmes/model/operations/documentations/RangeType.java @@ -3,9 +3,9 @@ import fr.insee.rmes.bauhaus_services.Constants; import fr.insee.rmes.persistance.ontologies.DCMITYPE; import fr.insee.rmes.persistance.ontologies.GEO; -import fr.insee.rmes.persistance.ontologies.ORG; import fr.insee.rmes.persistance.ontologies.SDMX_MM; import org.eclipse.rdf4j.model.IRI; +import org.eclipse.rdf4j.model.vocabulary.ORG; import org.eclipse.rdf4j.model.vocabulary.XSD; import java.util.HashMap; diff --git a/src/main/java/fr/insee/rmes/persistance/ontologies/ORG.java b/src/main/java/fr/insee/rmes/persistance/ontologies/ORG.java deleted file mode 100644 index 239441570..000000000 --- a/src/main/java/fr/insee/rmes/persistance/ontologies/ORG.java +++ /dev/null @@ -1,68 +0,0 @@ -package fr.insee.rmes.persistance.ontologies; - -import org.eclipse.rdf4j.model.IRI; -import org.eclipse.rdf4j.model.Namespace; -import org.eclipse.rdf4j.model.ValueFactory; -import org.eclipse.rdf4j.model.impl.SimpleNamespace; -import org.eclipse.rdf4j.model.impl.SimpleValueFactory; - -public class ORG { - - private ORG() { - throw new IllegalStateException("Utility class"); - } - - /** - * The ORG namespace: http://www.w3.org/ns/org# - */ - public static final String NAMESPACE = "http://www.w3.org/ns/org#"; - - /** - * The recommended prefix for the namespace: "org" - */ - public static final String PREFIX = "org"; - - /** - * An immutable {@link Namespace} constant that represents the XKOS namespace. - */ - public static final Namespace NS = new SimpleNamespace(PREFIX, NAMESPACE); - - - /* OWL classes */ - - /** - * The org:unitOf class - */ - public static final IRI UNIT_OF; - - /** - * The org:hasUnit class - */ - public static final IRI HAS_UNIT; - - /** - * The org:reportsTo class - */ - public static final IRI REPORTS_TO; - - /** - * The org:linkedTo class - */ - public static final IRI LINKED_TO; - - public static final IRI ORGANIZATION; - public static final IRI ORGANIZATION_UNIT; - - static { - final ValueFactory f = SimpleValueFactory.getInstance(); - - UNIT_OF = f.createIRI(NAMESPACE, "unitOf"); - HAS_UNIT = f.createIRI(NAMESPACE, "hasUnit"); - REPORTS_TO = f.createIRI(NAMESPACE, "reportsTo"); - LINKED_TO = f.createIRI(NAMESPACE, "linkedTo"); - - ORGANIZATION = f.createIRI(NAMESPACE, "Organization"); - ORGANIZATION_UNIT = f.createIRI(NAMESPACE, "OrganizationUnit"); - } - -} diff --git a/src/main/java/fr/insee/rmes/persistance/ontologies/PROV.java b/src/main/java/fr/insee/rmes/persistance/ontologies/PROV.java deleted file mode 100644 index 3b42fce90..000000000 --- a/src/main/java/fr/insee/rmes/persistance/ontologies/PROV.java +++ /dev/null @@ -1,35 +0,0 @@ -package fr.insee.rmes.persistance.ontologies; - -import org.eclipse.rdf4j.model.IRI; -import org.eclipse.rdf4j.model.Namespace; -import org.eclipse.rdf4j.model.ValueFactory; -import org.eclipse.rdf4j.model.impl.SimpleNamespace; -import org.eclipse.rdf4j.model.impl.SimpleValueFactory; - -public class PROV { - - private PROV() { - throw new IllegalStateException("Utility class"); - } - - - public static final String NAMESPACE = "http://www.w3.org/ns/prov#"; - - /** - * The recommended prefix for the Prov namespace: "prov" - */ - public static final String PREFIX = "prov"; - - public static final Namespace NS = new SimpleNamespace(PREFIX, NAMESPACE); - - public static final IRI WAS_GENERATED_BY; - - static { - final ValueFactory f = SimpleValueFactory.getInstance(); - - WAS_GENERATED_BY = f.createIRI(NAMESPACE, "wasGeneratedBy"); - - } - - -} diff --git a/src/test/java/fr/insee/rmes/bauhaus_services/classifications/item/ClassificationItemUtilsTest.java b/src/test/java/fr/insee/rmes/bauhaus_services/classifications/item/ClassificationItemUtilsTest.java index 45e3bd022..c245db0a0 100644 --- a/src/test/java/fr/insee/rmes/bauhaus_services/classifications/item/ClassificationItemUtilsTest.java +++ b/src/test/java/fr/insee/rmes/bauhaus_services/classifications/item/ClassificationItemUtilsTest.java @@ -3,6 +3,7 @@ import fr.insee.rmes.bauhaus_services.rdf_utils.RdfUtils; import fr.insee.rmes.bauhaus_services.rdf_utils.RepositoryGestion; import fr.insee.rmes.config.Config; +import fr.insee.rmes.exceptions.RmesBadRequestException; import fr.insee.rmes.exceptions.RmesException; import fr.insee.rmes.model.classification.ClassificationItem; import fr.insee.rmes.persistance.sparql_queries.classifications.ItemsQueries; @@ -17,6 +18,8 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; @@ -32,6 +35,25 @@ class ClassificationItemUtilsTest { @InjectMocks ClassificationItemUtils classificationItemUtils; + @Test + void shouldThrowExceptionIfPrefLabelLg1Null() throws RmesException { + when(config.getLg1()).thenReturn("fr"); + when(config.getLg2()).thenReturn("en"); + + + RdfUtils.setConfig(config); + ItemsQueries.setConfig(config); + ClassificationItem item = new ClassificationItem(); + item.setId("1"); + item.setPrefLabelLg2("label2"); + item.setDefinitionLg1("

Definition Lg1

"); + item.setDefinitionLg1Uri("http://definition-lg1"); + + RmesException exception = assertThrows(RmesBadRequestException.class, () -> classificationItemUtils.updateClassificationItem(item, "http://uri", "1")); + assertThat(exception.getDetails()).contains("The property prefLabelLg1 is required"); + + } + @Test void shouldAddNotes() throws RmesException { diff --git a/src/test/java/fr/insee/rmes/bauhaus_services/rdf_utils/ObjectTypeTest.java b/src/test/java/fr/insee/rmes/bauhaus_services/rdf_utils/ObjectTypeTest.java new file mode 100644 index 000000000..1c887f56b --- /dev/null +++ b/src/test/java/fr/insee/rmes/bauhaus_services/rdf_utils/ObjectTypeTest.java @@ -0,0 +1,13 @@ +package fr.insee.rmes.bauhaus_services.rdf_utils; + +import org.eclipse.rdf4j.model.vocabulary.ORG; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class ObjectTypeTest { + @Test + void testOrganizationEnumValues() { + assertEquals("organization", ObjectType.getEnum(ORG.ORGANIZATION).labelType()); + } +} \ No newline at end of file diff --git a/src/test/java/fr/insee/rmes/model/operations/documentations/RangeTypeTest.java b/src/test/java/fr/insee/rmes/model/operations/documentations/RangeTypeTest.java new file mode 100644 index 000000000..6a76a65c7 --- /dev/null +++ b/src/test/java/fr/insee/rmes/model/operations/documentations/RangeTypeTest.java @@ -0,0 +1,14 @@ +package fr.insee.rmes.model.operations.documentations; + +import org.eclipse.rdf4j.model.vocabulary.ORG; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class RangeTypeTest { + + @Test + void testOrganizationEnumValues() { + assertEquals("ORGANIZATION", RangeType.getEnumByRdfType(ORG.ORGANIZATION).getJsonType()); + } +} \ No newline at end of file