From dfdb146b3d34714af8a9e6f2fbe4e90d7a56d789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Such=C3=A1nek?= Date: Mon, 22 Sep 2025 08:59:02 +0200 Subject: [PATCH 01/53] WIP: Add bootstrapping from fixtures --- data/_schemas/membership.schema.json | 41 +++++ data/_schemas/metadata-schema.schema.json | 94 ++++++++++++ data/_schemas/records.schema.json | 39 +++++ data/_schemas/resource-definition.schema.json | 119 +++++++++++++++ data/_schemas/settings.schema.json | 141 ++++++++++++++++++ data/_schemas/user.schema.json | 44 ++++++ data/membership/data-provider.json | 9 ++ data/membership/owner.json | 14 ++ data/metadata-schemas/catalog.json | 18 +++ data/metadata-schemas/catalog.ttl | 35 +++++ data/metadata-schemas/data-service.json | 18 +++ data/metadata-schemas/data-service.ttl | 22 +++ data/metadata-schemas/dataset.json | 18 +++ data/metadata-schemas/dataset.ttl | 51 +++++++ data/metadata-schemas/distribution.json | 18 +++ data/metadata-schemas/distribution.ttl | 58 +++++++ data/metadata-schemas/fdp.json | 18 +++ data/metadata-schemas/fdp.ttl | 39 +++++ data/metadata-schemas/metadata-service.json | 18 +++ data/metadata-schemas/metadata-service.ttl | 6 + data/metadata-schemas/resource.json | 13 ++ data/metadata-schemas/resource.ttl | 73 +++++++++ data/records/records.json | 10 ++ data/records/repository.ttl | 28 ++++ data/resource-definitions/catalog.json | 20 +++ data/resource-definitions/dataset.json | 25 ++++ data/resource-definitions/distribution.json | 19 +++ data/resource-definitions/repository.json | 20 +++ data/settings/settings.json | 16 ++ data/users/albert-einstein.json | 19 +++ data/users/nikola-tesla.json | 7 + .../properties/BootstrapProperties.java | 39 +++++ .../service/boostrap/BootstrapContext.java | 39 +++++ .../service/boostrap/BootstrapRunner.java | 43 ++++++ .../service/boostrap/BootstrapService.java | 111 ++++++++++++++ .../components/AbstractBootstrapper.java | 77 ++++++++++ .../boostrap/components/IBootstrapper.java | 34 +++++ .../components/MembershipBootstrapper.java | 80 ++++++++++ .../MetadataRecordsBootstrapper.java | 113 ++++++++++++++ .../MetadataSchemaBootstrapper.java | 86 +++++++++++ .../MetadataSchemaVersionsBootstrapper.java | 113 ++++++++++++++ .../ResourceDefinitionBootstrapper.java | 104 +++++++++++++ ...esourceDefinitionChildrenBootstrapper.java | 102 +++++++++++++ .../components/SettingsBootstrapper.java | 121 +++++++++++++++ .../boostrap/components/UserBootstrapper.java | 102 +++++++++++++ .../boostrap/fixtures/MembershipFixture.java | 36 +++++ .../fixtures/MetadataSchemaFixture.java | 34 +++++ .../MetadataSchemaVersionFixture.java | 49 ++++++ .../boostrap/fixtures/RecordFixture.java | 32 ++++ .../boostrap/fixtures/RecordsFixture.java | 34 +++++ .../fixtures/ResourceDefinitionFixture.java | 41 +++++ .../fixtures/SearchSavedQueryFixture.java | 36 +++++ .../boostrap/fixtures/SettingsFixture.java | 43 ++++++ .../boostrap/fixtures/UserFixture.java | 42 ++++++ .../service/membership/MembershipMapper.java | 16 ++ .../resource/ResourceDefinitionMapper.java | 11 ++ .../service/schema/MetadataSchemaMapper.java | 21 +++ .../search/query/SearchSavedQueryMapper.java | 16 ++ .../service/settings/SettingsMapper.java | 15 +- .../service/user/UserMapper.java | 12 ++ src/main/resources/application.yml | 4 + 61 files changed, 2675 insertions(+), 1 deletion(-) create mode 100644 data/_schemas/membership.schema.json create mode 100644 data/_schemas/metadata-schema.schema.json create mode 100644 data/_schemas/records.schema.json create mode 100644 data/_schemas/resource-definition.schema.json create mode 100644 data/_schemas/settings.schema.json create mode 100644 data/_schemas/user.schema.json create mode 100644 data/membership/data-provider.json create mode 100644 data/membership/owner.json create mode 100644 data/metadata-schemas/catalog.json create mode 100644 data/metadata-schemas/catalog.ttl create mode 100644 data/metadata-schemas/data-service.json create mode 100644 data/metadata-schemas/data-service.ttl create mode 100644 data/metadata-schemas/dataset.json create mode 100644 data/metadata-schemas/dataset.ttl create mode 100644 data/metadata-schemas/distribution.json create mode 100644 data/metadata-schemas/distribution.ttl create mode 100644 data/metadata-schemas/fdp.json create mode 100644 data/metadata-schemas/fdp.ttl create mode 100644 data/metadata-schemas/metadata-service.json create mode 100644 data/metadata-schemas/metadata-service.ttl create mode 100644 data/metadata-schemas/resource.json create mode 100644 data/metadata-schemas/resource.ttl create mode 100644 data/records/records.json create mode 100644 data/records/repository.ttl create mode 100644 data/resource-definitions/catalog.json create mode 100644 data/resource-definitions/dataset.json create mode 100644 data/resource-definitions/distribution.json create mode 100644 data/resource-definitions/repository.json create mode 100644 data/settings/settings.json create mode 100644 data/users/albert-einstein.json create mode 100644 data/users/nikola-tesla.json create mode 100644 src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/BootstrapContext.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/BootstrapRunner.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/BootstrapService.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/components/AbstractBootstrapper.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/components/IBootstrapper.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/components/MembershipBootstrapper.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/components/MetadataRecordsBootstrapper.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/components/MetadataSchemaBootstrapper.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/components/MetadataSchemaVersionsBootstrapper.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/components/ResourceDefinitionBootstrapper.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/components/ResourceDefinitionChildrenBootstrapper.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/components/SettingsBootstrapper.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/components/UserBootstrapper.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/fixtures/MembershipFixture.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/fixtures/MetadataSchemaFixture.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/fixtures/MetadataSchemaVersionFixture.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/fixtures/RecordFixture.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/fixtures/RecordsFixture.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/fixtures/ResourceDefinitionFixture.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/fixtures/SearchSavedQueryFixture.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/fixtures/SettingsFixture.java create mode 100644 src/main/java/org/fairdatapoint/service/boostrap/fixtures/UserFixture.java diff --git a/data/_schemas/membership.schema.json b/data/_schemas/membership.schema.json new file mode 100644 index 000000000..5378b8f75 --- /dev/null +++ b/data/_schemas/membership.schema.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Membership", + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Name of membership" + }, + "allowedEntities": { + "type": "array", + "description": "UUIDs for resource definitions related to this membership", + "items": { + "type": "string", + "format": "uuid" + } + }, + "permissions": { + "type": "array", + "description": "Permissions associated with this membership", + "items": { + "type": "object", + "properties": { + "mask": { + "type": "integer", + "description": "Permission mask value" + }, + "code": { + "type": "string", + "description": "Permission code (character)", + "enum": ["C", "W", "D", "A"] + } + }, + "required": ["mask", "code"], + "additionalProperties": false + } + } + }, + "required": ["name", "allowedEntities", "permissions"], + "additionalProperties": false +} diff --git a/data/_schemas/metadata-schema.schema.json b/data/_schemas/metadata-schema.schema.json new file mode 100644 index 000000000..bde739940 --- /dev/null +++ b/data/_schemas/metadata-schema.schema.json @@ -0,0 +1,94 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Metadata Schema", + "type": "object", + "properties": { + "uuid": { + "type": "string", + "format": "uuid", + "description": "Unique identifier of the metadata schema" + }, + "versions": { + "type": "array", + "description": "List of schema versions", + "items": { + "type": "object", + "title": "MetadataSchemaVersionFixture", + "properties": { + "version": { + "type": "string", + "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$", + "description": "Semantic version of the schema" + }, + "name": { + "type": "string", + "description": "Human-readable name of the schema" + }, + "description": { + "type": "string", + "default": "", + "description": "Description of the schema" + }, + "definition": { + "type": "string", + "description": "Schema definition content (inline)" + }, + "definitionFile": { + "type": "string", + "description": "Reference to an external definition file" + }, + "type": { + "type": "string", + "enum": ["CUSTOM", "REFERENCE", "INTERNAL"], + "default": "CUSTOM", + "description": "Schema type" + }, + "origin": { + "type": ["string", "null"], + "description": "Original source of the schema" + }, + "importedFrom": { + "type": ["string", "null"], + "description": "Source system from which the schema was imported" + }, + "state": { + "type": "string", + "enum": ["LATEST", "LEGACY", "DRAFT"], + "default": "LATEST", + "description": "Current state of the schema, make sure only one version is LATEST and there is possibly one DRAFT" + }, + "published": { + "type": "boolean", + "default": false, + "description": "Indicates whether the schema is published" + }, + "abstractSchema": { + "type": "boolean", + "default": false, + "description": "Marks schema as abstract (cannot be instantiated)" + }, + "suggestedResourceName": { + "type": ["string", "null"], + "description": "Suggested resource name for entities using this schema" + }, + "suggestedUrlPrefix": { + "type": ["string", "null"], + "description": "Suggested URL prefix for entities using this schema" + }, + "extendsSchemaUuids": { + "type": "array", + "items": { + "type": "string", + "format": "uuid" + }, + "default": [], + "description": "List of UUIDs of extended schemas" + } + }, + "required": ["version", "name"] + } + } + }, + "required": ["uuid", "versions"], + "additionalProperties": false +} diff --git a/data/_schemas/records.schema.json b/data/_schemas/records.schema.json new file mode 100644 index 000000000..7ba23d533 --- /dev/null +++ b/data/_schemas/records.schema.json @@ -0,0 +1,39 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Records", + "type": "object", + "properties": { + "records": { + "type": "array", + "description": "RDF Record fixture descriptions", + "items": { + "type": "object", + "properties": { + "file": { + "type": "string", + "description": "Filename (of RDF Turtle file) in data/records/ directory (the file can use the persistentUrlVar value)" + }, + "repository": { + "type": "string", + "description": "Target repository for the RDF data", + "enum": ["main", "drafts"], + "default": "main" + }, + "uri": { + "type": "string", + "description": "URI for the RDF resource, can include replacement variable for persistent URL (you can use the persistentUrlVar value)" + } + }, + "required": ["file", "repository", "uri"], + "additionalProperties": false + } + }, + "persistentUrlVar": { + "type": "string", + "description": "Replacement variable for persistent URL", + "default": "{{ persistentUrl }}" + } + }, + "required": ["records", "persistentUrlVar"], + "additionalProperties": false +} diff --git a/data/_schemas/resource-definition.schema.json b/data/_schemas/resource-definition.schema.json new file mode 100644 index 000000000..a87505cd5 --- /dev/null +++ b/data/_schemas/resource-definition.schema.json @@ -0,0 +1,119 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Resource Definition", + "type": "object", + "properties": { + "uuid": { + "type": "string", + "format": "uuid", + "description": "Unique identifier for the resource definition" + }, + "name": { + "type": "string", + "description": "Name of the resource definition" + }, + "urlPrefix": { + "type": "string", + "description": "URL prefix for the resource definition" + }, + "children": { + "type": "array", + "description": "Child resource definitions", + "items": { + "type": "object", + "properties": { + "resourceDefinitionUuid": { + "type": "string", + "format": "uuid", + "description": "UUID of the child resource definition" + }, + "relationUri": { + "type": "string", + "description": "URI defining the relationship to the child resource", + "format": "uri" + }, + "listView": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "Title for the list view of the child resource" + }, + "tagsUri": { + "type": "string", + "description": "URI for tags in the list view", + "format": "uri" + }, + "metadata": { + "type": "array", + "description": "Metadata fields to display in the list view", + "items": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "Title of the metadata field" + }, + "propertyUri": { + "type": "string", + "description": "Property URI of the metadata field", + "format": "uri" + } + }, + "required": [ + "title", + "propertyUri" + ], + "additionalProperties": false + } + } + } + }, + "required": [ + "title", + "tagsUri", + "metadata" + ], + "additionalProperties": false + } + }, + "externalLinks": { + "type": "array", + "description": "External links associated with the resource definition", + "items": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "Title of the external link" + }, + "propertyUri": { + "type": "string", + "description": "Property URI of the external link", + "format": "uri" + } + }, + "required": [ + "title", + "propertyUri" + ], + "additionalProperties": false + } + }, + "metadataSchemaUuids": { + "type": "array", + "description": "UUIDs for metadata schemas used by this resource definition", + "items": { + "type": "string", + "format": "uuid" + } + } + }, + "required": [ + "name", + "urlPrefix", + "metadataSchemaUuids" + ], + "additionalProperties": false + } +} diff --git a/data/_schemas/settings.schema.json b/data/_schemas/settings.schema.json new file mode 100644 index 000000000..ed98d3afd --- /dev/null +++ b/data/_schemas/settings.schema.json @@ -0,0 +1,141 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Settings", + "type": "object", + "properties": { + "appTitle": { + "type": "string", + "description": "Title of the application", + "default": "FAIR Data Point" + }, + "appSubtitle": { + "type": "string", + "description": "Subtitle of the application", + "default": "Metadata for Machines" + }, + "pingEnabled": { + "type": "boolean", + "description": "Enable or disable the ping feature" + }, + "pingEndpoints": { + "type": "array", + "description": "List of endpoints to ping", + "items": { + "type": "string", + "format": "uri" + } + }, + "autocompleteSearchNamespace": { + "type": "boolean", + "description": "Enable or disable namespace autocomplete in search", + "default": true + }, + "autocompleteSources": { + "type": "array", + "description": "List of sources for autocomplete", + "items": { + "type": "object", + "properties": { + "rdfType": { + "type": "string", + "description": "RDF type for the autocomplete source" + }, + "sparqlEndpoint": { + "type": "string", + "format": "uri" + }, + "sparqlQuery": { + "type": "string", + "description": "SPARQL query to fetch autocomplete suggestions" + } + }, + "required": ["rdfType", "sparqlEndpoint", "sparqlQuery"], + "additionalProperties": false + } + }, + "metrics": { + "type": "array", + "description": "List of metrics to be collected", + "items": { + "type": "object", + "properties": { + "metricUri": { + "type": "string", + "format": "uri", + "description": "URI of the metric" + }, + "resourceUri": { + "type": "string", + "format": "uri", + "description": "URI of the resource associated with the metric" + } + }, + "required": ["metricUri", "resourceUri"], + "additionalProperties": false + } + }, + "searchFilters": { + "type": "array", + "description": "List of search filters", + "items": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "Type of the filter (e.g., 'dropdown', 'checkbox')" + }, + "label": { + "type": "string", + "description": "Label for the filter" + }, + "predicate": { + "type": "string", + "format": "uri", + "description": "Predicate URI for the filter" + }, + "queryFromRecords": { + "type": "boolean", + "description": "Whether to query from records" + }, + "values": { + "type": "array", + "description": "List of values for the filter", + "items": { + "type": "object", + "properties": { + "value": { + "type": "string", + "description": "Value of the filter option" + }, + "label": { + "type": "string", + "description": "Label for the filter option" + }, + "preset": { + "type": "boolean", + "description": "Whether this option is a preset", + "default": true + } + }, + "required": [ + "value", + "label" + ], + "additionalProperties": false + } + } + }, + "required": [ + "type", + "label", + "predicate", + "queryFromRecords", + "values" + ], + "additionalProperties": false + } + } + }, + "required": [], + "additionalProperties": false +} diff --git a/data/_schemas/user.schema.json b/data/_schemas/user.schema.json new file mode 100644 index 000000000..e9f28d4a9 --- /dev/null +++ b/data/_schemas/user.schema.json @@ -0,0 +1,44 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "UserWithApiKeys", + "type": "object", + "properties": { + "uuid": { + "type": "string", + "format": "uuid", + "description": "Unique identifier for the user" + }, + "firstName": { + "type": "string", + "description": "First name of the user" + }, + "lastName": { + "type": "string", + "description": "Last name of the user" + }, + "email": { + "type": "string", + "format": "email", + "description": "Email address of the user" + }, + "password": { + "type": "string", + "description": "Password of the user" + }, + "role": { + "type": "string", + "enum": ["USER", "ADMIN"], + "description": "Role assigned to the user" + }, + "apiKeyTokens": { + "type": "array", + "items": { + "type": "string" + }, + "description": "List of API key tokens for the user", + "default": [] + } + }, + "required": ["email", "password"], + "additionalProperties": false +} diff --git a/data/membership/data-provider.json b/data/membership/data-provider.json new file mode 100644 index 000000000..243856cf4 --- /dev/null +++ b/data/membership/data-provider.json @@ -0,0 +1,9 @@ +{ + "name": "Data Provider", + "allowedEntities": [ + "a0949e72-4466-4d53-8900-9436d1049a4b" + ], + "permissions": [ + { "mask": 4, "code": "C" } + ] +} \ No newline at end of file diff --git a/data/membership/owner.json b/data/membership/owner.json new file mode 100644 index 000000000..39059c21d --- /dev/null +++ b/data/membership/owner.json @@ -0,0 +1,14 @@ +{ + "name": "Owner", + "allowedEntities": [ + "a0949e72-4466-4d53-8900-9436d1049a4b", + "2f08228e-1789-40f8-84cd-28e3288c3604", + "02c649de-c579-43bb-b470-306abdc808c7" + ], + "permissions": [ + { "mask": 4, "code": "C" }, + { "mask": 2, "code": "W" }, + { "mask": 8, "code": "D" }, + { "mask": 16, "code": "A" } + ] +} diff --git a/data/metadata-schemas/catalog.json b/data/metadata-schemas/catalog.json new file mode 100644 index 000000000..47a9f91e8 --- /dev/null +++ b/data/metadata-schemas/catalog.json @@ -0,0 +1,18 @@ +{ + "uuid": "2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660", + "versions": [ + { + "version": "1.0.0", + "name": "Catalog", + "definitionFile": "catalog.ttl", + "abstractSchema": false, + "type": "INTERNAL", + "state": "LATEST", + "extendsSchemaUuids": [ + "6a668323-3936-4b53-8380-a4fd2ed082ee" + ], + "suggestedResourceName": "Catalog", + "suggestedUrlPrefix": "catalog" + } + ] +} diff --git a/data/metadata-schemas/catalog.ttl b/data/metadata-schemas/catalog.ttl new file mode 100644 index 000000000..d118b7741 --- /dev/null +++ b/data/metadata-schemas/catalog.ttl @@ -0,0 +1,35 @@ +@prefix : . +@prefix dash: . +@prefix dcat: . +@prefix dct: . +@prefix foaf: . +@prefix sh: . +@prefix xsd: . + +:CatalogShape a sh:NodeShape ; + sh:targetClass dcat:Catalog ; + sh:property [ + sh:path dct:issued ; + sh:datatype xsd:dateTime ; + sh:maxCount 1 ; + dash:viewer dash:LiteralViewer ; + sh:order 20 ; + ], [ + sh:path dct:modified ; + sh:datatype xsd:dateTime ; + sh:maxCount 1 ; + dash:viewer dash:LiteralViewer ; + sh:order 21 ; + ], [ + sh:path foaf:homePage ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + dash:editor dash:URIEditor ; + dash:viewer dash:LabelViewer ; + sh:order 22 ; + ], [ + sh:path dcat:themeTaxonomy ; + sh:nodeKind sh:IRI ; + dash:viewer dash:LabelViewer ; + sh:order 23 ; + ] . diff --git a/data/metadata-schemas/data-service.json b/data/metadata-schemas/data-service.json new file mode 100644 index 000000000..6dc4ab55b --- /dev/null +++ b/data/metadata-schemas/data-service.json @@ -0,0 +1,18 @@ +{ + "uuid": "89d94c1b-f6ff-4545-ba9b-120b2d1921d0", + "versions": [ + { + "version": "1.0.0", + "name": "Data Service", + "definitionFile": "data-service.ttl", + "abstractSchema": false, + "type": "INTERNAL", + "state": "LATEST", + "extendsSchemaUuids": [ + "6a668323-3936-4b53-8380-a4fd2ed082ee" + ], + "suggestedResourceName": "Data Service", + "suggestedUrlPrefix": "data-service" + } + ] +} \ No newline at end of file diff --git a/data/metadata-schemas/data-service.ttl b/data/metadata-schemas/data-service.ttl new file mode 100644 index 000000000..e6e7c78f6 --- /dev/null +++ b/data/metadata-schemas/data-service.ttl @@ -0,0 +1,22 @@ +@prefix : . +@prefix dash: . +@prefix dcat: . +@prefix dct: . +@prefix sh: . +@prefix xsd: . + +:DataServiceShape a sh:NodeShape ; + sh:targetClass dcat:DataService ; + sh:property [ + sh:path dcat:endpointURL ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + sh:order 20 ; + ] , [ + sh:path dcat:endpointDescription ; + sh:nodeKind sh:Literal ; + sh:maxCount 1 ; + dash:editor dash:TextAreaEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 21 ; + ] . diff --git a/data/metadata-schemas/dataset.json b/data/metadata-schemas/dataset.json new file mode 100644 index 000000000..d391a23d7 --- /dev/null +++ b/data/metadata-schemas/dataset.json @@ -0,0 +1,18 @@ +{ + "uuid": "866d7fb8-5982-4215-9c7c-18d0ed1bd5f3", + "versions": [ + { + "version": "1.0.0", + "name": "Dataset", + "definitionFile": "dataset.ttl", + "abstractSchema": false, + "type": "INTERNAL", + "state": "LATEST", + "extendsSchemaUuids": [ + "6a668323-3936-4b53-8380-a4fd2ed082ee" + ], + "suggestedResourceName": "Dataset", + "suggestedUrlPrefix": "dataset" + } + ] +} \ No newline at end of file diff --git a/data/metadata-schemas/dataset.ttl b/data/metadata-schemas/dataset.ttl new file mode 100644 index 000000000..1d1c6f586 --- /dev/null +++ b/data/metadata-schemas/dataset.ttl @@ -0,0 +1,51 @@ +@prefix : . +@prefix dash: . +@prefix dcat: . +@prefix dct: . +@prefix sh: . +@prefix xsd: . + +:DatasetShape a sh:NodeShape ; + sh:targetClass dcat:Dataset ; + sh:property [ + sh:path dct:issued ; + sh:datatype xsd:dateTime ; + sh:maxCount 1 ; + dash:editor dash:DateTimePickerEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 20 ; + ], [ + sh:path dct:modified ; + sh:datatype xsd:dateTime ; + sh:maxCount 1 ; + dash:editor dash:DateTimePickerEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 21 ; + ], [ + sh:path dcat:theme ; + sh:nodeKind sh:IRI ; + sh:minCount 1 ; + dash:editor dash:URIEditor ; + dash:viewer dash:LabelViewer ; + sh:order 22 ; + ], [ + sh:path dcat:contactPoint ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + dash:editor dash:URIEditor ; + dash:viewer dash:LabelViewer ; + sh:order 23 ; + ], [ + sh:path dcat:keyword ; + sh:nodeKind sh:Literal ; + dash:editor dash:TextFieldEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 24 ; + ], [ + sh:path dcat:landingPage ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + dash:editor dash:URIEditor ; + dash:viewer dash:LabelViewer ; + sh:order 25 ; + ] . diff --git a/data/metadata-schemas/distribution.json b/data/metadata-schemas/distribution.json new file mode 100644 index 000000000..3871715ac --- /dev/null +++ b/data/metadata-schemas/distribution.json @@ -0,0 +1,18 @@ +{ + "uuid": "ebacbf83-cd4f-4113-8738-d73c0735b0ab", + "versions": [ + { + "version": "1.0.0", + "name": "Distribution", + "definitionFile": "distribution.ttl", + "abstractSchema": false, + "type": "INTERNAL", + "state": "LATEST", + "extendsSchemaUuids": [ + "6a668323-3936-4b53-8380-a4fd2ed082ee" + ], + "suggestedResourceName": "Distribution", + "suggestedUrlPrefix": "distribution" + } + ] +} \ No newline at end of file diff --git a/data/metadata-schemas/distribution.ttl b/data/metadata-schemas/distribution.ttl new file mode 100644 index 000000000..710fff238 --- /dev/null +++ b/data/metadata-schemas/distribution.ttl @@ -0,0 +1,58 @@ +@prefix : . +@prefix dash: . +@prefix dcat: . +@prefix dct: . +@prefix sh: . +@prefix xsd: . + +:DistributionShape a sh:NodeShape ; + sh:targetClass dcat:Distribution ; + sh:property [ + sh:path dct:issued ; + sh:datatype xsd:dateTime ; + sh:maxCount 1 ; + dash:editor dash:DateTimePickerEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 20 ; + ], [ + sh:path dct:modified ; + sh:datatype xsd:dateTime ; + sh:maxCount 1 ; + dash:editor dash:DateTimePickerEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 21 ; + ], [ + sh:path dcat:accessURL ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + dash:editor dash:URIEditor ; + sh:order 22 ; + ], [ + sh:path dcat:downloadURL ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + dash:editor dash:URIEditor ; + sh:order 23 ; + ], [ + sh:path dcat:mediaType ; + sh:nodeKind sh:Literal ; + sh:minCount 1 ; + sh:maxCount 1 ; + dash:editor dash:TextFieldEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 24 ; + ], [ + sh:path dcat:format ; + sh:nodeKind sh:Literal ; + sh:maxCount 1 ; + dash:editor dash:TextFieldEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 25 ; + ], [ + sh:path dcat:byteSize ; + sh:nodeKind sh:Literal ; + sh:maxCount 1 ; + dash:editor dash:TextFieldEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 26 ; + ] . diff --git a/data/metadata-schemas/fdp.json b/data/metadata-schemas/fdp.json new file mode 100644 index 000000000..bf92d41aa --- /dev/null +++ b/data/metadata-schemas/fdp.json @@ -0,0 +1,18 @@ +{ + "uuid": "a92958ab-a414-47e6-8e17-68ba96ba3a2b", + "versions": [ + { + "version": "1.0.0", + "name": "FAIR Data Point", + "definitionFile": "fdp.ttl", + "abstractSchema": false, + "type": "INTERNAL", + "state": "LATEST", + "extendsSchemaUuids": [ + "6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad" + ], + "suggestedResourceName": "FAIR Data Point", + "suggestedUrlPrefix": "" + } + ] +} \ No newline at end of file diff --git a/data/metadata-schemas/fdp.ttl b/data/metadata-schemas/fdp.ttl new file mode 100644 index 000000000..5dec656b3 --- /dev/null +++ b/data/metadata-schemas/fdp.ttl @@ -0,0 +1,39 @@ +@prefix : . +@prefix dash: . +@prefix dct: . +@prefix fdp: . +@prefix sh: . +@prefix xsd: . + +:FDPShape a sh:NodeShape ; + sh:targetClass fdp:FAIRDataPoint ; + sh:property [ + sh:path fdp:startDate ; + sh:datatype xsd:date ; + sh:maxCount 1 ; + dash:editor dash:DatePickerEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 40 ; + ] , [ + sh:path fdp:endDate ; + sh:datatype xsd:date ; + sh:maxCount 1 ; + dash:editor dash:DatePickerEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 41 ; + ] , [ + sh:path fdp:uiLanguage ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + sh:defaultValue ; + dash:editor dash:URIEditor ; + dash:viewer dash:LabelViewer ; + sh:order 42 ; + ] , [ + sh:path fdp:metadataIdentifier ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + dash:editor dash:URIEditor ; + dash:viewer dash:LabelViewer ; + sh:order 43 ; + ] . diff --git a/data/metadata-schemas/metadata-service.json b/data/metadata-schemas/metadata-service.json new file mode 100644 index 000000000..f7ff02f34 --- /dev/null +++ b/data/metadata-schemas/metadata-service.json @@ -0,0 +1,18 @@ +{ + "uuid": "6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad", + "versions": [ + { + "version": "1.0.0", + "name": "Metaata Service", + "definitionFile": "metadata-service.ttl", + "abstractSchema": false, + "type": "INTERNAL", + "state": "LATEST", + "extendsSchemaUuids": [ + "89d94c1b-f6ff-4545-ba9b-120b2d1921d0" + ], + "suggestedResourceName": "Metadata Service", + "suggestedUrlPrefix": "metadata-service" + } + ] +} \ No newline at end of file diff --git a/data/metadata-schemas/metadata-service.ttl b/data/metadata-schemas/metadata-service.ttl new file mode 100644 index 000000000..d5057480d --- /dev/null +++ b/data/metadata-schemas/metadata-service.ttl @@ -0,0 +1,6 @@ +@prefix : . +@prefix fdp: . +@prefix sh: . + +:MetadataServiceShape a sh:NodeShape ; + sh:targetClass fdp:MetadataService . diff --git a/data/metadata-schemas/resource.json b/data/metadata-schemas/resource.json new file mode 100644 index 000000000..8e6b687c4 --- /dev/null +++ b/data/metadata-schemas/resource.json @@ -0,0 +1,13 @@ +{ + "uuid": "6a668323-3936-4b53-8380-a4fd2ed082ee", + "versions": [ + { + "version": "1.0.0", + "name": "Resource", + "definitionFile": "resource.ttl", + "abstractSchema": true, + "type": "INTERNAL", + "state": "LATEST" + } + ] +} \ No newline at end of file diff --git a/data/metadata-schemas/resource.ttl b/data/metadata-schemas/resource.ttl new file mode 100644 index 000000000..f77bb42bd --- /dev/null +++ b/data/metadata-schemas/resource.ttl @@ -0,0 +1,73 @@ +@prefix : . +@prefix dash: . +@prefix dcat: . +@prefix dct: . +@prefix foaf: . +@prefix sh: . +@prefix xsd: . + +:ResourceShape a sh:NodeShape ; + sh:targetClass dcat:Resource ; + sh:property [ + sh:path dct:title ; + sh:nodeKind sh:Literal ; + sh:minCount 1 ; + sh:maxCount 1 ; + dash:editor dash:TextFieldEditor ; + sh:order 1 ; + ], [ + sh:path dct:description ; + sh:nodeKind sh:Literal ; + sh:maxCount 1 ; + dash:editor dash:TextAreaEditor ; + sh:order 2 ; + ], [ + sh:path dct:publisher ; + sh:node :AgentShape ; + sh:minCount 1 ; + sh:maxCount 1 ; + dash:editor dash:BlankNodeEditor ; + sh:order 3 ; + ], [ + sh:path dcat:version ; + sh:name "version" ; + sh:nodeKind sh:Literal ; + sh:minCount 1 ; + sh:maxCount 1 ; + dash:editor dash:TextFieldEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 4 ; + ], [ + sh:path dct:language ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + dash:editor dash:URIEditor ; + dash:viewer dash:LabelViewer ; + sh:defaultValue ; + sh:order 5 ; + ], [ + sh:path dct:license ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + dash:editor dash:URIEditor ; + dash:viewer dash:LabelViewer ; + sh:defaultValue ; + sh:order 6 ; + ], [ + sh:path dct:rights ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + dash:editor dash:URIEditor ; + dash:viewer dash:LabelViewer ; + sh:order 7 ; + ] . + +:AgentShape a sh:NodeShape ; + sh:targetClass foaf:Agent ; + sh:property [ + sh:path foaf:name ; + sh:nodeKind sh:Literal ; + sh:minCount 1 ; + sh:maxCount 1 ; + dash:editor dash:TextFieldEditor ; + ] . diff --git a/data/records/records.json b/data/records/records.json new file mode 100644 index 000000000..46c9c64b7 --- /dev/null +++ b/data/records/records.json @@ -0,0 +1,10 @@ +{ + "records": [ + { + "file": "repository.ttl", + "repository": "main", + "uri": "{{ persistentUrl }}" + } + ], + "persistentUrlVar": "{{ persistentUrl }}" +} diff --git a/data/records/repository.ttl b/data/records/repository.ttl new file mode 100644 index 000000000..3908c213f --- /dev/null +++ b/data/records/repository.ttl @@ -0,0 +1,28 @@ +@prefix dcterms: . +@prefix dcat: . +@prefix foaf: . +@prefix xsd: . +@prefix ldp: . + +<{{ persistentUrl }}> a dcat:Resource, dcat:DataService, , + ; + dcterms:title "My FAIR Data Point"; + "My FAIR Data Point"; + dcat:version "1.0"; + dcterms:license ; + dcterms:description "Duis pellentesque, nunc a fringilla varius, magna dui porta quam, nec ultricies augue turpis sed velit. Donec id consectetur ligula. Suspendisse pharetra egestas massa, vel varius leo viverra at. Donec scelerisque id ipsum id semper. Maecenas facilisis augue vel justo molestie aliquet. Maecenas sed mattis lacus, sed viverra risus. Donec iaculis quis lacus vitae scelerisque. Nullam fermentum lectus nisi, id vulputate nisi congue nec. Morbi fermentum justo at justo bibendum, at tempus ipsum tempor. Donec facilisis nibh sed lectus blandit venenatis. Cras ullamcorper, justo vitae feugiat commodo, orci metus suscipit purus, quis sagittis turpis ante eget ex. Pellentesque malesuada a metus eu pulvinar. Morbi rutrum euismod eros at varius. Duis finibus dapibus ex, a hendrerit mauris efficitur at."; + dcterms:language ; + <{{ persistentUrl }}#identifier>; + <{{ persistentUrl }}#identifier>; + dcterms:accessRights <{{ persistentUrl }}#accessRights>; + dcterms:publisher <{{ persistentUrl }}#publisher>; + dcat:endpointURL <{{ persistentUrl }}> . + +<{{ persistentUrl }}#identifier> a ; + dcterms:identifier "{{ persistentUrl }}" . + +<{{ persistentUrl }}#accessRights> a dcterms:RightsStatement; + dcterms:description "This resource has no access restriction" . + +<{{ persistentUrl }}#publisher> a foaf:Agent; + foaf:name "Default Publisher" . diff --git a/data/resource-definitions/catalog.json b/data/resource-definitions/catalog.json new file mode 100644 index 000000000..00cd629ff --- /dev/null +++ b/data/resource-definitions/catalog.json @@ -0,0 +1,20 @@ +{ + "uuid": "a0949e72-4466-4d53-8900-9436d1049a4b", + "name": "Catalog", + "urlPrefix": "catalog", + "children": [ + { + "resourceDefinitionUuid": "2f08228e-1789-40f8-84cd-28e3288c3604", + "relationUri": "http://www.w3.org/ns/dcat#dataset", + "listView": { + "title": "Datasets", + "tagsUri": "http://www.w3.org/ns/dcat#theme", + "metadata": [] + } + } + ], + "externalLinks": [], + "metadataSchemaUuids": [ + "2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660" + ] +} diff --git a/data/resource-definitions/dataset.json b/data/resource-definitions/dataset.json new file mode 100644 index 000000000..f96b9e62c --- /dev/null +++ b/data/resource-definitions/dataset.json @@ -0,0 +1,25 @@ +{ + "uuid": "2f08228e-1789-40f8-84cd-28e3288c3604", + "name": "Dataset", + "urlPrefix": "dataset", + "children": [ + { + "resourceDefinitionUuid": "02c649de-c579-43bb-b470-306abdc808c7", + "relationUri": "http://www.w3.org/ns/dcat#distribution", + "listView": { + "title": "Distributions", + "tagsUri": null, + "metadata": [ + { + "title": "Media Type", + "propertyUri": "http://www.w3.org/ns/dcat#mediaType" + } + ] + } + } + ], + "externalLinks": [], + "metadataSchemaUuids": [ + "866d7fb8-5982-4215-9c7c-18d0ed1bd5f3" + ] +} diff --git a/data/resource-definitions/distribution.json b/data/resource-definitions/distribution.json new file mode 100644 index 000000000..ecaf01400 --- /dev/null +++ b/data/resource-definitions/distribution.json @@ -0,0 +1,19 @@ +{ + "uuid": "02c649de-c579-43bb-b470-306abdc808c7", + "name": "Distribution", + "urlPrefix": "distribution", + "children": [], + "externalLinks": [ + { + "title": "Access online", + "propertyUri": "http://www.w3.org/ns/dcat#accessURL" + }, + { + "title": "Download", + "propertyUri": "http://www.w3.org/ns/dcat#downloadURL" + } + ], + "metadataSchemaUuids": [ + "ebacbf83-cd4f-4113-8738-d73c0735b0ab" + ] +} diff --git a/data/resource-definitions/repository.json b/data/resource-definitions/repository.json new file mode 100644 index 000000000..2356f6bae --- /dev/null +++ b/data/resource-definitions/repository.json @@ -0,0 +1,20 @@ +{ + "uuid": "77aaad6a-0136-4c6e-88b9-07ffccd0ee4c", + "name": "FAIR Data Point", + "urlPrefix": "", + "children": [ + { + "resourceDefinitionUuid": "a0949e72-4466-4d53-8900-9436d1049a4b", + "relationUri": "https://w3id.org/fdp/fdp-o#metadataCatalog", + "listView": { + "title": "Catalogs", + "tagsUri": "http://www.w3.org/ns/dcat#themeTaxonomy", + "metadata": [] + } + } + ], + "externalLinks": [], + "metadataSchemaUuids": [ + "a92958ab-a414-47e6-8e17-68ba96ba3a2b" + ] +} diff --git a/data/settings/settings.json b/data/settings/settings.json new file mode 100644 index 000000000..99070f429 --- /dev/null +++ b/data/settings/settings.json @@ -0,0 +1,16 @@ +{ + "appTitle": "FAIR DAta Point", + "appSubtitle": "Metadata for Machines", + "autocompleteSources": [], + "metrics": [ + { + "metricUri": "https://purl.org/fair-metrics/FM_F1A", + "resourceUri": "https://www.ietf.org/rfc/rfc3986.txt" + }, + { + "metricUri": "https://purl.org/fair-metrics/FM_A1.1", + "resourceUri": "https://www.wikidata.org/wiki/Q8777" + } + ], + "searchFilters": [] +} \ No newline at end of file diff --git a/data/users/albert-einstein.json b/data/users/albert-einstein.json new file mode 100644 index 000000000..7c1f42bd1 --- /dev/null +++ b/data/users/albert-einstein.json @@ -0,0 +1,19 @@ +{ + "uuid": "123e4567-e89b-12d3-a456-426614174000", + "firstName": "Albert", + "lastName": "Einstein", + "email": "albert.einstein@example.com", + "password": "example", + "role": "Admin", + "apiKeyTokens": ["example-token-123"], + "savedQueries": [ + { + "name": "All datasets", + "description": "Quickly query all datasets (DCAT)", + "type": "PUBLIC", + "prefixes": "PREFIX dcat: ", + "graphPattern": "?entity rdf:type dcat:Dataset .", + "ordering": "ASC(?title)" + } + ] +} diff --git a/data/users/nikola-tesla.json b/data/users/nikola-tesla.json new file mode 100644 index 000000000..e31b3335f --- /dev/null +++ b/data/users/nikola-tesla.json @@ -0,0 +1,7 @@ +{ + "firstName": "Nikola", + "lastName": "Tesla", + "email": "nikola.tesla@example.com", + "password": "password", + "role": "USER" +} diff --git a/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java b/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java new file mode 100644 index 000000000..a7180009c --- /dev/null +++ b/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java @@ -0,0 +1,39 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.config.properties; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; + +@NoArgsConstructor +@AllArgsConstructor +@Getter +@Setter +@ConfigurationProperties(prefix = "bootstrap") +public class BootstrapProperties { + private boolean enabled; + private String dataPath; +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/BootstrapContext.java b/src/main/java/org/fairdatapoint/service/boostrap/BootstrapContext.java new file mode 100644 index 000000000..e3c9a0f03 --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/BootstrapContext.java @@ -0,0 +1,39 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap; + +import lombok.Data; +import org.fairdatapoint.entity.resource.ResourceDefinition; +import org.fairdatapoint.entity.schema.MetadataSchema; +import org.fairdatapoint.entity.user.UserAccount; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +@Data +public class BootstrapContext { + private Map users = new HashMap<>(); + private Map metadataSchemas = new HashMap<>(); + private Map resourceDefinitions = new HashMap<>(); +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/BootstrapRunner.java b/src/main/java/org/fairdatapoint/service/boostrap/BootstrapRunner.java new file mode 100644 index 000000000..9a0901c41 --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/BootstrapRunner.java @@ -0,0 +1,43 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap; + +import lombok.RequiredArgsConstructor; +import org.fairdatapoint.config.properties.BootstrapProperties; +import org.springframework.boot.ApplicationRunner; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class BootstrapRunner implements ApplicationRunner { + private final BootstrapProperties bootstrapProperties; + private final BootstrapService bootstrapService; + + @Override + public void run(final org.springframework.boot.ApplicationArguments args) { + if (bootstrapProperties.isEnabled()) { + bootstrapService.bootstrapFromDir(bootstrapProperties.getDataPath()); + } + } + +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/BootstrapService.java b/src/main/java/org/fairdatapoint/service/boostrap/BootstrapService.java new file mode 100644 index 000000000..c631a32af --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/BootstrapService.java @@ -0,0 +1,111 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap; + +import jakarta.transaction.Transactional; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.fairdatapoint.service.boostrap.components.*; +import org.springframework.stereotype.Service; + +import java.nio.file.Path; + +@Slf4j +@Service +@RequiredArgsConstructor +public class BootstrapService { + private final UserBootstrapper userBootstrapper; + private final SettingsBootstrapper settingsBootstrapper; + private final MembershipBootstrapper membershipBootstrapper; + private final MetadataRecordsBootstrapper metadataRecordsBootstrapper; + private final MetadataSchemaBootstrapper metadataSchemaBootstrapper; + private final MetadataSchemaVersionsBootstrapper metadataSchemaVersionsBootstrapper; + private final ResourceDefinitionBootstrapper resourceDefinitionBootstrapper; + private final ResourceDefinitionChildrenBootstrapper resourceDefinitionChildrenBootstrapper; + + @Transactional + public void bootstrapFromDir(String dataPath) { + final Path basePath = Path.of(dataPath); + final BootstrapContext context = new BootstrapContext(); + log.info("Bootstrap process started"); + + if (!basePath.toFile().exists() || !basePath.toFile().isDirectory()) { + log.warn("Bootstrap directory {} does not exist or is not a directory, skipping bootstrapping", dataPath); + return; + } + + // Settings + if (settingsBootstrapper.shouldBootstrap()) { + settingsBootstrapper.bootstrapFromJson(basePath.resolve("settings"), context); + } + else { + log.info("Settings already exist, skipping settings bootstrapping"); + } + + // User (and related entities) + if (userBootstrapper.shouldBootstrap()) { + userBootstrapper.bootstrapAllFromDir(basePath.resolve("users"), context); + } + else { + log.info("Users already exist, skipping user bootstrapping"); + } + + // Metadata Schemas + if (metadataSchemaBootstrapper.shouldBootstrap()) { + final Path dir = basePath.resolve("metadata-schemas"); + metadataSchemaBootstrapper.bootstrapAllFromDir(dir, context); + metadataSchemaVersionsBootstrapper.bootstrapAllFromDir(dir, context); + } + else { + log.info("Metadata Schemas already exist, skipping metadata schema bootstrapping"); + } + + // Resource Definitions + if (resourceDefinitionBootstrapper.shouldBootstrap()) { + final Path dir = basePath.resolve("resource-definitions"); + resourceDefinitionBootstrapper.bootstrapAllFromDir(dir, context); + resourceDefinitionChildrenBootstrapper.bootstrapAllFromDir(dir, context); + } + else { + log.info("Resource Definitions already exist, skipping resource definition bootstrapping"); + } + + // Memberships + if (membershipBootstrapper.shouldBootstrap()) { + membershipBootstrapper.bootstrapAllFromDir(basePath.resolve("memberships"), context); + } + else { + log.info("Memberships already exist, skipping membership bootstrapping"); + } + + // RDF Records + if (metadataRecordsBootstrapper.shouldBootstrap()) { + metadataRecordsBootstrapper.bootstrapAllFromDir(basePath.resolve("records"), context); + } + else { + log.info("Metadata Records already exist, skipping metadata records bootstrapping"); + } + + log.info("Bootstrap process finished"); + } +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/AbstractBootstrapper.java b/src/main/java/org/fairdatapoint/service/boostrap/components/AbstractBootstrapper.java new file mode 100644 index 000000000..f44279706 --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/components/AbstractBootstrapper.java @@ -0,0 +1,77 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.components; + +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.fairdatapoint.service.boostrap.BootstrapContext; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.stream.Stream; + +@Slf4j +public abstract class AbstractBootstrapper implements IBootstrapper { + private final ObjectMapper objectMapper; + + protected AbstractBootstrapper(ObjectMapper objectMapper) { + this.objectMapper = objectMapper; + } + + @Override + public void bootstrapAllFromDir(Path dirPath, BootstrapContext context) { + if (!Files.isDirectory(dirPath)) { + log.info("Directory {} does not exist, nothing to bootstrap", dirPath); + return; + } + try (Stream paths = Files.walk(dirPath)) { + initBootstrap(); + paths.filter(Files::isRegularFile) + .filter(path -> path.toString().endsWith(".json")) + .forEach(path -> bootstrapFromJson(path, context)); + finalizeBootstrap(); + } + catch (IOException exception) { + throw new RuntimeException("Error loading entities", exception); + } + } + + protected ObjectMapper getObjectMapper() { + return objectMapper; + } + + protected void initBootstrap() { + } + + protected void finalizeBootstrap() { + getRepository().flush(); + } + + public boolean shouldBootstrap() { + return getRepository().count() == 0; + } + + protected abstract JpaRepository getRepository(); +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/IBootstrapper.java b/src/main/java/org/fairdatapoint/service/boostrap/components/IBootstrapper.java new file mode 100644 index 000000000..861953035 --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/components/IBootstrapper.java @@ -0,0 +1,34 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.components; + +import org.fairdatapoint.service.boostrap.BootstrapContext; + +import java.nio.file.Path; + +public interface IBootstrapper { + + void bootstrapAllFromDir(Path dirPath, BootstrapContext context); + + void bootstrapFromJson(Path resourcePath, BootstrapContext context); +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/MembershipBootstrapper.java b/src/main/java/org/fairdatapoint/service/boostrap/components/MembershipBootstrapper.java new file mode 100644 index 000000000..b782b2e5b --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/components/MembershipBootstrapper.java @@ -0,0 +1,80 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.components; + +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.fairdatapoint.database.db.repository.MembershipPermissionRepository; +import org.fairdatapoint.database.db.repository.MembershipRepository; +import org.fairdatapoint.entity.membership.Membership; +import org.fairdatapoint.service.boostrap.BootstrapContext; +import org.fairdatapoint.service.boostrap.fixtures.MembershipFixture; +import org.fairdatapoint.service.membership.MembershipMapper; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.nio.file.Path; + +@Slf4j +@Component +public class MembershipBootstrapper extends AbstractBootstrapper { + private final MembershipMapper membershipMapper; + private final MembershipRepository membershipRepository; + private final MembershipPermissionRepository membershipPermissionRepository; + + public MembershipBootstrapper(ObjectMapper objectMapper, MembershipMapper membershipMapper, + MembershipRepository membershipRepository, + MembershipPermissionRepository membershipPermissionRepository) { + super(objectMapper); + this.membershipMapper = membershipMapper; + this.membershipRepository = membershipRepository; + this.membershipPermissionRepository = membershipPermissionRepository; + } + + @Override + protected JpaRepository getRepository() { + return membershipRepository; + } + + @Override + public void bootstrapFromJson(Path resourcePath, BootstrapContext context) { + try { + final MembershipFixture membershipFixture = + getObjectMapper().readValue(resourcePath.toFile(), MembershipFixture.class); + final Membership membership = membershipRepository.saveAndFlush( + membershipMapper.fromFixture(membershipFixture) + ); + membershipPermissionRepository.saveAllAndFlush( + membershipFixture.getPermissions() + .stream() + .map(perm -> membershipMapper.permissionFromDTO(membership, perm)) + .toList() + ); + log.info("Created membership {}", membership.getName()); + } + catch (IOException exception) { + throw new RuntimeException(exception); + } + } +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/MetadataRecordsBootstrapper.java b/src/main/java/org/fairdatapoint/service/boostrap/components/MetadataRecordsBootstrapper.java new file mode 100644 index 000000000..ae585808e --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/components/MetadataRecordsBootstrapper.java @@ -0,0 +1,113 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.components; + +import lombok.extern.slf4j.Slf4j; +import org.eclipse.rdf4j.model.Model; +import org.eclipse.rdf4j.model.Statement; +import org.eclipse.rdf4j.rio.RDFFormat; +import org.eclipse.rdf4j.rio.Rio; +import org.fairdatapoint.database.rdf.repository.RepositoryMode; +import org.fairdatapoint.database.rdf.repository.generic.GenericMetadataRepository; +import org.fairdatapoint.service.boostrap.BootstrapContext; +import org.fairdatapoint.service.boostrap.fixtures.RecordsFixture; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Component; + +import java.io.StringReader; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.Locale; + +import static org.fairdatapoint.util.ValueFactoryHelper.i; + +@Slf4j +@Component +public class MetadataRecordsBootstrapper extends AbstractBootstrapper { + private final GenericMetadataRepository genericMetadataRepository; + private final String persistentUrl; + + public MetadataRecordsBootstrapper(GenericMetadataRepository genericMetadataRepository, + String persistentUrl) { + super(null); + this.genericMetadataRepository = genericMetadataRepository; + this.persistentUrl = persistentUrl; + } + + @Override + protected JpaRepository getRepository() { + return null; + } + + @Override + public void bootstrapFromJson(Path resourcePath, BootstrapContext context) { + if (!resourcePath.getFileName().toString().equals("records.json")) { + log.warn("Skipping file {}: only records.json is supported for records bootstrapping", resourcePath); + return; + } + try { + final RecordsFixture recordsFixture = + getObjectMapper().readValue(resourcePath.toFile(), RecordsFixture.class); + final Path resourceDir = resourcePath.getParent(); + recordsFixture.getRecords().forEach(record -> { + final Path recordPath = resourceDir.resolve(record.getFilename()); + try { + final String rdfContent = + Files + .readString(recordPath) + .replaceAll(recordsFixture.getPersistentUrlVar(), persistentUrl); + final String baseUri = + record.getUri().replaceAll(recordsFixture.getPersistentUrlVar(), persistentUrl); + final RepositoryMode repositoryMode = getRepositoryMode(record.getRepository()); + storeRecord(rdfContent, repositoryMode, baseUri); + log.info("Created metadata record {}", record.getUri()); + } + catch (Exception exception) { + log.warn("Failed to read record file {}: {}", recordPath, exception.getMessage()); + } + }); + } + catch (Exception exception) { + throw new RuntimeException(exception); + } + } + + private void storeRecord(String rdfContent, RepositoryMode repositoryMode, String baseUri) { + try { + final Model model = Rio.parse(new StringReader(rdfContent), baseUri, RDFFormat.TURTLE); + final List statements = model.stream().toList(); + genericMetadataRepository.save(statements, i(baseUri), repositoryMode); + } + catch (Exception exception) { + log.warn("Failed to parse RDF content: {}", exception.getMessage()); + } + } + + private RepositoryMode getRepositoryMode(String repository) { + if (repository.toLowerCase(Locale.ROOT).equals("drafts")) { + return RepositoryMode.DRAFTS; + } + return RepositoryMode.MAIN; + } +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/MetadataSchemaBootstrapper.java b/src/main/java/org/fairdatapoint/service/boostrap/components/MetadataSchemaBootstrapper.java new file mode 100644 index 000000000..a460eea4d --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/components/MetadataSchemaBootstrapper.java @@ -0,0 +1,86 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.components; + +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.fairdatapoint.database.db.repository.MetadataSchemaExtensionRepository; +import org.fairdatapoint.database.db.repository.MetadataSchemaRepository; +import org.fairdatapoint.database.db.repository.MetadataSchemaVersionRepository; +import org.fairdatapoint.entity.schema.MetadataSchema; +import org.fairdatapoint.service.boostrap.BootstrapContext; +import org.fairdatapoint.service.boostrap.fixtures.MetadataSchemaFixture; +import org.fairdatapoint.service.schema.MetadataSchemaMapper; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Component; + +import java.nio.file.Path; + +@Slf4j +@Component +public class MetadataSchemaBootstrapper extends AbstractBootstrapper { + private final MetadataSchemaRepository metadataSchemaRepository; + private final MetadataSchemaExtensionRepository metadataSchemaExtensionRepository; + private final MetadataSchemaVersionRepository metadataSchemaVersionRepository; + private final MetadataSchemaMapper metadataSchemaMapper; + + public MetadataSchemaBootstrapper(ObjectMapper objectMapper, MetadataSchemaRepository metadataSchemaRepository, + MetadataSchemaExtensionRepository metadataSchemaExtensionRepository, + MetadataSchemaVersionRepository metadataSchemaVersionRepository, + MetadataSchemaMapper metadataSchemaMapper) { + super(objectMapper); + this.metadataSchemaRepository = metadataSchemaRepository; + this.metadataSchemaExtensionRepository = metadataSchemaExtensionRepository; + this.metadataSchemaVersionRepository = metadataSchemaVersionRepository; + this.metadataSchemaMapper = metadataSchemaMapper; + } + + @Override + protected JpaRepository getRepository() { + return metadataSchemaRepository; + } + + @Override + public void bootstrapFromJson(Path resourcePath, BootstrapContext context) { + try { + final MetadataSchemaFixture metadataSchemaFixture = + getObjectMapper().readValue(resourcePath.toFile(), MetadataSchemaFixture.class); + final MetadataSchema metadataSchema = + metadataSchemaRepository.saveAndFlush(metadataSchemaMapper.newSchema()); + context.getMetadataSchemas().put(metadataSchemaFixture.getUuid(), metadataSchema); + // Versions and extensions + metadataSchemaVersionRepository.saveAllAndFlush( + metadataSchemaFixture.getVersions() + .stream() + .map(version -> { + return metadataSchemaMapper.fromMetadataSchemaVersionFixture(version, metadataSchema); + }) + .toList() + ); + // Extensions + } + catch (Exception exception) { + throw new RuntimeException(exception); + } + } +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/MetadataSchemaVersionsBootstrapper.java b/src/main/java/org/fairdatapoint/service/boostrap/components/MetadataSchemaVersionsBootstrapper.java new file mode 100644 index 000000000..42540850f --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/components/MetadataSchemaVersionsBootstrapper.java @@ -0,0 +1,113 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.components; + +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.fairdatapoint.database.db.repository.MetadataSchemaExtensionRepository; +import org.fairdatapoint.database.db.repository.MetadataSchemaVersionRepository; +import org.fairdatapoint.entity.schema.MetadataSchema; +import org.fairdatapoint.entity.schema.MetadataSchemaVersion; +import org.fairdatapoint.service.boostrap.BootstrapContext; +import org.fairdatapoint.service.boostrap.fixtures.MetadataSchemaFixture; +import org.fairdatapoint.service.boostrap.fixtures.MetadataSchemaVersionFixture; +import org.fairdatapoint.service.schema.MetadataSchemaMapper; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.UUID; +import java.util.stream.IntStream; + +@Slf4j +@Component +public class MetadataSchemaVersionsBootstrapper extends AbstractBootstrapper { + private final MetadataSchemaVersionRepository metadataSchemaVersionRepository; + private final MetadataSchemaExtensionRepository metadataSchemaExtensionRepository; + private final MetadataSchemaMapper metadataSchemaMapper; + + public MetadataSchemaVersionsBootstrapper(ObjectMapper objectMapper, + MetadataSchemaVersionRepository metadataSchemaVersionRepository, + MetadataSchemaExtensionRepository metadataSchemaExtensionRepository, + MetadataSchemaMapper metadataSchemaMapper) { + super(objectMapper); + this.metadataSchemaVersionRepository = metadataSchemaVersionRepository; + this.metadataSchemaExtensionRepository = metadataSchemaExtensionRepository; + this.metadataSchemaMapper = metadataSchemaMapper; + } + + @Override + protected JpaRepository getRepository() { + return metadataSchemaVersionRepository; + } + + @Override + public void bootstrapFromJson(Path resourcePath, BootstrapContext context) { + try { + final MetadataSchemaFixture metadataSchemaFixture = + getObjectMapper().readValue(resourcePath.toFile(), MetadataSchemaFixture.class); + final MetadataSchema metadataSchema = + context.getMetadataSchemas().get(metadataSchemaFixture.getUuid()); + metadataSchemaFixture.getVersions().forEach(version -> { + final MetadataSchemaVersion metadataSchemaVersion = metadataSchemaVersionRepository.saveAndFlush( + fromFixture(resourcePath, version, metadataSchema) + ); + + // Extensions + metadataSchemaExtensionRepository.saveAllAndFlush( + IntStream.range(0, version.getExtendsSchemaUuids().size()) + .mapToObj(index -> { + final UUID metadataSchemaUuid = version.getExtendsSchemaUuids().get(index); + return metadataSchemaMapper.newExtension( + metadataSchemaVersion, + context.getMetadataSchemas().get(metadataSchemaUuid), + index + ); + }) + .toList() + ); + }); + } + catch (Exception exception) { + throw new RuntimeException(exception); + } + } + + private MetadataSchemaVersion fromFixture(Path resourcePath, MetadataSchemaVersionFixture fixture, + MetadataSchema schema) { + final MetadataSchemaVersion version = metadataSchemaMapper.fromMetadataSchemaVersionFixture(fixture, schema); + if (fixture.getDefinitionFile() != null) { + final Path definitionPath = resourcePath.getParent().resolve(fixture.getDefinitionFile()); + try { + final String definition = Files.readString(definitionPath); + version.setDefinition(definition); + } + catch (IOException exception) { + log.warn("Failed to read definition file for schema version: {}", definitionPath); + } + } + return version; + } +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/ResourceDefinitionBootstrapper.java b/src/main/java/org/fairdatapoint/service/boostrap/components/ResourceDefinitionBootstrapper.java new file mode 100644 index 000000000..14834facf --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/components/ResourceDefinitionBootstrapper.java @@ -0,0 +1,104 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.components; + +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.fairdatapoint.database.db.repository.*; +import org.fairdatapoint.entity.resource.ResourceDefinition; +import org.fairdatapoint.service.boostrap.BootstrapContext; +import org.fairdatapoint.service.boostrap.fixtures.ResourceDefinitionFixture; +import org.fairdatapoint.service.resource.ResourceDefinitionMapper; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Component; + +import java.nio.file.Path; +import java.util.stream.IntStream; + +@Slf4j +@Component +public class ResourceDefinitionBootstrapper extends AbstractBootstrapper { + private final ResourceDefinitionRepository resourceDefinitionRepository; + private final ResourceDefinitionLinkRepository resourceDefinitionLinkRepository; + private final MetadataSchemaUsageRepository metadataSchemaUsageRepository; + private final ResourceDefinitionMapper resourceDefinitionMapper; + + public ResourceDefinitionBootstrapper(ObjectMapper objectMapper, + ResourceDefinitionRepository resourceDefinitionRepository, + ResourceDefinitionLinkRepository resourceDefinitionLinkRepository, + MetadataSchemaUsageRepository metadataSchemaUsageRepository, + ResourceDefinitionMapper resourceDefinitionMapper) { + super(objectMapper); + this.resourceDefinitionRepository = resourceDefinitionRepository; + this.resourceDefinitionLinkRepository = resourceDefinitionLinkRepository; + this.metadataSchemaUsageRepository = metadataSchemaUsageRepository; + this.resourceDefinitionMapper = resourceDefinitionMapper; + } + + @Override + protected JpaRepository getRepository() { + return resourceDefinitionRepository; + } + + @Override + public void bootstrapFromJson(Path resourcePath, BootstrapContext context) { + try { + final ResourceDefinitionFixture resourceDefinitionFixture = + getObjectMapper().readValue(resourcePath.toString(), ResourceDefinitionFixture.class); + final ResourceDefinition resourceDefinition = + resourceDefinitionRepository.saveAndFlush( + resourceDefinitionMapper.fromResourceDefinitionFixture(resourceDefinitionFixture) + ); + context.getResourceDefinitions().put(resourceDefinitionFixture.getUuid(), resourceDefinition); + // External Links + resourceDefinitionLinkRepository.saveAllAndFlush( + IntStream.range(0, resourceDefinitionFixture.getExternalLinks().size()) + .mapToObj(index -> { + return resourceDefinitionMapper.toLink( + resourceDefinitionFixture.getExternalLinks().get(index), + resourceDefinition, + index + ); + }) + .toList() + ); + // Metadata Schema Usages + metadataSchemaUsageRepository.saveAllAndFlush( + IntStream.range(0, resourceDefinitionFixture.getMetadataSchemaUuids().size()) + .mapToObj(index -> { + return resourceDefinitionMapper.toUsage( + context.getMetadataSchemas().get( + resourceDefinitionFixture.getMetadataSchemaUuids().get(index) + ), + resourceDefinition, + index + ); + }) + .toList() + ); + } + catch (Exception exception) { + throw new RuntimeException(exception); + } + } +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/ResourceDefinitionChildrenBootstrapper.java b/src/main/java/org/fairdatapoint/service/boostrap/components/ResourceDefinitionChildrenBootstrapper.java new file mode 100644 index 000000000..8e3a409a5 --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/components/ResourceDefinitionChildrenBootstrapper.java @@ -0,0 +1,102 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.components; + +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.fairdatapoint.api.dto.resource.ResourceDefinitionChildDTO; +import org.fairdatapoint.database.db.repository.*; +import org.fairdatapoint.entity.resource.ResourceDefinition; +import org.fairdatapoint.entity.resource.ResourceDefinitionChild; +import org.fairdatapoint.service.boostrap.BootstrapContext; +import org.fairdatapoint.service.boostrap.fixtures.ResourceDefinitionFixture; +import org.fairdatapoint.service.resource.ResourceDefinitionMapper; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Component; + +import java.nio.file.Path; +import java.util.stream.IntStream; + +@Slf4j +@Component +public class ResourceDefinitionChildrenBootstrapper extends AbstractBootstrapper { + private final ResourceDefinitionChildRepository childRepository; + private final ResourceDefinitionChildMetadataRepository childMetadataRepository; + private final ResourceDefinitionMapper resourceDefinitionMapper; + + public ResourceDefinitionChildrenBootstrapper(ObjectMapper objectMapper, + ResourceDefinitionChildRepository childRepository, + ResourceDefinitionChildMetadataRepository childMetadataRepository, + ResourceDefinitionMapper resourceDefinitionMapper) { + super(objectMapper); + this.childRepository = childRepository; + this.childMetadataRepository = childMetadataRepository; + this.resourceDefinitionMapper = resourceDefinitionMapper; + } + + @Override + protected JpaRepository getRepository() { + return childRepository; + } + + @Override + public void bootstrapFromJson(Path resourcePath, BootstrapContext context) { + try { + final ResourceDefinitionFixture resourceDefinitionFixture = + getObjectMapper().readValue(resourcePath.toString(), ResourceDefinitionFixture.class); + final ResourceDefinition resourceDefinition = + context.getResourceDefinitions().get(resourceDefinitionFixture.getUuid()); + // Children + IntStream.range(0, resourceDefinitionFixture.getChildren().size()) + .mapToObj(index -> { + final ResourceDefinitionChildDTO childDTO = + resourceDefinitionFixture.getChildren().get(index); + return resourceDefinitionMapper.toChild( + resourceDefinitionFixture.getChildren().get(index), + resourceDefinition, + context.getResourceDefinitions().get(childDTO.getResourceDefinitionUuid()), + index); + }) + .forEach(child -> { + final ResourceDefinitionChild savedChild = childRepository.saveAndFlush(child); + final ResourceDefinitionChildDTO childDTO = + resourceDefinitionFixture.getChildren().get(child.getOrderPriority()); + // Child metadata + childMetadataRepository.saveAllAndFlush( + IntStream.range(0, childDTO.getListView().getMetadata().size()) + .mapToObj(metaIndex -> { + return resourceDefinitionMapper.toChildMetadata( + childDTO.getListView().getMetadata().get(metaIndex), + savedChild, + metaIndex + ); + }) + .toList() + ); + }); + } + catch (Exception exception) { + throw new RuntimeException(exception); + } + } +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/SettingsBootstrapper.java b/src/main/java/org/fairdatapoint/service/boostrap/components/SettingsBootstrapper.java new file mode 100644 index 000000000..a2e87dc7f --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/components/SettingsBootstrapper.java @@ -0,0 +1,121 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.components; + +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.fairdatapoint.database.db.repository.*; +import org.fairdatapoint.entity.settings.Settings; +import org.fairdatapoint.entity.settings.SettingsSearchFilter; +import org.fairdatapoint.service.boostrap.BootstrapContext; +import org.fairdatapoint.service.boostrap.fixtures.SettingsFixture; +import org.fairdatapoint.service.settings.SettingsMapper; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Component; + +import java.nio.file.Path; +import java.util.stream.IntStream; + +@Slf4j +@Component +public class SettingsBootstrapper extends AbstractBootstrapper { + private final ObjectMapper objectMapper; + private final SettingsRepository settingsRepository; + private final SettingsMetricRepository settingsMetricRepository; + private final SettingsAutocompleteSourceRepository settingsAutocompleteSourceRepository; + private final SettingsSearchFilterRepository settingsSearchFilterRepository; + private final SettingsSearchFilterItemRepository settingsSearchFilterItemRepository; + private final SettingsMapper settingsMapper; + + public SettingsBootstrapper(ObjectMapper objectMapper, + SettingsRepository settingsRepository, + SettingsMetricRepository settingsMetricRepository, + SettingsAutocompleteSourceRepository settingsAutocompleteSourceRepository, + SettingsSearchFilterRepository settingsSearchFilterRepository, + SettingsSearchFilterItemRepository settingsSearchFilterItemRepository, + SettingsMapper settingsMapper) { + super(objectMapper); + this.objectMapper = objectMapper; + this.settingsRepository = settingsRepository; + this.settingsMetricRepository = settingsMetricRepository; + this.settingsAutocompleteSourceRepository = settingsAutocompleteSourceRepository; + this.settingsSearchFilterRepository = settingsSearchFilterRepository; + this.settingsSearchFilterItemRepository = settingsSearchFilterItemRepository; + this.settingsMapper = settingsMapper; + } + + public void bootstrapFromJson(Path resourcePath, BootstrapContext context) { + if (!resourcePath.getFileName().toString().equals("settings.json")) { + log.warn("Skipping file {}: only settings.json is supported for settings bootstrapping", resourcePath); + return; + } + try { + final SettingsFixture settingsFixture = + objectMapper.readValue(resourcePath.toFile(), SettingsFixture.class); + final Settings settings = settingsRepository.saveAndFlush( + settingsMapper.fromSettingsFixture(settingsFixture) + ); + // Metrics + settingsMetricRepository.saveAll( + IntStream.range(0, settingsFixture.getMetrics().size()) + .mapToObj(index -> { + final var metricFixture = settingsFixture.getMetrics().get(index); + return settingsMapper.fromMetricDTO(metricFixture, index, settings); + }) + .toList() + ); + // Autocomplete sources + settingsAutocompleteSourceRepository.saveAll( + IntStream.range(0, settingsFixture.getAutocompleteSources().size()) + .mapToObj(index -> { + final var sourceFixture = settingsFixture.getAutocompleteSources().get(index); + return settingsMapper.fromAutocompleteSourceDTO(sourceFixture, index, settings); + }) + .toList() + ); + // Search filters + settingsFixture.getSearchFilters().forEach(filterFixture -> { + final SettingsSearchFilter searchFilter = settingsSearchFilterRepository.saveAndFlush( + settingsMapper.fromSearchFilterDTO(filterFixture, 0, settings) + ); + // Filter items + settingsSearchFilterItemRepository.saveAll( + IntStream.range(0, filterFixture.getValues().size()) + .mapToObj(index -> { + final var itemFixture = filterFixture.getValues().get(index); + return settingsMapper.fromSearchFilterItemDTO(itemFixture, index, searchFilter); + }) + .toList() + ); + }); + } + catch (java.io.IOException exception) { + throw new RuntimeException(exception); + } + } + + @Override + protected JpaRepository getRepository() { + return settingsRepository; + } +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/UserBootstrapper.java b/src/main/java/org/fairdatapoint/service/boostrap/components/UserBootstrapper.java new file mode 100644 index 000000000..1554622ef --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/components/UserBootstrapper.java @@ -0,0 +1,102 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.components; + +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.fairdatapoint.database.db.repository.ApiKeyRepository; +import org.fairdatapoint.database.db.repository.SearchSavedQueryRepository; +import org.fairdatapoint.database.db.repository.UserAccountRepository; +import org.fairdatapoint.entity.apikey.ApiKey; +import org.fairdatapoint.entity.search.SearchSavedQuery; +import org.fairdatapoint.entity.user.UserAccount; +import org.fairdatapoint.service.apikey.ApiKeyMapper; +import org.fairdatapoint.service.boostrap.BootstrapContext; +import org.fairdatapoint.service.boostrap.fixtures.SearchSavedQueryFixture; +import org.fairdatapoint.service.boostrap.fixtures.UserFixture; +import org.fairdatapoint.service.search.query.SearchSavedQueryMapper; +import org.fairdatapoint.service.user.UserMapper; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.nio.file.Path; + +@Slf4j +@Component +public class UserBootstrapper extends AbstractBootstrapper { + private final UserMapper userMapper; + private final UserAccountRepository userAccountRepository; + private final ApiKeyMapper apiKeyMapper; + private final ApiKeyRepository apiKeyRepository; + private final SearchSavedQueryMapper searchSavedQueryMapper; + private final SearchSavedQueryRepository searchSavedQueryRepository; + + public UserBootstrapper(ObjectMapper objectMapper, UserMapper userMapper, + UserAccountRepository userAccountRepository, + ApiKeyMapper apiKeyMapper, ApiKeyRepository apiKeyRepository, + SearchSavedQueryMapper searchSavedQueryMapper, + SearchSavedQueryRepository searchSavedQueryRepository) { + super(objectMapper); + this.userMapper = userMapper; + this.userAccountRepository = userAccountRepository; + this.apiKeyMapper = apiKeyMapper; + this.apiKeyRepository = apiKeyRepository; + this.searchSavedQueryMapper = searchSavedQueryMapper; + this.searchSavedQueryRepository = searchSavedQueryRepository; + } + + @Override + protected JpaRepository getRepository() { + return userAccountRepository; + } + + @Override + public void bootstrapFromJson(Path resourcePath, BootstrapContext context) { + try { + final UserFixture userFixture = getObjectMapper().readValue(resourcePath.toFile(), UserFixture.class); + final UserAccount userAccount = userAccountRepository.saveAndFlush( + userMapper.fromFixture(userFixture) + ); + for (String token : userFixture.getApiKeyTokens()) { + final ApiKey apiKey = apiKeyRepository.saveAndFlush( + apiKeyMapper.createApiKey(userAccount, token) + ); + log.debug("Created API key for user {} with token {}", + userAccount.getEmail(), apiKey.getToken()); + } + for (SearchSavedQueryFixture queryFixture : userFixture.getSavedQueries()) { + final SearchSavedQuery savedQuery = searchSavedQueryRepository.saveAndFlush( + searchSavedQueryMapper.fromFixture(queryFixture, userAccount) + ); + log.debug("Created saved search query for user {} with UUID {}", + userAccount.getEmail(), savedQuery.getUuid()); + } + context.getUsers().put(userFixture.getUuid(), userAccount); + log.info("Loaded user: {}", userAccount.getEmail()); + } + catch (IOException exception) { + throw new RuntimeException(exception); + } + } +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/MembershipFixture.java b/src/main/java/org/fairdatapoint/service/boostrap/fixtures/MembershipFixture.java new file mode 100644 index 000000000..9b754c26a --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/fixtures/MembershipFixture.java @@ -0,0 +1,36 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.fixtures; + +import lombok.Data; +import org.fairdatapoint.api.dto.membership.MembershipPermissionDTO; + +import java.util.List; +import java.util.UUID; + +@Data +public class MembershipFixture { + private String name; + private List allowedEntities; + private List permissions; +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/MetadataSchemaFixture.java b/src/main/java/org/fairdatapoint/service/boostrap/fixtures/MetadataSchemaFixture.java new file mode 100644 index 000000000..5a04d6623 --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/fixtures/MetadataSchemaFixture.java @@ -0,0 +1,34 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.fixtures; + +import lombok.Data; + +import java.util.List; +import java.util.UUID; + +@Data +public class MetadataSchemaFixture { + private UUID uuid = UUID.randomUUID(); + private List versions; +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/MetadataSchemaVersionFixture.java b/src/main/java/org/fairdatapoint/service/boostrap/fixtures/MetadataSchemaVersionFixture.java new file mode 100644 index 000000000..40444348b --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/fixtures/MetadataSchemaVersionFixture.java @@ -0,0 +1,49 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.fixtures; + +import lombok.Data; +import org.fairdatapoint.entity.schema.MetadataSchemaState; +import org.fairdatapoint.entity.schema.MetadataSchemaType; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +@Data +public class MetadataSchemaVersionFixture { + private String version; + private String name; + private String description = ""; + private String definition; + private String definitionFile; + private MetadataSchemaType type = MetadataSchemaType.CUSTOM; + private String origin; + private String importedFrom; + private MetadataSchemaState state = MetadataSchemaState.LATEST; + private Boolean published = false; + private Boolean abstractSchema = false; + private String suggestedResourceName; + private String suggestedUrlPrefix; + private List extendsSchemaUuids = new ArrayList<>(); +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/RecordFixture.java b/src/main/java/org/fairdatapoint/service/boostrap/fixtures/RecordFixture.java new file mode 100644 index 000000000..4fd314ea6 --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/fixtures/RecordFixture.java @@ -0,0 +1,32 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.fixtures; + +import lombok.Data; + +@Data +public class RecordFixture { + private final String filename; + private final String repository; + private final String uri; +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/RecordsFixture.java b/src/main/java/org/fairdatapoint/service/boostrap/fixtures/RecordsFixture.java new file mode 100644 index 000000000..36aabe0f3 --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/fixtures/RecordsFixture.java @@ -0,0 +1,34 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.fixtures; + +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class RecordsFixture { + private List records = new ArrayList<>(); + private String persistentUrlVar = "{{ persistentUrl }}"; +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/ResourceDefinitionFixture.java b/src/main/java/org/fairdatapoint/service/boostrap/fixtures/ResourceDefinitionFixture.java new file mode 100644 index 000000000..96db8d342 --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/fixtures/ResourceDefinitionFixture.java @@ -0,0 +1,41 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.fixtures; + +import lombok.Data; +import org.fairdatapoint.api.dto.resource.ResourceDefinitionChildDTO; +import org.fairdatapoint.api.dto.resource.ResourceDefinitionLinkDTO; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +@Data +public class ResourceDefinitionFixture { + private UUID uuid = UUID.randomUUID(); + private String name; + private String urlPrefix; + private List children = new ArrayList<>(); + private List externalLinks = new ArrayList<>(); + private List metadataSchemaUuids = new ArrayList<>(); +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/SearchSavedQueryFixture.java b/src/main/java/org/fairdatapoint/service/boostrap/fixtures/SearchSavedQueryFixture.java new file mode 100644 index 000000000..d9d4f0ce5 --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/fixtures/SearchSavedQueryFixture.java @@ -0,0 +1,36 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.fixtures; + +import lombok.Data; +import org.fairdatapoint.entity.search.SearchSavedQueryType; + +@Data +public class SearchSavedQueryFixture { + private String name; + private String description; + private SearchSavedQueryType type; + private String prefixes; + private String graphPattern; + private String ordering; +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/SettingsFixture.java b/src/main/java/org/fairdatapoint/service/boostrap/fixtures/SettingsFixture.java new file mode 100644 index 000000000..45068b68a --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/fixtures/SettingsFixture.java @@ -0,0 +1,43 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.fixtures; + +import lombok.Data; +import org.fairdatapoint.api.dto.search.SearchFilterDTO; +import org.fairdatapoint.api.dto.settings.SettingsAutocompleteSourceDTO; +import org.fairdatapoint.api.dto.settings.SettingsMetricDTO; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class SettingsFixture { + private String appTitle = "FAIR Data Point"; + private String appSubtitle = "Metadata for Machines"; + private Boolean pingEnabled = true; + private List pingEndpoints = new ArrayList<>(); + private Boolean autocompleteSearchNamespace = true; + private List autocompleteSources = new ArrayList<>(); + private List metrics = new ArrayList<>(); + private List searchFilters = new ArrayList<>(); +} diff --git a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/UserFixture.java b/src/main/java/org/fairdatapoint/service/boostrap/fixtures/UserFixture.java new file mode 100644 index 000000000..5f32f4239 --- /dev/null +++ b/src/main/java/org/fairdatapoint/service/boostrap/fixtures/UserFixture.java @@ -0,0 +1,42 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.service.boostrap.fixtures; + +import lombok.Data; +import org.fairdatapoint.entity.user.UserRole; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +@Data +public class UserFixture { + private UUID uuid = UUID.randomUUID(); + private String firstName = ""; + private String lastName = ""; + private String email; + private String password; + private UserRole role = UserRole.USER; + private List apiKeyTokens = new ArrayList<>(); + private List savedQueries = new ArrayList<>(); +} diff --git a/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java b/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java index e431b4f41..aadaa3bcb 100644 --- a/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java +++ b/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java @@ -26,8 +26,10 @@ import org.fairdatapoint.api.dto.membership.MembershipPermissionDTO; import org.fairdatapoint.entity.membership.Membership; import org.fairdatapoint.entity.membership.MembershipPermission; +import org.fairdatapoint.service.boostrap.fixtures.MembershipFixture; import org.springframework.stereotype.Service; +import java.util.UUID; import java.util.stream.Collectors; @Service @@ -48,5 +50,19 @@ public MembershipPermissionDTO toPermissionDTO(MembershipPermission permission) return new MembershipPermissionDTO(permission.getMask(), permission.getCode()); } + public MembershipPermission permissionFromDTO(Membership membership, MembershipPermissionDTO permission) { + return MembershipPermission.builder() + .membership(membership) + .code(permission.getCode()) + .mask(permission.getMask()) + .build(); + } + + public Membership fromFixture(MembershipFixture membershipFixture) { + return Membership.builder() + .name(membershipFixture.getName()) + .allowedEntities(membershipFixture.getAllowedEntities().stream().map(UUID::toString).toList()) + .build(); + } } diff --git a/src/main/java/org/fairdatapoint/service/resource/ResourceDefinitionMapper.java b/src/main/java/org/fairdatapoint/service/resource/ResourceDefinitionMapper.java index 9bd1147d7..2d15eb129 100644 --- a/src/main/java/org/fairdatapoint/service/resource/ResourceDefinitionMapper.java +++ b/src/main/java/org/fairdatapoint/service/resource/ResourceDefinitionMapper.java @@ -25,6 +25,7 @@ import org.fairdatapoint.api.dto.resource.*; import org.fairdatapoint.entity.resource.*; import org.fairdatapoint.entity.schema.MetadataSchema; +import org.fairdatapoint.service.boostrap.fixtures.ResourceDefinitionFixture; import org.springframework.stereotype.Service; import java.time.Instant; @@ -168,4 +169,14 @@ public ResourceDefinitionChildMetadata toChildMetadata( .updatedAt(child.getUpdatedAt()) .build(); } + + public ResourceDefinition fromResourceDefinitionFixture(ResourceDefinitionFixture resourceDefinitionFixture) { + return ResourceDefinition.builder() + .uuid(null) + .name(resourceDefinitionFixture.getName()) + .urlPrefix(resourceDefinitionFixture.getUrlPrefix()) + .createdAt(Instant.now()) + .updatedAt(Instant.now()) + .build(); + } } diff --git a/src/main/java/org/fairdatapoint/service/schema/MetadataSchemaMapper.java b/src/main/java/org/fairdatapoint/service/schema/MetadataSchemaMapper.java index 2cb816d33..0f82bce77 100644 --- a/src/main/java/org/fairdatapoint/service/schema/MetadataSchemaMapper.java +++ b/src/main/java/org/fairdatapoint/service/schema/MetadataSchemaMapper.java @@ -24,6 +24,7 @@ import org.fairdatapoint.api.dto.schema.*; import org.fairdatapoint.entity.schema.*; +import org.fairdatapoint.service.boostrap.fixtures.MetadataSchemaVersionFixture; import org.springframework.stereotype.Service; import java.time.Instant; @@ -314,4 +315,24 @@ public MetadataSchemaExtension newExtension( .orderPriority(orderPriority) .build(); } + + public MetadataSchemaVersion fromMetadataSchemaVersionFixture(MetadataSchemaVersionFixture versionFixture, + MetadataSchema metadataSchema) { + final List targetClasses = + MetadataSchemaShaclUtils.extractTargetClasses(versionFixture.getDefinition()).stream().toList(); + return MetadataSchemaVersion.builder() + .uuid(UUID.randomUUID()) + .name(versionFixture.getName()) + .description(versionFixture.getDescription()) + .abstractSchema(versionFixture.getAbstractSchema()) + .type(MetadataSchemaType.CUSTOM) + .state(MetadataSchemaState.LATEST) + .version(versionFixture.getVersion()) + .definition(versionFixture.getDefinition()) + .targetClasses(targetClasses) + .suggestedResourceName(versionFixture.getSuggestedResourceName()) + .suggestedUrlPrefix(versionFixture.getSuggestedUrlPrefix()) + .schema(metadataSchema) + .build(); + } } diff --git a/src/main/java/org/fairdatapoint/service/search/query/SearchSavedQueryMapper.java b/src/main/java/org/fairdatapoint/service/search/query/SearchSavedQueryMapper.java index a88277f9d..bd4835a06 100644 --- a/src/main/java/org/fairdatapoint/service/search/query/SearchSavedQueryMapper.java +++ b/src/main/java/org/fairdatapoint/service/search/query/SearchSavedQueryMapper.java @@ -28,6 +28,7 @@ import org.fairdatapoint.api.dto.search.SearchSavedQueryDTO; import org.fairdatapoint.entity.search.SearchSavedQuery; import org.fairdatapoint.entity.user.UserAccount; +import org.fairdatapoint.service.boostrap.fixtures.SearchSavedQueryFixture; import org.fairdatapoint.service.user.UserMapper; import org.springframework.stereotype.Component; @@ -101,4 +102,19 @@ public SearchQueryVariablesDTO toVariablesDTO( .ordering(query.getVarOrdering()) .build(); } + + public SearchSavedQuery fromFixture(SearchSavedQueryFixture fixture, UserAccount userAccount) { + return SearchSavedQuery.builder() + .uuid(null) + .name(fixture.getName()) + .description(fixture.getDescription()) + .type(fixture.getType()) + .varPrefixes(fixture.getPrefixes()) + .varGraphPattern(fixture.getGraphPattern()) + .varOrdering(fixture.getOrdering()) + .userAccount(userAccount) + .createdAt(Instant.now()) + .updatedAt(Instant.now()) + .build(); + } } diff --git a/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java b/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java index 147e33d1a..4f99b57a6 100644 --- a/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java +++ b/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java @@ -31,6 +31,7 @@ import org.fairdatapoint.config.properties.RepositoryConnectionProperties; import org.fairdatapoint.config.properties.RepositoryProperties; import org.fairdatapoint.entity.settings.*; +import org.fairdatapoint.service.boostrap.fixtures.*; import org.springframework.stereotype.Component; import java.time.Instant; @@ -191,7 +192,7 @@ public SettingsSearchFilter fromSearchFilterDTO( return filter; } - private SettingsSearchFilterItem fromSearchFilterItemDTO( + public SettingsSearchFilterItem fromSearchFilterItemDTO( SearchFilterItemDTO dto, int orderPriority, SettingsSearchFilter filter ) { return SettingsSearchFilterItem.builder() @@ -201,4 +202,16 @@ private SettingsSearchFilterItem fromSearchFilterItemDTO( .filter(filter) .build(); } + + public Settings fromSettingsFixture(SettingsFixture settingsFixture) { + return Settings.builder() + .appTitle(settingsFixture.getAppTitle()) + .appSubtitle(settingsFixture.getAppSubtitle()) + .pingEnabled(settingsFixture.getPingEnabled()) + .pingEndpoints(settingsFixture.getPingEndpoints()) + .autocompleteSearchNamespace(settingsFixture.getAutocompleteSearchNamespace()) + .createdAt(Instant.now()) + .updatedAt(Instant.now()) + .build(); + } } diff --git a/src/main/java/org/fairdatapoint/service/user/UserMapper.java b/src/main/java/org/fairdatapoint/service/user/UserMapper.java index 8d5e78404..5d9b8f04d 100644 --- a/src/main/java/org/fairdatapoint/service/user/UserMapper.java +++ b/src/main/java/org/fairdatapoint/service/user/UserMapper.java @@ -25,6 +25,7 @@ import lombok.RequiredArgsConstructor; import org.fairdatapoint.api.dto.user.*; import org.fairdatapoint.entity.user.UserAccount; +import org.fairdatapoint.service.boostrap.fixtures.UserFixture; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Component; @@ -64,6 +65,17 @@ public UserAccount fromCreateDTO(UserCreateDTO dto) { .build(); } + public UserAccount fromFixture(UserFixture fixture) { + return UserAccount.builder() + .uuid(null) + .firstName(fixture.getFirstName()) + .lastName(fixture.getLastName()) + .email(fixture.getEmail()) + .passwordHash(passwordEncoder.encode(fixture.getPassword())) + .role(fixture.getRole()) + .build(); + } + public UserAccount fromChangeDTO(UserChangeDTO dto, UserAccount user) { return user diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 91f3a6246..32b61c873 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -111,3 +111,7 @@ springdoc: server: forward-headers-strategy: framework + +bootstrap: + enabled: true + data-path: '/data' From 63911763105e5bb037726935ed818df6efa36a01 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Tue, 23 Sep 2025 13:43:22 +0200 Subject: [PATCH 02/53] rename package boostrap to bootstrap --- .../service/{boostrap => bootstrap}/BootstrapContext.java | 2 +- .../service/{boostrap => bootstrap}/BootstrapRunner.java | 2 +- .../service/{boostrap => bootstrap}/BootstrapService.java | 4 ++-- .../components/AbstractBootstrapper.java | 4 ++-- .../{boostrap => bootstrap}/components/IBootstrapper.java | 4 ++-- .../components/MembershipBootstrapper.java | 6 +++--- .../components/MetadataRecordsBootstrapper.java | 6 +++--- .../components/MetadataSchemaBootstrapper.java | 6 +++--- .../components/MetadataSchemaVersionsBootstrapper.java | 8 ++++---- .../components/ResourceDefinitionBootstrapper.java | 6 +++--- .../ResourceDefinitionChildrenBootstrapper.java | 6 +++--- .../components/SettingsBootstrapper.java | 6 +++--- .../components/UserBootstrapper.java | 8 ++++---- .../fixtures/MembershipFixture.java | 2 +- .../fixtures/MetadataSchemaFixture.java | 2 +- .../fixtures/MetadataSchemaVersionFixture.java | 2 +- .../{boostrap => bootstrap}/fixtures/RecordFixture.java | 2 +- .../{boostrap => bootstrap}/fixtures/RecordsFixture.java | 2 +- .../fixtures/ResourceDefinitionFixture.java | 2 +- .../fixtures/SearchSavedQueryFixture.java | 2 +- .../{boostrap => bootstrap}/fixtures/SettingsFixture.java | 2 +- .../{boostrap => bootstrap}/fixtures/UserFixture.java | 2 +- .../service/membership/MembershipMapper.java | 2 +- .../service/resource/ResourceDefinitionMapper.java | 2 +- .../service/schema/MetadataSchemaMapper.java | 2 +- .../service/search/query/SearchSavedQueryMapper.java | 2 +- .../fairdatapoint/service/settings/SettingsMapper.java | 2 +- .../java/org/fairdatapoint/service/user/UserMapper.java | 2 +- 28 files changed, 49 insertions(+), 49 deletions(-) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/BootstrapContext.java (97%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/BootstrapRunner.java (97%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/BootstrapService.java (97%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/components/AbstractBootstrapper.java (95%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/components/IBootstrapper.java (92%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/components/MembershipBootstrapper.java (94%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/components/MetadataRecordsBootstrapper.java (96%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/components/MetadataSchemaBootstrapper.java (95%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/components/MetadataSchemaVersionsBootstrapper.java (95%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/components/ResourceDefinitionBootstrapper.java (96%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/components/ResourceDefinitionChildrenBootstrapper.java (96%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/components/SettingsBootstrapper.java (96%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/components/UserBootstrapper.java (94%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/fixtures/MembershipFixture.java (96%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/fixtures/MetadataSchemaFixture.java (96%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/fixtures/MetadataSchemaVersionFixture.java (97%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/fixtures/RecordFixture.java (96%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/fixtures/RecordsFixture.java (96%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/fixtures/ResourceDefinitionFixture.java (96%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/fixtures/SearchSavedQueryFixture.java (96%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/fixtures/SettingsFixture.java (97%) rename src/main/java/org/fairdatapoint/service/{boostrap => bootstrap}/fixtures/UserFixture.java (96%) diff --git a/src/main/java/org/fairdatapoint/service/boostrap/BootstrapContext.java b/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapContext.java similarity index 97% rename from src/main/java/org/fairdatapoint/service/boostrap/BootstrapContext.java rename to src/main/java/org/fairdatapoint/service/bootstrap/BootstrapContext.java index e3c9a0f03..b3a699399 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/BootstrapContext.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapContext.java @@ -20,7 +20,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap; +package org.fairdatapoint.service.bootstrap; import lombok.Data; import org.fairdatapoint.entity.resource.ResourceDefinition; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/BootstrapRunner.java b/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapRunner.java similarity index 97% rename from src/main/java/org/fairdatapoint/service/boostrap/BootstrapRunner.java rename to src/main/java/org/fairdatapoint/service/bootstrap/BootstrapRunner.java index 9a0901c41..b269e6239 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/BootstrapRunner.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapRunner.java @@ -20,7 +20,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap; +package org.fairdatapoint.service.bootstrap; import lombok.RequiredArgsConstructor; import org.fairdatapoint.config.properties.BootstrapProperties; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/BootstrapService.java b/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapService.java similarity index 97% rename from src/main/java/org/fairdatapoint/service/boostrap/BootstrapService.java rename to src/main/java/org/fairdatapoint/service/bootstrap/BootstrapService.java index c631a32af..90fefa785 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/BootstrapService.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapService.java @@ -20,12 +20,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap; +package org.fairdatapoint.service.bootstrap; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.fairdatapoint.service.boostrap.components.*; +import org.fairdatapoint.service.bootstrap.components.*; import org.springframework.stereotype.Service; import java.nio.file.Path; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/AbstractBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/AbstractBootstrapper.java similarity index 95% rename from src/main/java/org/fairdatapoint/service/boostrap/components/AbstractBootstrapper.java rename to src/main/java/org/fairdatapoint/service/bootstrap/components/AbstractBootstrapper.java index f44279706..2c7f56a81 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/components/AbstractBootstrapper.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/components/AbstractBootstrapper.java @@ -20,11 +20,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.components; +package org.fairdatapoint.service.bootstrap.components; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; -import org.fairdatapoint.service.boostrap.BootstrapContext; +import org.fairdatapoint.service.bootstrap.BootstrapContext; import org.springframework.data.jpa.repository.JpaRepository; import java.io.IOException; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/IBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/IBootstrapper.java similarity index 92% rename from src/main/java/org/fairdatapoint/service/boostrap/components/IBootstrapper.java rename to src/main/java/org/fairdatapoint/service/bootstrap/components/IBootstrapper.java index 861953035..bfaf1bb15 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/components/IBootstrapper.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/components/IBootstrapper.java @@ -20,9 +20,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.components; +package org.fairdatapoint.service.bootstrap.components; -import org.fairdatapoint.service.boostrap.BootstrapContext; +import org.fairdatapoint.service.bootstrap.BootstrapContext; import java.nio.file.Path; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/MembershipBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/MembershipBootstrapper.java similarity index 94% rename from src/main/java/org/fairdatapoint/service/boostrap/components/MembershipBootstrapper.java rename to src/main/java/org/fairdatapoint/service/bootstrap/components/MembershipBootstrapper.java index b782b2e5b..f7ab06914 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/components/MembershipBootstrapper.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/components/MembershipBootstrapper.java @@ -20,15 +20,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.components; +package org.fairdatapoint.service.bootstrap.components; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; import org.fairdatapoint.database.db.repository.MembershipPermissionRepository; import org.fairdatapoint.database.db.repository.MembershipRepository; import org.fairdatapoint.entity.membership.Membership; -import org.fairdatapoint.service.boostrap.BootstrapContext; -import org.fairdatapoint.service.boostrap.fixtures.MembershipFixture; +import org.fairdatapoint.service.bootstrap.BootstrapContext; +import org.fairdatapoint.service.bootstrap.fixtures.MembershipFixture; import org.fairdatapoint.service.membership.MembershipMapper; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Component; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/MetadataRecordsBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataRecordsBootstrapper.java similarity index 96% rename from src/main/java/org/fairdatapoint/service/boostrap/components/MetadataRecordsBootstrapper.java rename to src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataRecordsBootstrapper.java index ae585808e..23e274ea0 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/components/MetadataRecordsBootstrapper.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataRecordsBootstrapper.java @@ -20,7 +20,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.components; +package org.fairdatapoint.service.bootstrap.components; import lombok.extern.slf4j.Slf4j; import org.eclipse.rdf4j.model.Model; @@ -29,8 +29,8 @@ import org.eclipse.rdf4j.rio.Rio; import org.fairdatapoint.database.rdf.repository.RepositoryMode; import org.fairdatapoint.database.rdf.repository.generic.GenericMetadataRepository; -import org.fairdatapoint.service.boostrap.BootstrapContext; -import org.fairdatapoint.service.boostrap.fixtures.RecordsFixture; +import org.fairdatapoint.service.bootstrap.BootstrapContext; +import org.fairdatapoint.service.bootstrap.fixtures.RecordsFixture; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Component; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/MetadataSchemaBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataSchemaBootstrapper.java similarity index 95% rename from src/main/java/org/fairdatapoint/service/boostrap/components/MetadataSchemaBootstrapper.java rename to src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataSchemaBootstrapper.java index a460eea4d..005509102 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/components/MetadataSchemaBootstrapper.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataSchemaBootstrapper.java @@ -20,7 +20,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.components; +package org.fairdatapoint.service.bootstrap.components; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; @@ -28,8 +28,8 @@ import org.fairdatapoint.database.db.repository.MetadataSchemaRepository; import org.fairdatapoint.database.db.repository.MetadataSchemaVersionRepository; import org.fairdatapoint.entity.schema.MetadataSchema; -import org.fairdatapoint.service.boostrap.BootstrapContext; -import org.fairdatapoint.service.boostrap.fixtures.MetadataSchemaFixture; +import org.fairdatapoint.service.bootstrap.BootstrapContext; +import org.fairdatapoint.service.bootstrap.fixtures.MetadataSchemaFixture; import org.fairdatapoint.service.schema.MetadataSchemaMapper; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Component; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/MetadataSchemaVersionsBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataSchemaVersionsBootstrapper.java similarity index 95% rename from src/main/java/org/fairdatapoint/service/boostrap/components/MetadataSchemaVersionsBootstrapper.java rename to src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataSchemaVersionsBootstrapper.java index 42540850f..ac5f7ee8f 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/components/MetadataSchemaVersionsBootstrapper.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataSchemaVersionsBootstrapper.java @@ -20,7 +20,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.components; +package org.fairdatapoint.service.bootstrap.components; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; @@ -28,9 +28,9 @@ import org.fairdatapoint.database.db.repository.MetadataSchemaVersionRepository; import org.fairdatapoint.entity.schema.MetadataSchema; import org.fairdatapoint.entity.schema.MetadataSchemaVersion; -import org.fairdatapoint.service.boostrap.BootstrapContext; -import org.fairdatapoint.service.boostrap.fixtures.MetadataSchemaFixture; -import org.fairdatapoint.service.boostrap.fixtures.MetadataSchemaVersionFixture; +import org.fairdatapoint.service.bootstrap.BootstrapContext; +import org.fairdatapoint.service.bootstrap.fixtures.MetadataSchemaFixture; +import org.fairdatapoint.service.bootstrap.fixtures.MetadataSchemaVersionFixture; import org.fairdatapoint.service.schema.MetadataSchemaMapper; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Component; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/ResourceDefinitionBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/ResourceDefinitionBootstrapper.java similarity index 96% rename from src/main/java/org/fairdatapoint/service/boostrap/components/ResourceDefinitionBootstrapper.java rename to src/main/java/org/fairdatapoint/service/bootstrap/components/ResourceDefinitionBootstrapper.java index 14834facf..35db8dd72 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/components/ResourceDefinitionBootstrapper.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/components/ResourceDefinitionBootstrapper.java @@ -20,14 +20,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.components; +package org.fairdatapoint.service.bootstrap.components; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; import org.fairdatapoint.database.db.repository.*; import org.fairdatapoint.entity.resource.ResourceDefinition; -import org.fairdatapoint.service.boostrap.BootstrapContext; -import org.fairdatapoint.service.boostrap.fixtures.ResourceDefinitionFixture; +import org.fairdatapoint.service.bootstrap.BootstrapContext; +import org.fairdatapoint.service.bootstrap.fixtures.ResourceDefinitionFixture; import org.fairdatapoint.service.resource.ResourceDefinitionMapper; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Component; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/ResourceDefinitionChildrenBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/ResourceDefinitionChildrenBootstrapper.java similarity index 96% rename from src/main/java/org/fairdatapoint/service/boostrap/components/ResourceDefinitionChildrenBootstrapper.java rename to src/main/java/org/fairdatapoint/service/bootstrap/components/ResourceDefinitionChildrenBootstrapper.java index 8e3a409a5..8ef890119 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/components/ResourceDefinitionChildrenBootstrapper.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/components/ResourceDefinitionChildrenBootstrapper.java @@ -20,7 +20,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.components; +package org.fairdatapoint.service.bootstrap.components; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; @@ -28,8 +28,8 @@ import org.fairdatapoint.database.db.repository.*; import org.fairdatapoint.entity.resource.ResourceDefinition; import org.fairdatapoint.entity.resource.ResourceDefinitionChild; -import org.fairdatapoint.service.boostrap.BootstrapContext; -import org.fairdatapoint.service.boostrap.fixtures.ResourceDefinitionFixture; +import org.fairdatapoint.service.bootstrap.BootstrapContext; +import org.fairdatapoint.service.bootstrap.fixtures.ResourceDefinitionFixture; import org.fairdatapoint.service.resource.ResourceDefinitionMapper; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Component; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/SettingsBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/SettingsBootstrapper.java similarity index 96% rename from src/main/java/org/fairdatapoint/service/boostrap/components/SettingsBootstrapper.java rename to src/main/java/org/fairdatapoint/service/bootstrap/components/SettingsBootstrapper.java index a2e87dc7f..f95c440ba 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/components/SettingsBootstrapper.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/components/SettingsBootstrapper.java @@ -20,15 +20,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.components; +package org.fairdatapoint.service.bootstrap.components; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; import org.fairdatapoint.database.db.repository.*; import org.fairdatapoint.entity.settings.Settings; import org.fairdatapoint.entity.settings.SettingsSearchFilter; -import org.fairdatapoint.service.boostrap.BootstrapContext; -import org.fairdatapoint.service.boostrap.fixtures.SettingsFixture; +import org.fairdatapoint.service.bootstrap.BootstrapContext; +import org.fairdatapoint.service.bootstrap.fixtures.SettingsFixture; import org.fairdatapoint.service.settings.SettingsMapper; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Component; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/components/UserBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/UserBootstrapper.java similarity index 94% rename from src/main/java/org/fairdatapoint/service/boostrap/components/UserBootstrapper.java rename to src/main/java/org/fairdatapoint/service/bootstrap/components/UserBootstrapper.java index 1554622ef..8ba62a754 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/components/UserBootstrapper.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/components/UserBootstrapper.java @@ -20,7 +20,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.components; +package org.fairdatapoint.service.bootstrap.components; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; @@ -31,9 +31,9 @@ import org.fairdatapoint.entity.search.SearchSavedQuery; import org.fairdatapoint.entity.user.UserAccount; import org.fairdatapoint.service.apikey.ApiKeyMapper; -import org.fairdatapoint.service.boostrap.BootstrapContext; -import org.fairdatapoint.service.boostrap.fixtures.SearchSavedQueryFixture; -import org.fairdatapoint.service.boostrap.fixtures.UserFixture; +import org.fairdatapoint.service.bootstrap.BootstrapContext; +import org.fairdatapoint.service.bootstrap.fixtures.SearchSavedQueryFixture; +import org.fairdatapoint.service.bootstrap.fixtures.UserFixture; import org.fairdatapoint.service.search.query.SearchSavedQueryMapper; import org.fairdatapoint.service.user.UserMapper; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/MembershipFixture.java b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MembershipFixture.java similarity index 96% rename from src/main/java/org/fairdatapoint/service/boostrap/fixtures/MembershipFixture.java rename to src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MembershipFixture.java index 9b754c26a..acfd6aec9 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/MembershipFixture.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MembershipFixture.java @@ -20,7 +20,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.fixtures; +package org.fairdatapoint.service.bootstrap.fixtures; import lombok.Data; import org.fairdatapoint.api.dto.membership.MembershipPermissionDTO; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/MetadataSchemaFixture.java b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MetadataSchemaFixture.java similarity index 96% rename from src/main/java/org/fairdatapoint/service/boostrap/fixtures/MetadataSchemaFixture.java rename to src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MetadataSchemaFixture.java index 5a04d6623..f661843ff 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/MetadataSchemaFixture.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MetadataSchemaFixture.java @@ -20,7 +20,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.fixtures; +package org.fairdatapoint.service.bootstrap.fixtures; import lombok.Data; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/MetadataSchemaVersionFixture.java b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MetadataSchemaVersionFixture.java similarity index 97% rename from src/main/java/org/fairdatapoint/service/boostrap/fixtures/MetadataSchemaVersionFixture.java rename to src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MetadataSchemaVersionFixture.java index 40444348b..63f71faec 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/MetadataSchemaVersionFixture.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MetadataSchemaVersionFixture.java @@ -20,7 +20,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.fixtures; +package org.fairdatapoint.service.bootstrap.fixtures; import lombok.Data; import org.fairdatapoint.entity.schema.MetadataSchemaState; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/RecordFixture.java b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/RecordFixture.java similarity index 96% rename from src/main/java/org/fairdatapoint/service/boostrap/fixtures/RecordFixture.java rename to src/main/java/org/fairdatapoint/service/bootstrap/fixtures/RecordFixture.java index 4fd314ea6..6100b7e9b 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/RecordFixture.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/RecordFixture.java @@ -20,7 +20,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.fixtures; +package org.fairdatapoint.service.bootstrap.fixtures; import lombok.Data; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/RecordsFixture.java b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/RecordsFixture.java similarity index 96% rename from src/main/java/org/fairdatapoint/service/boostrap/fixtures/RecordsFixture.java rename to src/main/java/org/fairdatapoint/service/bootstrap/fixtures/RecordsFixture.java index 36aabe0f3..240f13d8b 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/RecordsFixture.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/RecordsFixture.java @@ -20,7 +20,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.fixtures; +package org.fairdatapoint.service.bootstrap.fixtures; import lombok.Data; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/ResourceDefinitionFixture.java b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/ResourceDefinitionFixture.java similarity index 96% rename from src/main/java/org/fairdatapoint/service/boostrap/fixtures/ResourceDefinitionFixture.java rename to src/main/java/org/fairdatapoint/service/bootstrap/fixtures/ResourceDefinitionFixture.java index 96db8d342..58a2b197b 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/ResourceDefinitionFixture.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/ResourceDefinitionFixture.java @@ -20,7 +20,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.fixtures; +package org.fairdatapoint.service.bootstrap.fixtures; import lombok.Data; import org.fairdatapoint.api.dto.resource.ResourceDefinitionChildDTO; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/SearchSavedQueryFixture.java b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/SearchSavedQueryFixture.java similarity index 96% rename from src/main/java/org/fairdatapoint/service/boostrap/fixtures/SearchSavedQueryFixture.java rename to src/main/java/org/fairdatapoint/service/bootstrap/fixtures/SearchSavedQueryFixture.java index d9d4f0ce5..f85dfdf8a 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/SearchSavedQueryFixture.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/SearchSavedQueryFixture.java @@ -20,7 +20,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.fixtures; +package org.fairdatapoint.service.bootstrap.fixtures; import lombok.Data; import org.fairdatapoint.entity.search.SearchSavedQueryType; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/SettingsFixture.java b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/SettingsFixture.java similarity index 97% rename from src/main/java/org/fairdatapoint/service/boostrap/fixtures/SettingsFixture.java rename to src/main/java/org/fairdatapoint/service/bootstrap/fixtures/SettingsFixture.java index 45068b68a..826095f66 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/SettingsFixture.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/SettingsFixture.java @@ -20,7 +20,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.fixtures; +package org.fairdatapoint.service.bootstrap.fixtures; import lombok.Data; import org.fairdatapoint.api.dto.search.SearchFilterDTO; diff --git a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/UserFixture.java b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/UserFixture.java similarity index 96% rename from src/main/java/org/fairdatapoint/service/boostrap/fixtures/UserFixture.java rename to src/main/java/org/fairdatapoint/service/bootstrap/fixtures/UserFixture.java index 5f32f4239..04dc440ad 100644 --- a/src/main/java/org/fairdatapoint/service/boostrap/fixtures/UserFixture.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/UserFixture.java @@ -20,7 +20,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.fairdatapoint.service.boostrap.fixtures; +package org.fairdatapoint.service.bootstrap.fixtures; import lombok.Data; import org.fairdatapoint.entity.user.UserRole; diff --git a/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java b/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java index aadaa3bcb..e45fe0417 100644 --- a/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java +++ b/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java @@ -26,7 +26,7 @@ import org.fairdatapoint.api.dto.membership.MembershipPermissionDTO; import org.fairdatapoint.entity.membership.Membership; import org.fairdatapoint.entity.membership.MembershipPermission; -import org.fairdatapoint.service.boostrap.fixtures.MembershipFixture; +import org.fairdatapoint.service.bootstrap.fixtures.MembershipFixture; import org.springframework.stereotype.Service; import java.util.UUID; diff --git a/src/main/java/org/fairdatapoint/service/resource/ResourceDefinitionMapper.java b/src/main/java/org/fairdatapoint/service/resource/ResourceDefinitionMapper.java index 2d15eb129..afad49f83 100644 --- a/src/main/java/org/fairdatapoint/service/resource/ResourceDefinitionMapper.java +++ b/src/main/java/org/fairdatapoint/service/resource/ResourceDefinitionMapper.java @@ -25,7 +25,7 @@ import org.fairdatapoint.api.dto.resource.*; import org.fairdatapoint.entity.resource.*; import org.fairdatapoint.entity.schema.MetadataSchema; -import org.fairdatapoint.service.boostrap.fixtures.ResourceDefinitionFixture; +import org.fairdatapoint.service.bootstrap.fixtures.ResourceDefinitionFixture; import org.springframework.stereotype.Service; import java.time.Instant; diff --git a/src/main/java/org/fairdatapoint/service/schema/MetadataSchemaMapper.java b/src/main/java/org/fairdatapoint/service/schema/MetadataSchemaMapper.java index 0f82bce77..759602314 100644 --- a/src/main/java/org/fairdatapoint/service/schema/MetadataSchemaMapper.java +++ b/src/main/java/org/fairdatapoint/service/schema/MetadataSchemaMapper.java @@ -24,7 +24,7 @@ import org.fairdatapoint.api.dto.schema.*; import org.fairdatapoint.entity.schema.*; -import org.fairdatapoint.service.boostrap.fixtures.MetadataSchemaVersionFixture; +import org.fairdatapoint.service.bootstrap.fixtures.MetadataSchemaVersionFixture; import org.springframework.stereotype.Service; import java.time.Instant; diff --git a/src/main/java/org/fairdatapoint/service/search/query/SearchSavedQueryMapper.java b/src/main/java/org/fairdatapoint/service/search/query/SearchSavedQueryMapper.java index bd4835a06..d92d19d8c 100644 --- a/src/main/java/org/fairdatapoint/service/search/query/SearchSavedQueryMapper.java +++ b/src/main/java/org/fairdatapoint/service/search/query/SearchSavedQueryMapper.java @@ -28,7 +28,7 @@ import org.fairdatapoint.api.dto.search.SearchSavedQueryDTO; import org.fairdatapoint.entity.search.SearchSavedQuery; import org.fairdatapoint.entity.user.UserAccount; -import org.fairdatapoint.service.boostrap.fixtures.SearchSavedQueryFixture; +import org.fairdatapoint.service.bootstrap.fixtures.SearchSavedQueryFixture; import org.fairdatapoint.service.user.UserMapper; import org.springframework.stereotype.Component; diff --git a/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java b/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java index 4f99b57a6..e189c2e9e 100644 --- a/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java +++ b/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java @@ -31,7 +31,7 @@ import org.fairdatapoint.config.properties.RepositoryConnectionProperties; import org.fairdatapoint.config.properties.RepositoryProperties; import org.fairdatapoint.entity.settings.*; -import org.fairdatapoint.service.boostrap.fixtures.*; +import org.fairdatapoint.service.bootstrap.fixtures.*; import org.springframework.stereotype.Component; import java.time.Instant; diff --git a/src/main/java/org/fairdatapoint/service/user/UserMapper.java b/src/main/java/org/fairdatapoint/service/user/UserMapper.java index 5d9b8f04d..e511cec26 100644 --- a/src/main/java/org/fairdatapoint/service/user/UserMapper.java +++ b/src/main/java/org/fairdatapoint/service/user/UserMapper.java @@ -25,7 +25,7 @@ import lombok.RequiredArgsConstructor; import org.fairdatapoint.api.dto.user.*; import org.fairdatapoint.entity.user.UserAccount; -import org.fairdatapoint.service.boostrap.fixtures.UserFixture; +import org.fairdatapoint.service.bootstrap.fixtures.UserFixture; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Component; From b41a40e5a65c82f840a3adf42e94c55eefdbcdc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Such=C3=A1nek?= Date: Wed, 15 Oct 2025 13:00:19 +1000 Subject: [PATCH 03/53] Switch to Spring Data Populators Co-authored-by: dennisvang <29799340+dennisvang@users.noreply.github.com> --- data/_schemas/membership.schema.json | 41 ----- data/_schemas/metadata-schema.schema.json | 94 ------------ data/_schemas/records.schema.json | 39 ----- data/_schemas/resource-definition.schema.json | 119 --------------- data/_schemas/settings.schema.json | 141 ------------------ data/_schemas/user.schema.json | 44 ------ data/membership/data-provider.json | 9 -- data/membership/owner.json | 14 -- data/metadata-schemas/catalog.json | 18 --- data/metadata-schemas/catalog.ttl | 35 ----- data/metadata-schemas/data-service.json | 18 --- data/metadata-schemas/data-service.ttl | 22 --- data/metadata-schemas/dataset.json | 18 --- data/metadata-schemas/dataset.ttl | 51 ------- data/metadata-schemas/distribution.json | 18 --- data/metadata-schemas/distribution.ttl | 58 ------- data/metadata-schemas/fdp.json | 18 --- data/metadata-schemas/fdp.ttl | 39 ----- data/metadata-schemas/metadata-service.json | 18 --- data/metadata-schemas/metadata-service.ttl | 6 - data/metadata-schemas/resource.json | 13 -- data/metadata-schemas/resource.ttl | 73 --------- data/resource-definitions/catalog.json | 20 --- data/resource-definitions/dataset.json | 25 ---- data/resource-definitions/distribution.json | 19 --- data/resource-definitions/repository.json | 20 --- data/settings/settings.json | 16 -- data/users/albert-einstein.json | 19 --- data/users/nikola-tesla.json | 7 - pom.xml | 6 + .../fairdatapoint/config/BootstrapConfig.java | 39 +++++ .../fairdatapoint/entity/base/BaseEntity.java | 2 +- .../entity/base/BaseEntityCustomUUID.java | 79 ---------- .../entity/base/CustomGeneratedUUID.java | 24 +++ .../entity/index/settings/IndexSettings.java | 4 +- .../entity/resource/MetadataSchemaUsage.java | 3 +- .../resource/ResourceDefinitionChild.java | 2 +- .../entity/schema/MetadataSchema.java | 4 +- .../schema/MetadataSchemaExtension.java | 3 +- .../entity/schema/MetadataSchemaVersion.java | 4 +- .../entity/settings/Settings.java | 4 +- .../service/bootstrap/BootstrapContext.java | 39 ----- .../service/bootstrap/BootstrapService.java | 54 +------ .../components/AbstractBootstrapper.java | 5 +- .../bootstrap/components/IBootstrapper.java | 6 +- .../components/MembershipBootstrapper.java | 80 ---------- .../MetadataRecordsBootstrapper.java | 3 +- .../MetadataSchemaBootstrapper.java | 86 ----------- .../MetadataSchemaVersionsBootstrapper.java | 113 -------------- .../ResourceDefinitionBootstrapper.java | 104 ------------- ...esourceDefinitionChildrenBootstrapper.java | 102 ------------- .../components/SettingsBootstrapper.java | 121 --------------- .../components/UserBootstrapper.java | 102 ------------- .../bootstrap/fixtures/MembershipFixture.java | 36 ----- .../fixtures/MetadataSchemaFixture.java | 34 ----- .../MetadataSchemaVersionFixture.java | 49 ------ .../fixtures/ResourceDefinitionFixture.java | 41 ----- .../fixtures/SearchSavedQueryFixture.java | 36 ----- .../bootstrap/fixtures/SettingsFixture.java | 43 ------ .../bootstrap/fixtures/UserFixture.java | 42 ------ .../service/membership/MembershipMapper.java | 8 - .../resource/ResourceDefinitionMapper.java | 11 -- .../service/schema/MetadataSchemaMapper.java | 21 --- .../search/query/SearchSavedQueryMapper.java | 16 -- .../service/settings/SettingsMapper.java | 12 -- .../service/user/UserMapper.java | 12 -- .../util/CustomUuidGenerator.java | 62 ++++++++ .../resources/fixtures/0010_settings.json | 33 ++++ .../fixtures/0100_user-accounts.json | 20 +++ .../resources/fixtures/0110_api-keys.json | 10 ++ .../fixtures/0120_saved-queries.json | 15 ++ .../0200_metadata-schemas_resource.json | 26 ++++ .../0210_metadata-schemas_data-service.json | 40 +++++ ...220_metadata-schemas_metadata-service.json | 41 +++++ .../fixtures/0230_metadata-schemas_fdp.json | 42 ++++++ .../0240_metadata-schemas_catalog.json | 40 +++++ .../0250_metadata-schemas_dataset.json | 40 +++++ .../0260_metadata-schemas_distribution.json | 40 +++++ ...300_resource-definitions_distribution.json | 39 +++++ .../0310_resource-definitions_dataset.json | 43 ++++++ .../0320_resource-definitions_catalog.json | 33 ++++ .../0330_resource-definitions_repository.json | 33 ++++ .../fixtures/0400_memberships_owner.json | 48 ++++++ .../0410_memberships_data-provider.json | 19 +++ 84 files changed, 713 insertions(+), 2293 deletions(-) delete mode 100644 data/_schemas/membership.schema.json delete mode 100644 data/_schemas/metadata-schema.schema.json delete mode 100644 data/_schemas/records.schema.json delete mode 100644 data/_schemas/resource-definition.schema.json delete mode 100644 data/_schemas/settings.schema.json delete mode 100644 data/_schemas/user.schema.json delete mode 100644 data/membership/data-provider.json delete mode 100644 data/membership/owner.json delete mode 100644 data/metadata-schemas/catalog.json delete mode 100644 data/metadata-schemas/catalog.ttl delete mode 100644 data/metadata-schemas/data-service.json delete mode 100644 data/metadata-schemas/data-service.ttl delete mode 100644 data/metadata-schemas/dataset.json delete mode 100644 data/metadata-schemas/dataset.ttl delete mode 100644 data/metadata-schemas/distribution.json delete mode 100644 data/metadata-schemas/distribution.ttl delete mode 100644 data/metadata-schemas/fdp.json delete mode 100644 data/metadata-schemas/fdp.ttl delete mode 100644 data/metadata-schemas/metadata-service.json delete mode 100644 data/metadata-schemas/metadata-service.ttl delete mode 100644 data/metadata-schemas/resource.json delete mode 100644 data/metadata-schemas/resource.ttl delete mode 100644 data/resource-definitions/catalog.json delete mode 100644 data/resource-definitions/dataset.json delete mode 100644 data/resource-definitions/distribution.json delete mode 100644 data/resource-definitions/repository.json delete mode 100644 data/settings/settings.json delete mode 100644 data/users/albert-einstein.json delete mode 100644 data/users/nikola-tesla.json create mode 100644 src/main/java/org/fairdatapoint/config/BootstrapConfig.java delete mode 100644 src/main/java/org/fairdatapoint/entity/base/BaseEntityCustomUUID.java create mode 100644 src/main/java/org/fairdatapoint/entity/base/CustomGeneratedUUID.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/BootstrapContext.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/components/MembershipBootstrapper.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataSchemaBootstrapper.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataSchemaVersionsBootstrapper.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/components/ResourceDefinitionBootstrapper.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/components/ResourceDefinitionChildrenBootstrapper.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/components/SettingsBootstrapper.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/components/UserBootstrapper.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MembershipFixture.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MetadataSchemaFixture.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MetadataSchemaVersionFixture.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/fixtures/ResourceDefinitionFixture.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/fixtures/SearchSavedQueryFixture.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/fixtures/SettingsFixture.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/fixtures/UserFixture.java create mode 100644 src/main/java/org/fairdatapoint/util/CustomUuidGenerator.java create mode 100644 src/main/resources/fixtures/0010_settings.json create mode 100644 src/main/resources/fixtures/0100_user-accounts.json create mode 100644 src/main/resources/fixtures/0110_api-keys.json create mode 100644 src/main/resources/fixtures/0120_saved-queries.json create mode 100644 src/main/resources/fixtures/0200_metadata-schemas_resource.json create mode 100644 src/main/resources/fixtures/0210_metadata-schemas_data-service.json create mode 100644 src/main/resources/fixtures/0220_metadata-schemas_metadata-service.json create mode 100644 src/main/resources/fixtures/0230_metadata-schemas_fdp.json create mode 100644 src/main/resources/fixtures/0240_metadata-schemas_catalog.json create mode 100644 src/main/resources/fixtures/0250_metadata-schemas_dataset.json create mode 100644 src/main/resources/fixtures/0260_metadata-schemas_distribution.json create mode 100644 src/main/resources/fixtures/0300_resource-definitions_distribution.json create mode 100644 src/main/resources/fixtures/0310_resource-definitions_dataset.json create mode 100644 src/main/resources/fixtures/0320_resource-definitions_catalog.json create mode 100644 src/main/resources/fixtures/0330_resource-definitions_repository.json create mode 100644 src/main/resources/fixtures/0400_memberships_owner.json create mode 100644 src/main/resources/fixtures/0410_memberships_data-provider.json diff --git a/data/_schemas/membership.schema.json b/data/_schemas/membership.schema.json deleted file mode 100644 index 5378b8f75..000000000 --- a/data/_schemas/membership.schema.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "title": "Membership", - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "Name of membership" - }, - "allowedEntities": { - "type": "array", - "description": "UUIDs for resource definitions related to this membership", - "items": { - "type": "string", - "format": "uuid" - } - }, - "permissions": { - "type": "array", - "description": "Permissions associated with this membership", - "items": { - "type": "object", - "properties": { - "mask": { - "type": "integer", - "description": "Permission mask value" - }, - "code": { - "type": "string", - "description": "Permission code (character)", - "enum": ["C", "W", "D", "A"] - } - }, - "required": ["mask", "code"], - "additionalProperties": false - } - } - }, - "required": ["name", "allowedEntities", "permissions"], - "additionalProperties": false -} diff --git a/data/_schemas/metadata-schema.schema.json b/data/_schemas/metadata-schema.schema.json deleted file mode 100644 index bde739940..000000000 --- a/data/_schemas/metadata-schema.schema.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "title": "Metadata Schema", - "type": "object", - "properties": { - "uuid": { - "type": "string", - "format": "uuid", - "description": "Unique identifier of the metadata schema" - }, - "versions": { - "type": "array", - "description": "List of schema versions", - "items": { - "type": "object", - "title": "MetadataSchemaVersionFixture", - "properties": { - "version": { - "type": "string", - "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$", - "description": "Semantic version of the schema" - }, - "name": { - "type": "string", - "description": "Human-readable name of the schema" - }, - "description": { - "type": "string", - "default": "", - "description": "Description of the schema" - }, - "definition": { - "type": "string", - "description": "Schema definition content (inline)" - }, - "definitionFile": { - "type": "string", - "description": "Reference to an external definition file" - }, - "type": { - "type": "string", - "enum": ["CUSTOM", "REFERENCE", "INTERNAL"], - "default": "CUSTOM", - "description": "Schema type" - }, - "origin": { - "type": ["string", "null"], - "description": "Original source of the schema" - }, - "importedFrom": { - "type": ["string", "null"], - "description": "Source system from which the schema was imported" - }, - "state": { - "type": "string", - "enum": ["LATEST", "LEGACY", "DRAFT"], - "default": "LATEST", - "description": "Current state of the schema, make sure only one version is LATEST and there is possibly one DRAFT" - }, - "published": { - "type": "boolean", - "default": false, - "description": "Indicates whether the schema is published" - }, - "abstractSchema": { - "type": "boolean", - "default": false, - "description": "Marks schema as abstract (cannot be instantiated)" - }, - "suggestedResourceName": { - "type": ["string", "null"], - "description": "Suggested resource name for entities using this schema" - }, - "suggestedUrlPrefix": { - "type": ["string", "null"], - "description": "Suggested URL prefix for entities using this schema" - }, - "extendsSchemaUuids": { - "type": "array", - "items": { - "type": "string", - "format": "uuid" - }, - "default": [], - "description": "List of UUIDs of extended schemas" - } - }, - "required": ["version", "name"] - } - } - }, - "required": ["uuid", "versions"], - "additionalProperties": false -} diff --git a/data/_schemas/records.schema.json b/data/_schemas/records.schema.json deleted file mode 100644 index 7ba23d533..000000000 --- a/data/_schemas/records.schema.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "title": "Records", - "type": "object", - "properties": { - "records": { - "type": "array", - "description": "RDF Record fixture descriptions", - "items": { - "type": "object", - "properties": { - "file": { - "type": "string", - "description": "Filename (of RDF Turtle file) in data/records/ directory (the file can use the persistentUrlVar value)" - }, - "repository": { - "type": "string", - "description": "Target repository for the RDF data", - "enum": ["main", "drafts"], - "default": "main" - }, - "uri": { - "type": "string", - "description": "URI for the RDF resource, can include replacement variable for persistent URL (you can use the persistentUrlVar value)" - } - }, - "required": ["file", "repository", "uri"], - "additionalProperties": false - } - }, - "persistentUrlVar": { - "type": "string", - "description": "Replacement variable for persistent URL", - "default": "{{ persistentUrl }}" - } - }, - "required": ["records", "persistentUrlVar"], - "additionalProperties": false -} diff --git a/data/_schemas/resource-definition.schema.json b/data/_schemas/resource-definition.schema.json deleted file mode 100644 index a87505cd5..000000000 --- a/data/_schemas/resource-definition.schema.json +++ /dev/null @@ -1,119 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "title": "Resource Definition", - "type": "object", - "properties": { - "uuid": { - "type": "string", - "format": "uuid", - "description": "Unique identifier for the resource definition" - }, - "name": { - "type": "string", - "description": "Name of the resource definition" - }, - "urlPrefix": { - "type": "string", - "description": "URL prefix for the resource definition" - }, - "children": { - "type": "array", - "description": "Child resource definitions", - "items": { - "type": "object", - "properties": { - "resourceDefinitionUuid": { - "type": "string", - "format": "uuid", - "description": "UUID of the child resource definition" - }, - "relationUri": { - "type": "string", - "description": "URI defining the relationship to the child resource", - "format": "uri" - }, - "listView": { - "type": "object", - "properties": { - "title": { - "type": "string", - "description": "Title for the list view of the child resource" - }, - "tagsUri": { - "type": "string", - "description": "URI for tags in the list view", - "format": "uri" - }, - "metadata": { - "type": "array", - "description": "Metadata fields to display in the list view", - "items": { - "type": "object", - "properties": { - "title": { - "type": "string", - "description": "Title of the metadata field" - }, - "propertyUri": { - "type": "string", - "description": "Property URI of the metadata field", - "format": "uri" - } - }, - "required": [ - "title", - "propertyUri" - ], - "additionalProperties": false - } - } - } - }, - "required": [ - "title", - "tagsUri", - "metadata" - ], - "additionalProperties": false - } - }, - "externalLinks": { - "type": "array", - "description": "External links associated with the resource definition", - "items": { - "type": "object", - "properties": { - "title": { - "type": "string", - "description": "Title of the external link" - }, - "propertyUri": { - "type": "string", - "description": "Property URI of the external link", - "format": "uri" - } - }, - "required": [ - "title", - "propertyUri" - ], - "additionalProperties": false - } - }, - "metadataSchemaUuids": { - "type": "array", - "description": "UUIDs for metadata schemas used by this resource definition", - "items": { - "type": "string", - "format": "uuid" - } - } - }, - "required": [ - "name", - "urlPrefix", - "metadataSchemaUuids" - ], - "additionalProperties": false - } -} diff --git a/data/_schemas/settings.schema.json b/data/_schemas/settings.schema.json deleted file mode 100644 index ed98d3afd..000000000 --- a/data/_schemas/settings.schema.json +++ /dev/null @@ -1,141 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "title": "Settings", - "type": "object", - "properties": { - "appTitle": { - "type": "string", - "description": "Title of the application", - "default": "FAIR Data Point" - }, - "appSubtitle": { - "type": "string", - "description": "Subtitle of the application", - "default": "Metadata for Machines" - }, - "pingEnabled": { - "type": "boolean", - "description": "Enable or disable the ping feature" - }, - "pingEndpoints": { - "type": "array", - "description": "List of endpoints to ping", - "items": { - "type": "string", - "format": "uri" - } - }, - "autocompleteSearchNamespace": { - "type": "boolean", - "description": "Enable or disable namespace autocomplete in search", - "default": true - }, - "autocompleteSources": { - "type": "array", - "description": "List of sources for autocomplete", - "items": { - "type": "object", - "properties": { - "rdfType": { - "type": "string", - "description": "RDF type for the autocomplete source" - }, - "sparqlEndpoint": { - "type": "string", - "format": "uri" - }, - "sparqlQuery": { - "type": "string", - "description": "SPARQL query to fetch autocomplete suggestions" - } - }, - "required": ["rdfType", "sparqlEndpoint", "sparqlQuery"], - "additionalProperties": false - } - }, - "metrics": { - "type": "array", - "description": "List of metrics to be collected", - "items": { - "type": "object", - "properties": { - "metricUri": { - "type": "string", - "format": "uri", - "description": "URI of the metric" - }, - "resourceUri": { - "type": "string", - "format": "uri", - "description": "URI of the resource associated with the metric" - } - }, - "required": ["metricUri", "resourceUri"], - "additionalProperties": false - } - }, - "searchFilters": { - "type": "array", - "description": "List of search filters", - "items": { - "type": "object", - "properties": { - "type": { - "type": "string", - "description": "Type of the filter (e.g., 'dropdown', 'checkbox')" - }, - "label": { - "type": "string", - "description": "Label for the filter" - }, - "predicate": { - "type": "string", - "format": "uri", - "description": "Predicate URI for the filter" - }, - "queryFromRecords": { - "type": "boolean", - "description": "Whether to query from records" - }, - "values": { - "type": "array", - "description": "List of values for the filter", - "items": { - "type": "object", - "properties": { - "value": { - "type": "string", - "description": "Value of the filter option" - }, - "label": { - "type": "string", - "description": "Label for the filter option" - }, - "preset": { - "type": "boolean", - "description": "Whether this option is a preset", - "default": true - } - }, - "required": [ - "value", - "label" - ], - "additionalProperties": false - } - } - }, - "required": [ - "type", - "label", - "predicate", - "queryFromRecords", - "values" - ], - "additionalProperties": false - } - } - }, - "required": [], - "additionalProperties": false -} diff --git a/data/_schemas/user.schema.json b/data/_schemas/user.schema.json deleted file mode 100644 index e9f28d4a9..000000000 --- a/data/_schemas/user.schema.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "title": "UserWithApiKeys", - "type": "object", - "properties": { - "uuid": { - "type": "string", - "format": "uuid", - "description": "Unique identifier for the user" - }, - "firstName": { - "type": "string", - "description": "First name of the user" - }, - "lastName": { - "type": "string", - "description": "Last name of the user" - }, - "email": { - "type": "string", - "format": "email", - "description": "Email address of the user" - }, - "password": { - "type": "string", - "description": "Password of the user" - }, - "role": { - "type": "string", - "enum": ["USER", "ADMIN"], - "description": "Role assigned to the user" - }, - "apiKeyTokens": { - "type": "array", - "items": { - "type": "string" - }, - "description": "List of API key tokens for the user", - "default": [] - } - }, - "required": ["email", "password"], - "additionalProperties": false -} diff --git a/data/membership/data-provider.json b/data/membership/data-provider.json deleted file mode 100644 index 243856cf4..000000000 --- a/data/membership/data-provider.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "Data Provider", - "allowedEntities": [ - "a0949e72-4466-4d53-8900-9436d1049a4b" - ], - "permissions": [ - { "mask": 4, "code": "C" } - ] -} \ No newline at end of file diff --git a/data/membership/owner.json b/data/membership/owner.json deleted file mode 100644 index 39059c21d..000000000 --- a/data/membership/owner.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "Owner", - "allowedEntities": [ - "a0949e72-4466-4d53-8900-9436d1049a4b", - "2f08228e-1789-40f8-84cd-28e3288c3604", - "02c649de-c579-43bb-b470-306abdc808c7" - ], - "permissions": [ - { "mask": 4, "code": "C" }, - { "mask": 2, "code": "W" }, - { "mask": 8, "code": "D" }, - { "mask": 16, "code": "A" } - ] -} diff --git a/data/metadata-schemas/catalog.json b/data/metadata-schemas/catalog.json deleted file mode 100644 index 47a9f91e8..000000000 --- a/data/metadata-schemas/catalog.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "uuid": "2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660", - "versions": [ - { - "version": "1.0.0", - "name": "Catalog", - "definitionFile": "catalog.ttl", - "abstractSchema": false, - "type": "INTERNAL", - "state": "LATEST", - "extendsSchemaUuids": [ - "6a668323-3936-4b53-8380-a4fd2ed082ee" - ], - "suggestedResourceName": "Catalog", - "suggestedUrlPrefix": "catalog" - } - ] -} diff --git a/data/metadata-schemas/catalog.ttl b/data/metadata-schemas/catalog.ttl deleted file mode 100644 index d118b7741..000000000 --- a/data/metadata-schemas/catalog.ttl +++ /dev/null @@ -1,35 +0,0 @@ -@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix foaf: . -@prefix sh: . -@prefix xsd: . - -:CatalogShape a sh:NodeShape ; - sh:targetClass dcat:Catalog ; - sh:property [ - sh:path dct:issued ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:viewer dash:LiteralViewer ; - sh:order 20 ; - ], [ - sh:path dct:modified ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:viewer dash:LiteralViewer ; - sh:order 21 ; - ], [ - sh:path foaf:homePage ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 22 ; - ], [ - sh:path dcat:themeTaxonomy ; - sh:nodeKind sh:IRI ; - dash:viewer dash:LabelViewer ; - sh:order 23 ; - ] . diff --git a/data/metadata-schemas/data-service.json b/data/metadata-schemas/data-service.json deleted file mode 100644 index 6dc4ab55b..000000000 --- a/data/metadata-schemas/data-service.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "uuid": "89d94c1b-f6ff-4545-ba9b-120b2d1921d0", - "versions": [ - { - "version": "1.0.0", - "name": "Data Service", - "definitionFile": "data-service.ttl", - "abstractSchema": false, - "type": "INTERNAL", - "state": "LATEST", - "extendsSchemaUuids": [ - "6a668323-3936-4b53-8380-a4fd2ed082ee" - ], - "suggestedResourceName": "Data Service", - "suggestedUrlPrefix": "data-service" - } - ] -} \ No newline at end of file diff --git a/data/metadata-schemas/data-service.ttl b/data/metadata-schemas/data-service.ttl deleted file mode 100644 index e6e7c78f6..000000000 --- a/data/metadata-schemas/data-service.ttl +++ /dev/null @@ -1,22 +0,0 @@ -@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix sh: . -@prefix xsd: . - -:DataServiceShape a sh:NodeShape ; - sh:targetClass dcat:DataService ; - sh:property [ - sh:path dcat:endpointURL ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - sh:order 20 ; - ] , [ - sh:path dcat:endpointDescription ; - sh:nodeKind sh:Literal ; - sh:maxCount 1 ; - dash:editor dash:TextAreaEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 21 ; - ] . diff --git a/data/metadata-schemas/dataset.json b/data/metadata-schemas/dataset.json deleted file mode 100644 index d391a23d7..000000000 --- a/data/metadata-schemas/dataset.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "uuid": "866d7fb8-5982-4215-9c7c-18d0ed1bd5f3", - "versions": [ - { - "version": "1.0.0", - "name": "Dataset", - "definitionFile": "dataset.ttl", - "abstractSchema": false, - "type": "INTERNAL", - "state": "LATEST", - "extendsSchemaUuids": [ - "6a668323-3936-4b53-8380-a4fd2ed082ee" - ], - "suggestedResourceName": "Dataset", - "suggestedUrlPrefix": "dataset" - } - ] -} \ No newline at end of file diff --git a/data/metadata-schemas/dataset.ttl b/data/metadata-schemas/dataset.ttl deleted file mode 100644 index 1d1c6f586..000000000 --- a/data/metadata-schemas/dataset.ttl +++ /dev/null @@ -1,51 +0,0 @@ -@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix sh: . -@prefix xsd: . - -:DatasetShape a sh:NodeShape ; - sh:targetClass dcat:Dataset ; - sh:property [ - sh:path dct:issued ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DateTimePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 20 ; - ], [ - sh:path dct:modified ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DateTimePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 21 ; - ], [ - sh:path dcat:theme ; - sh:nodeKind sh:IRI ; - sh:minCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 22 ; - ], [ - sh:path dcat:contactPoint ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 23 ; - ], [ - sh:path dcat:keyword ; - sh:nodeKind sh:Literal ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 24 ; - ], [ - sh:path dcat:landingPage ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 25 ; - ] . diff --git a/data/metadata-schemas/distribution.json b/data/metadata-schemas/distribution.json deleted file mode 100644 index 3871715ac..000000000 --- a/data/metadata-schemas/distribution.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "uuid": "ebacbf83-cd4f-4113-8738-d73c0735b0ab", - "versions": [ - { - "version": "1.0.0", - "name": "Distribution", - "definitionFile": "distribution.ttl", - "abstractSchema": false, - "type": "INTERNAL", - "state": "LATEST", - "extendsSchemaUuids": [ - "6a668323-3936-4b53-8380-a4fd2ed082ee" - ], - "suggestedResourceName": "Distribution", - "suggestedUrlPrefix": "distribution" - } - ] -} \ No newline at end of file diff --git a/data/metadata-schemas/distribution.ttl b/data/metadata-schemas/distribution.ttl deleted file mode 100644 index 710fff238..000000000 --- a/data/metadata-schemas/distribution.ttl +++ /dev/null @@ -1,58 +0,0 @@ -@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix sh: . -@prefix xsd: . - -:DistributionShape a sh:NodeShape ; - sh:targetClass dcat:Distribution ; - sh:property [ - sh:path dct:issued ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DateTimePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 20 ; - ], [ - sh:path dct:modified ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DateTimePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 21 ; - ], [ - sh:path dcat:accessURL ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - sh:order 22 ; - ], [ - sh:path dcat:downloadURL ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - sh:order 23 ; - ], [ - sh:path dcat:mediaType ; - sh:nodeKind sh:Literal ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 24 ; - ], [ - sh:path dcat:format ; - sh:nodeKind sh:Literal ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 25 ; - ], [ - sh:path dcat:byteSize ; - sh:nodeKind sh:Literal ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 26 ; - ] . diff --git a/data/metadata-schemas/fdp.json b/data/metadata-schemas/fdp.json deleted file mode 100644 index bf92d41aa..000000000 --- a/data/metadata-schemas/fdp.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "uuid": "a92958ab-a414-47e6-8e17-68ba96ba3a2b", - "versions": [ - { - "version": "1.0.0", - "name": "FAIR Data Point", - "definitionFile": "fdp.ttl", - "abstractSchema": false, - "type": "INTERNAL", - "state": "LATEST", - "extendsSchemaUuids": [ - "6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad" - ], - "suggestedResourceName": "FAIR Data Point", - "suggestedUrlPrefix": "" - } - ] -} \ No newline at end of file diff --git a/data/metadata-schemas/fdp.ttl b/data/metadata-schemas/fdp.ttl deleted file mode 100644 index 5dec656b3..000000000 --- a/data/metadata-schemas/fdp.ttl +++ /dev/null @@ -1,39 +0,0 @@ -@prefix : . -@prefix dash: . -@prefix dct: . -@prefix fdp: . -@prefix sh: . -@prefix xsd: . - -:FDPShape a sh:NodeShape ; - sh:targetClass fdp:FAIRDataPoint ; - sh:property [ - sh:path fdp:startDate ; - sh:datatype xsd:date ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 40 ; - ] , [ - sh:path fdp:endDate ; - sh:datatype xsd:date ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 41 ; - ] , [ - sh:path fdp:uiLanguage ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - sh:defaultValue ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 42 ; - ] , [ - sh:path fdp:metadataIdentifier ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 43 ; - ] . diff --git a/data/metadata-schemas/metadata-service.json b/data/metadata-schemas/metadata-service.json deleted file mode 100644 index f7ff02f34..000000000 --- a/data/metadata-schemas/metadata-service.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "uuid": "6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad", - "versions": [ - { - "version": "1.0.0", - "name": "Metaata Service", - "definitionFile": "metadata-service.ttl", - "abstractSchema": false, - "type": "INTERNAL", - "state": "LATEST", - "extendsSchemaUuids": [ - "89d94c1b-f6ff-4545-ba9b-120b2d1921d0" - ], - "suggestedResourceName": "Metadata Service", - "suggestedUrlPrefix": "metadata-service" - } - ] -} \ No newline at end of file diff --git a/data/metadata-schemas/metadata-service.ttl b/data/metadata-schemas/metadata-service.ttl deleted file mode 100644 index d5057480d..000000000 --- a/data/metadata-schemas/metadata-service.ttl +++ /dev/null @@ -1,6 +0,0 @@ -@prefix : . -@prefix fdp: . -@prefix sh: . - -:MetadataServiceShape a sh:NodeShape ; - sh:targetClass fdp:MetadataService . diff --git a/data/metadata-schemas/resource.json b/data/metadata-schemas/resource.json deleted file mode 100644 index 8e6b687c4..000000000 --- a/data/metadata-schemas/resource.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "uuid": "6a668323-3936-4b53-8380-a4fd2ed082ee", - "versions": [ - { - "version": "1.0.0", - "name": "Resource", - "definitionFile": "resource.ttl", - "abstractSchema": true, - "type": "INTERNAL", - "state": "LATEST" - } - ] -} \ No newline at end of file diff --git a/data/metadata-schemas/resource.ttl b/data/metadata-schemas/resource.ttl deleted file mode 100644 index f77bb42bd..000000000 --- a/data/metadata-schemas/resource.ttl +++ /dev/null @@ -1,73 +0,0 @@ -@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix foaf: . -@prefix sh: . -@prefix xsd: . - -:ResourceShape a sh:NodeShape ; - sh:targetClass dcat:Resource ; - sh:property [ - sh:path dct:title ; - sh:nodeKind sh:Literal ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - sh:order 1 ; - ], [ - sh:path dct:description ; - sh:nodeKind sh:Literal ; - sh:maxCount 1 ; - dash:editor dash:TextAreaEditor ; - sh:order 2 ; - ], [ - sh:path dct:publisher ; - sh:node :AgentShape ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:BlankNodeEditor ; - sh:order 3 ; - ], [ - sh:path dcat:version ; - sh:name "version" ; - sh:nodeKind sh:Literal ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 4 ; - ], [ - sh:path dct:language ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:defaultValue ; - sh:order 5 ; - ], [ - sh:path dct:license ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:defaultValue ; - sh:order 6 ; - ], [ - sh:path dct:rights ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 7 ; - ] . - -:AgentShape a sh:NodeShape ; - sh:targetClass foaf:Agent ; - sh:property [ - sh:path foaf:name ; - sh:nodeKind sh:Literal ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - ] . diff --git a/data/resource-definitions/catalog.json b/data/resource-definitions/catalog.json deleted file mode 100644 index 00cd629ff..000000000 --- a/data/resource-definitions/catalog.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "uuid": "a0949e72-4466-4d53-8900-9436d1049a4b", - "name": "Catalog", - "urlPrefix": "catalog", - "children": [ - { - "resourceDefinitionUuid": "2f08228e-1789-40f8-84cd-28e3288c3604", - "relationUri": "http://www.w3.org/ns/dcat#dataset", - "listView": { - "title": "Datasets", - "tagsUri": "http://www.w3.org/ns/dcat#theme", - "metadata": [] - } - } - ], - "externalLinks": [], - "metadataSchemaUuids": [ - "2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660" - ] -} diff --git a/data/resource-definitions/dataset.json b/data/resource-definitions/dataset.json deleted file mode 100644 index f96b9e62c..000000000 --- a/data/resource-definitions/dataset.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "uuid": "2f08228e-1789-40f8-84cd-28e3288c3604", - "name": "Dataset", - "urlPrefix": "dataset", - "children": [ - { - "resourceDefinitionUuid": "02c649de-c579-43bb-b470-306abdc808c7", - "relationUri": "http://www.w3.org/ns/dcat#distribution", - "listView": { - "title": "Distributions", - "tagsUri": null, - "metadata": [ - { - "title": "Media Type", - "propertyUri": "http://www.w3.org/ns/dcat#mediaType" - } - ] - } - } - ], - "externalLinks": [], - "metadataSchemaUuids": [ - "866d7fb8-5982-4215-9c7c-18d0ed1bd5f3" - ] -} diff --git a/data/resource-definitions/distribution.json b/data/resource-definitions/distribution.json deleted file mode 100644 index ecaf01400..000000000 --- a/data/resource-definitions/distribution.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "uuid": "02c649de-c579-43bb-b470-306abdc808c7", - "name": "Distribution", - "urlPrefix": "distribution", - "children": [], - "externalLinks": [ - { - "title": "Access online", - "propertyUri": "http://www.w3.org/ns/dcat#accessURL" - }, - { - "title": "Download", - "propertyUri": "http://www.w3.org/ns/dcat#downloadURL" - } - ], - "metadataSchemaUuids": [ - "ebacbf83-cd4f-4113-8738-d73c0735b0ab" - ] -} diff --git a/data/resource-definitions/repository.json b/data/resource-definitions/repository.json deleted file mode 100644 index 2356f6bae..000000000 --- a/data/resource-definitions/repository.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "uuid": "77aaad6a-0136-4c6e-88b9-07ffccd0ee4c", - "name": "FAIR Data Point", - "urlPrefix": "", - "children": [ - { - "resourceDefinitionUuid": "a0949e72-4466-4d53-8900-9436d1049a4b", - "relationUri": "https://w3id.org/fdp/fdp-o#metadataCatalog", - "listView": { - "title": "Catalogs", - "tagsUri": "http://www.w3.org/ns/dcat#themeTaxonomy", - "metadata": [] - } - } - ], - "externalLinks": [], - "metadataSchemaUuids": [ - "a92958ab-a414-47e6-8e17-68ba96ba3a2b" - ] -} diff --git a/data/settings/settings.json b/data/settings/settings.json deleted file mode 100644 index 99070f429..000000000 --- a/data/settings/settings.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "appTitle": "FAIR DAta Point", - "appSubtitle": "Metadata for Machines", - "autocompleteSources": [], - "metrics": [ - { - "metricUri": "https://purl.org/fair-metrics/FM_F1A", - "resourceUri": "https://www.ietf.org/rfc/rfc3986.txt" - }, - { - "metricUri": "https://purl.org/fair-metrics/FM_A1.1", - "resourceUri": "https://www.wikidata.org/wiki/Q8777" - } - ], - "searchFilters": [] -} \ No newline at end of file diff --git a/data/users/albert-einstein.json b/data/users/albert-einstein.json deleted file mode 100644 index 7c1f42bd1..000000000 --- a/data/users/albert-einstein.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "uuid": "123e4567-e89b-12d3-a456-426614174000", - "firstName": "Albert", - "lastName": "Einstein", - "email": "albert.einstein@example.com", - "password": "example", - "role": "Admin", - "apiKeyTokens": ["example-token-123"], - "savedQueries": [ - { - "name": "All datasets", - "description": "Quickly query all datasets (DCAT)", - "type": "PUBLIC", - "prefixes": "PREFIX dcat: ", - "graphPattern": "?entity rdf:type dcat:Dataset .", - "ordering": "ASC(?title)" - } - ] -} diff --git a/data/users/nikola-tesla.json b/data/users/nikola-tesla.json deleted file mode 100644 index e31b3335f..000000000 --- a/data/users/nikola-tesla.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "firstName": "Nikola", - "lastName": "Tesla", - "email": "nikola.tesla@example.com", - "password": "password", - "role": "USER" -} diff --git a/pom.xml b/pom.xml index 058ebc5f5..361daa58d 100644 --- a/pom.xml +++ b/pom.xml @@ -61,6 +61,7 @@ 0.12.6 1.18.38 3.9.10 + 3.0.0 5.5 @@ -207,6 +208,11 @@ hypersistence-utils-hibernate-63 ${hypersistence.version} + + tools.jackson.core + jackson-databind + ${jackson.version} + org.postgresql diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java new file mode 100644 index 000000000..dfe51b8f3 --- /dev/null +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -0,0 +1,39 @@ +package org.fairdatapoint.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.Resource; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; +import org.springframework.core.io.support.ResourcePatternResolver; +import org.springframework.data.repository.init.Jackson2RepositoryPopulatorFactoryBean; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Comparator; + +@Configuration +public class BootstrapConfig { + private final ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver(); + + @Bean + public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { + final Jackson2RepositoryPopulatorFactoryBean factory = new Jackson2RepositoryPopulatorFactoryBean(); + // load all json resources from the fixtures dir + try { + final Resource[] resources = resourceResolver.getResources("classpath:fixtures/*.json"); + // sort resources to guarantee lexicographic order + Arrays.sort( + resources, + Comparator.comparing( + Resource::getFilename, + Comparator.nullsLast(String::compareTo) + ) + ); + factory.setResources(resources); + } + catch (IOException exception) { + exception.printStackTrace(); + } + return factory; + } +} diff --git a/src/main/java/org/fairdatapoint/entity/base/BaseEntity.java b/src/main/java/org/fairdatapoint/entity/base/BaseEntity.java index 24fb116ca..b04dc8312 100644 --- a/src/main/java/org/fairdatapoint/entity/base/BaseEntity.java +++ b/src/main/java/org/fairdatapoint/entity/base/BaseEntity.java @@ -42,7 +42,7 @@ public class BaseEntity { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @CustomGeneratedUUID @NotNull @Column(name = "uuid", nullable = false, updatable = false, unique = true) private UUID uuid; diff --git a/src/main/java/org/fairdatapoint/entity/base/BaseEntityCustomUUID.java b/src/main/java/org/fairdatapoint/entity/base/BaseEntityCustomUUID.java deleted file mode 100644 index 620409ef9..000000000 --- a/src/main/java/org/fairdatapoint/entity/base/BaseEntityCustomUUID.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.entity.base; - -import jakarta.persistence.Column; -import jakarta.persistence.Id; -import jakarta.persistence.MappedSuperclass; -import jakarta.validation.constraints.NotNull; -import lombok.*; -import lombok.experimental.SuperBuilder; -import org.hibernate.annotations.CreationTimestamp; -import org.hibernate.annotations.UpdateTimestamp; - -import java.time.Instant; -import java.util.Objects; -import java.util.UUID; - -@MappedSuperclass -@SuperBuilder(toBuilder = true) -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -public class BaseEntityCustomUUID { - - @Id - @NotNull - @Column(name = "uuid", nullable = false, updatable = false, unique = true) - private UUID uuid; - - @Builder.Default - @CreationTimestamp - @NotNull - @Column(name = "created_at", nullable = false, updatable = false) - private Instant createdAt = Instant.now(); - - @Builder.Default - @UpdateTimestamp - @NotNull - @Column(name = "updated_at", nullable = false) - private Instant updatedAt = Instant.now(); - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final BaseEntityCustomUUID that = (BaseEntityCustomUUID) o; - return uuid.equals(that.uuid); - } - - @Override - public int hashCode() { - return Objects.hash(uuid); - } -} diff --git a/src/main/java/org/fairdatapoint/entity/base/CustomGeneratedUUID.java b/src/main/java/org/fairdatapoint/entity/base/CustomGeneratedUUID.java new file mode 100644 index 000000000..50fda0cad --- /dev/null +++ b/src/main/java/org/fairdatapoint/entity/base/CustomGeneratedUUID.java @@ -0,0 +1,24 @@ +package org.fairdatapoint.entity.base; + +import org.fairdatapoint.util.CustomUuidGenerator; +import org.hibernate.annotations.IdGeneratorType; +import org.hibernate.annotations.UuidGenerator; +import org.hibernate.annotations.ValueGenerationType; +import org.hibernate.id.uuid.UuidValueGenerator; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@IdGeneratorType(CustomUuidGenerator.class) +@ValueGenerationType(generatedBy = CustomUuidGenerator.class) +@Target({ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface CustomGeneratedUUID { + + UuidGenerator.Style style() default UuidGenerator.Style.AUTO; + + Class algorithm() default UuidValueGenerator.class; + +} diff --git a/src/main/java/org/fairdatapoint/entity/index/settings/IndexSettings.java b/src/main/java/org/fairdatapoint/entity/index/settings/IndexSettings.java index 5ae6bc90d..cb2792543 100644 --- a/src/main/java/org/fairdatapoint/entity/index/settings/IndexSettings.java +++ b/src/main/java/org/fairdatapoint/entity/index/settings/IndexSettings.java @@ -27,7 +27,7 @@ import jakarta.validation.constraints.NotNull; import lombok.*; import lombok.experimental.SuperBuilder; -import org.fairdatapoint.entity.base.BaseEntityCustomUUID; +import org.fairdatapoint.entity.base.BaseEntity; import org.hibernate.annotations.Type; import java.time.Duration; @@ -40,7 +40,7 @@ @Getter @Setter @SuperBuilder(toBuilder = true) -public class IndexSettings extends BaseEntityCustomUUID { +public class IndexSettings extends BaseEntity { @NotNull @Column(name = "auto_permit", nullable = false) diff --git a/src/main/java/org/fairdatapoint/entity/resource/MetadataSchemaUsage.java b/src/main/java/org/fairdatapoint/entity/resource/MetadataSchemaUsage.java index d004fa095..7fa8d67e4 100644 --- a/src/main/java/org/fairdatapoint/entity/resource/MetadataSchemaUsage.java +++ b/src/main/java/org/fairdatapoint/entity/resource/MetadataSchemaUsage.java @@ -29,6 +29,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; import lombok.experimental.SuperBuilder; +import org.fairdatapoint.entity.base.CustomGeneratedUUID; import org.fairdatapoint.entity.schema.MetadataSchema; import java.util.UUID; @@ -43,7 +44,7 @@ public class MetadataSchemaUsage { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @CustomGeneratedUUID @NotNull @Column(name = "uuid", nullable = false, updatable = false) private UUID uuid; diff --git a/src/main/java/org/fairdatapoint/entity/resource/ResourceDefinitionChild.java b/src/main/java/org/fairdatapoint/entity/resource/ResourceDefinitionChild.java index 705868362..344c8fcf1 100644 --- a/src/main/java/org/fairdatapoint/entity/resource/ResourceDefinitionChild.java +++ b/src/main/java/org/fairdatapoint/entity/resource/ResourceDefinitionChild.java @@ -68,6 +68,6 @@ public class ResourceDefinitionChild extends BaseEntity { private ResourceDefinition target; @OrderBy("orderPriority") - @OneToMany(fetch = FetchType.LAZY, mappedBy = "child") + @OneToMany(fetch = FetchType.LAZY, mappedBy = "child", cascade = CascadeType.ALL, orphanRemoval = true) private List metadata; } diff --git a/src/main/java/org/fairdatapoint/entity/schema/MetadataSchema.java b/src/main/java/org/fairdatapoint/entity/schema/MetadataSchema.java index 997232b3d..9053e367d 100644 --- a/src/main/java/org/fairdatapoint/entity/schema/MetadataSchema.java +++ b/src/main/java/org/fairdatapoint/entity/schema/MetadataSchema.java @@ -28,7 +28,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; import lombok.experimental.SuperBuilder; -import org.fairdatapoint.entity.base.BaseEntityCustomUUID; +import org.fairdatapoint.entity.base.BaseEntity; import org.fairdatapoint.entity.resource.MetadataSchemaUsage; import java.util.List; @@ -40,7 +40,7 @@ @NoArgsConstructor @AllArgsConstructor @SuperBuilder -public class MetadataSchema extends BaseEntityCustomUUID { +public class MetadataSchema extends BaseEntity { @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "schema") diff --git a/src/main/java/org/fairdatapoint/entity/schema/MetadataSchemaExtension.java b/src/main/java/org/fairdatapoint/entity/schema/MetadataSchemaExtension.java index 1bae57738..5024e07ec 100644 --- a/src/main/java/org/fairdatapoint/entity/schema/MetadataSchemaExtension.java +++ b/src/main/java/org/fairdatapoint/entity/schema/MetadataSchemaExtension.java @@ -25,6 +25,7 @@ import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; import lombok.*; +import org.fairdatapoint.entity.base.CustomGeneratedUUID; import java.util.UUID; @@ -38,7 +39,7 @@ public class MetadataSchemaExtension { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @CustomGeneratedUUID @NotNull @Column(name = "uuid", nullable = false, updatable = false) private UUID uuid; diff --git a/src/main/java/org/fairdatapoint/entity/schema/MetadataSchemaVersion.java b/src/main/java/org/fairdatapoint/entity/schema/MetadataSchemaVersion.java index 6e463ca50..fb42e189d 100644 --- a/src/main/java/org/fairdatapoint/entity/schema/MetadataSchemaVersion.java +++ b/src/main/java/org/fairdatapoint/entity/schema/MetadataSchemaVersion.java @@ -28,7 +28,7 @@ import jakarta.validation.constraints.NotNull; import lombok.*; import lombok.experimental.SuperBuilder; -import org.fairdatapoint.entity.base.BaseEntityCustomUUID; +import org.fairdatapoint.entity.base.BaseEntity; import org.hibernate.annotations.JdbcType; import org.hibernate.annotations.Type; import org.hibernate.dialect.PostgreSQLEnumJdbcType; @@ -45,7 +45,7 @@ @NoArgsConstructor @AllArgsConstructor @SuperBuilder(toBuilder = true) -public class MetadataSchemaVersion extends BaseEntityCustomUUID { +public class MetadataSchemaVersion extends BaseEntity { @NotNull @ManyToOne diff --git a/src/main/java/org/fairdatapoint/entity/settings/Settings.java b/src/main/java/org/fairdatapoint/entity/settings/Settings.java index 54851d0d8..c0aa15cc7 100644 --- a/src/main/java/org/fairdatapoint/entity/settings/Settings.java +++ b/src/main/java/org/fairdatapoint/entity/settings/Settings.java @@ -27,7 +27,7 @@ import jakarta.validation.constraints.NotNull; import lombok.*; import lombok.experimental.SuperBuilder; -import org.fairdatapoint.entity.base.BaseEntityCustomUUID; +import org.fairdatapoint.entity.base.BaseEntity; import org.hibernate.annotations.Type; import java.util.List; @@ -39,7 +39,7 @@ @Getter @Setter @SuperBuilder(toBuilder = true) -public class Settings extends BaseEntityCustomUUID { +public class Settings extends BaseEntity { @Column(name = "app_title") private String appTitle; diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapContext.java b/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapContext.java deleted file mode 100644 index b3a699399..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapContext.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap; - -import lombok.Data; -import org.fairdatapoint.entity.resource.ResourceDefinition; -import org.fairdatapoint.entity.schema.MetadataSchema; -import org.fairdatapoint.entity.user.UserAccount; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -@Data -public class BootstrapContext { - private Map users = new HashMap<>(); - private Map metadataSchemas = new HashMap<>(); - private Map resourceDefinitions = new HashMap<>(); -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapService.java b/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapService.java index 90fefa785..96636cf4e 100644 --- a/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapService.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapService.java @@ -34,19 +34,11 @@ @Service @RequiredArgsConstructor public class BootstrapService { - private final UserBootstrapper userBootstrapper; - private final SettingsBootstrapper settingsBootstrapper; - private final MembershipBootstrapper membershipBootstrapper; private final MetadataRecordsBootstrapper metadataRecordsBootstrapper; - private final MetadataSchemaBootstrapper metadataSchemaBootstrapper; - private final MetadataSchemaVersionsBootstrapper metadataSchemaVersionsBootstrapper; - private final ResourceDefinitionBootstrapper resourceDefinitionBootstrapper; - private final ResourceDefinitionChildrenBootstrapper resourceDefinitionChildrenBootstrapper; @Transactional public void bootstrapFromDir(String dataPath) { final Path basePath = Path.of(dataPath); - final BootstrapContext context = new BootstrapContext(); log.info("Bootstrap process started"); if (!basePath.toFile().exists() || !basePath.toFile().isDirectory()) { @@ -54,53 +46,9 @@ public void bootstrapFromDir(String dataPath) { return; } - // Settings - if (settingsBootstrapper.shouldBootstrap()) { - settingsBootstrapper.bootstrapFromJson(basePath.resolve("settings"), context); - } - else { - log.info("Settings already exist, skipping settings bootstrapping"); - } - - // User (and related entities) - if (userBootstrapper.shouldBootstrap()) { - userBootstrapper.bootstrapAllFromDir(basePath.resolve("users"), context); - } - else { - log.info("Users already exist, skipping user bootstrapping"); - } - - // Metadata Schemas - if (metadataSchemaBootstrapper.shouldBootstrap()) { - final Path dir = basePath.resolve("metadata-schemas"); - metadataSchemaBootstrapper.bootstrapAllFromDir(dir, context); - metadataSchemaVersionsBootstrapper.bootstrapAllFromDir(dir, context); - } - else { - log.info("Metadata Schemas already exist, skipping metadata schema bootstrapping"); - } - - // Resource Definitions - if (resourceDefinitionBootstrapper.shouldBootstrap()) { - final Path dir = basePath.resolve("resource-definitions"); - resourceDefinitionBootstrapper.bootstrapAllFromDir(dir, context); - resourceDefinitionChildrenBootstrapper.bootstrapAllFromDir(dir, context); - } - else { - log.info("Resource Definitions already exist, skipping resource definition bootstrapping"); - } - - // Memberships - if (membershipBootstrapper.shouldBootstrap()) { - membershipBootstrapper.bootstrapAllFromDir(basePath.resolve("memberships"), context); - } - else { - log.info("Memberships already exist, skipping membership bootstrapping"); - } - // RDF Records if (metadataRecordsBootstrapper.shouldBootstrap()) { - metadataRecordsBootstrapper.bootstrapAllFromDir(basePath.resolve("records"), context); + metadataRecordsBootstrapper.bootstrapAllFromDir(basePath.resolve("records")); } else { log.info("Metadata Records already exist, skipping metadata records bootstrapping"); diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/components/AbstractBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/AbstractBootstrapper.java index 2c7f56a81..87261d84a 100644 --- a/src/main/java/org/fairdatapoint/service/bootstrap/components/AbstractBootstrapper.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/components/AbstractBootstrapper.java @@ -24,7 +24,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; -import org.fairdatapoint.service.bootstrap.BootstrapContext; import org.springframework.data.jpa.repository.JpaRepository; import java.io.IOException; @@ -41,7 +40,7 @@ protected AbstractBootstrapper(ObjectMapper objectMapper) { } @Override - public void bootstrapAllFromDir(Path dirPath, BootstrapContext context) { + public void bootstrapAllFromDir(Path dirPath) { if (!Files.isDirectory(dirPath)) { log.info("Directory {} does not exist, nothing to bootstrap", dirPath); return; @@ -50,7 +49,7 @@ public void bootstrapAllFromDir(Path dirPath, BootstrapContext context) { initBootstrap(); paths.filter(Files::isRegularFile) .filter(path -> path.toString().endsWith(".json")) - .forEach(path -> bootstrapFromJson(path, context)); + .forEach(path -> bootstrapFromJson(path)); finalizeBootstrap(); } catch (IOException exception) { diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/components/IBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/IBootstrapper.java index bfaf1bb15..83414e2c1 100644 --- a/src/main/java/org/fairdatapoint/service/bootstrap/components/IBootstrapper.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/components/IBootstrapper.java @@ -22,13 +22,11 @@ */ package org.fairdatapoint.service.bootstrap.components; -import org.fairdatapoint.service.bootstrap.BootstrapContext; - import java.nio.file.Path; public interface IBootstrapper { - void bootstrapAllFromDir(Path dirPath, BootstrapContext context); + void bootstrapAllFromDir(Path dirPath); - void bootstrapFromJson(Path resourcePath, BootstrapContext context); + void bootstrapFromJson(Path resourcePath); } diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/components/MembershipBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/MembershipBootstrapper.java deleted file mode 100644 index f7ab06914..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/components/MembershipBootstrapper.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.components; - -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import org.fairdatapoint.database.db.repository.MembershipPermissionRepository; -import org.fairdatapoint.database.db.repository.MembershipRepository; -import org.fairdatapoint.entity.membership.Membership; -import org.fairdatapoint.service.bootstrap.BootstrapContext; -import org.fairdatapoint.service.bootstrap.fixtures.MembershipFixture; -import org.fairdatapoint.service.membership.MembershipMapper; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Component; - -import java.io.IOException; -import java.nio.file.Path; - -@Slf4j -@Component -public class MembershipBootstrapper extends AbstractBootstrapper { - private final MembershipMapper membershipMapper; - private final MembershipRepository membershipRepository; - private final MembershipPermissionRepository membershipPermissionRepository; - - public MembershipBootstrapper(ObjectMapper objectMapper, MembershipMapper membershipMapper, - MembershipRepository membershipRepository, - MembershipPermissionRepository membershipPermissionRepository) { - super(objectMapper); - this.membershipMapper = membershipMapper; - this.membershipRepository = membershipRepository; - this.membershipPermissionRepository = membershipPermissionRepository; - } - - @Override - protected JpaRepository getRepository() { - return membershipRepository; - } - - @Override - public void bootstrapFromJson(Path resourcePath, BootstrapContext context) { - try { - final MembershipFixture membershipFixture = - getObjectMapper().readValue(resourcePath.toFile(), MembershipFixture.class); - final Membership membership = membershipRepository.saveAndFlush( - membershipMapper.fromFixture(membershipFixture) - ); - membershipPermissionRepository.saveAllAndFlush( - membershipFixture.getPermissions() - .stream() - .map(perm -> membershipMapper.permissionFromDTO(membership, perm)) - .toList() - ); - log.info("Created membership {}", membership.getName()); - } - catch (IOException exception) { - throw new RuntimeException(exception); - } - } -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataRecordsBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataRecordsBootstrapper.java index 23e274ea0..560a426cb 100644 --- a/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataRecordsBootstrapper.java +++ b/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataRecordsBootstrapper.java @@ -29,7 +29,6 @@ import org.eclipse.rdf4j.rio.Rio; import org.fairdatapoint.database.rdf.repository.RepositoryMode; import org.fairdatapoint.database.rdf.repository.generic.GenericMetadataRepository; -import org.fairdatapoint.service.bootstrap.BootstrapContext; import org.fairdatapoint.service.bootstrap.fixtures.RecordsFixture; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Component; @@ -61,7 +60,7 @@ protected JpaRepository getRepository() { } @Override - public void bootstrapFromJson(Path resourcePath, BootstrapContext context) { + public void bootstrapFromJson(Path resourcePath) { if (!resourcePath.getFileName().toString().equals("records.json")) { log.warn("Skipping file {}: only records.json is supported for records bootstrapping", resourcePath); return; diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataSchemaBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataSchemaBootstrapper.java deleted file mode 100644 index 005509102..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataSchemaBootstrapper.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.components; - -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import org.fairdatapoint.database.db.repository.MetadataSchemaExtensionRepository; -import org.fairdatapoint.database.db.repository.MetadataSchemaRepository; -import org.fairdatapoint.database.db.repository.MetadataSchemaVersionRepository; -import org.fairdatapoint.entity.schema.MetadataSchema; -import org.fairdatapoint.service.bootstrap.BootstrapContext; -import org.fairdatapoint.service.bootstrap.fixtures.MetadataSchemaFixture; -import org.fairdatapoint.service.schema.MetadataSchemaMapper; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Component; - -import java.nio.file.Path; - -@Slf4j -@Component -public class MetadataSchemaBootstrapper extends AbstractBootstrapper { - private final MetadataSchemaRepository metadataSchemaRepository; - private final MetadataSchemaExtensionRepository metadataSchemaExtensionRepository; - private final MetadataSchemaVersionRepository metadataSchemaVersionRepository; - private final MetadataSchemaMapper metadataSchemaMapper; - - public MetadataSchemaBootstrapper(ObjectMapper objectMapper, MetadataSchemaRepository metadataSchemaRepository, - MetadataSchemaExtensionRepository metadataSchemaExtensionRepository, - MetadataSchemaVersionRepository metadataSchemaVersionRepository, - MetadataSchemaMapper metadataSchemaMapper) { - super(objectMapper); - this.metadataSchemaRepository = metadataSchemaRepository; - this.metadataSchemaExtensionRepository = metadataSchemaExtensionRepository; - this.metadataSchemaVersionRepository = metadataSchemaVersionRepository; - this.metadataSchemaMapper = metadataSchemaMapper; - } - - @Override - protected JpaRepository getRepository() { - return metadataSchemaRepository; - } - - @Override - public void bootstrapFromJson(Path resourcePath, BootstrapContext context) { - try { - final MetadataSchemaFixture metadataSchemaFixture = - getObjectMapper().readValue(resourcePath.toFile(), MetadataSchemaFixture.class); - final MetadataSchema metadataSchema = - metadataSchemaRepository.saveAndFlush(metadataSchemaMapper.newSchema()); - context.getMetadataSchemas().put(metadataSchemaFixture.getUuid(), metadataSchema); - // Versions and extensions - metadataSchemaVersionRepository.saveAllAndFlush( - metadataSchemaFixture.getVersions() - .stream() - .map(version -> { - return metadataSchemaMapper.fromMetadataSchemaVersionFixture(version, metadataSchema); - }) - .toList() - ); - // Extensions - } - catch (Exception exception) { - throw new RuntimeException(exception); - } - } -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataSchemaVersionsBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataSchemaVersionsBootstrapper.java deleted file mode 100644 index ac5f7ee8f..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataSchemaVersionsBootstrapper.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.components; - -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import org.fairdatapoint.database.db.repository.MetadataSchemaExtensionRepository; -import org.fairdatapoint.database.db.repository.MetadataSchemaVersionRepository; -import org.fairdatapoint.entity.schema.MetadataSchema; -import org.fairdatapoint.entity.schema.MetadataSchemaVersion; -import org.fairdatapoint.service.bootstrap.BootstrapContext; -import org.fairdatapoint.service.bootstrap.fixtures.MetadataSchemaFixture; -import org.fairdatapoint.service.bootstrap.fixtures.MetadataSchemaVersionFixture; -import org.fairdatapoint.service.schema.MetadataSchemaMapper; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Component; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.UUID; -import java.util.stream.IntStream; - -@Slf4j -@Component -public class MetadataSchemaVersionsBootstrapper extends AbstractBootstrapper { - private final MetadataSchemaVersionRepository metadataSchemaVersionRepository; - private final MetadataSchemaExtensionRepository metadataSchemaExtensionRepository; - private final MetadataSchemaMapper metadataSchemaMapper; - - public MetadataSchemaVersionsBootstrapper(ObjectMapper objectMapper, - MetadataSchemaVersionRepository metadataSchemaVersionRepository, - MetadataSchemaExtensionRepository metadataSchemaExtensionRepository, - MetadataSchemaMapper metadataSchemaMapper) { - super(objectMapper); - this.metadataSchemaVersionRepository = metadataSchemaVersionRepository; - this.metadataSchemaExtensionRepository = metadataSchemaExtensionRepository; - this.metadataSchemaMapper = metadataSchemaMapper; - } - - @Override - protected JpaRepository getRepository() { - return metadataSchemaVersionRepository; - } - - @Override - public void bootstrapFromJson(Path resourcePath, BootstrapContext context) { - try { - final MetadataSchemaFixture metadataSchemaFixture = - getObjectMapper().readValue(resourcePath.toFile(), MetadataSchemaFixture.class); - final MetadataSchema metadataSchema = - context.getMetadataSchemas().get(metadataSchemaFixture.getUuid()); - metadataSchemaFixture.getVersions().forEach(version -> { - final MetadataSchemaVersion metadataSchemaVersion = metadataSchemaVersionRepository.saveAndFlush( - fromFixture(resourcePath, version, metadataSchema) - ); - - // Extensions - metadataSchemaExtensionRepository.saveAllAndFlush( - IntStream.range(0, version.getExtendsSchemaUuids().size()) - .mapToObj(index -> { - final UUID metadataSchemaUuid = version.getExtendsSchemaUuids().get(index); - return metadataSchemaMapper.newExtension( - metadataSchemaVersion, - context.getMetadataSchemas().get(metadataSchemaUuid), - index - ); - }) - .toList() - ); - }); - } - catch (Exception exception) { - throw new RuntimeException(exception); - } - } - - private MetadataSchemaVersion fromFixture(Path resourcePath, MetadataSchemaVersionFixture fixture, - MetadataSchema schema) { - final MetadataSchemaVersion version = metadataSchemaMapper.fromMetadataSchemaVersionFixture(fixture, schema); - if (fixture.getDefinitionFile() != null) { - final Path definitionPath = resourcePath.getParent().resolve(fixture.getDefinitionFile()); - try { - final String definition = Files.readString(definitionPath); - version.setDefinition(definition); - } - catch (IOException exception) { - log.warn("Failed to read definition file for schema version: {}", definitionPath); - } - } - return version; - } -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/components/ResourceDefinitionBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/ResourceDefinitionBootstrapper.java deleted file mode 100644 index 35db8dd72..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/components/ResourceDefinitionBootstrapper.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.components; - -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import org.fairdatapoint.database.db.repository.*; -import org.fairdatapoint.entity.resource.ResourceDefinition; -import org.fairdatapoint.service.bootstrap.BootstrapContext; -import org.fairdatapoint.service.bootstrap.fixtures.ResourceDefinitionFixture; -import org.fairdatapoint.service.resource.ResourceDefinitionMapper; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Component; - -import java.nio.file.Path; -import java.util.stream.IntStream; - -@Slf4j -@Component -public class ResourceDefinitionBootstrapper extends AbstractBootstrapper { - private final ResourceDefinitionRepository resourceDefinitionRepository; - private final ResourceDefinitionLinkRepository resourceDefinitionLinkRepository; - private final MetadataSchemaUsageRepository metadataSchemaUsageRepository; - private final ResourceDefinitionMapper resourceDefinitionMapper; - - public ResourceDefinitionBootstrapper(ObjectMapper objectMapper, - ResourceDefinitionRepository resourceDefinitionRepository, - ResourceDefinitionLinkRepository resourceDefinitionLinkRepository, - MetadataSchemaUsageRepository metadataSchemaUsageRepository, - ResourceDefinitionMapper resourceDefinitionMapper) { - super(objectMapper); - this.resourceDefinitionRepository = resourceDefinitionRepository; - this.resourceDefinitionLinkRepository = resourceDefinitionLinkRepository; - this.metadataSchemaUsageRepository = metadataSchemaUsageRepository; - this.resourceDefinitionMapper = resourceDefinitionMapper; - } - - @Override - protected JpaRepository getRepository() { - return resourceDefinitionRepository; - } - - @Override - public void bootstrapFromJson(Path resourcePath, BootstrapContext context) { - try { - final ResourceDefinitionFixture resourceDefinitionFixture = - getObjectMapper().readValue(resourcePath.toString(), ResourceDefinitionFixture.class); - final ResourceDefinition resourceDefinition = - resourceDefinitionRepository.saveAndFlush( - resourceDefinitionMapper.fromResourceDefinitionFixture(resourceDefinitionFixture) - ); - context.getResourceDefinitions().put(resourceDefinitionFixture.getUuid(), resourceDefinition); - // External Links - resourceDefinitionLinkRepository.saveAllAndFlush( - IntStream.range(0, resourceDefinitionFixture.getExternalLinks().size()) - .mapToObj(index -> { - return resourceDefinitionMapper.toLink( - resourceDefinitionFixture.getExternalLinks().get(index), - resourceDefinition, - index - ); - }) - .toList() - ); - // Metadata Schema Usages - metadataSchemaUsageRepository.saveAllAndFlush( - IntStream.range(0, resourceDefinitionFixture.getMetadataSchemaUuids().size()) - .mapToObj(index -> { - return resourceDefinitionMapper.toUsage( - context.getMetadataSchemas().get( - resourceDefinitionFixture.getMetadataSchemaUuids().get(index) - ), - resourceDefinition, - index - ); - }) - .toList() - ); - } - catch (Exception exception) { - throw new RuntimeException(exception); - } - } -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/components/ResourceDefinitionChildrenBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/ResourceDefinitionChildrenBootstrapper.java deleted file mode 100644 index 8ef890119..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/components/ResourceDefinitionChildrenBootstrapper.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.components; - -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import org.fairdatapoint.api.dto.resource.ResourceDefinitionChildDTO; -import org.fairdatapoint.database.db.repository.*; -import org.fairdatapoint.entity.resource.ResourceDefinition; -import org.fairdatapoint.entity.resource.ResourceDefinitionChild; -import org.fairdatapoint.service.bootstrap.BootstrapContext; -import org.fairdatapoint.service.bootstrap.fixtures.ResourceDefinitionFixture; -import org.fairdatapoint.service.resource.ResourceDefinitionMapper; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Component; - -import java.nio.file.Path; -import java.util.stream.IntStream; - -@Slf4j -@Component -public class ResourceDefinitionChildrenBootstrapper extends AbstractBootstrapper { - private final ResourceDefinitionChildRepository childRepository; - private final ResourceDefinitionChildMetadataRepository childMetadataRepository; - private final ResourceDefinitionMapper resourceDefinitionMapper; - - public ResourceDefinitionChildrenBootstrapper(ObjectMapper objectMapper, - ResourceDefinitionChildRepository childRepository, - ResourceDefinitionChildMetadataRepository childMetadataRepository, - ResourceDefinitionMapper resourceDefinitionMapper) { - super(objectMapper); - this.childRepository = childRepository; - this.childMetadataRepository = childMetadataRepository; - this.resourceDefinitionMapper = resourceDefinitionMapper; - } - - @Override - protected JpaRepository getRepository() { - return childRepository; - } - - @Override - public void bootstrapFromJson(Path resourcePath, BootstrapContext context) { - try { - final ResourceDefinitionFixture resourceDefinitionFixture = - getObjectMapper().readValue(resourcePath.toString(), ResourceDefinitionFixture.class); - final ResourceDefinition resourceDefinition = - context.getResourceDefinitions().get(resourceDefinitionFixture.getUuid()); - // Children - IntStream.range(0, resourceDefinitionFixture.getChildren().size()) - .mapToObj(index -> { - final ResourceDefinitionChildDTO childDTO = - resourceDefinitionFixture.getChildren().get(index); - return resourceDefinitionMapper.toChild( - resourceDefinitionFixture.getChildren().get(index), - resourceDefinition, - context.getResourceDefinitions().get(childDTO.getResourceDefinitionUuid()), - index); - }) - .forEach(child -> { - final ResourceDefinitionChild savedChild = childRepository.saveAndFlush(child); - final ResourceDefinitionChildDTO childDTO = - resourceDefinitionFixture.getChildren().get(child.getOrderPriority()); - // Child metadata - childMetadataRepository.saveAllAndFlush( - IntStream.range(0, childDTO.getListView().getMetadata().size()) - .mapToObj(metaIndex -> { - return resourceDefinitionMapper.toChildMetadata( - childDTO.getListView().getMetadata().get(metaIndex), - savedChild, - metaIndex - ); - }) - .toList() - ); - }); - } - catch (Exception exception) { - throw new RuntimeException(exception); - } - } -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/components/SettingsBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/SettingsBootstrapper.java deleted file mode 100644 index f95c440ba..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/components/SettingsBootstrapper.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.components; - -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import org.fairdatapoint.database.db.repository.*; -import org.fairdatapoint.entity.settings.Settings; -import org.fairdatapoint.entity.settings.SettingsSearchFilter; -import org.fairdatapoint.service.bootstrap.BootstrapContext; -import org.fairdatapoint.service.bootstrap.fixtures.SettingsFixture; -import org.fairdatapoint.service.settings.SettingsMapper; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Component; - -import java.nio.file.Path; -import java.util.stream.IntStream; - -@Slf4j -@Component -public class SettingsBootstrapper extends AbstractBootstrapper { - private final ObjectMapper objectMapper; - private final SettingsRepository settingsRepository; - private final SettingsMetricRepository settingsMetricRepository; - private final SettingsAutocompleteSourceRepository settingsAutocompleteSourceRepository; - private final SettingsSearchFilterRepository settingsSearchFilterRepository; - private final SettingsSearchFilterItemRepository settingsSearchFilterItemRepository; - private final SettingsMapper settingsMapper; - - public SettingsBootstrapper(ObjectMapper objectMapper, - SettingsRepository settingsRepository, - SettingsMetricRepository settingsMetricRepository, - SettingsAutocompleteSourceRepository settingsAutocompleteSourceRepository, - SettingsSearchFilterRepository settingsSearchFilterRepository, - SettingsSearchFilterItemRepository settingsSearchFilterItemRepository, - SettingsMapper settingsMapper) { - super(objectMapper); - this.objectMapper = objectMapper; - this.settingsRepository = settingsRepository; - this.settingsMetricRepository = settingsMetricRepository; - this.settingsAutocompleteSourceRepository = settingsAutocompleteSourceRepository; - this.settingsSearchFilterRepository = settingsSearchFilterRepository; - this.settingsSearchFilterItemRepository = settingsSearchFilterItemRepository; - this.settingsMapper = settingsMapper; - } - - public void bootstrapFromJson(Path resourcePath, BootstrapContext context) { - if (!resourcePath.getFileName().toString().equals("settings.json")) { - log.warn("Skipping file {}: only settings.json is supported for settings bootstrapping", resourcePath); - return; - } - try { - final SettingsFixture settingsFixture = - objectMapper.readValue(resourcePath.toFile(), SettingsFixture.class); - final Settings settings = settingsRepository.saveAndFlush( - settingsMapper.fromSettingsFixture(settingsFixture) - ); - // Metrics - settingsMetricRepository.saveAll( - IntStream.range(0, settingsFixture.getMetrics().size()) - .mapToObj(index -> { - final var metricFixture = settingsFixture.getMetrics().get(index); - return settingsMapper.fromMetricDTO(metricFixture, index, settings); - }) - .toList() - ); - // Autocomplete sources - settingsAutocompleteSourceRepository.saveAll( - IntStream.range(0, settingsFixture.getAutocompleteSources().size()) - .mapToObj(index -> { - final var sourceFixture = settingsFixture.getAutocompleteSources().get(index); - return settingsMapper.fromAutocompleteSourceDTO(sourceFixture, index, settings); - }) - .toList() - ); - // Search filters - settingsFixture.getSearchFilters().forEach(filterFixture -> { - final SettingsSearchFilter searchFilter = settingsSearchFilterRepository.saveAndFlush( - settingsMapper.fromSearchFilterDTO(filterFixture, 0, settings) - ); - // Filter items - settingsSearchFilterItemRepository.saveAll( - IntStream.range(0, filterFixture.getValues().size()) - .mapToObj(index -> { - final var itemFixture = filterFixture.getValues().get(index); - return settingsMapper.fromSearchFilterItemDTO(itemFixture, index, searchFilter); - }) - .toList() - ); - }); - } - catch (java.io.IOException exception) { - throw new RuntimeException(exception); - } - } - - @Override - protected JpaRepository getRepository() { - return settingsRepository; - } -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/components/UserBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/UserBootstrapper.java deleted file mode 100644 index 8ba62a754..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/components/UserBootstrapper.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.components; - -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import org.fairdatapoint.database.db.repository.ApiKeyRepository; -import org.fairdatapoint.database.db.repository.SearchSavedQueryRepository; -import org.fairdatapoint.database.db.repository.UserAccountRepository; -import org.fairdatapoint.entity.apikey.ApiKey; -import org.fairdatapoint.entity.search.SearchSavedQuery; -import org.fairdatapoint.entity.user.UserAccount; -import org.fairdatapoint.service.apikey.ApiKeyMapper; -import org.fairdatapoint.service.bootstrap.BootstrapContext; -import org.fairdatapoint.service.bootstrap.fixtures.SearchSavedQueryFixture; -import org.fairdatapoint.service.bootstrap.fixtures.UserFixture; -import org.fairdatapoint.service.search.query.SearchSavedQueryMapper; -import org.fairdatapoint.service.user.UserMapper; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Component; - -import java.io.IOException; -import java.nio.file.Path; - -@Slf4j -@Component -public class UserBootstrapper extends AbstractBootstrapper { - private final UserMapper userMapper; - private final UserAccountRepository userAccountRepository; - private final ApiKeyMapper apiKeyMapper; - private final ApiKeyRepository apiKeyRepository; - private final SearchSavedQueryMapper searchSavedQueryMapper; - private final SearchSavedQueryRepository searchSavedQueryRepository; - - public UserBootstrapper(ObjectMapper objectMapper, UserMapper userMapper, - UserAccountRepository userAccountRepository, - ApiKeyMapper apiKeyMapper, ApiKeyRepository apiKeyRepository, - SearchSavedQueryMapper searchSavedQueryMapper, - SearchSavedQueryRepository searchSavedQueryRepository) { - super(objectMapper); - this.userMapper = userMapper; - this.userAccountRepository = userAccountRepository; - this.apiKeyMapper = apiKeyMapper; - this.apiKeyRepository = apiKeyRepository; - this.searchSavedQueryMapper = searchSavedQueryMapper; - this.searchSavedQueryRepository = searchSavedQueryRepository; - } - - @Override - protected JpaRepository getRepository() { - return userAccountRepository; - } - - @Override - public void bootstrapFromJson(Path resourcePath, BootstrapContext context) { - try { - final UserFixture userFixture = getObjectMapper().readValue(resourcePath.toFile(), UserFixture.class); - final UserAccount userAccount = userAccountRepository.saveAndFlush( - userMapper.fromFixture(userFixture) - ); - for (String token : userFixture.getApiKeyTokens()) { - final ApiKey apiKey = apiKeyRepository.saveAndFlush( - apiKeyMapper.createApiKey(userAccount, token) - ); - log.debug("Created API key for user {} with token {}", - userAccount.getEmail(), apiKey.getToken()); - } - for (SearchSavedQueryFixture queryFixture : userFixture.getSavedQueries()) { - final SearchSavedQuery savedQuery = searchSavedQueryRepository.saveAndFlush( - searchSavedQueryMapper.fromFixture(queryFixture, userAccount) - ); - log.debug("Created saved search query for user {} with UUID {}", - userAccount.getEmail(), savedQuery.getUuid()); - } - context.getUsers().put(userFixture.getUuid(), userAccount); - log.info("Loaded user: {}", userAccount.getEmail()); - } - catch (IOException exception) { - throw new RuntimeException(exception); - } - } -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MembershipFixture.java b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MembershipFixture.java deleted file mode 100644 index acfd6aec9..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MembershipFixture.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.fixtures; - -import lombok.Data; -import org.fairdatapoint.api.dto.membership.MembershipPermissionDTO; - -import java.util.List; -import java.util.UUID; - -@Data -public class MembershipFixture { - private String name; - private List allowedEntities; - private List permissions; -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MetadataSchemaFixture.java b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MetadataSchemaFixture.java deleted file mode 100644 index f661843ff..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MetadataSchemaFixture.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.fixtures; - -import lombok.Data; - -import java.util.List; -import java.util.UUID; - -@Data -public class MetadataSchemaFixture { - private UUID uuid = UUID.randomUUID(); - private List versions; -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MetadataSchemaVersionFixture.java b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MetadataSchemaVersionFixture.java deleted file mode 100644 index 63f71faec..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/MetadataSchemaVersionFixture.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.fixtures; - -import lombok.Data; -import org.fairdatapoint.entity.schema.MetadataSchemaState; -import org.fairdatapoint.entity.schema.MetadataSchemaType; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -@Data -public class MetadataSchemaVersionFixture { - private String version; - private String name; - private String description = ""; - private String definition; - private String definitionFile; - private MetadataSchemaType type = MetadataSchemaType.CUSTOM; - private String origin; - private String importedFrom; - private MetadataSchemaState state = MetadataSchemaState.LATEST; - private Boolean published = false; - private Boolean abstractSchema = false; - private String suggestedResourceName; - private String suggestedUrlPrefix; - private List extendsSchemaUuids = new ArrayList<>(); -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/ResourceDefinitionFixture.java b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/ResourceDefinitionFixture.java deleted file mode 100644 index 58a2b197b..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/ResourceDefinitionFixture.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.fixtures; - -import lombok.Data; -import org.fairdatapoint.api.dto.resource.ResourceDefinitionChildDTO; -import org.fairdatapoint.api.dto.resource.ResourceDefinitionLinkDTO; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -@Data -public class ResourceDefinitionFixture { - private UUID uuid = UUID.randomUUID(); - private String name; - private String urlPrefix; - private List children = new ArrayList<>(); - private List externalLinks = new ArrayList<>(); - private List metadataSchemaUuids = new ArrayList<>(); -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/SearchSavedQueryFixture.java b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/SearchSavedQueryFixture.java deleted file mode 100644 index f85dfdf8a..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/SearchSavedQueryFixture.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.fixtures; - -import lombok.Data; -import org.fairdatapoint.entity.search.SearchSavedQueryType; - -@Data -public class SearchSavedQueryFixture { - private String name; - private String description; - private SearchSavedQueryType type; - private String prefixes; - private String graphPattern; - private String ordering; -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/SettingsFixture.java b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/SettingsFixture.java deleted file mode 100644 index 826095f66..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/SettingsFixture.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.fixtures; - -import lombok.Data; -import org.fairdatapoint.api.dto.search.SearchFilterDTO; -import org.fairdatapoint.api.dto.settings.SettingsAutocompleteSourceDTO; -import org.fairdatapoint.api.dto.settings.SettingsMetricDTO; - -import java.util.ArrayList; -import java.util.List; - -@Data -public class SettingsFixture { - private String appTitle = "FAIR Data Point"; - private String appSubtitle = "Metadata for Machines"; - private Boolean pingEnabled = true; - private List pingEndpoints = new ArrayList<>(); - private Boolean autocompleteSearchNamespace = true; - private List autocompleteSources = new ArrayList<>(); - private List metrics = new ArrayList<>(); - private List searchFilters = new ArrayList<>(); -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/UserFixture.java b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/UserFixture.java deleted file mode 100644 index 04dc440ad..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/UserFixture.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.fixtures; - -import lombok.Data; -import org.fairdatapoint.entity.user.UserRole; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -@Data -public class UserFixture { - private UUID uuid = UUID.randomUUID(); - private String firstName = ""; - private String lastName = ""; - private String email; - private String password; - private UserRole role = UserRole.USER; - private List apiKeyTokens = new ArrayList<>(); - private List savedQueries = new ArrayList<>(); -} diff --git a/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java b/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java index e45fe0417..a1415e3de 100644 --- a/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java +++ b/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java @@ -26,7 +26,6 @@ import org.fairdatapoint.api.dto.membership.MembershipPermissionDTO; import org.fairdatapoint.entity.membership.Membership; import org.fairdatapoint.entity.membership.MembershipPermission; -import org.fairdatapoint.service.bootstrap.fixtures.MembershipFixture; import org.springframework.stereotype.Service; import java.util.UUID; @@ -57,12 +56,5 @@ public MembershipPermission permissionFromDTO(Membership membership, MembershipP .mask(permission.getMask()) .build(); } - - public Membership fromFixture(MembershipFixture membershipFixture) { - return Membership.builder() - .name(membershipFixture.getName()) - .allowedEntities(membershipFixture.getAllowedEntities().stream().map(UUID::toString).toList()) - .build(); - } } diff --git a/src/main/java/org/fairdatapoint/service/resource/ResourceDefinitionMapper.java b/src/main/java/org/fairdatapoint/service/resource/ResourceDefinitionMapper.java index afad49f83..9bd1147d7 100644 --- a/src/main/java/org/fairdatapoint/service/resource/ResourceDefinitionMapper.java +++ b/src/main/java/org/fairdatapoint/service/resource/ResourceDefinitionMapper.java @@ -25,7 +25,6 @@ import org.fairdatapoint.api.dto.resource.*; import org.fairdatapoint.entity.resource.*; import org.fairdatapoint.entity.schema.MetadataSchema; -import org.fairdatapoint.service.bootstrap.fixtures.ResourceDefinitionFixture; import org.springframework.stereotype.Service; import java.time.Instant; @@ -169,14 +168,4 @@ public ResourceDefinitionChildMetadata toChildMetadata( .updatedAt(child.getUpdatedAt()) .build(); } - - public ResourceDefinition fromResourceDefinitionFixture(ResourceDefinitionFixture resourceDefinitionFixture) { - return ResourceDefinition.builder() - .uuid(null) - .name(resourceDefinitionFixture.getName()) - .urlPrefix(resourceDefinitionFixture.getUrlPrefix()) - .createdAt(Instant.now()) - .updatedAt(Instant.now()) - .build(); - } } diff --git a/src/main/java/org/fairdatapoint/service/schema/MetadataSchemaMapper.java b/src/main/java/org/fairdatapoint/service/schema/MetadataSchemaMapper.java index 759602314..2cb816d33 100644 --- a/src/main/java/org/fairdatapoint/service/schema/MetadataSchemaMapper.java +++ b/src/main/java/org/fairdatapoint/service/schema/MetadataSchemaMapper.java @@ -24,7 +24,6 @@ import org.fairdatapoint.api.dto.schema.*; import org.fairdatapoint.entity.schema.*; -import org.fairdatapoint.service.bootstrap.fixtures.MetadataSchemaVersionFixture; import org.springframework.stereotype.Service; import java.time.Instant; @@ -315,24 +314,4 @@ public MetadataSchemaExtension newExtension( .orderPriority(orderPriority) .build(); } - - public MetadataSchemaVersion fromMetadataSchemaVersionFixture(MetadataSchemaVersionFixture versionFixture, - MetadataSchema metadataSchema) { - final List targetClasses = - MetadataSchemaShaclUtils.extractTargetClasses(versionFixture.getDefinition()).stream().toList(); - return MetadataSchemaVersion.builder() - .uuid(UUID.randomUUID()) - .name(versionFixture.getName()) - .description(versionFixture.getDescription()) - .abstractSchema(versionFixture.getAbstractSchema()) - .type(MetadataSchemaType.CUSTOM) - .state(MetadataSchemaState.LATEST) - .version(versionFixture.getVersion()) - .definition(versionFixture.getDefinition()) - .targetClasses(targetClasses) - .suggestedResourceName(versionFixture.getSuggestedResourceName()) - .suggestedUrlPrefix(versionFixture.getSuggestedUrlPrefix()) - .schema(metadataSchema) - .build(); - } } diff --git a/src/main/java/org/fairdatapoint/service/search/query/SearchSavedQueryMapper.java b/src/main/java/org/fairdatapoint/service/search/query/SearchSavedQueryMapper.java index d92d19d8c..a88277f9d 100644 --- a/src/main/java/org/fairdatapoint/service/search/query/SearchSavedQueryMapper.java +++ b/src/main/java/org/fairdatapoint/service/search/query/SearchSavedQueryMapper.java @@ -28,7 +28,6 @@ import org.fairdatapoint.api.dto.search.SearchSavedQueryDTO; import org.fairdatapoint.entity.search.SearchSavedQuery; import org.fairdatapoint.entity.user.UserAccount; -import org.fairdatapoint.service.bootstrap.fixtures.SearchSavedQueryFixture; import org.fairdatapoint.service.user.UserMapper; import org.springframework.stereotype.Component; @@ -102,19 +101,4 @@ public SearchQueryVariablesDTO toVariablesDTO( .ordering(query.getVarOrdering()) .build(); } - - public SearchSavedQuery fromFixture(SearchSavedQueryFixture fixture, UserAccount userAccount) { - return SearchSavedQuery.builder() - .uuid(null) - .name(fixture.getName()) - .description(fixture.getDescription()) - .type(fixture.getType()) - .varPrefixes(fixture.getPrefixes()) - .varGraphPattern(fixture.getGraphPattern()) - .varOrdering(fixture.getOrdering()) - .userAccount(userAccount) - .createdAt(Instant.now()) - .updatedAt(Instant.now()) - .build(); - } } diff --git a/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java b/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java index e189c2e9e..73819df1d 100644 --- a/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java +++ b/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java @@ -202,16 +202,4 @@ public SettingsSearchFilterItem fromSearchFilterItemDTO( .filter(filter) .build(); } - - public Settings fromSettingsFixture(SettingsFixture settingsFixture) { - return Settings.builder() - .appTitle(settingsFixture.getAppTitle()) - .appSubtitle(settingsFixture.getAppSubtitle()) - .pingEnabled(settingsFixture.getPingEnabled()) - .pingEndpoints(settingsFixture.getPingEndpoints()) - .autocompleteSearchNamespace(settingsFixture.getAutocompleteSearchNamespace()) - .createdAt(Instant.now()) - .updatedAt(Instant.now()) - .build(); - } } diff --git a/src/main/java/org/fairdatapoint/service/user/UserMapper.java b/src/main/java/org/fairdatapoint/service/user/UserMapper.java index e511cec26..8d5e78404 100644 --- a/src/main/java/org/fairdatapoint/service/user/UserMapper.java +++ b/src/main/java/org/fairdatapoint/service/user/UserMapper.java @@ -25,7 +25,6 @@ import lombok.RequiredArgsConstructor; import org.fairdatapoint.api.dto.user.*; import org.fairdatapoint.entity.user.UserAccount; -import org.fairdatapoint.service.bootstrap.fixtures.UserFixture; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Component; @@ -65,17 +64,6 @@ public UserAccount fromCreateDTO(UserCreateDTO dto) { .build(); } - public UserAccount fromFixture(UserFixture fixture) { - return UserAccount.builder() - .uuid(null) - .firstName(fixture.getFirstName()) - .lastName(fixture.getLastName()) - .email(fixture.getEmail()) - .passwordHash(passwordEncoder.encode(fixture.getPassword())) - .role(fixture.getRole()) - .build(); - } - public UserAccount fromChangeDTO(UserChangeDTO dto, UserAccount user) { return user diff --git a/src/main/java/org/fairdatapoint/util/CustomUuidGenerator.java b/src/main/java/org/fairdatapoint/util/CustomUuidGenerator.java new file mode 100644 index 000000000..8c58ed69a --- /dev/null +++ b/src/main/java/org/fairdatapoint/util/CustomUuidGenerator.java @@ -0,0 +1,62 @@ +package org.fairdatapoint.util; + +import org.fairdatapoint.entity.base.CustomGeneratedUUID; +import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.generator.EventType; +import org.hibernate.id.factory.spi.CustomIdGeneratorCreationContext; +import org.hibernate.id.uuid.UuidGenerator; +import org.hibernate.id.uuid.UuidValueGenerator; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Member; +import java.util.UUID; + +public class CustomUuidGenerator extends UuidGenerator { + + public CustomUuidGenerator( + CustomGeneratedUUID config, + Member member, + CustomIdGeneratorCreationContext creationContext + ) { + super(createUuidGeneratorFromCustomUuid(config), member, creationContext); + } + + @Override + public Object generate( + SharedSessionContractImplementor session, + Object owner, + Object currentValue, + EventType eventType + ) { + if (currentValue instanceof UUID) { + return currentValue; + } + return super.generate(session, owner, currentValue, eventType); + } + + @Override + public boolean allowAssignedIdentifiers() { + return true; + } + + private static org.hibernate.annotations.UuidGenerator createUuidGeneratorFromCustomUuid( + CustomGeneratedUUID annotation + ) { + return new org.hibernate.annotations.UuidGenerator() { + @Override + public Class annotationType() { + return org.hibernate.annotations.UuidGenerator.class; + } + + @Override + public Style style() { + return annotation.style(); + } + + @Override + public Class algorithm() { + return annotation.algorithm(); + } + }; + } +} diff --git a/src/main/resources/fixtures/0010_settings.json b/src/main/resources/fixtures/0010_settings.json new file mode 100644 index 000000000..f0ce8d700 --- /dev/null +++ b/src/main/resources/fixtures/0010_settings.json @@ -0,0 +1,33 @@ +[ + { + "_class": "org.fairdatapoint.entity.settings.Settings", + "uuid": "00000000-0000-0000-0000-000000000000", + "appTitle": "FAIR Data Point", + "appSubtitle": "Metadata for Machines", + "pingEnabled": true, + "pingEndpoints": [ + "https://home.fairdatapoint.org" + ], + "autocompleteSearchNamespace": true + }, + { + "_class": "org.fairdatapoint.entity.settings.SettingsMetric", + "uuid": "8435491b-c16c-4457-ae94-e0f4128603d5", + "settings": { + "uuid": "00000000-0000-0000-0000-000000000000" + }, + "metricUri": "https://purl.org/fair-metrics/FM_F1A", + "resourceUri": "https://www.ietf.org/rfc/rfc3986.txt", + "orderPriority": 0 + }, + { + "_class": "org.fairdatapoint.entity.settings.SettingsMetric", + "uuid": "af93d36a-0af0-4054-8c00-2675d460b231", + "settings": { + "uuid": "00000000-0000-0000-0000-000000000000" + }, + "metricUri": "https://purl.org/fair-metrics/FM_A1.1", + "resourceUri": "https://www.wikidata.org/wiki/Q8777", + "orderPriority": 0 + } +] diff --git a/src/main/resources/fixtures/0100_user-accounts.json b/src/main/resources/fixtures/0100_user-accounts.json new file mode 100644 index 000000000..4b5f3d3b1 --- /dev/null +++ b/src/main/resources/fixtures/0100_user-accounts.json @@ -0,0 +1,20 @@ +[ + { + "_class" : "org.fairdatapoint.entity.user.UserAccount", + "uuid": "7e64818d-6276-46fb-8bb1-732e6e09f7e9", + "firstName": "Albert", + "lastName": "Einstein", + "email": "albert.einstein@example.org", + "passwordHash": "$2a$10$hZF1abbZ48Tf.3RndC9W6OlDt6gnBoD/2HbzJayTs6be7d.5DbpnW", + "role": "ADMIN" + }, + { + "_class" : "org.fairdatapoint.entity.user.UserAccount", + "uuid": "b5b92c69-5ed9-4054-954d-0121c29b6800", + "firstName": "Nikola", + "lastName": "Tesla", + "email": "nikola.tesla@example.org", + "passwordHash": "$2a$10$tMbZUZg9AbYL514R.hZ0tuzvfZJR5NQhSVeJPTQhNwPf6gv/cvrna", + "role": "USER" + } +] diff --git a/src/main/resources/fixtures/0110_api-keys.json b/src/main/resources/fixtures/0110_api-keys.json new file mode 100644 index 000000000..64521759d --- /dev/null +++ b/src/main/resources/fixtures/0110_api-keys.json @@ -0,0 +1,10 @@ +[ + { + "_class" : "org.fairdatapoint.entity.apikey.ApiKey", + "uuid": "761aa902-8a0a-4a19-9c81-4e106c579b29", + "token": "example-token", + "userAccount": { + "uuid": "7e64818d-6276-46fb-8bb1-732e6e09f7e9" + } + } +] diff --git a/src/main/resources/fixtures/0120_saved-queries.json b/src/main/resources/fixtures/0120_saved-queries.json new file mode 100644 index 000000000..e49fd726a --- /dev/null +++ b/src/main/resources/fixtures/0120_saved-queries.json @@ -0,0 +1,15 @@ +[ + { + "_class" : "org.fairdatapoint.entity.search.SearchSavedQuery", + "uuid": "e5e16561-97db-4518-a41e-2cc8736ec06f", + "name": "All datasets", + "description": "Quickly query all datasets (DCAT)", + "type": "PUBLIC", + "varPrefixes": "PREFIX dcat: ", + "varGraphPattern": "?entity rdf:type dcat:Dataset .", + "varOrdering": "ASC(?title)", + "userAccount": { + "uuid": "7e64818d-6276-46fb-8bb1-732e6e09f7e9" + } + } +] diff --git a/src/main/resources/fixtures/0200_metadata-schemas_resource.json b/src/main/resources/fixtures/0200_metadata-schemas_resource.json new file mode 100644 index 000000000..3c0f659fe --- /dev/null +++ b/src/main/resources/fixtures/0200_metadata-schemas_resource.json @@ -0,0 +1,26 @@ +[ + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchema", + "uuid": "6a668323-3936-4b53-8380-a4fd2ed082ee" + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "71d77460-f919-4f72-b265-ed26567fe361", + "schema": { + "uuid": "6a668323-3936-4b53-8380-a4fd2ed082ee" + }, + "version": "1.0.0", + "name": "Resource", + "description": "", + "definition": "@prefix : .\n@prefix dash: .\n@prefix dcat: .\n@prefix dct: .\n@prefix foaf: .\n@prefix sh: .\n@prefix xsd: .\n\n:ResourceShape a sh:NodeShape ;\n sh:targetClass dcat:Resource ;\n sh:property [\n sh:path dct:title ;\n sh:nodeKind sh:Literal ;\n sh:minCount 1 ;\n sh:maxCount 1 ;\n dash:editor dash:TextFieldEditor ;\n sh:order 1 ;\n ], [\n sh:path dct:description ;\n sh:nodeKind sh:Literal ;\n sh:maxCount 1 ;\n dash:editor dash:TextAreaEditor ;\n sh:order 2 ;\n ], [\n sh:path dct:publisher ;\n sh:node :AgentShape ;\n sh:minCount 1 ;\n sh:maxCount 1 ;\n dash:editor dash:BlankNodeEditor ;\n sh:order 3 ;\n ], [\n sh:path dcat:version ;\n sh:name \"version\" ;\n sh:nodeKind sh:Literal ;\n sh:minCount 1 ;\n sh:maxCount 1 ;\n dash:editor dash:TextFieldEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 4 ;\n ], [\n sh:path dct:language ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n sh:defaultValue ;\n sh:order 5 ;\n ], [\n sh:path dct:license ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n sh:defaultValue ;\n sh:order 6 ;\n ], [\n sh:path dct:rights ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n sh:order 7 ;\n ] .\n\n:AgentShape a sh:NodeShape ;\n sh:targetClass foaf:Agent ;\n sh:property [\n sh:path foaf:name ;\n sh:nodeKind sh:Literal ;\n sh:minCount 1 ;\n sh:maxCount 1 ;\n dash:editor dash:TextFieldEditor ;\n ] .\n", + "targetClasses": ["http://www.w3.org/ns/dcat#Resource"], + "type": "INTERNAL", + "origin": null, + "importedFrom": null, + "state": "LATEST", + "published": false, + "abstractSchema": true, + "suggestedResourceName": null, + "suggestedUrlPrefix": null + } +] diff --git a/src/main/resources/fixtures/0210_metadata-schemas_data-service.json b/src/main/resources/fixtures/0210_metadata-schemas_data-service.json new file mode 100644 index 000000000..41fc172db --- /dev/null +++ b/src/main/resources/fixtures/0210_metadata-schemas_data-service.json @@ -0,0 +1,40 @@ +[ + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchema", + "uuid": "89d94c1b-f6ff-4545-ba9b-120b2d1921d0" + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "9111d436-fe58-4bd5-97ae-e6f86bc2997a", + "schema": { + "uuid": "89d94c1b-f6ff-4545-ba9b-120b2d1921d0" + }, + "version": "1.0.0", + "name": "Data Service", + "description": "", + "definition": "@prefix : .\n@prefix dash: .\n@prefix dcat: .\n@prefix dct: .\n@prefix sh: .\n@prefix xsd: .\n\n:DataServiceShape a sh:NodeShape ;\n sh:targetClass dcat:DataService ;\n sh:property [\n sh:path dcat:endpointURL ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n sh:order 20 ;\n ] , [\n sh:path dcat:endpointDescription ;\n sh:nodeKind sh:Literal ;\n sh:maxCount 1 ;\n dash:editor dash:TextAreaEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 21 ;\n ] .\n", + "targetClasses": [ + "http://www.w3.org/ns/dcat#Resource", + "http://www.w3.org/ns/dcat#DataService" + ], + "type": "INTERNAL", + "origin": null, + "importedFrom": null, + "state": "LATEST", + "published": false, + "abstractSchema": false, + "suggestedResourceName": null, + "suggestedUrlPrefix": null + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaExtension", + "uuid": "2efc8366-541d-493f-8661-69ad8f72dfa1", + "metadataSchemaVersion": { + "uuid": "9111d436-fe58-4bd5-97ae-e6f86bc2997a" + }, + "extendedMetadataSchema": { + "uuid": "6a668323-3936-4b53-8380-a4fd2ed082ee" + }, + "orderPriority": 0 + } +] diff --git a/src/main/resources/fixtures/0220_metadata-schemas_metadata-service.json b/src/main/resources/fixtures/0220_metadata-schemas_metadata-service.json new file mode 100644 index 000000000..401b48f32 --- /dev/null +++ b/src/main/resources/fixtures/0220_metadata-schemas_metadata-service.json @@ -0,0 +1,41 @@ +[ + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchema", + "uuid": "6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad" + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "36b22b70-6203-4dd2-9fb6-b39a776bf467", + "schema": { + "uuid": "6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad" + }, + "version": "1.0.0", + "name": "Metadata Service", + "description": "", + "definition": "@prefix : .\n@prefix fdp: .\n@prefix sh: .\n\n:MetadataServiceShape a sh:NodeShape ;\n sh:targetClass fdp:MetadataService .\n", + "targetClasses": [ + "http://www.w3.org/ns/dcat#Resource", + "http://www.w3.org/ns/dcat#DataService", + "https://w3id.org/fdp/fdp-o#MetadataService" + ], + "type": "INTERNAL", + "origin": null, + "importedFrom": null, + "state": "LATEST", + "published": false, + "abstractSchema": false, + "suggestedResourceName": null, + "suggestedUrlPrefix": null + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaExtension", + "uuid": "8742361b-cd00-4167-b859-e45fa36d0cb7", + "metadataSchemaVersion": { + "uuid": "36b22b70-6203-4dd2-9fb6-b39a776bf467" + }, + "extendedMetadataSchema": { + "uuid": "89d94c1b-f6ff-4545-ba9b-120b2d1921d0" + }, + "orderPriority": 0 + } +] diff --git a/src/main/resources/fixtures/0230_metadata-schemas_fdp.json b/src/main/resources/fixtures/0230_metadata-schemas_fdp.json new file mode 100644 index 000000000..fa30f3a0a --- /dev/null +++ b/src/main/resources/fixtures/0230_metadata-schemas_fdp.json @@ -0,0 +1,42 @@ +[ + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchema", + "uuid": "a92958ab-a414-47e6-8e17-68ba96ba3a2b" + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "4e64208d-f102-45a0-96e3-17b002e6213e", + "schema": { + "uuid": "a92958ab-a414-47e6-8e17-68ba96ba3a2b" + }, + "version": "1.0.0", + "name": "FAIR Data Point", + "description": "", + "definition": "@prefix : .\n@prefix dash: .\n@prefix dct: .\n@prefix fdp: .\n@prefix sh: .\n@prefix xsd: .\n\n:FDPShape a sh:NodeShape ;\n sh:targetClass fdp:FAIRDataPoint ;\n sh:property [\n sh:path fdp:startDate ;\n sh:datatype xsd:date ;\n sh:maxCount 1 ;\n dash:editor dash:DatePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 40 ;\n ] , [\n sh:path fdp:endDate ;\n sh:datatype xsd:date ;\n sh:maxCount 1 ;\n dash:editor dash:DatePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 41 ;\n ] , [\n sh:path fdp:uiLanguage ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n sh:defaultValue ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n sh:order 42 ;\n ] , [\n sh:path fdp:metadataIdentifier ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n sh:order 43 ;\n ] .\n", + "targetClasses": [ + "http://www.w3.org/ns/dcat#Resource", + "http://www.w3.org/ns/dcat#DataService", + "https://w3id.org/fdp/fdp-o#MetadataService", + "https://w3id.org/fdp/fdp-o#FAIRDataPoint" + ], + "type": "INTERNAL", + "origin": null, + "importedFrom": null, + "state": "LATEST", + "published": false, + "abstractSchema": false, + "suggestedResourceName": null, + "suggestedUrlPrefix": null + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaExtension", + "uuid": "afebd441-8aa5-464d-bc3c-033f175449b4", + "metadataSchemaVersion": { + "uuid": "4e64208d-f102-45a0-96e3-17b002e6213e" + }, + "extendedMetadataSchema": { + "uuid": "6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad" + }, + "orderPriority": 0 + } +] diff --git a/src/main/resources/fixtures/0240_metadata-schemas_catalog.json b/src/main/resources/fixtures/0240_metadata-schemas_catalog.json new file mode 100644 index 000000000..f3c549962 --- /dev/null +++ b/src/main/resources/fixtures/0240_metadata-schemas_catalog.json @@ -0,0 +1,40 @@ +[ + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchema", + "uuid": "2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660" + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "c9640671-945d-4114-88fb-e81314cb7ab2", + "schema": { + "uuid": "2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660" + }, + "version": "1.0.0", + "name": "Catalog", + "description": "", + "definition": "@prefix : .\n@prefix dash: .\n@prefix dcat: .\n@prefix dct: .\n@prefix foaf: .\n@prefix sh: .\n@prefix xsd: .\n\n:CatalogShape a sh:NodeShape ;\n sh:targetClass dcat:Catalog ;\n sh:property [\n sh:path dct:issued ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:viewer dash:LiteralViewer ;\n sh:order 20 ;\n ], [\n sh:path dct:modified ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:viewer dash:LiteralViewer ;\n sh:order 21 ;\n ], [\n sh:path foaf:homePage ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n sh:order 22 ;\n ], [\n sh:path dcat:themeTaxonomy ;\n sh:nodeKind sh:IRI ;\n dash:viewer dash:LabelViewer ;\n sh:order 23 ;\n ] .\n", + "targetClasses": [ + "http://www.w3.org/ns/dcat#Resource", + "http://www.w3.org/ns/dcat#Catalog" + ], + "type": "INTERNAL", + "origin": null, + "importedFrom": null, + "state": "LATEST", + "published": false, + "abstractSchema": false, + "suggestedResourceName": "Catalog", + "suggestedUrlPrefix": "catalog" + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaExtension", + "uuid": "e75cb601-318d-41ea-9a8b-32e0749c80a7", + "metadataSchemaVersion": { + "uuid": "c9640671-945d-4114-88fb-e81314cb7ab2" + }, + "extendedMetadataSchema": { + "uuid": "6a668323-3936-4b53-8380-a4fd2ed082ee" + }, + "orderPriority": 0 + } +] diff --git a/src/main/resources/fixtures/0250_metadata-schemas_dataset.json b/src/main/resources/fixtures/0250_metadata-schemas_dataset.json new file mode 100644 index 000000000..70fe0c4ba --- /dev/null +++ b/src/main/resources/fixtures/0250_metadata-schemas_dataset.json @@ -0,0 +1,40 @@ +[ + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchema", + "uuid": "866d7fb8-5982-4215-9c7c-18d0ed1bd5f3" + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "9cc3c89a-76cf-4639-a71f-652627af51db", + "schema": { + "uuid": "866d7fb8-5982-4215-9c7c-18d0ed1bd5f3" + }, + "version": "1.0.0", + "name": "Dataset", + "description": "", + "definition": "@prefix : .\n@prefix dash: .\n@prefix dcat: .\n@prefix dct: .\n@prefix sh: .\n@prefix xsd: .\n\n:DatasetShape a sh:NodeShape ;\n sh:targetClass dcat:Dataset ;\n sh:property [\n sh:path dct:issued ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:editor dash:DateTimePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 20 ;\n ], [\n sh:path dct:modified ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:editor dash:DateTimePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 21 ;\n ], [\n sh:path dcat:theme ;\n sh:nodeKind sh:IRI ;\n sh:minCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n sh:order 22 ;\n ], [\n sh:path dcat:contactPoint ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n sh:order 23 ;\n ], [\n sh:path dcat:keyword ;\n sh:nodeKind sh:Literal ;\n dash:editor dash:TextFieldEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 24 ;\n ], [\n sh:path dcat:landingPage ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n sh:order 25 ;\n ] .\n", + "targetClasses": [ + "http://www.w3.org/ns/dcat#Resource", + "http://www.w3.org/ns/dcat#Dataset" + ], + "type": "INTERNAL", + "origin": null, + "importedFrom": null, + "state": "LATEST", + "published": false, + "abstractSchema": false, + "suggestedResourceName": "Dataset", + "suggestedUrlPrefix": "dataset" + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaExtension", + "uuid": "da13ba37-09f8-4937-9055-e3ee3aefc57c", + "metadataSchemaVersion": { + "uuid": "9cc3c89a-76cf-4639-a71f-652627af51db" + }, + "extendedMetadataSchema": { + "uuid": "6a668323-3936-4b53-8380-a4fd2ed082ee" + }, + "orderPriority": 0 + } +] diff --git a/src/main/resources/fixtures/0260_metadata-schemas_distribution.json b/src/main/resources/fixtures/0260_metadata-schemas_distribution.json new file mode 100644 index 000000000..3ebe704f2 --- /dev/null +++ b/src/main/resources/fixtures/0260_metadata-schemas_distribution.json @@ -0,0 +1,40 @@ +[ + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchema", + "uuid": "ebacbf83-cd4f-4113-8738-d73c0735b0ab" + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "3cda8cd3-b08b-4797-822d-d3f3e83c466a", + "schema": { + "uuid": "ebacbf83-cd4f-4113-8738-d73c0735b0ab" + }, + "version": "1.0.0", + "name": "Distribution", + "description": "", + "definition": "@prefix : .\n@prefix dash: .\n@prefix dcat: .\n@prefix dct: .\n@prefix sh: .\n@prefix xsd: .\n\n:DistributionShape a sh:NodeShape ;\n sh:targetClass dcat:Distribution ;\n sh:property [\n sh:path dct:issued ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:editor dash:DateTimePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 20 ;\n ], [\n sh:path dct:modified ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:editor dash:DateTimePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 21 ;\n ], [\n sh:path dcat:accessURL ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n sh:order 22 ;\n ], [\n sh:path dcat:downloadURL ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n sh:order 23 ;\n ], [\n sh:path dcat:mediaType ;\n sh:nodeKind sh:Literal ;\n sh:minCount 1 ;\n sh:maxCount 1 ;\n dash:editor dash:TextFieldEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 24 ;\n ], [\n sh:path dcat:format ;\n sh:nodeKind sh:Literal ;\n sh:maxCount 1 ;\n dash:editor dash:TextFieldEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 25 ;\n ], [\n sh:path dcat:byteSize ;\n sh:nodeKind sh:Literal ;\n sh:maxCount 1 ;\n dash:editor dash:TextFieldEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 26 ;\n ] .\n", + "targetClasses": [ + "http://www.w3.org/ns/dcat#Resource", + "http://www.w3.org/ns/dcat#Distribution" + ], + "type": "INTERNAL", + "origin": null, + "importedFrom": null, + "state": "LATEST", + "published": false, + "abstractSchema": false, + "suggestedResourceName": "Distribution", + "suggestedUrlPrefix": "distribution" + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaExtension", + "uuid": "a3b16a4e-cac7-4b71-a3de-94bb86714b5b", + "metadataSchemaVersion": { + "uuid": "3cda8cd3-b08b-4797-822d-d3f3e83c466a" + }, + "extendedMetadataSchema": { + "uuid": "6a668323-3936-4b53-8380-a4fd2ed082ee" + }, + "orderPriority": 0 + } +] diff --git a/src/main/resources/fixtures/0300_resource-definitions_distribution.json b/src/main/resources/fixtures/0300_resource-definitions_distribution.json new file mode 100644 index 000000000..f48199a38 --- /dev/null +++ b/src/main/resources/fixtures/0300_resource-definitions_distribution.json @@ -0,0 +1,39 @@ +[ + { + "_class": "org.fairdatapoint.entity.resource.ResourceDefinition", + "uuid": "02c649de-c579-43bb-b470-306abdc808c7", + "name": "Distribution", + "urlPrefix": "distribution" + }, + { + "_class": "org.fairdatapoint.entity.resource.ResourceDefinitionLink", + "uuid": "660a1821-a5d2-48d0-a26b-0c6d5bac3de4", + "resourceDefinition": { + "uuid": "02c649de-c579-43bb-b470-306abdc808c7" + }, + "title": "Access online", + "propertyUri": "http://www.w3.org/ns/dcat#accessURL", + "orderPriority": 0 + }, + { + "_class": "org.fairdatapoint.entity.resource.ResourceDefinitionLink", + "uuid": "c2eaebb8-4d8d-469d-8736-269adeded996", + "resourceDefinition": { + "uuid": "02c649de-c579-43bb-b470-306abdc808c7" + }, + "title": "Download", + "propertyUri": "http://www.w3.org/ns/dcat#downloadURL", + "orderPriority": 1 + }, + { + "_class": "org.fairdatapoint.entity.resource.MetadataSchemaUsage", + "uuid": "bbf4ecb3-c529-4c02-955c-7160755debf5", + "resourceDefinition": { + "uuid": "02c649de-c579-43bb-b470-306abdc808c7" + }, + "usedMetadataSchema": { + "uuid": "ebacbf83-cd4f-4113-8738-d73c0735b0ab" + }, + "orderPriority": 0 + } +] diff --git a/src/main/resources/fixtures/0310_resource-definitions_dataset.json b/src/main/resources/fixtures/0310_resource-definitions_dataset.json new file mode 100644 index 000000000..8521fb5c1 --- /dev/null +++ b/src/main/resources/fixtures/0310_resource-definitions_dataset.json @@ -0,0 +1,43 @@ +[ + { + "_class": "org.fairdatapoint.entity.resource.ResourceDefinition", + "uuid": "2f08228e-1789-40f8-84cd-28e3288c3604", + "name": "Dataset", + "urlPrefix": "dataset" + }, + { + "_class": "org.fairdatapoint.entity.resource.ResourceDefinitionChild", + "uuid": "9f138a13-9d45-4371-b763-0a3b9e0ec912", + "source": { + "uuid": "2f08228e-1789-40f8-84cd-28e3288c3604" + }, + "target": { + "uuid": "02c649de-c579-43bb-b470-306abdc808c7" + }, + "relationUri": "http://www.w3.org/ns/dcat#distribution", + "title": "Distributions", + "tagsUri": null, + "orderPriority": 0 + }, + { + "_class": "org.fairdatapoint.entity.resource.ResourceDefinitionChildMetadata", + "uuid": "723e95d3-1696-45e2-9429-f6e98e3fb893", + "child": { + "uuid": "9f138a13-9d45-4371-b763-0a3b9e0ec912" + }, + "title": "Media Type", + "propertyUri": "http://www.w3.org/ns/dcat#mediaType", + "orderPriority": 0 + }, + { + "_class": "org.fairdatapoint.entity.resource.MetadataSchemaUsage", + "uuid": "b8a0ed37-42a1-487e-8842-09fe082c4cc6", + "resourceDefinition": { + "uuid": "2f08228e-1789-40f8-84cd-28e3288c3604" + }, + "usedMetadataSchema": { + "uuid": "866d7fb8-5982-4215-9c7c-18d0ed1bd5f3" + }, + "orderPriority": 0 + } +] diff --git a/src/main/resources/fixtures/0320_resource-definitions_catalog.json b/src/main/resources/fixtures/0320_resource-definitions_catalog.json new file mode 100644 index 000000000..27f4c115b --- /dev/null +++ b/src/main/resources/fixtures/0320_resource-definitions_catalog.json @@ -0,0 +1,33 @@ +[ + { + "_class": "org.fairdatapoint.entity.resource.ResourceDefinition", + "uuid": "a0949e72-4466-4d53-8900-9436d1049a4b", + "name": "Catalog", + "urlPrefix": "catalog" + }, + { + "_class": "org.fairdatapoint.entity.resource.ResourceDefinitionChild", + "uuid": "e9f0f5d3-2a93-4aa3-9dd0-acb1d76f54fc", + "source": { + "uuid": "a0949e72-4466-4d53-8900-9436d1049a4b" + }, + "target": { + "uuid": "2f08228e-1789-40f8-84cd-28e3288c3604" + }, + "relationUri": "http://www.w3.org/ns/dcat#dataset", + "title": "Datasets", + "tagsUri": "http://www.w3.org/ns/dcat#theme", + "orderPriority": 0 + }, + { + "_class": "org.fairdatapoint.entity.resource.MetadataSchemaUsage", + "uuid": "e4df9510-a3ad-4e3b-a1a9-5fc330d8b1f0", + "resourceDefinition": { + "uuid": "a0949e72-4466-4d53-8900-9436d1049a4b" + }, + "usedMetadataSchema": { + "uuid": "2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660" + }, + "orderPriority": 0 + } +] diff --git a/src/main/resources/fixtures/0330_resource-definitions_repository.json b/src/main/resources/fixtures/0330_resource-definitions_repository.json new file mode 100644 index 000000000..3ee9837da --- /dev/null +++ b/src/main/resources/fixtures/0330_resource-definitions_repository.json @@ -0,0 +1,33 @@ +[ + { + "_class": "org.fairdatapoint.entity.resource.ResourceDefinition", + "uuid": "77aaad6a-0136-4c6e-88b9-07ffccd0ee4c", + "name": "FAIR Data Point", + "urlPrefix": "" + }, + { + "_class": "org.fairdatapoint.entity.resource.ResourceDefinitionChild", + "uuid": "b8648597-8fbd-4b89-9e30-5eab82675e42", + "source": { + "uuid": "77aaad6a-0136-4c6e-88b9-07ffccd0ee4c" + }, + "target": { + "uuid": "a0949e72-4466-4d53-8900-9436d1049a4b" + }, + "relationUri": "https://w3id.org/fdp/fdp-o#metadataCatalog", + "title": "Catalogs", + "tagsUri": "http://www.w3.org/ns/dcat#themeTaxonomy", + "orderPriority": 0 + }, + { + "_class": "org.fairdatapoint.entity.resource.MetadataSchemaUsage", + "uuid": "9b3a32a8-a14c-4eb0-ba02-3aa8e13a8f11", + "resourceDefinition": { + "uuid": "77aaad6a-0136-4c6e-88b9-07ffccd0ee4c" + }, + "usedMetadataSchema": { + "uuid": "a92958ab-a414-47e6-8e17-68ba96ba3a2b" + }, + "orderPriority": 0 + } +] diff --git a/src/main/resources/fixtures/0400_memberships_owner.json b/src/main/resources/fixtures/0400_memberships_owner.json new file mode 100644 index 000000000..35b3d9585 --- /dev/null +++ b/src/main/resources/fixtures/0400_memberships_owner.json @@ -0,0 +1,48 @@ +[ + { + "_class": "org.fairdatapoint.entity.membership.Membership", + "uuid": "49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8", + "name": "Owner", + "allowedEntities": [ + "a0949e72-4466-4d53-8900-9436d1049a4b", + "2f08228e-1789-40f8-84cd-28e3288c3604", + "02c649de-c579-43bb-b470-306abdc808c7" + ] + }, + { + "_class": "org.fairdatapoint.entity.membership.MembershipPermission", + "uuid": "e0d9f853-637b-4c50-9ad9-07b6349bf76f", + "membership": { + "uuid": "49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8" + }, + "mask": 2, + "code": "W" + }, + { + "_class": "org.fairdatapoint.entity.membership.MembershipPermission", + "uuid": "de4e4f85-f11d-475b-b6f0-33bdfe5f923a", + "membership": { + "uuid": "49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8" + }, + "mask": 4, + "code": "C" + }, + { + "_class": "org.fairdatapoint.entity.membership.MembershipPermission", + "uuid": "60bebbf0-210d-4b05-af85-ca1b58546261", + "membership": { + "uuid": "49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8" + }, + "mask": 8, + "code": "D" + }, + { + "_class": "org.fairdatapoint.entity.membership.MembershipPermission", + "uuid": "36c3b6e9-f2e3-48b7-bae1-4dc3196a3657", + "membership": { + "uuid": "49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8" + }, + "mask": 16, + "code": "A" + } +] diff --git a/src/main/resources/fixtures/0410_memberships_data-provider.json b/src/main/resources/fixtures/0410_memberships_data-provider.json new file mode 100644 index 000000000..f968cff75 --- /dev/null +++ b/src/main/resources/fixtures/0410_memberships_data-provider.json @@ -0,0 +1,19 @@ +[ + { + "_class": "org.fairdatapoint.entity.membership.Membership", + "uuid": "87a2d984-7db2-43f6-805c-6b0040afead5", + "name": "Data Provider", + "allowedEntities": [ + "a0949e72-4466-4d53-8900-9436d1049a4b" + ] + }, + { + "_class": "org.fairdatapoint.entity.membership.MembershipPermission", + "uuid": "589d09d3-1c29-4c6f-97fc-6ea4e007fb85", + "membership": { + "uuid": "87a2d984-7db2-43f6-805c-6b0040afead5" + }, + "mask": 4, + "code": "C" + } +] From 5fe8fcb20be05ef202a10de038617eb06770ae11 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Fri, 17 Oct 2025 16:46:00 +0200 Subject: [PATCH 04/53] add autogenerated license text --- .../fairdatapoint/config/BootstrapConfig.java | 22 +++++++++++++++++++ .../entity/base/CustomGeneratedUUID.java | 22 +++++++++++++++++++ .../util/CustomUuidGenerator.java | 22 +++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java index dfe51b8f3..d6659a0b8 100644 --- a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package org.fairdatapoint.config; import org.springframework.context.annotation.Bean; diff --git a/src/main/java/org/fairdatapoint/entity/base/CustomGeneratedUUID.java b/src/main/java/org/fairdatapoint/entity/base/CustomGeneratedUUID.java index 50fda0cad..35a338935 100644 --- a/src/main/java/org/fairdatapoint/entity/base/CustomGeneratedUUID.java +++ b/src/main/java/org/fairdatapoint/entity/base/CustomGeneratedUUID.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package org.fairdatapoint.entity.base; import org.fairdatapoint.util.CustomUuidGenerator; diff --git a/src/main/java/org/fairdatapoint/util/CustomUuidGenerator.java b/src/main/java/org/fairdatapoint/util/CustomUuidGenerator.java index 8c58ed69a..f4a4a4dfa 100644 --- a/src/main/java/org/fairdatapoint/util/CustomUuidGenerator.java +++ b/src/main/java/org/fairdatapoint/util/CustomUuidGenerator.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package org.fairdatapoint.util; import org.fairdatapoint.entity.base.CustomGeneratedUUID; From cde629459bc7ce8fb34d29428cb422ec3abf1cc8 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Fri, 17 Oct 2025 16:47:17 +0200 Subject: [PATCH 05/53] remove unused import --- .../org/fairdatapoint/service/membership/MembershipMapper.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java b/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java index a1415e3de..09d909e57 100644 --- a/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java +++ b/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java @@ -28,7 +28,6 @@ import org.fairdatapoint.entity.membership.MembershipPermission; import org.springframework.stereotype.Service; -import java.util.UUID; import java.util.stream.Collectors; @Service From 1d249982e74580e3a73ae9d51d1204330642fae0 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Fri, 17 Oct 2025 14:16:41 +0200 Subject: [PATCH 06/53] move fixtures dir from src/main/resources into project root --- {src/main/resources/fixtures => fixtures}/0010_settings.json | 0 {src/main/resources/fixtures => fixtures}/0100_user-accounts.json | 0 {src/main/resources/fixtures => fixtures}/0110_api-keys.json | 0 {src/main/resources/fixtures => fixtures}/0120_saved-queries.json | 0 .../fixtures => fixtures}/0200_metadata-schemas_resource.json | 0 .../fixtures => fixtures}/0210_metadata-schemas_data-service.json | 0 .../0220_metadata-schemas_metadata-service.json | 0 .../fixtures => fixtures}/0230_metadata-schemas_fdp.json | 0 .../fixtures => fixtures}/0240_metadata-schemas_catalog.json | 0 .../fixtures => fixtures}/0250_metadata-schemas_dataset.json | 0 .../fixtures => fixtures}/0260_metadata-schemas_distribution.json | 0 .../0300_resource-definitions_distribution.json | 0 .../fixtures => fixtures}/0310_resource-definitions_dataset.json | 0 .../fixtures => fixtures}/0320_resource-definitions_catalog.json | 0 .../0330_resource-definitions_repository.json | 0 .../resources/fixtures => fixtures}/0400_memberships_owner.json | 0 .../fixtures => fixtures}/0410_memberships_data-provider.json | 0 17 files changed, 0 insertions(+), 0 deletions(-) rename {src/main/resources/fixtures => fixtures}/0010_settings.json (100%) rename {src/main/resources/fixtures => fixtures}/0100_user-accounts.json (100%) rename {src/main/resources/fixtures => fixtures}/0110_api-keys.json (100%) rename {src/main/resources/fixtures => fixtures}/0120_saved-queries.json (100%) rename {src/main/resources/fixtures => fixtures}/0200_metadata-schemas_resource.json (100%) rename {src/main/resources/fixtures => fixtures}/0210_metadata-schemas_data-service.json (100%) rename {src/main/resources/fixtures => fixtures}/0220_metadata-schemas_metadata-service.json (100%) rename {src/main/resources/fixtures => fixtures}/0230_metadata-schemas_fdp.json (100%) rename {src/main/resources/fixtures => fixtures}/0240_metadata-schemas_catalog.json (100%) rename {src/main/resources/fixtures => fixtures}/0250_metadata-schemas_dataset.json (100%) rename {src/main/resources/fixtures => fixtures}/0260_metadata-schemas_distribution.json (100%) rename {src/main/resources/fixtures => fixtures}/0300_resource-definitions_distribution.json (100%) rename {src/main/resources/fixtures => fixtures}/0310_resource-definitions_dataset.json (100%) rename {src/main/resources/fixtures => fixtures}/0320_resource-definitions_catalog.json (100%) rename {src/main/resources/fixtures => fixtures}/0330_resource-definitions_repository.json (100%) rename {src/main/resources/fixtures => fixtures}/0400_memberships_owner.json (100%) rename {src/main/resources/fixtures => fixtures}/0410_memberships_data-provider.json (100%) diff --git a/src/main/resources/fixtures/0010_settings.json b/fixtures/0010_settings.json similarity index 100% rename from src/main/resources/fixtures/0010_settings.json rename to fixtures/0010_settings.json diff --git a/src/main/resources/fixtures/0100_user-accounts.json b/fixtures/0100_user-accounts.json similarity index 100% rename from src/main/resources/fixtures/0100_user-accounts.json rename to fixtures/0100_user-accounts.json diff --git a/src/main/resources/fixtures/0110_api-keys.json b/fixtures/0110_api-keys.json similarity index 100% rename from src/main/resources/fixtures/0110_api-keys.json rename to fixtures/0110_api-keys.json diff --git a/src/main/resources/fixtures/0120_saved-queries.json b/fixtures/0120_saved-queries.json similarity index 100% rename from src/main/resources/fixtures/0120_saved-queries.json rename to fixtures/0120_saved-queries.json diff --git a/src/main/resources/fixtures/0200_metadata-schemas_resource.json b/fixtures/0200_metadata-schemas_resource.json similarity index 100% rename from src/main/resources/fixtures/0200_metadata-schemas_resource.json rename to fixtures/0200_metadata-schemas_resource.json diff --git a/src/main/resources/fixtures/0210_metadata-schemas_data-service.json b/fixtures/0210_metadata-schemas_data-service.json similarity index 100% rename from src/main/resources/fixtures/0210_metadata-schemas_data-service.json rename to fixtures/0210_metadata-schemas_data-service.json diff --git a/src/main/resources/fixtures/0220_metadata-schemas_metadata-service.json b/fixtures/0220_metadata-schemas_metadata-service.json similarity index 100% rename from src/main/resources/fixtures/0220_metadata-schemas_metadata-service.json rename to fixtures/0220_metadata-schemas_metadata-service.json diff --git a/src/main/resources/fixtures/0230_metadata-schemas_fdp.json b/fixtures/0230_metadata-schemas_fdp.json similarity index 100% rename from src/main/resources/fixtures/0230_metadata-schemas_fdp.json rename to fixtures/0230_metadata-schemas_fdp.json diff --git a/src/main/resources/fixtures/0240_metadata-schemas_catalog.json b/fixtures/0240_metadata-schemas_catalog.json similarity index 100% rename from src/main/resources/fixtures/0240_metadata-schemas_catalog.json rename to fixtures/0240_metadata-schemas_catalog.json diff --git a/src/main/resources/fixtures/0250_metadata-schemas_dataset.json b/fixtures/0250_metadata-schemas_dataset.json similarity index 100% rename from src/main/resources/fixtures/0250_metadata-schemas_dataset.json rename to fixtures/0250_metadata-schemas_dataset.json diff --git a/src/main/resources/fixtures/0260_metadata-schemas_distribution.json b/fixtures/0260_metadata-schemas_distribution.json similarity index 100% rename from src/main/resources/fixtures/0260_metadata-schemas_distribution.json rename to fixtures/0260_metadata-schemas_distribution.json diff --git a/src/main/resources/fixtures/0300_resource-definitions_distribution.json b/fixtures/0300_resource-definitions_distribution.json similarity index 100% rename from src/main/resources/fixtures/0300_resource-definitions_distribution.json rename to fixtures/0300_resource-definitions_distribution.json diff --git a/src/main/resources/fixtures/0310_resource-definitions_dataset.json b/fixtures/0310_resource-definitions_dataset.json similarity index 100% rename from src/main/resources/fixtures/0310_resource-definitions_dataset.json rename to fixtures/0310_resource-definitions_dataset.json diff --git a/src/main/resources/fixtures/0320_resource-definitions_catalog.json b/fixtures/0320_resource-definitions_catalog.json similarity index 100% rename from src/main/resources/fixtures/0320_resource-definitions_catalog.json rename to fixtures/0320_resource-definitions_catalog.json diff --git a/src/main/resources/fixtures/0330_resource-definitions_repository.json b/fixtures/0330_resource-definitions_repository.json similarity index 100% rename from src/main/resources/fixtures/0330_resource-definitions_repository.json rename to fixtures/0330_resource-definitions_repository.json diff --git a/src/main/resources/fixtures/0400_memberships_owner.json b/fixtures/0400_memberships_owner.json similarity index 100% rename from src/main/resources/fixtures/0400_memberships_owner.json rename to fixtures/0400_memberships_owner.json diff --git a/src/main/resources/fixtures/0410_memberships_data-provider.json b/fixtures/0410_memberships_data-provider.json similarity index 100% rename from src/main/resources/fixtures/0410_memberships_data-provider.json rename to fixtures/0410_memberships_data-provider.json From 9a5c110fa0d4c0e058a5aadc34e60793a27cee35 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Fri, 17 Oct 2025 14:18:37 +0200 Subject: [PATCH 07/53] wire BootstrapProperties into BootstrapConfig using constructor injection instead of field injection --- src/main/java/org/fairdatapoint/config/BootstrapConfig.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java index d6659a0b8..cdb8f77c7 100644 --- a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -22,6 +22,7 @@ */ package org.fairdatapoint.config; +import org.fairdatapoint.config.properties.BootstrapProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.Resource; @@ -36,6 +37,11 @@ @Configuration public class BootstrapConfig { private final ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver(); + private final BootstrapProperties bootstrapProperties; + + public BootstrapConfig(BootstrapProperties bootstrapProperties) { + this.bootstrapProperties = bootstrapProperties; + } @Bean public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { From 44aea3b0fafcb707ba04e9866124e29e9ca6d55a Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Fri, 17 Oct 2025 14:19:57 +0200 Subject: [PATCH 08/53] get fixtures from dir specified in bootstrap.db-fixtures-path --- src/main/java/org/fairdatapoint/config/BootstrapConfig.java | 5 ++++- .../fairdatapoint/config/properties/BootstrapProperties.java | 1 + src/main/resources/application.yml | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java index cdb8f77c7..7f1dc3be3 100644 --- a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -31,6 +31,7 @@ import org.springframework.data.repository.init.Jackson2RepositoryPopulatorFactoryBean; import java.io.IOException; +import java.nio.file.Path; import java.util.Arrays; import java.util.Comparator; @@ -48,7 +49,9 @@ public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { final Jackson2RepositoryPopulatorFactoryBean factory = new Jackson2RepositoryPopulatorFactoryBean(); // load all json resources from the fixtures dir try { - final Resource[] resources = resourceResolver.getResources("classpath:fixtures/*.json"); + // collect fixture resources + final Path fixturesPath = Path.of(bootstrapProperties.getDbFixturesPath(), "*.json"); + final Resource[] resources = resourceResolver.getResources("file:" + fixturesPath); // sort resources to guarantee lexicographic order Arrays.sort( resources, diff --git a/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java b/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java index a7180009c..487336647 100644 --- a/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java +++ b/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java @@ -36,4 +36,5 @@ public class BootstrapProperties { private boolean enabled; private String dataPath; + private String dbFixturesPath; } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 32b61c873..96b6627a4 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -115,3 +115,4 @@ server: bootstrap: enabled: true data-path: '/data' + db-fixtures-path: "fixtures" From 9706c09779b73c558aef60ab72e09e8741ff42b6 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Fri, 17 Oct 2025 16:44:39 +0200 Subject: [PATCH 09/53] copy db fixtures dir into docker image --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index ec1a9fb2d..6040315ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,5 +26,6 @@ USER spring:spring WORKDIR /fdp COPY --from=builder /builder/target/fdp-spring-boot.jar /fdp/app.jar +COPY --from=builder /builder/fixtures /fdp/fixtures ENTRYPOINT ["java", "-jar", "app.jar"] From 52e72f0397cf1f5d7c1e4a8d61d3ca276d6674ff Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Fri, 17 Oct 2025 17:43:41 +0200 Subject: [PATCH 10/53] add some todos w.r.t. rdf data dir --- Dockerfile | 1 + src/main/resources/application.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 6040315ec..592745849 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,5 +27,6 @@ WORKDIR /fdp COPY --from=builder /builder/target/fdp-spring-boot.jar /fdp/app.jar COPY --from=builder /builder/fixtures /fdp/fixtures +# TODO: copy the (rdf) "data" dir as well, or move that into the fixtures dir, e.g. fixtures/rdf and fixtures/db ENTRYPOINT ["java", "-jar", "app.jar"] diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 96b6627a4..465eaaf5d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -114,5 +114,6 @@ server: bootstrap: enabled: true + # TODO: consistent naming for rdf data path and db fixtures path data-path: '/data' db-fixtures-path: "fixtures" From 9779545b54d6b9d51e95cf61ba7eb284d8e91cdc Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Wed, 22 Oct 2025 12:02:59 +0200 Subject: [PATCH 11/53] use bootstrap.enabled property in populator and use @Value injection instead of BootstrapProperties this makes it slightly more difficult to see where the properties are defined in code, but easier to see the name of the actual property in the external config file --- .../fairdatapoint/config/BootstrapConfig.java | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java index 7f1dc3be3..b3fe65873 100644 --- a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -22,7 +22,7 @@ */ package org.fairdatapoint.config; -import org.fairdatapoint.config.properties.BootstrapProperties; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.Resource; @@ -38,33 +38,40 @@ @Configuration public class BootstrapConfig { private final ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver(); - private final BootstrapProperties bootstrapProperties; + private final boolean bootstrapEnabled; + private final Path dbFixturesPath; - public BootstrapConfig(BootstrapProperties bootstrapProperties) { - this.bootstrapProperties = bootstrapProperties; + public BootstrapConfig( + @Value("${bootstrap.enabled:false}") boolean bootstrapEnabled, + @Value("${bootstrap.db-fixtures-path}") String dbFixturesDir + ) { + this.bootstrapEnabled = bootstrapEnabled; + this.dbFixturesPath = Path.of(dbFixturesDir); } @Bean public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { final Jackson2RepositoryPopulatorFactoryBean factory = new Jackson2RepositoryPopulatorFactoryBean(); - // load all json resources from the fixtures dir - try { - // collect fixture resources - final Path fixturesPath = Path.of(bootstrapProperties.getDbFixturesPath(), "*.json"); - final Resource[] resources = resourceResolver.getResources("file:" + fixturesPath); - // sort resources to guarantee lexicographic order - Arrays.sort( - resources, - Comparator.comparing( - Resource::getFilename, - Comparator.nullsLast(String::compareTo) - ) - ); - factory.setResources(resources); - } - catch (IOException exception) { - exception.printStackTrace(); + if (bootstrapEnabled) { + try { + // collect fixture resources + final Path fixturesPath = dbFixturesPath.resolve("*.json"); + final Resource[] resources = resourceResolver.getResources("file:" + fixturesPath); + // sort resources to guarantee lexicographic order + Arrays.sort( + resources, + Comparator.comparing( + Resource::getFilename, + Comparator.nullsLast(String::compareTo) + ) + ); + factory.setResources(resources); + } + catch (IOException exception) { + exception.printStackTrace(); + } } + return factory; } } From 48a87589fabf73bffd9793e37e0787dad16be9de Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Wed, 22 Oct 2025 12:04:02 +0200 Subject: [PATCH 12/53] add some bootstrap logging --- src/main/java/org/fairdatapoint/config/BootstrapConfig.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java index b3fe65873..496f9382b 100644 --- a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -22,6 +22,7 @@ */ package org.fairdatapoint.config; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -36,6 +37,7 @@ import java.util.Comparator; @Configuration +@Slf4j public class BootstrapConfig { private final ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver(); private final boolean bootstrapEnabled; @@ -53,6 +55,7 @@ public BootstrapConfig( public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { final Jackson2RepositoryPopulatorFactoryBean factory = new Jackson2RepositoryPopulatorFactoryBean(); if (bootstrapEnabled) { + log.info("Bootstrap repository populator enabled"); try { // collect fixture resources final Path fixturesPath = dbFixturesPath.resolve("*.json"); @@ -70,6 +73,8 @@ public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { catch (IOException exception) { exception.printStackTrace(); } + } else { + log.info("Bootstrap repository populator disabled"); } return factory; From a1ddea28f2e8ed56522ce6f44bf2c92db56e8869 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Wed, 22 Oct 2025 12:45:38 +0200 Subject: [PATCH 13/53] remove bootstrap.enabled from application.yml we want to rely on the default false, and only override by setting environment property BOOTSTRAP_ENABLED on the command line --- src/main/resources/application.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 465eaaf5d..7aed496d3 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -113,7 +113,6 @@ server: forward-headers-strategy: framework bootstrap: - enabled: true # TODO: consistent naming for rdf data path and db fixtures path data-path: '/data' db-fixtures-path: "fixtures" From 1e050f601487a8152acdb83886563539fbf3e4dc Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Wed, 22 Oct 2025 15:14:09 +0200 Subject: [PATCH 14/53] rename dbFixturesPath property to dbFixturesDir --- src/main/java/org/fairdatapoint/config/BootstrapConfig.java | 2 +- .../fairdatapoint/config/properties/BootstrapProperties.java | 3 ++- src/main/resources/application.yml | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java index 496f9382b..c20164c2f 100644 --- a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -45,7 +45,7 @@ public class BootstrapConfig { public BootstrapConfig( @Value("${bootstrap.enabled:false}") boolean bootstrapEnabled, - @Value("${bootstrap.db-fixtures-path}") String dbFixturesDir + @Value("${bootstrap.db-fixtures-dir}") String dbFixturesDir ) { this.bootstrapEnabled = bootstrapEnabled; this.dbFixturesPath = Path.of(dbFixturesDir); diff --git a/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java b/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java index 487336647..bb5a19091 100644 --- a/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java +++ b/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java @@ -36,5 +36,6 @@ public class BootstrapProperties { private boolean enabled; private String dataPath; - private String dbFixturesPath; + // directories relative to project root + private String dbFixturesDir; } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 7aed496d3..191da5a76 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -113,6 +113,6 @@ server: forward-headers-strategy: framework bootstrap: - # TODO: consistent naming for rdf data path and db fixtures path + # TODO: consistent naming for rdf data path and db fixtures dir data-path: '/data' - db-fixtures-path: "fixtures" + db-fixtures-dir: "fixtures" From 06084a2159441442f0e89238fcb37329b8c295ec Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Wed, 22 Oct 2025 15:52:36 +0200 Subject: [PATCH 15/53] add instructions to BootstrapConfig javadoc --- .../org/fairdatapoint/config/BootstrapConfig.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java index c20164c2f..f25f63bda 100644 --- a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -36,6 +36,17 @@ import java.util.Arrays; import java.util.Comparator; +/** + * The {@code BootstrapConfig} class configures a repository populator to load initial data into the relational database, based on JSON fixture files. + * Bootstrapping is disabled by default, and should only be enabled once, on the very first run of the application. + * It can also be enabled on subsequent runs, but then it will overwrite any changes that may have been made by users. + * To enable on the first run, set the env variable {@code BOOTSTRAP_ENABLED=true} on the command line, before running the app. + * When using e.g. docker compose, you can define {@code BOOTSTRAP_ENABLED: ${BOOTSTRAP_ENABLED:-false}} in the {@code environment} section and then set up the stack by running {@code BOOTSTRAP_ENABLED=true docker compose up -d}. + * The default fixtures are located in the {@code /fixtures} directory. + * To add custom fixtures and/or override any of the default fixtures in a docker compose setup, we can bind-mount individual fixture files. + * For example: {@code ./my-fixtures/0100_user-accounts.json:/fdp/fixtures/0100_user-accounts.json:ro} + * Note that bind-mounting the entire directory, instead of individual files, would hide all default files. + */ @Configuration @Slf4j public class BootstrapConfig { From eef76db3739b893ffcdc29c45e06d63b6403b7d4 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Fri, 24 Oct 2025 16:57:51 +0200 Subject: [PATCH 16/53] fix checkstyle issues --- .../fairdatapoint/config/BootstrapConfig.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java index f25f63bda..4c05478aa 100644 --- a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -37,13 +37,17 @@ import java.util.Comparator; /** - * The {@code BootstrapConfig} class configures a repository populator to load initial data into the relational database, based on JSON fixture files. + * The {@code BootstrapConfig} class configures a repository populator to load initial data into the relational + * database, based on JSON fixture files. * Bootstrapping is disabled by default, and should only be enabled once, on the very first run of the application. * It can also be enabled on subsequent runs, but then it will overwrite any changes that may have been made by users. - * To enable on the first run, set the env variable {@code BOOTSTRAP_ENABLED=true} on the command line, before running the app. - * When using e.g. docker compose, you can define {@code BOOTSTRAP_ENABLED: ${BOOTSTRAP_ENABLED:-false}} in the {@code environment} section and then set up the stack by running {@code BOOTSTRAP_ENABLED=true docker compose up -d}. + * To enable on the first run, set the env variable {@code BOOTSTRAP_ENABLED=true} on the command line, before running + * the app. + * When using e.g. docker compose, you can define {@code BOOTSTRAP_ENABLED: ${BOOTSTRAP_ENABLED:-false}} in the + * {@code environment} section and then set up the stack by running {@code BOOTSTRAP_ENABLED=true docker compose up -d}. * The default fixtures are located in the {@code /fixtures} directory. - * To add custom fixtures and/or override any of the default fixtures in a docker compose setup, we can bind-mount individual fixture files. + * To add custom fixtures and/or override any of the default fixtures in a docker compose setup, we can bind-mount + * individual fixture files. * For example: {@code ./my-fixtures/0100_user-accounts.json:/fdp/fixtures/0100_user-accounts.json:ro} * Note that bind-mounting the entire directory, instead of individual files, would hide all default files. */ @@ -65,7 +69,7 @@ public BootstrapConfig( @Bean public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { final Jackson2RepositoryPopulatorFactoryBean factory = new Jackson2RepositoryPopulatorFactoryBean(); - if (bootstrapEnabled) { + if (bootstrapEnabled) { log.info("Bootstrap repository populator enabled"); try { // collect fixture resources @@ -84,7 +88,8 @@ public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { catch (IOException exception) { exception.printStackTrace(); } - } else { + } + else { log.info("Bootstrap repository populator disabled"); } From 47a7119c1e82135b38e6770f35ce37f595620038 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Mon, 27 Oct 2025 11:47:30 +0100 Subject: [PATCH 17/53] remove files and variables related to RDF bootstrap to be re-applied in a new branch --- Dockerfile | 1 - data/records/records.json | 10 -- data/records/repository.ttl | 28 ----- .../properties/BootstrapProperties.java | 1 - .../service/bootstrap/BootstrapRunner.java | 43 ------- .../service/bootstrap/BootstrapService.java | 59 --------- .../components/AbstractBootstrapper.java | 76 ------------ .../bootstrap/components/IBootstrapper.java | 32 ----- .../MetadataRecordsBootstrapper.java | 112 ------------------ .../bootstrap/fixtures/RecordFixture.java | 32 ----- .../bootstrap/fixtures/RecordsFixture.java | 34 ------ .../service/settings/SettingsMapper.java | 1 - src/main/resources/application.yml | 2 - 13 files changed, 431 deletions(-) delete mode 100644 data/records/records.json delete mode 100644 data/records/repository.ttl delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/BootstrapRunner.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/BootstrapService.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/components/AbstractBootstrapper.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/components/IBootstrapper.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataRecordsBootstrapper.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/fixtures/RecordFixture.java delete mode 100644 src/main/java/org/fairdatapoint/service/bootstrap/fixtures/RecordsFixture.java diff --git a/Dockerfile b/Dockerfile index 592745849..6040315ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,5 @@ WORKDIR /fdp COPY --from=builder /builder/target/fdp-spring-boot.jar /fdp/app.jar COPY --from=builder /builder/fixtures /fdp/fixtures -# TODO: copy the (rdf) "data" dir as well, or move that into the fixtures dir, e.g. fixtures/rdf and fixtures/db ENTRYPOINT ["java", "-jar", "app.jar"] diff --git a/data/records/records.json b/data/records/records.json deleted file mode 100644 index 46c9c64b7..000000000 --- a/data/records/records.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "records": [ - { - "file": "repository.ttl", - "repository": "main", - "uri": "{{ persistentUrl }}" - } - ], - "persistentUrlVar": "{{ persistentUrl }}" -} diff --git a/data/records/repository.ttl b/data/records/repository.ttl deleted file mode 100644 index 3908c213f..000000000 --- a/data/records/repository.ttl +++ /dev/null @@ -1,28 +0,0 @@ -@prefix dcterms: . -@prefix dcat: . -@prefix foaf: . -@prefix xsd: . -@prefix ldp: . - -<{{ persistentUrl }}> a dcat:Resource, dcat:DataService, , - ; - dcterms:title "My FAIR Data Point"; - "My FAIR Data Point"; - dcat:version "1.0"; - dcterms:license ; - dcterms:description "Duis pellentesque, nunc a fringilla varius, magna dui porta quam, nec ultricies augue turpis sed velit. Donec id consectetur ligula. Suspendisse pharetra egestas massa, vel varius leo viverra at. Donec scelerisque id ipsum id semper. Maecenas facilisis augue vel justo molestie aliquet. Maecenas sed mattis lacus, sed viverra risus. Donec iaculis quis lacus vitae scelerisque. Nullam fermentum lectus nisi, id vulputate nisi congue nec. Morbi fermentum justo at justo bibendum, at tempus ipsum tempor. Donec facilisis nibh sed lectus blandit venenatis. Cras ullamcorper, justo vitae feugiat commodo, orci metus suscipit purus, quis sagittis turpis ante eget ex. Pellentesque malesuada a metus eu pulvinar. Morbi rutrum euismod eros at varius. Duis finibus dapibus ex, a hendrerit mauris efficitur at."; - dcterms:language ; - <{{ persistentUrl }}#identifier>; - <{{ persistentUrl }}#identifier>; - dcterms:accessRights <{{ persistentUrl }}#accessRights>; - dcterms:publisher <{{ persistentUrl }}#publisher>; - dcat:endpointURL <{{ persistentUrl }}> . - -<{{ persistentUrl }}#identifier> a ; - dcterms:identifier "{{ persistentUrl }}" . - -<{{ persistentUrl }}#accessRights> a dcterms:RightsStatement; - dcterms:description "This resource has no access restriction" . - -<{{ persistentUrl }}#publisher> a foaf:Agent; - foaf:name "Default Publisher" . diff --git a/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java b/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java index bb5a19091..efe2d084d 100644 --- a/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java +++ b/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java @@ -35,7 +35,6 @@ @ConfigurationProperties(prefix = "bootstrap") public class BootstrapProperties { private boolean enabled; - private String dataPath; // directories relative to project root private String dbFixturesDir; } diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapRunner.java b/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapRunner.java deleted file mode 100644 index b269e6239..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapRunner.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap; - -import lombok.RequiredArgsConstructor; -import org.fairdatapoint.config.properties.BootstrapProperties; -import org.springframework.boot.ApplicationRunner; -import org.springframework.stereotype.Component; - -@Component -@RequiredArgsConstructor -public class BootstrapRunner implements ApplicationRunner { - private final BootstrapProperties bootstrapProperties; - private final BootstrapService bootstrapService; - - @Override - public void run(final org.springframework.boot.ApplicationArguments args) { - if (bootstrapProperties.isEnabled()) { - bootstrapService.bootstrapFromDir(bootstrapProperties.getDataPath()); - } - } - -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapService.java b/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapService.java deleted file mode 100644 index 96636cf4e..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/BootstrapService.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap; - -import jakarta.transaction.Transactional; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.fairdatapoint.service.bootstrap.components.*; -import org.springframework.stereotype.Service; - -import java.nio.file.Path; - -@Slf4j -@Service -@RequiredArgsConstructor -public class BootstrapService { - private final MetadataRecordsBootstrapper metadataRecordsBootstrapper; - - @Transactional - public void bootstrapFromDir(String dataPath) { - final Path basePath = Path.of(dataPath); - log.info("Bootstrap process started"); - - if (!basePath.toFile().exists() || !basePath.toFile().isDirectory()) { - log.warn("Bootstrap directory {} does not exist or is not a directory, skipping bootstrapping", dataPath); - return; - } - - // RDF Records - if (metadataRecordsBootstrapper.shouldBootstrap()) { - metadataRecordsBootstrapper.bootstrapAllFromDir(basePath.resolve("records")); - } - else { - log.info("Metadata Records already exist, skipping metadata records bootstrapping"); - } - - log.info("Bootstrap process finished"); - } -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/components/AbstractBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/AbstractBootstrapper.java deleted file mode 100644 index 87261d84a..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/components/AbstractBootstrapper.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.components; - -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import org.springframework.data.jpa.repository.JpaRepository; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.stream.Stream; - -@Slf4j -public abstract class AbstractBootstrapper implements IBootstrapper { - private final ObjectMapper objectMapper; - - protected AbstractBootstrapper(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } - - @Override - public void bootstrapAllFromDir(Path dirPath) { - if (!Files.isDirectory(dirPath)) { - log.info("Directory {} does not exist, nothing to bootstrap", dirPath); - return; - } - try (Stream paths = Files.walk(dirPath)) { - initBootstrap(); - paths.filter(Files::isRegularFile) - .filter(path -> path.toString().endsWith(".json")) - .forEach(path -> bootstrapFromJson(path)); - finalizeBootstrap(); - } - catch (IOException exception) { - throw new RuntimeException("Error loading entities", exception); - } - } - - protected ObjectMapper getObjectMapper() { - return objectMapper; - } - - protected void initBootstrap() { - } - - protected void finalizeBootstrap() { - getRepository().flush(); - } - - public boolean shouldBootstrap() { - return getRepository().count() == 0; - } - - protected abstract JpaRepository getRepository(); -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/components/IBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/IBootstrapper.java deleted file mode 100644 index 83414e2c1..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/components/IBootstrapper.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.components; - -import java.nio.file.Path; - -public interface IBootstrapper { - - void bootstrapAllFromDir(Path dirPath); - - void bootstrapFromJson(Path resourcePath); -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataRecordsBootstrapper.java b/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataRecordsBootstrapper.java deleted file mode 100644 index 560a426cb..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/components/MetadataRecordsBootstrapper.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.components; - -import lombok.extern.slf4j.Slf4j; -import org.eclipse.rdf4j.model.Model; -import org.eclipse.rdf4j.model.Statement; -import org.eclipse.rdf4j.rio.RDFFormat; -import org.eclipse.rdf4j.rio.Rio; -import org.fairdatapoint.database.rdf.repository.RepositoryMode; -import org.fairdatapoint.database.rdf.repository.generic.GenericMetadataRepository; -import org.fairdatapoint.service.bootstrap.fixtures.RecordsFixture; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Component; - -import java.io.StringReader; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.List; -import java.util.Locale; - -import static org.fairdatapoint.util.ValueFactoryHelper.i; - -@Slf4j -@Component -public class MetadataRecordsBootstrapper extends AbstractBootstrapper { - private final GenericMetadataRepository genericMetadataRepository; - private final String persistentUrl; - - public MetadataRecordsBootstrapper(GenericMetadataRepository genericMetadataRepository, - String persistentUrl) { - super(null); - this.genericMetadataRepository = genericMetadataRepository; - this.persistentUrl = persistentUrl; - } - - @Override - protected JpaRepository getRepository() { - return null; - } - - @Override - public void bootstrapFromJson(Path resourcePath) { - if (!resourcePath.getFileName().toString().equals("records.json")) { - log.warn("Skipping file {}: only records.json is supported for records bootstrapping", resourcePath); - return; - } - try { - final RecordsFixture recordsFixture = - getObjectMapper().readValue(resourcePath.toFile(), RecordsFixture.class); - final Path resourceDir = resourcePath.getParent(); - recordsFixture.getRecords().forEach(record -> { - final Path recordPath = resourceDir.resolve(record.getFilename()); - try { - final String rdfContent = - Files - .readString(recordPath) - .replaceAll(recordsFixture.getPersistentUrlVar(), persistentUrl); - final String baseUri = - record.getUri().replaceAll(recordsFixture.getPersistentUrlVar(), persistentUrl); - final RepositoryMode repositoryMode = getRepositoryMode(record.getRepository()); - storeRecord(rdfContent, repositoryMode, baseUri); - log.info("Created metadata record {}", record.getUri()); - } - catch (Exception exception) { - log.warn("Failed to read record file {}: {}", recordPath, exception.getMessage()); - } - }); - } - catch (Exception exception) { - throw new RuntimeException(exception); - } - } - - private void storeRecord(String rdfContent, RepositoryMode repositoryMode, String baseUri) { - try { - final Model model = Rio.parse(new StringReader(rdfContent), baseUri, RDFFormat.TURTLE); - final List statements = model.stream().toList(); - genericMetadataRepository.save(statements, i(baseUri), repositoryMode); - } - catch (Exception exception) { - log.warn("Failed to parse RDF content: {}", exception.getMessage()); - } - } - - private RepositoryMode getRepositoryMode(String repository) { - if (repository.toLowerCase(Locale.ROOT).equals("drafts")) { - return RepositoryMode.DRAFTS; - } - return RepositoryMode.MAIN; - } -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/RecordFixture.java b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/RecordFixture.java deleted file mode 100644 index 6100b7e9b..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/RecordFixture.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.fixtures; - -import lombok.Data; - -@Data -public class RecordFixture { - private final String filename; - private final String repository; - private final String uri; -} diff --git a/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/RecordsFixture.java b/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/RecordsFixture.java deleted file mode 100644 index 240f13d8b..000000000 --- a/src/main/java/org/fairdatapoint/service/bootstrap/fixtures/RecordsFixture.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * The MIT License - * Copyright © 2016-2024 FAIR Data Team - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.fairdatapoint.service.bootstrap.fixtures; - -import lombok.Data; - -import java.util.ArrayList; -import java.util.List; - -@Data -public class RecordsFixture { - private List records = new ArrayList<>(); - private String persistentUrlVar = "{{ persistentUrl }}"; -} diff --git a/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java b/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java index 73819df1d..af5d55b49 100644 --- a/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java +++ b/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java @@ -31,7 +31,6 @@ import org.fairdatapoint.config.properties.RepositoryConnectionProperties; import org.fairdatapoint.config.properties.RepositoryProperties; import org.fairdatapoint.entity.settings.*; -import org.fairdatapoint.service.bootstrap.fixtures.*; import org.springframework.stereotype.Component; import java.time.Instant; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 191da5a76..7e3d89ec7 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -113,6 +113,4 @@ server: forward-headers-strategy: framework bootstrap: - # TODO: consistent naming for rdf data path and db fixtures dir - data-path: '/data' db-fixtures-dir: "fixtures" From 9eeb9acffbea63a630a3af30c2cdf883623d9307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Such=C3=A1nek?= Date: Sun, 9 Nov 2025 11:34:19 +0100 Subject: [PATCH 18/53] Polish code based on reviews --- pom.xml | 6 ------ .../java/org/fairdatapoint/config/BootstrapConfig.java | 2 +- .../service/membership/MembershipMapper.java | 8 -------- .../fairdatapoint/service/settings/SettingsMapper.java | 2 +- 4 files changed, 2 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index 361daa58d..058ebc5f5 100644 --- a/pom.xml +++ b/pom.xml @@ -61,7 +61,6 @@ 0.12.6 1.18.38 3.9.10 - 3.0.0 5.5 @@ -208,11 +207,6 @@ hypersistence-utils-hibernate-63 ${hypersistence.version} - - tools.jackson.core - jackson-databind - ${jackson.version} - org.postgresql diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java index 4c05478aa..95b9f3a3f 100644 --- a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -86,7 +86,7 @@ public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { factory.setResources(resources); } catch (IOException exception) { - exception.printStackTrace(); + log.error("Failed to load relational database fixtures", exception); } } else { diff --git a/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java b/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java index 09d909e57..ec8b4d961 100644 --- a/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java +++ b/src/main/java/org/fairdatapoint/service/membership/MembershipMapper.java @@ -47,13 +47,5 @@ public MembershipDTO toDTO(Membership membership) { public MembershipPermissionDTO toPermissionDTO(MembershipPermission permission) { return new MembershipPermissionDTO(permission.getMask(), permission.getCode()); } - - public MembershipPermission permissionFromDTO(Membership membership, MembershipPermissionDTO permission) { - return MembershipPermission.builder() - .membership(membership) - .code(permission.getCode()) - .mask(permission.getMask()) - .build(); - } } diff --git a/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java b/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java index af5d55b49..147e33d1a 100644 --- a/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java +++ b/src/main/java/org/fairdatapoint/service/settings/SettingsMapper.java @@ -191,7 +191,7 @@ public SettingsSearchFilter fromSearchFilterDTO( return filter; } - public SettingsSearchFilterItem fromSearchFilterItemDTO( + private SettingsSearchFilterItem fromSearchFilterItemDTO( SearchFilterItemDTO dto, int orderPriority, SettingsSearchFilter filter ) { return SettingsSearchFilterItem.builder() From ca929b416cd9ddf9a94de44ce72b533aa5532bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Such=C3=A1nek?= Date: Sun, 9 Nov 2025 13:05:01 +0100 Subject: [PATCH 19/53] Unify SHACL shapes indentation --- fixtures/0200_metadata-schemas_resource.json | 2 +- fixtures/0210_metadata-schemas_data-service.json | 2 +- .../0220_metadata-schemas_metadata-service.json | 2 +- fixtures/0230_metadata-schemas_fdp.json | 2 +- fixtures/0240_metadata-schemas_catalog.json | 2 +- fixtures/0250_metadata-schemas_dataset.json | 2 +- fixtures/0260_metadata-schemas_distribution.json | 2 +- .../database/fixtures/shape-catalog.ttl | 14 +++++++------- .../database/fixtures/shape-custom-edited.ttl | 8 ++++---- .../database/fixtures/shape-custom.ttl | 8 ++++---- .../database/fixtures/shape-data-service.ttl | 12 ++++++------ .../database/fixtures/shape-dataset.ttl | 12 ++++++------ .../database/fixtures/shape-distribution.ttl | 12 ++++++------ .../fairdatapoint/database/fixtures/shape-fdp.ttl | 12 ++++++------ .../database/fixtures/shape-metadata-service.ttl | 6 +++--- .../database/fixtures/shape-resource.ttl | 14 +++++++------- 16 files changed, 56 insertions(+), 56 deletions(-) diff --git a/fixtures/0200_metadata-schemas_resource.json b/fixtures/0200_metadata-schemas_resource.json index 3c0f659fe..9c91c11ca 100644 --- a/fixtures/0200_metadata-schemas_resource.json +++ b/fixtures/0200_metadata-schemas_resource.json @@ -12,7 +12,7 @@ "version": "1.0.0", "name": "Resource", "description": "", - "definition": "@prefix : .\n@prefix dash: .\n@prefix dcat: .\n@prefix dct: .\n@prefix foaf: .\n@prefix sh: .\n@prefix xsd: .\n\n:ResourceShape a sh:NodeShape ;\n sh:targetClass dcat:Resource ;\n sh:property [\n sh:path dct:title ;\n sh:nodeKind sh:Literal ;\n sh:minCount 1 ;\n sh:maxCount 1 ;\n dash:editor dash:TextFieldEditor ;\n sh:order 1 ;\n ], [\n sh:path dct:description ;\n sh:nodeKind sh:Literal ;\n sh:maxCount 1 ;\n dash:editor dash:TextAreaEditor ;\n sh:order 2 ;\n ], [\n sh:path dct:publisher ;\n sh:node :AgentShape ;\n sh:minCount 1 ;\n sh:maxCount 1 ;\n dash:editor dash:BlankNodeEditor ;\n sh:order 3 ;\n ], [\n sh:path dcat:version ;\n sh:name \"version\" ;\n sh:nodeKind sh:Literal ;\n sh:minCount 1 ;\n sh:maxCount 1 ;\n dash:editor dash:TextFieldEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 4 ;\n ], [\n sh:path dct:language ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n sh:defaultValue ;\n sh:order 5 ;\n ], [\n sh:path dct:license ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n sh:defaultValue ;\n sh:order 6 ;\n ], [\n sh:path dct:rights ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n sh:order 7 ;\n ] .\n\n:AgentShape a sh:NodeShape ;\n sh:targetClass foaf:Agent ;\n sh:property [\n sh:path foaf:name ;\n sh:nodeKind sh:Literal ;\n sh:minCount 1 ;\n sh:maxCount 1 ;\n dash:editor dash:TextFieldEditor ;\n ] .\n", + "definition": "@prefix : .\n@prefix dash: .\n@prefix dcat: .\n@prefix dct: .\n@prefix foaf: .\n@prefix sh: .\n@prefix xsd: .\n\n:ResourceShape a sh:NodeShape ;\n sh:targetClass dcat:Resource ;\n sh:property [\n sh:path dct:title ;\n sh:nodeKind sh:Literal ;\n sh:minCount 1 ;\n sh:maxCount 1 ;\n dash:editor dash:TextFieldEditor ;\n ], [\n sh:path dct:description ;\n sh:nodeKind sh:Literal ;\n sh:maxCount 1 ;\n dash:editor dash:TextAreaEditor ;\n ], [\n sh:path dct:publisher ;\n sh:node :AgentShape ;\n sh:minCount 1 ;\n sh:maxCount 1 ;\n dash:editor dash:BlankNodeEditor ;\n ], [\n sh:path dcat:version ;\n sh:name \"version\" ;\n sh:nodeKind sh:Literal ;\n sh:minCount 1 ;\n sh:maxCount 1 ;\n dash:editor dash:TextFieldEditor ;\n dash:viewer dash:LiteralViewer ;\n ], [\n sh:path dct:language ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n ], [\n sh:path dct:license ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n ], [\n sh:path dct:rights ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n ] .\n\n:AgentShape a sh:NodeShape ;\n sh:targetClass foaf:Agent ;\n sh:property [\n sh:path foaf:name;\n sh:nodeKind sh:Literal ;\n sh:minCount 1 ;\n sh:maxCount 1 ;\n dash:editor dash:TextFieldEditor ;\n ] .\n", "targetClasses": ["http://www.w3.org/ns/dcat#Resource"], "type": "INTERNAL", "origin": null, diff --git a/fixtures/0210_metadata-schemas_data-service.json b/fixtures/0210_metadata-schemas_data-service.json index 41fc172db..8d34dc1b1 100644 --- a/fixtures/0210_metadata-schemas_data-service.json +++ b/fixtures/0210_metadata-schemas_data-service.json @@ -12,7 +12,7 @@ "version": "1.0.0", "name": "Data Service", "description": "", - "definition": "@prefix : .\n@prefix dash: .\n@prefix dcat: .\n@prefix dct: .\n@prefix sh: .\n@prefix xsd: .\n\n:DataServiceShape a sh:NodeShape ;\n sh:targetClass dcat:DataService ;\n sh:property [\n sh:path dcat:endpointURL ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n sh:order 20 ;\n ] , [\n sh:path dcat:endpointDescription ;\n sh:nodeKind sh:Literal ;\n sh:maxCount 1 ;\n dash:editor dash:TextAreaEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 21 ;\n ] .\n", + "definition": "@prefix : .\n@prefix dash: .\n@prefix dcat: .\n@prefix dct: .\n@prefix sh: .\n@prefix xsd: .\n\n:DataServiceShape a sh:NodeShape ;\n sh:targetClass dcat:DataService ;\n sh:property [\n sh:path dcat:endpointURL ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n ] , [\n sh:path dcat:endpointDescription ;\n sh:nodeKind sh:Literal ;\n sh:maxCount 1 ;\n dash:editor dash:TextAreaEditor ;\n dash:viewer dash:LiteralViewer ;\n] .\n", "targetClasses": [ "http://www.w3.org/ns/dcat#Resource", "http://www.w3.org/ns/dcat#DataService" diff --git a/fixtures/0220_metadata-schemas_metadata-service.json b/fixtures/0220_metadata-schemas_metadata-service.json index 401b48f32..6549bc0c1 100644 --- a/fixtures/0220_metadata-schemas_metadata-service.json +++ b/fixtures/0220_metadata-schemas_metadata-service.json @@ -12,7 +12,7 @@ "version": "1.0.0", "name": "Metadata Service", "description": "", - "definition": "@prefix : .\n@prefix fdp: .\n@prefix sh: .\n\n:MetadataServiceShape a sh:NodeShape ;\n sh:targetClass fdp:MetadataService .\n", + "definition": "@prefix : .\n@prefix fdp: .\n@prefix sh: .\n\n:MetadataServiceShape a sh:NodeShape ;\n sh:targetClass fdp:MetadataService .\n", "targetClasses": [ "http://www.w3.org/ns/dcat#Resource", "http://www.w3.org/ns/dcat#DataService", diff --git a/fixtures/0230_metadata-schemas_fdp.json b/fixtures/0230_metadata-schemas_fdp.json index fa30f3a0a..4176f923d 100644 --- a/fixtures/0230_metadata-schemas_fdp.json +++ b/fixtures/0230_metadata-schemas_fdp.json @@ -12,7 +12,7 @@ "version": "1.0.0", "name": "FAIR Data Point", "description": "", - "definition": "@prefix : .\n@prefix dash: .\n@prefix dct: .\n@prefix fdp: .\n@prefix sh: .\n@prefix xsd: .\n\n:FDPShape a sh:NodeShape ;\n sh:targetClass fdp:FAIRDataPoint ;\n sh:property [\n sh:path fdp:startDate ;\n sh:datatype xsd:date ;\n sh:maxCount 1 ;\n dash:editor dash:DatePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 40 ;\n ] , [\n sh:path fdp:endDate ;\n sh:datatype xsd:date ;\n sh:maxCount 1 ;\n dash:editor dash:DatePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 41 ;\n ] , [\n sh:path fdp:uiLanguage ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n sh:defaultValue ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n sh:order 42 ;\n ] , [\n sh:path fdp:metadataIdentifier ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n sh:order 43 ;\n ] .\n", + "definition": "@prefix : .\n@prefix dash: .\n@prefix dct: .\n@prefix fdp: .\n@prefix sh: .\n@prefix xsd: .\n\n:FDPShape a sh:NodeShape ;\n sh:targetClass fdp:FAIRDataPoint ;\n sh:property [\n sh:path fdp:startDate ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:editor dash:DatePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n ] , [\n sh:path fdp:endDate ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:editor dash:DatePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n ] , [\n sh:path fdp:uiLanguage ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n sh:defaultValue ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n ] , [\n sh:path fdp:metadataIdentifier ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n ] , [\n sh:path fdp:metadataIssued ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:editor dash:DatePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n ] , [\n sh:path fdp:metadataModified ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:editor dash:DatePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n ] .\n", "targetClasses": [ "http://www.w3.org/ns/dcat#Resource", "http://www.w3.org/ns/dcat#DataService", diff --git a/fixtures/0240_metadata-schemas_catalog.json b/fixtures/0240_metadata-schemas_catalog.json index f3c549962..0ac55c440 100644 --- a/fixtures/0240_metadata-schemas_catalog.json +++ b/fixtures/0240_metadata-schemas_catalog.json @@ -12,7 +12,7 @@ "version": "1.0.0", "name": "Catalog", "description": "", - "definition": "@prefix : .\n@prefix dash: .\n@prefix dcat: .\n@prefix dct: .\n@prefix foaf: .\n@prefix sh: .\n@prefix xsd: .\n\n:CatalogShape a sh:NodeShape ;\n sh:targetClass dcat:Catalog ;\n sh:property [\n sh:path dct:issued ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:viewer dash:LiteralViewer ;\n sh:order 20 ;\n ], [\n sh:path dct:modified ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:viewer dash:LiteralViewer ;\n sh:order 21 ;\n ], [\n sh:path foaf:homePage ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n sh:order 22 ;\n ], [\n sh:path dcat:themeTaxonomy ;\n sh:nodeKind sh:IRI ;\n dash:viewer dash:LabelViewer ;\n sh:order 23 ;\n ] .\n", + "definition": "@prefix : .\n@prefix dash: .\n@prefix dcat: .\n@prefix dct: .\n@prefix foaf: .\n@prefix sh: .\n@prefix xsd: .\n\n:CatalogShape a sh:NodeShape ;\n sh:targetClass dcat:Catalog ;\n sh:property [\n sh:path dct:issued ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:viewer dash:LiteralViewer ;\n ], [\n sh:path dct:modified ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:viewer dash:LiteralViewer ;\n ], [\n sh:path foaf:homePage ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n ], [\n sh:path dcat:themeTaxonomy ;\n sh:nodeKind sh:IRI ;\n dash:viewer dash:LabelViewer ;\n ] .\n", "targetClasses": [ "http://www.w3.org/ns/dcat#Resource", "http://www.w3.org/ns/dcat#Catalog" diff --git a/fixtures/0250_metadata-schemas_dataset.json b/fixtures/0250_metadata-schemas_dataset.json index 70fe0c4ba..1d8506ce9 100644 --- a/fixtures/0250_metadata-schemas_dataset.json +++ b/fixtures/0250_metadata-schemas_dataset.json @@ -12,7 +12,7 @@ "version": "1.0.0", "name": "Dataset", "description": "", - "definition": "@prefix : .\n@prefix dash: .\n@prefix dcat: .\n@prefix dct: .\n@prefix sh: .\n@prefix xsd: .\n\n:DatasetShape a sh:NodeShape ;\n sh:targetClass dcat:Dataset ;\n sh:property [\n sh:path dct:issued ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:editor dash:DateTimePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 20 ;\n ], [\n sh:path dct:modified ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:editor dash:DateTimePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 21 ;\n ], [\n sh:path dcat:theme ;\n sh:nodeKind sh:IRI ;\n sh:minCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n sh:order 22 ;\n ], [\n sh:path dcat:contactPoint ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n sh:order 23 ;\n ], [\n sh:path dcat:keyword ;\n sh:nodeKind sh:Literal ;\n dash:editor dash:TextFieldEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 24 ;\n ], [\n sh:path dcat:landingPage ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n sh:order 25 ;\n ] .\n", + "definition": "@prefix : .\n@prefix dash: .\n@prefix dcat: .\n@prefix dct: .\n@prefix sh: .\n@prefix xsd: .\n\n:DatasetShape a sh:NodeShape ;\n sh:targetClass dcat:Dataset ;\n sh:property [\n sh:path dct:issued ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:editor dash:DatePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n ], [\n sh:path dct:modified ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:editor dash:DatePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n ], [\n sh:path dcat:theme ;\n sh:nodeKind sh:IRI ;\n sh:minCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n ], [\n sh:path dcat:contactPoint ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n ], [\n sh:path dcat:keyword ;\n sh:nodeKind sh:Literal ;\n dash:editor dash:TextFieldEditor ;\n dash:viewer dash:LiteralViewer ;\n ], [\n sh:path dcat:landingPage ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n dash:viewer dash:LabelViewer ;\n ] .\n", "targetClasses": [ "http://www.w3.org/ns/dcat#Resource", "http://www.w3.org/ns/dcat#Dataset" diff --git a/fixtures/0260_metadata-schemas_distribution.json b/fixtures/0260_metadata-schemas_distribution.json index 3ebe704f2..4b1b937bf 100644 --- a/fixtures/0260_metadata-schemas_distribution.json +++ b/fixtures/0260_metadata-schemas_distribution.json @@ -12,7 +12,7 @@ "version": "1.0.0", "name": "Distribution", "description": "", - "definition": "@prefix : .\n@prefix dash: .\n@prefix dcat: .\n@prefix dct: .\n@prefix sh: .\n@prefix xsd: .\n\n:DistributionShape a sh:NodeShape ;\n sh:targetClass dcat:Distribution ;\n sh:property [\n sh:path dct:issued ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:editor dash:DateTimePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 20 ;\n ], [\n sh:path dct:modified ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:editor dash:DateTimePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 21 ;\n ], [\n sh:path dcat:accessURL ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n sh:order 22 ;\n ], [\n sh:path dcat:downloadURL ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n sh:order 23 ;\n ], [\n sh:path dcat:mediaType ;\n sh:nodeKind sh:Literal ;\n sh:minCount 1 ;\n sh:maxCount 1 ;\n dash:editor dash:TextFieldEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 24 ;\n ], [\n sh:path dcat:format ;\n sh:nodeKind sh:Literal ;\n sh:maxCount 1 ;\n dash:editor dash:TextFieldEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 25 ;\n ], [\n sh:path dcat:byteSize ;\n sh:nodeKind sh:Literal ;\n sh:maxCount 1 ;\n dash:editor dash:TextFieldEditor ;\n dash:viewer dash:LiteralViewer ;\n sh:order 26 ;\n ] .\n", + "definition": "@prefix : .\n@prefix dash: .\n@prefix dcat: .\n@prefix dct: .\n@prefix sh: .\n@prefix xsd: .\n\n:DistributionShape a sh:NodeShape ;\n sh:targetClass dcat:Distribution ;\n sh:property [\n sh:path dct:issued ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:editor dash:DatePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n ] , [\n sh:path dct:modified ;\n sh:datatype xsd:dateTime ;\n sh:maxCount 1 ;\n dash:editor dash:DatePickerEditor ;\n dash:viewer dash:LiteralViewer ;\n ] , [\n sh:path dcat:accessURL ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n ] , [\n sh:path dcat:downloadURL ;\n sh:nodeKind sh:IRI ;\n sh:maxCount 1 ;\n dash:editor dash:URIEditor ;\n ] , [\n sh:path dcat:mediaType ;\n sh:nodeKind sh:Literal ;\n sh:minCount 1 ;\n sh:maxCount 1 ;\n dash:editor dash:TextFieldEditor ;\n dash:viewer dash:LiteralViewer ;\n ] , [\n sh:path dcat:format ;\n sh:nodeKind sh:Literal ;\n sh:maxCount 1 ;\n dash:editor dash:TextFieldEditor ;\n dash:viewer dash:LiteralViewer ;\n ] , [\n sh:path dcat:byteSize ;\n sh:nodeKind sh:Literal ;\n sh:maxCount 1 ;\n dash:editor dash:TextFieldEditor ;\n dash:viewer dash:LiteralViewer ;\n ] .\n", "targetClasses": [ "http://www.w3.org/ns/dcat#Resource", "http://www.w3.org/ns/dcat#Distribution" diff --git a/src/main/resources/org/fairdatapoint/database/fixtures/shape-catalog.ttl b/src/main/resources/org/fairdatapoint/database/fixtures/shape-catalog.ttl index 516a3a59a..9c3be3870 100644 --- a/src/main/resources/org/fairdatapoint/database/fixtures/shape-catalog.ttl +++ b/src/main/resources/org/fairdatapoint/database/fixtures/shape-catalog.ttl @@ -1,10 +1,10 @@ -@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix foaf: . -@prefix sh: . -@prefix xsd: . +@prefix : . +@prefix dash: . +@prefix dcat: . +@prefix dct: . +@prefix foaf: . +@prefix sh: . +@prefix xsd: . :CatalogShape a sh:NodeShape ; sh:targetClass dcat:Catalog ; diff --git a/src/main/resources/org/fairdatapoint/database/fixtures/shape-custom-edited.ttl b/src/main/resources/org/fairdatapoint/database/fixtures/shape-custom-edited.ttl index 29d1647fd..6c781549c 100644 --- a/src/main/resources/org/fairdatapoint/database/fixtures/shape-custom-edited.ttl +++ b/src/main/resources/org/fairdatapoint/database/fixtures/shape-custom-edited.ttl @@ -1,7 +1,7 @@ -@prefix : . -@prefix sh: . -@prefix dash: . -@prefix ex: . +@prefix : . +@prefix sh: . +@prefix dash: . +@prefix ex: . :CustomShape a sh:NodeShape ; sh:targetClass ex:Dog ; diff --git a/src/main/resources/org/fairdatapoint/database/fixtures/shape-custom.ttl b/src/main/resources/org/fairdatapoint/database/fixtures/shape-custom.ttl index b425ce3e5..c6062352b 100644 --- a/src/main/resources/org/fairdatapoint/database/fixtures/shape-custom.ttl +++ b/src/main/resources/org/fairdatapoint/database/fixtures/shape-custom.ttl @@ -1,7 +1,7 @@ -@prefix : . -@prefix sh: . -@prefix dash: . -@prefix ex: . +@prefix : . +@prefix sh: . +@prefix dash: . +@prefix ex: . :CustomShape a sh:NodeShape ; sh:targetClass ex:Dog ; diff --git a/src/main/resources/org/fairdatapoint/database/fixtures/shape-data-service.ttl b/src/main/resources/org/fairdatapoint/database/fixtures/shape-data-service.ttl index e23084794..be36c06a9 100644 --- a/src/main/resources/org/fairdatapoint/database/fixtures/shape-data-service.ttl +++ b/src/main/resources/org/fairdatapoint/database/fixtures/shape-data-service.ttl @@ -1,9 +1,9 @@ -@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix sh: . -@prefix xsd: . +@prefix : . +@prefix dash: . +@prefix dcat: . +@prefix dct: . +@prefix sh: . +@prefix xsd: . :DataServiceShape a sh:NodeShape ; sh:targetClass dcat:DataService ; diff --git a/src/main/resources/org/fairdatapoint/database/fixtures/shape-dataset.ttl b/src/main/resources/org/fairdatapoint/database/fixtures/shape-dataset.ttl index 55536b307..26b1dc4d2 100644 --- a/src/main/resources/org/fairdatapoint/database/fixtures/shape-dataset.ttl +++ b/src/main/resources/org/fairdatapoint/database/fixtures/shape-dataset.ttl @@ -1,9 +1,9 @@ -@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix sh: . -@prefix xsd: . +@prefix : . +@prefix dash: . +@prefix dcat: . +@prefix dct: . +@prefix sh: . +@prefix xsd: . :DatasetShape a sh:NodeShape ; sh:targetClass dcat:Dataset ; diff --git a/src/main/resources/org/fairdatapoint/database/fixtures/shape-distribution.ttl b/src/main/resources/org/fairdatapoint/database/fixtures/shape-distribution.ttl index 3cbd6a4b5..e6d9b2e90 100644 --- a/src/main/resources/org/fairdatapoint/database/fixtures/shape-distribution.ttl +++ b/src/main/resources/org/fairdatapoint/database/fixtures/shape-distribution.ttl @@ -1,9 +1,9 @@ -@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix sh: . -@prefix xsd: . +@prefix : . +@prefix dash: . +@prefix dcat: . +@prefix dct: . +@prefix sh: . +@prefix xsd: . :DistributionShape a sh:NodeShape ; sh:targetClass dcat:Distribution ; diff --git a/src/main/resources/org/fairdatapoint/database/fixtures/shape-fdp.ttl b/src/main/resources/org/fairdatapoint/database/fixtures/shape-fdp.ttl index 02acd7106..a07bb13eb 100644 --- a/src/main/resources/org/fairdatapoint/database/fixtures/shape-fdp.ttl +++ b/src/main/resources/org/fairdatapoint/database/fixtures/shape-fdp.ttl @@ -1,9 +1,9 @@ -@prefix : . -@prefix dash: . -@prefix dct: . -@prefix fdp: . -@prefix sh: . -@prefix xsd: . +@prefix : . +@prefix dash: . +@prefix dct: . +@prefix fdp: . +@prefix sh: . +@prefix xsd: . :FDPShape a sh:NodeShape ; sh:targetClass fdp:FAIRDataPoint ; diff --git a/src/main/resources/org/fairdatapoint/database/fixtures/shape-metadata-service.ttl b/src/main/resources/org/fairdatapoint/database/fixtures/shape-metadata-service.ttl index 3943c4675..227b90580 100644 --- a/src/main/resources/org/fairdatapoint/database/fixtures/shape-metadata-service.ttl +++ b/src/main/resources/org/fairdatapoint/database/fixtures/shape-metadata-service.ttl @@ -1,6 +1,6 @@ -@prefix : . -@prefix fdp: . -@prefix sh: . +@prefix : . +@prefix fdp: . +@prefix sh: . :MetadataServiceShape a sh:NodeShape ; sh:targetClass fdp:MetadataService . diff --git a/src/main/resources/org/fairdatapoint/database/fixtures/shape-resource.ttl b/src/main/resources/org/fairdatapoint/database/fixtures/shape-resource.ttl index bc54d66af..3fd97bc53 100644 --- a/src/main/resources/org/fairdatapoint/database/fixtures/shape-resource.ttl +++ b/src/main/resources/org/fairdatapoint/database/fixtures/shape-resource.ttl @@ -1,10 +1,10 @@ -@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix foaf: . -@prefix sh: . -@prefix xsd: . +@prefix : . +@prefix dash: . +@prefix dcat: . +@prefix dct: . +@prefix foaf: . +@prefix sh: . +@prefix xsd: . :ResourceShape a sh:NodeShape ; sh:targetClass dcat:Resource ; From 1bc18281cbc358b9530c9a7d64bdfb9ee063c893 Mon Sep 17 00:00:00 2001 From: Dennis <29799340+dennisvang@users.noreply.github.com> Date: Mon, 10 Nov 2025 14:55:29 +0100 Subject: [PATCH 20/53] Use JSON fixtures instead of SQL migrations in development profile (#790) * remove dev sql migrations (most of these have been moved into the json fixtures, except for some users, saved queries, and dev settings) * adapt application-development.yml to bootstrap from fixtures instead of the sql migrations from resources/dev/db/migration * temporary quick-fix to make sure rdf migrations run after postgres bootstrap from fixtures (rdf migrations will be handled in an upcoming PR) --- .../RdfDevelopmentMigrationRunner.java | 5 +- .../resources/application-development.yml | 5 +- .../db/migration/V0001.1__dev-data-users.sql | 61 --- .../migration/V0001.2__dev-data-schemas.sql | 505 ------------------ .../db/migration/V0001.3__dev-data-rds.sql | 68 --- .../V0001.4__dev-data-membership.sql | 43 -- .../db/migration/V0001.5__dev-settings.sql | 73 --- 7 files changed, 7 insertions(+), 753 deletions(-) delete mode 100644 src/main/resources/dev/db/migration/V0001.1__dev-data-users.sql delete mode 100644 src/main/resources/dev/db/migration/V0001.2__dev-data-schemas.sql delete mode 100644 src/main/resources/dev/db/migration/V0001.3__dev-data-rds.sql delete mode 100644 src/main/resources/dev/db/migration/V0001.4__dev-data-membership.sql delete mode 100644 src/main/resources/dev/db/migration/V0001.5__dev-settings.sql diff --git a/src/main/java/org/fairdatapoint/database/rdf/migration/RdfDevelopmentMigrationRunner.java b/src/main/java/org/fairdatapoint/database/rdf/migration/RdfDevelopmentMigrationRunner.java index 59c4aeb2c..4e825f0eb 100644 --- a/src/main/java/org/fairdatapoint/database/rdf/migration/RdfDevelopmentMigrationRunner.java +++ b/src/main/java/org/fairdatapoint/database/rdf/migration/RdfDevelopmentMigrationRunner.java @@ -22,7 +22,6 @@ */ package org.fairdatapoint.database.rdf.migration; -import jakarta.annotation.PostConstruct; import org.fairdatapoint.Profiles; import org.fairdatapoint.database.rdf.migration.development.metadata.AclMigration; import org.fairdatapoint.database.rdf.migration.development.metadata.RdfMetadataMigration; @@ -32,7 +31,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.context.annotation.Profile; +import org.springframework.context.event.EventListener; import org.springframework.stereotype.Service; @Service @@ -52,7 +53,7 @@ public class RdfDevelopmentMigrationRunner { @Qualifier("genericMetadataRepository") private GenericMetadataRepository metadataRepository; - @PostConstruct + @EventListener(ApplicationReadyEvent.class) public void run() { rdfMetadataMigration.runMigration(); if (activeProfile.equals(Profiles.DEVELOPMENT)) { diff --git a/src/main/resources/application-development.yml b/src/main/resources/application-development.yml index 359635210..171b64706 100644 --- a/src/main/resources/application-development.yml +++ b/src/main/resources/application-development.yml @@ -12,6 +12,9 @@ spring: username: fdp password: fdp flyway: - locations: classpath:dev/db/migration,classpath:db/migration + locations: classpath:db/migration fail-on-missing-locations: true clean-disabled: false + +bootstrap: + enabled: true diff --git a/src/main/resources/dev/db/migration/V0001.1__dev-data-users.sql b/src/main/resources/dev/db/migration/V0001.1__dev-data-users.sql deleted file mode 100644 index 998d05ade..000000000 --- a/src/main/resources/dev/db/migration/V0001.1__dev-data-users.sql +++ /dev/null @@ -1,61 +0,0 @@ --- --- The MIT License --- Copyright © 2016-2024 FAIR Data Team --- --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- - --- User Accounts -INSERT INTO public.user_account (uuid, first_name, last_name, email, password_hash, user_role, created_at, updated_at) -VALUES ('95589e50-d261-492b-8852-9324e9a66a42', 'Admin', 'von Universe', 'admin@example.com', '$2a$10$L.0OZ8QjV3yLhoCDvU04gu.WP1wGQih41MsBdvtQOshJJntaugBxe', 'ADMIN', NOW(), NOW()); - -INSERT INTO public.user_account (uuid, first_name, last_name, email, password_hash, user_role, created_at, updated_at) -VALUES ('7e64818d-6276-46fb-8bb1-732e6e09f7e9', 'Albert', 'Einstein', 'albert.einstein@example.com', '$2a$10$hZF1abbZ48Tf.3RndC9W6OlDt6gnBoD/2HbzJayTs6be7d.5DbpnW', 'USER', NOW(), NOW()); - -INSERT INTO public.user_account (uuid, first_name, last_name, email, password_hash, user_role, created_at, updated_at) -VALUES ('b5b92c69-5ed9-4054-954d-0121c29b6800', 'Nikola', 'Tesla', 'nikola.tesla@example.com', '$2a$10$tMbZUZg9AbYL514R.hZ0tuzvfZJR5NQhSVeJPTQhNwPf6gv/cvrna', 'USER', NOW(), NOW()); - -INSERT INTO public.user_account (uuid, first_name, last_name, email, password_hash, user_role, created_at, updated_at) -VALUES ('8d1a4c06-bb0e-4d03-a01f-14fa49bbc152', 'Isaac', 'Newton', 'isaac.newton@example.com', '$2a$10$DLkI7NAZDzWVaKG1lVtloeoPNLPoAgDDBqQKQiSAYDZXrf2QKkuHC', 'USER', NOW(), NOW()); - --- API Keys -INSERT INTO public.api_key (uuid, token, user_account_id, created_at, updated_at) -VALUES ('a1c00673-24c5-4e0a-bdbe-22e961ee7548', 'a274793046e34a219fd0ea6362fcca61a001500b71724f4c973a017031653c20', '7e64818d-6276-46fb-8bb1-732e6e09f7e9', NOW(), NOW()); - -INSERT INTO public.api_key (uuid, token, user_account_id, created_at, updated_at) -VALUES ('62657760-21fe-488c-a0ea-f612a70493da', 'dd5dc3b53b6145cfa9f6c58b72ebad21cd2f860ace62451ba4e3c74a0e63540a', 'b5b92c69-5ed9-4054-954d-0121c29b6800', NOW(), NOW()); - --- Saved Search Queries -INSERT INTO public.search_saved_query (uuid, name, description, type, var_prefixes, var_graph_pattern, var_ordering, user_account_id, created_at, updated_at) -VALUES ('d31e3da1-2cfa-4b55-a8cb-71d1acf01aef', 'All datasets', 'Quickly query all datasets (DCAT)', 'PUBLIC', - 'PREFIX dcat: ', '?entity rdf:type dcat:Dataset .', 'ASC(?title)', '7e64818d-6276-46fb-8bb1-732e6e09f7e9', - NOW(), NOW()); - -INSERT INTO public.search_saved_query (uuid, name, description, type, var_prefixes, var_graph_pattern, var_ordering, user_account_id, created_at, updated_at) -VALUES ('c7d0b6a0-5b0a-4b0e-9b0a-9b0a9b0a9b0a', 'All distributions', 'Quickly query all distributions (DCAT)', 'INTERNAL', - 'PREFIX dcat: ', '?entity rdf:type dcat:Distribution .', 'ASC(?title)', '7e64818d-6276-46fb-8bb1-732e6e09f7e9', - NOW(), NOW()); - -INSERT INTO public.search_saved_query (uuid, name, description, type, var_prefixes, var_graph_pattern, var_ordering, user_account_id, created_at, updated_at) -VALUES ('97da9119-834e-4687-8321-3df157547178', 'Things with data', 'This is private query of Nikola Tesla!', 'PRIVATE', - 'PREFIX dcat: ', - '?entity ?relationPredicate ?relationObject . - FILTER isLiteral(?relationObject) - FILTER CONTAINS(LCASE(str(?relationObject)), LCASE("data"))', - 'ASC(?title)', '7e64818d-6276-46fb-8bb1-732e6e09f7e9', NOW(), NOW()); diff --git a/src/main/resources/dev/db/migration/V0001.2__dev-data-schemas.sql b/src/main/resources/dev/db/migration/V0001.2__dev-data-schemas.sql deleted file mode 100644 index 310c8377f..000000000 --- a/src/main/resources/dev/db/migration/V0001.2__dev-data-schemas.sql +++ /dev/null @@ -1,505 +0,0 @@ --- --- The MIT License --- Copyright © 2016-2024 FAIR Data Team --- --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- - --- Resource -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('6a668323-3936-4b53-8380-a4fd2ed082ee', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('71d77460-f919-4f72-b265-ed26567fe361', - '6a668323-3936-4b53-8380-a4fd2ed082ee', - NULL, - '1.0.0', - 'Resource', - '', - '@prefix : . - @prefix dash: . - @prefix dcat: . - @prefix dct: . - @prefix foaf: . - @prefix sh: . - @prefix xsd: . - - :ResourceShape a sh:NodeShape ; - sh:targetClass dcat:Resource ; - sh:property [ - sh:path dct:title ; - sh:nodeKind sh:Literal ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - sh:order 1 ; - ], [ - sh:path dct:description ; - sh:nodeKind sh:Literal ; - sh:maxCount 1 ; - dash:editor dash:TextAreaEditor ; - sh:order 2 ; - ], [ - sh:path dct:publisher ; - sh:node :AgentShape ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:BlankNodeEditor ; - sh:order 3 ; - ], [ - sh:path dcat:version ; - sh:name "version" ; - sh:nodeKind sh:Literal ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 4 ; - ], [ - sh:path dct:language ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:defaultValue ; - sh:order 5 ; - ], [ - sh:path dct:license ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:defaultValue ; - sh:order 6 ; - ], [ - sh:path dct:rights ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 7 ; - ] . - - :AgentShape a sh:NodeShape ; - sh:targetClass foaf:Agent ; - sh:property [ - sh:path foaf:name ; - sh:nodeKind sh:Literal ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - ] . - ', - ARRAY ['http://www.w3.org/ns/dcat#Resource'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - TRUE, - NULL, - NULL, - NOW(), - NOW()); - --- Data Service -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('89d94c1b-f6ff-4545-ba9b-120b2d1921d0', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('9111d436-fe58-4bd5-97ae-e6f86bc2997a', - '89d94c1b-f6ff-4545-ba9b-120b2d1921d0', - NULL, - '1.0.0', - 'Data Service', - '', - '@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix sh: . -@prefix xsd: . - -:DataServiceShape a sh:NodeShape ; - sh:targetClass dcat:DataService ; - sh:property [ - sh:path dcat:endpointURL ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - sh:order 20 ; - ] , [ - sh:path dcat:endpointDescription ; - sh:nodeKind sh:Literal ; - sh:maxCount 1 ; - dash:editor dash:TextAreaEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 21 ; -] . -', - ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#DataService'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - FALSE, - NULL, - NULL, - NOW(), - NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('2efc8366-541d-493f-8661-69ad8f72dfa1', '9111d436-fe58-4bd5-97ae-e6f86bc2997a', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); - --- Metadata Service -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('36b22b70-6203-4dd2-9fb6-b39a776bf467', - '6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad', - NULL, - '1.0.0', - 'Metadata Service', - '', - '@prefix : . -@prefix fdp: . -@prefix sh: . - -:MetadataServiceShape a sh:NodeShape ; - sh:targetClass fdp:MetadataService . -', - ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#DataService', 'https://w3id.org/fdp/fdp-o#MetadataService'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - FALSE, - NULL, - NULL, - NOW(), - NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('8742361b-cd00-4167-b859-e45fa36d0cb7', '36b22b70-6203-4dd2-9fb6-b39a776bf467', '89d94c1b-f6ff-4545-ba9b-120b2d1921d0', 0); - --- FAIR Data Point -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('a92958ab-a414-47e6-8e17-68ba96ba3a2b', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('4e64208d-f102-45a0-96e3-17b002e6213e', - 'a92958ab-a414-47e6-8e17-68ba96ba3a2b', - NULL, - '1.0.0', - 'FAIR Data Point', - '', - '@prefix : . -@prefix dash: . -@prefix dct: . -@prefix fdp: . -@prefix sh: . -@prefix xsd: . - -:FDPShape a sh:NodeShape ; - sh:targetClass fdp:FAIRDataPoint ; - sh:property [ - sh:path fdp:startDate ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 40 ; - ] , [ - sh:path fdp:endDate ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 41 ; - ] , [ - sh:path fdp:uiLanguage ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - sh:defaultValue ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 42 ; - ] , [ - sh:path fdp:metadataIdentifier ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 43 ; - ] , [ - sh:path fdp:metadataIssued ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:viewer dash:LiteralViewer ; - sh:order 44 ; - ] , [ - sh:path fdp:metadataModified ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:viewer dash:LiteralViewer ; - sh:order 45 ; - ] . - ', - ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#DataService', 'https://w3id.org/fdp/fdp-o#MetadataService', 'https://w3id.org/fdp/fdp-o#FAIRDataPoint'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - FALSE, - NULL, - NULL, - NOW(), - NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('afebd441-8aa5-464d-bc3c-033f175449b4', '4e64208d-f102-45a0-96e3-17b002e6213e', '6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad', 0); - --- Catalog -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('c9640671-945d-4114-88fb-e81314cb7ab2', - '2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660', - NULL, - '1.0.0', - 'Catalog', - '', - '@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix foaf: . -@prefix sh: . -@prefix xsd: . - -:CatalogShape a sh:NodeShape ; - sh:targetClass dcat:Catalog ; - sh:property [ - sh:path dct:issued ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:viewer dash:LiteralViewer ; - sh:order 20 ; - ], [ - sh:path dct:modified ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:viewer dash:LiteralViewer ; - sh:order 21 ; - ], [ - sh:path foaf:homePage ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 22 ; - ], [ - sh:path dcat:themeTaxonomy ; - sh:nodeKind sh:IRI ; - dash:viewer dash:LabelViewer ; - sh:order 23 ; - ] . -', - ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#Catalog'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - FALSE, - NULL, - NULL, - NOW(), - NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('e75cb601-318d-41ea-9a8b-32e0749c80a7', 'c9640671-945d-4114-88fb-e81314cb7ab2', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); - --- Dataset -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('866d7fb8-5982-4215-9c7c-18d0ed1bd5f3', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('9cc3c89a-76cf-4639-a71f-652627af51db', - '866d7fb8-5982-4215-9c7c-18d0ed1bd5f3', - NULL, - '1.0.0', - 'Dataset', - '', - '@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix sh: . -@prefix xsd: . - -:DatasetShape a sh:NodeShape ; - sh:targetClass dcat:Dataset ; - sh:property [ - sh:path dct:issued ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 20 ; - ], [ - sh:path dct:modified ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 21 ; - ], [ - sh:path dcat:theme ; - sh:nodeKind sh:IRI ; - sh:minCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 22 ; - ], [ - sh:path dcat:contactPoint ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 23 ; - ], [ - sh:path dcat:keyword ; - sh:nodeKind sh:Literal ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 24 ; - ], [ - sh:path dcat:landingPage ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 25 ; - ] . -', - ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#Dataset'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - FALSE, - NULL, - NULL, - NOW(), - NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('da13ba37-09f8-4937-9055-e3ee3aefc57c', '9cc3c89a-76cf-4639-a71f-652627af51db', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); - --- Distribution -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('ebacbf83-cd4f-4113-8738-d73c0735b0ab', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('3cda8cd3-b08b-4797-822d-d3f3e83c466a', - 'ebacbf83-cd4f-4113-8738-d73c0735b0ab', - NULL, - '1.0.0', - 'Distribution', - '', - '@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix sh: . -@prefix xsd: . - -:DistributionShape a sh:NodeShape ; - sh:targetClass dcat:Distribution ; - sh:property [ - sh:path dct:issued ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 20 ; - ] , [ - sh:path dct:modified ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 21 ; - ] , [ - sh:path dcat:accessURL ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - sh:order 22 ; - ] , [ - sh:path dcat:downloadURL ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - sh:order 23 ; - ] , [ - sh:path dcat:mediaType ; - sh:nodeKind sh:Literal ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 24 ; - ] , [ - sh:path dcat:format ; - sh:nodeKind sh:Literal ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 25 ; - ] , [ - sh:path dcat:byteSize ; - sh:nodeKind sh:Literal ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 26 ; - ] . -', - ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#Distribution'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - FALSE, - NULL, - NULL, - NOW(), - NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('a3b16a4e-cac7-4b71-a3de-94bb86714b5b', '3cda8cd3-b08b-4797-822d-d3f3e83c466a', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); diff --git a/src/main/resources/dev/db/migration/V0001.3__dev-data-rds.sql b/src/main/resources/dev/db/migration/V0001.3__dev-data-rds.sql deleted file mode 100644 index ed4f047ff..000000000 --- a/src/main/resources/dev/db/migration/V0001.3__dev-data-rds.sql +++ /dev/null @@ -1,68 +0,0 @@ --- --- The MIT License --- Copyright © 2016-2024 FAIR Data Team --- --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- - --- Distribution -INSERT INTO resource_definition (uuid, name, url_prefix, created_at, updated_at) -VALUES ('02c649de-c579-43bb-b470-306abdc808c7', 'Distribution', 'distribution', now(), now()); - -INSERT INTO resource_definition_link (uuid, resource_definition_id, title, property_uri, order_priority, created_at, updated_at) -VALUES ('660a1821-a5d2-48d0-a26b-0c6d5bac3de4', '02c649de-c579-43bb-b470-306abdc808c7', 'Access online', 'http://www.w3.org/ns/dcat#accessURL', 1, now(), now()); - -INSERT INTO resource_definition_link (uuid, resource_definition_id, title, property_uri, order_priority, created_at, updated_at) -VALUES ('c2eaebb8-4d8d-469d-8736-269adeded996', '02c649de-c579-43bb-b470-306abdc808c7', 'Download', 'http://www.w3.org/ns/dcat#downloadURL', 2, now(), now()); - -INSERT INTO metadata_schema_usage (uuid, resource_definition_id, metadata_schema_id, order_priority) -VALUES ('bbf4ecb3-c529-4c02-955c-7160755debf5', '02c649de-c579-43bb-b470-306abdc808c7', 'ebacbf83-cd4f-4113-8738-d73c0735b0ab', 1); - --- Dataset -INSERT INTO resource_definition (uuid, name, url_prefix, created_at, updated_at) -VALUES ('2f08228e-1789-40f8-84cd-28e3288c3604', 'Dataset', 'dataset', now(), now()); - -INSERT INTO resource_definition_child (uuid, source_resource_definition_id, target_resource_definition_id, relation_uri, title, tags_uri, order_priority, created_at, updated_at) -VALUES ('9f138a13-9d45-4371-b763-0a3b9e0ec912', '2f08228e-1789-40f8-84cd-28e3288c3604', '02c649de-c579-43bb-b470-306abdc808c7', 'http://www.w3.org/ns/dcat#distribution', 'Distributions', NULL, 1, now(), now()); - -INSERT INTO resource_definition_child_metadata (uuid, resource_definition_child_id, title, property_uri, order_priority, created_at, updated_at) -VALUES ('723e95d3-1696-45e2-9429-f6e98e3fb893', '9f138a13-9d45-4371-b763-0a3b9e0ec912', 'Media Type', 'http://www.w3.org/ns/dcat#mediaType', 1, now(), now()); - -INSERT INTO metadata_schema_usage (uuid, resource_definition_id, metadata_schema_id, order_priority) -VALUES ('b8a0ed37-42a1-487e-8842-09fe082c4cc6', '2f08228e-1789-40f8-84cd-28e3288c3604', '866d7fb8-5982-4215-9c7c-18d0ed1bd5f3', 1); - --- Catalog -INSERT INTO resource_definition (uuid, name, url_prefix, created_at, updated_at) -VALUES ('a0949e72-4466-4d53-8900-9436d1049a4b', 'Catalog', 'catalog', now(), now()); - -INSERT INTO resource_definition_child (uuid, source_resource_definition_id, target_resource_definition_id, relation_uri, title, tags_uri, order_priority, created_at, updated_at) -VALUES ('e9f0f5d3-2a93-4aa3-9dd0-acb1d76f54fc', 'a0949e72-4466-4d53-8900-9436d1049a4b', '2f08228e-1789-40f8-84cd-28e3288c3604', 'http://www.w3.org/ns/dcat#dataset', 'Datasets', 'http://www.w3.org/ns/dcat#theme', 1, now(), now()); - -INSERT INTO metadata_schema_usage (uuid, resource_definition_id, metadata_schema_id, order_priority) -VALUES ('e4df9510-a3ad-4e3b-a1a9-5fc330d8b1f0', 'a0949e72-4466-4d53-8900-9436d1049a4b', '2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660', 1); - --- FAIR Data Point -INSERT INTO resource_definition (uuid, name, url_prefix, created_at, updated_at) -VALUES ('77aaad6a-0136-4c6e-88b9-07ffccd0ee4c', 'FAIR Data Point', '', now(), now()); - -INSERT INTO resource_definition_child (uuid, source_resource_definition_id, target_resource_definition_id, relation_uri, title, tags_uri, order_priority, created_at, updated_at) -VALUES ('b8648597-8fbd-4b89-9e30-5eab82675e42', '77aaad6a-0136-4c6e-88b9-07ffccd0ee4c', 'a0949e72-4466-4d53-8900-9436d1049a4b', 'https://w3id.org/fdp/fdp-o#metadataCatalog', 'Catalogs', 'http://www.w3.org/ns/dcat#themeTaxonomy', 1, now(), now()); - -INSERT INTO metadata_schema_usage (uuid, resource_definition_id, metadata_schema_id, order_priority) -VALUES ('9b3a32a8-a14c-4eb0-ba02-3aa8e13a8f11', '77aaad6a-0136-4c6e-88b9-07ffccd0ee4c', 'a92958ab-a414-47e6-8e17-68ba96ba3a2b', 1); diff --git a/src/main/resources/dev/db/migration/V0001.4__dev-data-membership.sql b/src/main/resources/dev/db/migration/V0001.4__dev-data-membership.sql deleted file mode 100644 index 8240e0bfe..000000000 --- a/src/main/resources/dev/db/migration/V0001.4__dev-data-membership.sql +++ /dev/null @@ -1,43 +0,0 @@ --- --- The MIT License --- Copyright © 2016-2024 FAIR Data Team --- --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- - -INSERT INTO membership (uuid, name, allowed_entities, created_at, updated_at) -VALUES ('49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 'Owner', ARRAY ['a0949e72-4466-4d53-8900-9436d1049a4b', '2f08228e-1789-40f8-84cd-28e3288c3604', '02c649de-c579-43bb-b470-306abdc808c7'], NOW(), NOW()); - -INSERT INTO membership (uuid, name, allowed_entities, created_at, updated_at) -VALUES ('87a2d984-7db2-43f6-805c-6b0040afead5', 'Data Provider', ARRAY ['a0949e72-4466-4d53-8900-9436d1049a4b'], NOW(), NOW()); - -INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) -VALUES ('e0d9f853-637b-4c50-9ad9-07b6349bf76f', '49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 2, 'W', NOW(), NOW()); - -INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) -VALUES ('de4e4f85-f11d-475b-b6f0-33bdfe5f923a', '49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 4, 'C', NOW(), NOW()); - -INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) -VALUES ('60bebbf0-210d-4b05-af85-ca1b58546261', '49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 8, 'D', NOW(), NOW()); - -INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) -VALUES ('36c3b6e9-f2e3-48b7-bae1-4dc3196a3657', '49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 16, 'A', NOW(), NOW()); - -INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) -VALUES ('589d09d3-1c29-4c6f-97fc-6ea4e007fb85', '87a2d984-7db2-43f6-805c-6b0040afead5', 4, 'C', NOW(), NOW()); diff --git a/src/main/resources/dev/db/migration/V0001.5__dev-settings.sql b/src/main/resources/dev/db/migration/V0001.5__dev-settings.sql deleted file mode 100644 index 75496e02a..000000000 --- a/src/main/resources/dev/db/migration/V0001.5__dev-settings.sql +++ /dev/null @@ -1,73 +0,0 @@ --- --- The MIT License --- Copyright © 2016-2024 FAIR Data Team --- --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- - --- Settings -INSERT INTO settings (uuid, app_title, app_subtitle, ping_enabled, ping_endpoints, autocomplete_search_ns, created_at, updated_at) -VALUES ('00000000-0000-0000-0000-000000000000', 'FAIR Data Point', 'FDP Development Instance', False, ARRAY ['https://home.fairdatapoint.org'], True, now(), now()); - --- Autocomplete Sources -INSERT INTO settings_autocomplete_source (uuid, settings_id, rdf_type, sparql_endpoint, sparql_query, order_priority, created_at, updated_at) -VALUES ('d4045a98-dd25-493e-a0b1-d704921c0930', '00000000-0000-0000-0000-000000000000', 'http://www.w3.org/2000/01/rdf-schema#Class', 'http://localhost:3030/ds/query', -'SELECT DISTINCT ?uri ?label -WHERE { ?uri a . -?uri ?label . -FILTER regex(?label, ".*%s.*", "i") } -ORDER BY ?label', - 1, now(), now()); - --- Search Filters: Type -INSERT INTO settings_search_filter (uuid, settings_id, type, label, predicate, query_records, order_priority, created_at, updated_at) -VALUES ('57a98728-ce8c-4e7f-b0f8-94e2668b44d3', '00000000-0000-0000-0000-000000000000', 'IRI', 'Type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', False, 1, now(), now()); - -INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) -VALUES ('b48c2c7f-d7fb-47ae-a72c-b1b360e16f6e', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Catalog', 'http://www.w3.org/ns/dcat#Catalog', 1, now(), now()); - -INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) -VALUES ('3e1598ac-9d29-47f0-8e7b-3c26ca0134a0', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Dataset', 'http://www.w3.org/ns/dcat#Dataset', 2, now(), now()); - -INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) -VALUES ('5697d8d9-f09d-4ebe-b834-b37eb0624c3f', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Distribution', 'http://www.w3.org/ns/dcat#Distribution', 3, now(), now()); - -INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) -VALUES ('022c3bc6-0598-408c-8d2e-b486dafb73dd', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Data Service', 'http://www.w3.org/ns/dcat#DataService', 4, now(), now()); - -INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) -VALUES ('7cee5591-8620-4fea-b883-a94285012b8d', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Metadata Service', 'https://w3id.org/fdp/fdp-o#MetadataService', 5, now(), now()); - -INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) -VALUES ('9d661dca-8017-4dba-b930-cd2834ea59e8', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'FAIR Data Point', 'https://w3id.org/fdp/fdp-o#FAIRDataPoint', 6, now(), now()); - --- Search Filters: License -INSERT INTO settings_search_filter (uuid, settings_id, type, label, predicate, query_records, order_priority, created_at, updated_at) -VALUES ('26913eb3-67dd-45c9-b8ff-4c97e8162a9b', '00000000-0000-0000-0000-000000000000', 'IRI', 'License', 'http://purl.org/dc/terms/license', True, 2, now(), now()); - --- Search Filters: License -INSERT INTO settings_search_filter (uuid, settings_id, type, label, predicate, query_records, order_priority, created_at, updated_at) -VALUES ('cb25afb4-6169-42f8-bde5-181c803773a8', '00000000-0000-0000-0000-000000000000', 'IRI', 'Version', 'http://www.w3.org/ns/dcat#version', True, 3, now(), now()); - --- Metrics -INSERT INTO settings_metric (uuid, settings_id, metric_uri, resource_uri, order_priority, created_at, updated_at) -VALUES ('8435491b-c16c-4457-ae94-e0f4128603d5', '00000000-0000-0000-0000-000000000000', 'https://purl.org/fair-metrics/FM_F1A', 'https://www.ietf.org/rfc/rfc3986.txt', 1, now(), now()); - -INSERT INTO settings_metric (uuid, settings_id, metric_uri, resource_uri, order_priority, created_at, updated_at) -VALUES ('af93d36a-0af0-4054-8c00-2675d460b231', '00000000-0000-0000-0000-000000000000', 'https://purl.org/fair-metrics/FM_A1.1', 'https://www.wikidata.org/wiki/Q8777', 2, now(), now()); From 042c07073b6a3333b594bd8ae4030832f7581329 Mon Sep 17 00:00:00 2001 From: Dennis <29799340+dennisvang@users.noreply.github.com> Date: Mon, 10 Nov 2025 16:59:18 +0100 Subject: [PATCH 21/53] Add history for relational database fixtures (#797) * create fixture_history db table * add FixtureHistory entity * add FixtureHistoryRepository * add some rudimentary tests for FixtureHistory * do not apply fixtures if they are in the FixtureHistoryRepository * log if fixtures are skipped * update fixture history when RepositoriesPopulatedEvent triggers (this event is triggered by the ResourceReaderRepositoryPopulator.populate() method) --- .../fairdatapoint/config/BootstrapConfig.java | 53 +++++++++--- .../repository/FixtureHistoryRepository.java | 34 ++++++++ .../entity/bootstrap/FixtureHistory.java | 45 +++++++++++ .../db/migration/V0001.0__init-fdp-db.sql | 11 +++ .../FixtureHistoryRepositoryTests.java | 80 +++++++++++++++++++ 5 files changed, 213 insertions(+), 10 deletions(-) create mode 100644 src/main/java/org/fairdatapoint/database/db/repository/FixtureHistoryRepository.java create mode 100644 src/main/java/org/fairdatapoint/entity/bootstrap/FixtureHistory.java create mode 100644 src/test/java/org/fairdatapoint/database/db/repository/bootstrap/FixtureHistoryRepositoryTests.java diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java index 95b9f3a3f..9c8eab998 100644 --- a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -22,19 +22,27 @@ */ package org.fairdatapoint.config; +import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; +import org.fairdatapoint.database.db.repository.FixtureHistoryRepository; +import org.fairdatapoint.entity.bootstrap.FixtureHistory; + import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.ApplicationListener; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.core.io.support.ResourcePatternResolver; import org.springframework.data.repository.init.Jackson2RepositoryPopulatorFactoryBean; +import org.springframework.data.repository.init.RepositoriesPopulatedEvent; +import org.springframework.stereotype.Component; import java.io.IOException; import java.nio.file.Path; -import java.util.Arrays; +import java.util.ArrayList; import java.util.Comparator; +import java.util.List; /** * The {@code BootstrapConfig} class configures a repository populator to load initial data into the relational @@ -55,15 +63,19 @@ @Slf4j public class BootstrapConfig { private final ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver(); + private final FixtureHistoryRepository fixtureHistoryRepository; private final boolean bootstrapEnabled; private final Path dbFixturesPath; + private final List resources = new ArrayList<>(); public BootstrapConfig( + FixtureHistoryRepository fixtureHistoryRepository, @Value("${bootstrap.enabled:false}") boolean bootstrapEnabled, @Value("${bootstrap.db-fixtures-dir}") String dbFixturesDir ) { this.bootstrapEnabled = bootstrapEnabled; this.dbFixturesPath = Path.of(dbFixturesDir); + this.fixtureHistoryRepository = fixtureHistoryRepository; } @Bean @@ -74,16 +86,19 @@ public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { try { // collect fixture resources final Path fixturesPath = dbFixturesPath.resolve("*.json"); - final Resource[] resources = resourceResolver.getResources("file:" + fixturesPath); + resources.addAll(List.of(resourceResolver.getResources("file:" + fixturesPath))); + // remove resources that have been applied already + final List appliedFixtures = fixtureHistoryRepository.findAll().stream() + .map(FixtureHistory::getFilename).toList(); + final List resourcesToSkip = resources.stream() + .filter(resource -> appliedFixtures.contains(resource.getFilename())).toList(); + resources.removeAll(resourcesToSkip); // sort resources to guarantee lexicographic order - Arrays.sort( - resources, - Comparator.comparing( - Resource::getFilename, - Comparator.nullsLast(String::compareTo) - ) - ); - factory.setResources(resources); + resources.sort(Comparator.comparing(Resource::getFilename, Comparator.nullsLast(String::compareTo))); + // add resources to factory + log.info("Applying {} db fixtures ({} have been applied already)", + resources.size(), resourcesToSkip.size()); + factory.setResources(resources.toArray(new Resource[0])); } catch (IOException exception) { log.error("Failed to load relational database fixtures", exception); @@ -95,4 +110,22 @@ public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { return factory; } + + @Component + public class RepositoriesPopulatedEventListener implements ApplicationListener { + @Override + public void onApplicationEvent(@NotNull RepositoriesPopulatedEvent event) { + log.info("Repositories populated"); + // Create fixture history records for all resources that have been applied. + // Note: This assumes that all items in the resources list have been *successfully* applied. However, I'm + // not sure if this can be guaranteed. If it does turn out to be a problem, we could try e.g. extending the + // ResourceReaderRepositoryPopulator.persist() method, so the history record is added there. + for (final Resource resource : resources) { + final String filename = resource.getFilename(); + final FixtureHistory fixtureHistory = fixtureHistoryRepository.save(new FixtureHistory(filename)); + log.debug("Fixture history updated: {} ({})", fixtureHistory.getFilename(), fixtureHistory.getUuid()); + } + } + } + } diff --git a/src/main/java/org/fairdatapoint/database/db/repository/FixtureHistoryRepository.java b/src/main/java/org/fairdatapoint/database/db/repository/FixtureHistoryRepository.java new file mode 100644 index 000000000..6912e2318 --- /dev/null +++ b/src/main/java/org/fairdatapoint/database/db/repository/FixtureHistoryRepository.java @@ -0,0 +1,34 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.database.db.repository; + +import org.fairdatapoint.database.db.repository.base.BaseRepository; +import org.fairdatapoint.entity.bootstrap.FixtureHistory; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface FixtureHistoryRepository extends BaseRepository { + Optional findByFilename(String filename); +} diff --git a/src/main/java/org/fairdatapoint/entity/bootstrap/FixtureHistory.java b/src/main/java/org/fairdatapoint/entity/bootstrap/FixtureHistory.java new file mode 100644 index 000000000..70469d34e --- /dev/null +++ b/src/main/java/org/fairdatapoint/entity/bootstrap/FixtureHistory.java @@ -0,0 +1,45 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.entity.bootstrap; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.fairdatapoint.entity.base.BaseEntity; + +@Entity +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class FixtureHistory extends BaseEntity { + + @NotNull + @Column(unique = true) + private String filename; + +} diff --git a/src/main/resources/db/migration/V0001.0__init-fdp-db.sql b/src/main/resources/db/migration/V0001.0__init-fdp-db.sql index c411d0586..4c59d5217 100644 --- a/src/main/resources/db/migration/V0001.0__init-fdp-db.sql +++ b/src/main/resources/db/migration/V0001.0__init-fdp-db.sql @@ -436,3 +436,14 @@ create table acl_entry( constraint foreign_fk_4 foreign key(acl_object_identity) references acl_object_identity(id), constraint foreign_fk_5 foreign key(sid) references acl_sid(id) ); + +-- history of applied fixtures + +CREATE TABLE IF NOT EXISTS fixture_history +( + uuid UUID NOT NULL, + created_at TIMESTAMPTZ NOT NULL, + updated_at TIMESTAMPTZ NOT NULL, + filename TEXT NOT NULL UNIQUE, + PRIMARY KEY (uuid) +); diff --git a/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/FixtureHistoryRepositoryTests.java b/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/FixtureHistoryRepositoryTests.java new file mode 100644 index 000000000..08b16056d --- /dev/null +++ b/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/FixtureHistoryRepositoryTests.java @@ -0,0 +1,80 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.database.db.repository.bootstrap; + +import jakarta.transaction.Transactional; +import org.fairdatapoint.BaseIntegrationTest; +import org.fairdatapoint.database.db.repository.FixtureHistoryRepository; +import org.fairdatapoint.entity.bootstrap.FixtureHistory; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestEntityManager; +import org.springframework.dao.DataIntegrityViolationException; + +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.*; + + +@AutoConfigureTestEntityManager +@Transactional +public class FixtureHistoryRepositoryTests extends BaseIntegrationTest { + @Autowired + FixtureHistoryRepository repository; + + final String filename = "0001-whatever.json"; + + @Test + public void testSave() { + FixtureHistory fixtureHistory = repository.saveAndFlush(new FixtureHistory(filename)); + assertEquals(filename, fixtureHistory.getFilename()); + assertEquals(1, repository.count()); + } + + @Test + public void testSaveWithExistingFilename() { + repository.saveAndFlush(new FixtureHistory(filename)); + assertEquals(1, repository.count()); + assertThrows( + DataIntegrityViolationException.class, + () -> repository.saveAndFlush(new FixtureHistory(filename)), + "filename is not unique, but no exception was raised" + ); + } + + @Test + public void testSaveWithoutFilename() { + assertThrows( + Exception.class, + () -> repository.saveAndFlush(new FixtureHistory()), + "filename was not provided, but no exception was raised" + ); + } + + @Test + public void testFindByFilenameWithExistingFilename() { + repository.saveAndFlush(new FixtureHistory(filename)); + Optional appliedFixture = repository.findByFilename(filename); + assertTrue(appliedFixture.isPresent()); + } +} From ce5b29b9e80c1c323325878074790abf63586120 Mon Sep 17 00:00:00 2001 From: Dennis <29799340+dennisvang@users.noreply.github.com> Date: Thu, 13 Nov 2025 17:54:50 +0100 Subject: [PATCH 22/53] Enable loading relational db fixtures from multiple directories (#793) * convert dbFixtureDir property to list * adapt BootstrapConfig to handle multiple directories * simplify BootstrapConfig resource collection * enable bootstrap by default (this is possible because we take history into account, since #797) * disable bootstrap for FixtureHistory tests (The test assertions expect the db to be empty. Previously, bootstrap.enabled was false by default, but now it is true by default. Therefore we need to disable bootstrap explicitly in these tests.) * workaround for path resolution failure on windows (don't try to resolve *.json because * is illegal in windows paths) --- .../fairdatapoint/config/BootstrapConfig.java | 28 +++++++++---------- .../properties/BootstrapProperties.java | 5 +++- .../resources/application-development.yml | 3 -- src/main/resources/application.yml | 4 ++- .../FixtureHistoryRepositoryTests.java | 2 ++ 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java index 9c8eab998..8ea83bceb 100644 --- a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -24,10 +24,9 @@ import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; +import org.fairdatapoint.config.properties.BootstrapProperties; import org.fairdatapoint.database.db.repository.FixtureHistoryRepository; import org.fairdatapoint.entity.bootstrap.FixtureHistory; - -import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationListener; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -63,30 +62,30 @@ @Slf4j public class BootstrapConfig { private final ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver(); + private final BootstrapProperties bootstrap; private final FixtureHistoryRepository fixtureHistoryRepository; - private final boolean bootstrapEnabled; - private final Path dbFixturesPath; private final List resources = new ArrayList<>(); - public BootstrapConfig( - FixtureHistoryRepository fixtureHistoryRepository, - @Value("${bootstrap.enabled:false}") boolean bootstrapEnabled, - @Value("${bootstrap.db-fixtures-dir}") String dbFixturesDir - ) { - this.bootstrapEnabled = bootstrapEnabled; - this.dbFixturesPath = Path.of(dbFixturesDir); + public BootstrapConfig(BootstrapProperties bootstrapProperties, FixtureHistoryRepository fixtureHistoryRepository) { + this.bootstrap = bootstrapProperties; this.fixtureHistoryRepository = fixtureHistoryRepository; } @Bean public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { final Jackson2RepositoryPopulatorFactoryBean factory = new Jackson2RepositoryPopulatorFactoryBean(); - if (bootstrapEnabled) { + if (this.bootstrap.isEnabled()) { log.info("Bootstrap repository populator enabled"); try { // collect fixture resources - final Path fixturesPath = dbFixturesPath.resolve("*.json"); - resources.addAll(List.of(resourceResolver.getResources("file:" + fixturesPath))); + log.info("Looking for db fixtures in the following directories: {}", + String.join(", ", this.bootstrap.getDbFixturesDirs())); + for (String fixturesDir : this.bootstrap.getDbFixturesDirs()) { + // Path.of() removes trailing slashes, so it is safe to concatenate "/*.json". + // Note that Path.of(fixturesDir).resolve("*.json") could work on unix but fails on windows. + final String locationPattern = "file:" + Path.of(fixturesDir) + "/*.json"; + resources.addAll(List.of(resourceResolver.getResources(locationPattern))); + } // remove resources that have been applied already final List appliedFixtures = fixtureHistoryRepository.findAll().stream() .map(FixtureHistory::getFilename).toList(); @@ -127,5 +126,4 @@ public void onApplicationEvent(@NotNull RepositoriesPopulatedEvent event) { } } } - } diff --git a/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java b/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java index efe2d084d..a7dd4810a 100644 --- a/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java +++ b/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java @@ -28,13 +28,16 @@ import lombok.Setter; import org.springframework.boot.context.properties.ConfigurationProperties; +import java.util.List; + @NoArgsConstructor @AllArgsConstructor @Getter @Setter @ConfigurationProperties(prefix = "bootstrap") public class BootstrapProperties { + // boolean defaults to false private boolean enabled; // directories relative to project root - private String dbFixturesDir; + private List dbFixturesDirs; } diff --git a/src/main/resources/application-development.yml b/src/main/resources/application-development.yml index 171b64706..0a3be3bc9 100644 --- a/src/main/resources/application-development.yml +++ b/src/main/resources/application-development.yml @@ -15,6 +15,3 @@ spring: locations: classpath:db/migration fail-on-missing-locations: true clean-disabled: false - -bootstrap: - enabled: true diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 7e3d89ec7..c58e969cf 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -113,4 +113,6 @@ server: forward-headers-strategy: framework bootstrap: - db-fixtures-dir: "fixtures" + enabled: true + db-fixtures-dirs: + - "fixtures" diff --git a/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/FixtureHistoryRepositoryTests.java b/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/FixtureHistoryRepositoryTests.java index 08b16056d..7bfc3a580 100644 --- a/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/FixtureHistoryRepositoryTests.java +++ b/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/FixtureHistoryRepositoryTests.java @@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestEntityManager; import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.test.context.TestPropertySource; import java.util.Optional; @@ -38,6 +39,7 @@ @AutoConfigureTestEntityManager @Transactional +@TestPropertySource(properties = "bootstrap.enabled=false") public class FixtureHistoryRepositoryTests extends BaseIntegrationTest { @Autowired FixtureHistoryRepository repository; From 6c624466d05f0da03b4a4e5a8e3c90ef492e4c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Such=C3=A1nek?= Date: Sun, 30 Nov 2025 13:54:19 +0100 Subject: [PATCH 23/53] Add missing javadoc and populator tests --- .../entity/base/CustomGeneratedUUID.java | 3 + .../util/CustomUuidGenerator.java | 7 ++ .../bootstrap/DatabaseBootstrapTests.java | 86 +++++++++++++++++++ .../fixtures/0100_user-accounts.json | 11 +++ .../resources/fixtures/0110_api-keys.json | 10 +++ .../fixtures/0120_saved-queries.json | 28 ++++++ 6 files changed, 145 insertions(+) create mode 100644 src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java create mode 100644 src/test/resources/fixtures/0100_user-accounts.json create mode 100644 src/test/resources/fixtures/0110_api-keys.json create mode 100644 src/test/resources/fixtures/0120_saved-queries.json diff --git a/src/main/java/org/fairdatapoint/entity/base/CustomGeneratedUUID.java b/src/main/java/org/fairdatapoint/entity/base/CustomGeneratedUUID.java index 35a338935..8dc5bb2cf 100644 --- a/src/main/java/org/fairdatapoint/entity/base/CustomGeneratedUUID.java +++ b/src/main/java/org/fairdatapoint/entity/base/CustomGeneratedUUID.java @@ -33,6 +33,9 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** + * Custom annotation to mark a field or method for automatic UUID generation using a custom generator. + */ @IdGeneratorType(CustomUuidGenerator.class) @ValueGenerationType(generatedBy = CustomUuidGenerator.class) @Target({ElementType.FIELD, ElementType.METHOD}) diff --git a/src/main/java/org/fairdatapoint/util/CustomUuidGenerator.java b/src/main/java/org/fairdatapoint/util/CustomUuidGenerator.java index f4a4a4dfa..57d29e81a 100644 --- a/src/main/java/org/fairdatapoint/util/CustomUuidGenerator.java +++ b/src/main/java/org/fairdatapoint/util/CustomUuidGenerator.java @@ -33,6 +33,13 @@ import java.lang.reflect.Member; import java.util.UUID; +/** + * Custom UUID generator that allows for assigned UUIDs. + * If a UUID is already assigned to the entity, it will be used as is. + * Otherwise, a new UUID will be generated using the specified strategy. + * This is needed because the default UuidGenerator does not allow for assigned identifiers + * that we want to support in some cases such as populating initial data fixtures. + */ public class CustomUuidGenerator extends UuidGenerator { public CustomUuidGenerator( diff --git a/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java b/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java new file mode 100644 index 000000000..0a8cedff4 --- /dev/null +++ b/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java @@ -0,0 +1,86 @@ +/** + * The MIT License + * Copyright © 2016-2024 FAIR Data Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.fairdatapoint.database.db.repository.bootstrap; + + +import jakarta.transaction.Transactional; +import org.fairdatapoint.BaseIntegrationTest; +import org.fairdatapoint.database.db.repository.ApiKeyRepository; +import org.fairdatapoint.database.db.repository.SearchSavedQueryRepository; +import org.fairdatapoint.database.db.repository.UserAccountRepository; +import org.fairdatapoint.entity.apikey.ApiKey; +import org.fairdatapoint.entity.search.SearchSavedQuery; +import org.fairdatapoint.entity.user.UserAccount; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestEntityManager; +import org.springframework.test.context.TestPropertySource; + +import java.util.Optional; +import java.util.UUID; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@AutoConfigureTestEntityManager +@Transactional +@TestPropertySource( + properties = """ + bootstrap.enabled=true + bootstrap.db-fixtures-dirs=src/test/resources/fixtures + """ +) +public class DatabaseBootstrapTests extends BaseIntegrationTest { + @Autowired + private UserAccountRepository userAccountRepository; + + @Autowired + private ApiKeyRepository apiKeyRepository; + + @Autowired + private SearchSavedQueryRepository searchSavedQueryRepository; + + @Test + public void testSingleEntityBootstrap() { + final Optional userAccount = userAccountRepository.findByEmail("john.doe@example.org"); + assertEquals(true, userAccount.isPresent()); + assertEquals("John", userAccount.get().getFirstName()); + assertEquals("Doe", userAccount.get().getLastName()); + assertEquals(UUID.fromString("e8f98d8e-0c4f-4a4b-9cc7-dd884f0c75ee"), userAccount.get().getUuid()); + } + + @Test + public void testRelatedEntityBootstrap() { + final Optional apiKey = apiKeyRepository.findByToken("testing-token"); + assertEquals(true, apiKey.isPresent()); + assertEquals("john.doe@example.org", apiKey.get().getUserAccount().getEmail()); + assertEquals(UUID.fromString("9d734008-91bb-47e3-97aa-2f537e67d9e6"), apiKey.get().getUuid()); + } + + @Test + public void testDuplicateIdEntityOverwriteBootstrap() { + final Optional savedQuery = searchSavedQueryRepository.findByUuid(UUID.fromString("4c57eff3-4608-40ae-85af-b442cfea0746")); + assertEquals(true, savedQuery.isPresent()); + assertEquals("john.doe@example.org", savedQuery.get().getUserAccount().getEmail()); + assertEquals("Some query 2", savedQuery.get().getName()); + } +} diff --git a/src/test/resources/fixtures/0100_user-accounts.json b/src/test/resources/fixtures/0100_user-accounts.json new file mode 100644 index 000000000..1b33940a0 --- /dev/null +++ b/src/test/resources/fixtures/0100_user-accounts.json @@ -0,0 +1,11 @@ +[ + { + "_class" : "org.fairdatapoint.entity.user.UserAccount", + "uuid": "e8f98d8e-0c4f-4a4b-9cc7-dd884f0c75ee", + "firstName": "John", + "lastName": "Doe", + "email": "john.doe@example.org", + "passwordHash": "$2a$10$hZF1abbZ48Tf.3RndC9W6OlDt6gnBoD/2HbzJayTs6be7d.5DbpnW", + "role": "USER" + } +] diff --git a/src/test/resources/fixtures/0110_api-keys.json b/src/test/resources/fixtures/0110_api-keys.json new file mode 100644 index 000000000..3a4f9bbdc --- /dev/null +++ b/src/test/resources/fixtures/0110_api-keys.json @@ -0,0 +1,10 @@ +[ + { + "_class" : "org.fairdatapoint.entity.apikey.ApiKey", + "uuid": "9d734008-91bb-47e3-97aa-2f537e67d9e6", + "token": "testing-token", + "userAccount": { + "uuid": "e8f98d8e-0c4f-4a4b-9cc7-dd884f0c75ee" + } + } +] diff --git a/src/test/resources/fixtures/0120_saved-queries.json b/src/test/resources/fixtures/0120_saved-queries.json new file mode 100644 index 000000000..5fe68c721 --- /dev/null +++ b/src/test/resources/fixtures/0120_saved-queries.json @@ -0,0 +1,28 @@ +[ + { + "_class" : "org.fairdatapoint.entity.search.SearchSavedQuery", + "uuid": "4c57eff3-4608-40ae-85af-b442cfea0746", + "name": "Some query 1", + "description": "Example query", + "type": "PUBLIC", + "varPrefixes": "PREFIX dcat: ", + "varGraphPattern": "?entity rdf:type dcat:Dataset .", + "varOrdering": "ASC(?title)", + "userAccount": { + "uuid": "e8f98d8e-0c4f-4a4b-9cc7-dd884f0c75ee" + } + }, + { + "_class" : "org.fairdatapoint.entity.search.SearchSavedQuery", + "uuid": "4c57eff3-4608-40ae-85af-b442cfea0746", + "name": "Some query 2", + "description": "Example query (with same UUID as previous)", + "type": "PUBLIC", + "varPrefixes": "PREFIX dcat: ", + "varGraphPattern": "?entity rdf:type dcat:Dataset .", + "varOrdering": "ASC(?title)", + "userAccount": { + "uuid": "e8f98d8e-0c4f-4a4b-9cc7-dd884f0c75ee" + } + } +] From 57ceddacae636baa6a6c97a72efed96b100dabe1 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Mon, 1 Dec 2025 15:25:30 +0100 Subject: [PATCH 24/53] update BootstrapConfig javadoc --- .../org/fairdatapoint/config/BootstrapConfig.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java index 8ea83bceb..cd1beeb01 100644 --- a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -44,17 +44,14 @@ import java.util.List; /** - * The {@code BootstrapConfig} class configures a repository populator to load initial data into the relational + * The {@code BootstrapConfig} class configures a repository populator that loads initial data into the relational * database, based on JSON fixture files. - * Bootstrapping is disabled by default, and should only be enabled once, on the very first run of the application. - * It can also be enabled on subsequent runs, but then it will overwrite any changes that may have been made by users. - * To enable on the first run, set the env variable {@code BOOTSTRAP_ENABLED=true} on the command line, before running - * the app. - * When using e.g. docker compose, you can define {@code BOOTSTRAP_ENABLED: ${BOOTSTRAP_ENABLED:-false}} in the - * {@code environment} section and then set up the stack by running {@code BOOTSTRAP_ENABLED=true docker compose up -d}. - * The default fixtures are located in the {@code /fixtures} directory. + * The default fixture files are located in the {@code /fixtures} directory. + * Additional fixture directories can also be specified, using the {@code dbFixturesDirs} property. + * Fixture files are collected from all specified directories and are applied in lexicographic order. + * A FixtureHistory repository keeps track of fixture files that have been applied, so they are only applied once. * To add custom fixtures and/or override any of the default fixtures in a docker compose setup, we can bind-mount - * individual fixture files. + * individual fixture files or entire directories. * For example: {@code ./my-fixtures/0100_user-accounts.json:/fdp/fixtures/0100_user-accounts.json:ro} * Note that bind-mounting the entire directory, instead of individual files, would hide all default files. */ From 3d2864445664c14c073e6001bbab0c216bc56831 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Thu, 13 Nov 2025 09:32:33 +0100 Subject: [PATCH 25/53] remove data migrations from src/test/resources/test/db --- .../db/migration/V0001.1__dev-data-users.sql | 61 --- .../migration/V0001.2__dev-data-schemas.sql | 505 ------------------ .../db/migration/V0001.3__dev-data-rds.sql | 68 --- .../V0001.4__dev-data-membership.sql | 43 -- .../db/migration/V0001.5__dev-settings.sql | 73 --- .../db/migration/V0001.6__test-schemas.sql | 161 ------ 6 files changed, 911 deletions(-) delete mode 100644 src/test/resources/test/db/migration/V0001.1__dev-data-users.sql delete mode 100644 src/test/resources/test/db/migration/V0001.2__dev-data-schemas.sql delete mode 100644 src/test/resources/test/db/migration/V0001.3__dev-data-rds.sql delete mode 100644 src/test/resources/test/db/migration/V0001.4__dev-data-membership.sql delete mode 100644 src/test/resources/test/db/migration/V0001.5__dev-settings.sql delete mode 100644 src/test/resources/test/db/migration/V0001.6__test-schemas.sql diff --git a/src/test/resources/test/db/migration/V0001.1__dev-data-users.sql b/src/test/resources/test/db/migration/V0001.1__dev-data-users.sql deleted file mode 100644 index cd8e0a967..000000000 --- a/src/test/resources/test/db/migration/V0001.1__dev-data-users.sql +++ /dev/null @@ -1,61 +0,0 @@ --- --- The MIT License --- Copyright © 2016-2024 FAIR Data Team --- --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- - --- User Accounts -INSERT INTO public.user_account (uuid, first_name, last_name, email, password_hash, user_role, created_at, updated_at) -VALUES ('95589e50-d261-492b-8852-9324e9a66a42', 'Admin', 'von Universe', 'admin@example.com', '$2a$10$L.0OZ8QjV3yLhoCDvU04gu.WP1wGQih41MsBdvtQOshJJntaugBxe', 'ADMIN', NOW(), NOW()); - -INSERT INTO public.user_account (uuid, first_name, last_name, email, password_hash, user_role, created_at, updated_at) -VALUES ('7e64818d-6276-46fb-8bb1-732e6e09f7e9', 'Albert', 'Einstein', 'albert.einstein@example.com', '$2a$10$hZF1abbZ48Tf.3RndC9W6OlDt6gnBoD/2HbzJayTs6be7d.5DbpnW', 'USER', NOW(), NOW()); - -INSERT INTO public.user_account (uuid, first_name, last_name, email, password_hash, user_role, created_at, updated_at) -VALUES ('b5b92c69-5ed9-4054-954d-0121c29b6800', 'Nikola', 'Tesla', 'nikola.tesla@example.com', '$2a$10$tMbZUZg9AbYL514R.hZ0tuzvfZJR5NQhSVeJPTQhNwPf6gv/cvrna', 'USER', NOW(), NOW()); - -INSERT INTO public.user_account (uuid, first_name, last_name, email, password_hash, user_role, created_at, updated_at) -VALUES ('8d1a4c06-bb0e-4d03-a01f-14fa49bbc152', 'Isaac', 'Newton', 'isaac.newton@example.com', '$2a$10$DLkI7NAZDzWVaKG1lVtloeoPNLPoAgDDBqQKQiSAYDZXrf2QKkuHC', 'USER', NOW(), NOW()); - --- API Keys -INSERT INTO public.api_key (uuid, token, user_account_id, created_at, updated_at) -VALUES ('a1c00673-24c5-4e0a-bdbe-22e961ee7548', 'a274793046e34a219fd0ea6362fcca61a001500b71724f4c973a017031653c20', '7e64818d-6276-46fb-8bb1-732e6e09f7e9', NOW(), NOW()); - -INSERT INTO public.api_key (uuid, token, user_account_id, created_at, updated_at) -VALUES ('62657760-21fe-488c-a0ea-f612a70493da', 'dd5dc3b53b6145cfa9f6c58b72ebad21cd2f860ace62451ba4e3c74a0e63540a', 'b5b92c69-5ed9-4054-954d-0121c29b6800', NOW(), NOW()); - --- Saved Search Queries -INSERT INTO public.search_saved_query (uuid, name, description, type, var_prefixes, var_graph_pattern, var_ordering, user_account_id, created_at, updated_at) -VALUES ('d31e3da1-2cfa-4b55-a8cb-71d1acf01aef', 'All datasets', 'Quickly query all datasets (DCAT)', 'PUBLIC', - 'PREFIX dcat: ', '?entity rdf:type dcat:Dataset .', 'ASC(?title)', '7e64818d-6276-46fb-8bb1-732e6e09f7e9', - NOW(), NOW()); - -INSERT INTO public.search_saved_query (uuid, name, description, type, var_prefixes, var_graph_pattern, var_ordering, user_account_id, created_at, updated_at) -VALUES ('c7d0b6a0-5b0a-4b0e-9b0a-9b0a9b0a9b0a', 'All distributions', 'Quickly query all distributions (DCAT)', 'INTERNAL', - 'PREFIX dcat: ', '?entity rdf:type dcat:Distribution .', 'ASC(?title)', '7e64818d-6276-46fb-8bb1-732e6e09f7e9', - NOW(), NOW()); - -INSERT INTO public.search_saved_query (uuid, name, description, type, var_prefixes, var_graph_pattern, var_ordering, user_account_id, created_at, updated_at) -VALUES ('97da9119-834e-4687-8321-3df157547178', 'Things with data', 'This is private query of Nikola Tesla!', 'PRIVATE', - 'PREFIX dcat: ', -'?entity ?relationPredicate ?relationObject . -FILTER isLiteral(?relationObject) -FILTER CONTAINS(LCASE(str(?relationObject)), LCASE("data"))', - 'ASC(?title)', '7e64818d-6276-46fb-8bb1-732e6e09f7e9', NOW(), NOW()); diff --git a/src/test/resources/test/db/migration/V0001.2__dev-data-schemas.sql b/src/test/resources/test/db/migration/V0001.2__dev-data-schemas.sql deleted file mode 100644 index 310c8377f..000000000 --- a/src/test/resources/test/db/migration/V0001.2__dev-data-schemas.sql +++ /dev/null @@ -1,505 +0,0 @@ --- --- The MIT License --- Copyright © 2016-2024 FAIR Data Team --- --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- - --- Resource -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('6a668323-3936-4b53-8380-a4fd2ed082ee', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('71d77460-f919-4f72-b265-ed26567fe361', - '6a668323-3936-4b53-8380-a4fd2ed082ee', - NULL, - '1.0.0', - 'Resource', - '', - '@prefix : . - @prefix dash: . - @prefix dcat: . - @prefix dct: . - @prefix foaf: . - @prefix sh: . - @prefix xsd: . - - :ResourceShape a sh:NodeShape ; - sh:targetClass dcat:Resource ; - sh:property [ - sh:path dct:title ; - sh:nodeKind sh:Literal ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - sh:order 1 ; - ], [ - sh:path dct:description ; - sh:nodeKind sh:Literal ; - sh:maxCount 1 ; - dash:editor dash:TextAreaEditor ; - sh:order 2 ; - ], [ - sh:path dct:publisher ; - sh:node :AgentShape ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:BlankNodeEditor ; - sh:order 3 ; - ], [ - sh:path dcat:version ; - sh:name "version" ; - sh:nodeKind sh:Literal ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 4 ; - ], [ - sh:path dct:language ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:defaultValue ; - sh:order 5 ; - ], [ - sh:path dct:license ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:defaultValue ; - sh:order 6 ; - ], [ - sh:path dct:rights ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 7 ; - ] . - - :AgentShape a sh:NodeShape ; - sh:targetClass foaf:Agent ; - sh:property [ - sh:path foaf:name ; - sh:nodeKind sh:Literal ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - ] . - ', - ARRAY ['http://www.w3.org/ns/dcat#Resource'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - TRUE, - NULL, - NULL, - NOW(), - NOW()); - --- Data Service -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('89d94c1b-f6ff-4545-ba9b-120b2d1921d0', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('9111d436-fe58-4bd5-97ae-e6f86bc2997a', - '89d94c1b-f6ff-4545-ba9b-120b2d1921d0', - NULL, - '1.0.0', - 'Data Service', - '', - '@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix sh: . -@prefix xsd: . - -:DataServiceShape a sh:NodeShape ; - sh:targetClass dcat:DataService ; - sh:property [ - sh:path dcat:endpointURL ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - sh:order 20 ; - ] , [ - sh:path dcat:endpointDescription ; - sh:nodeKind sh:Literal ; - sh:maxCount 1 ; - dash:editor dash:TextAreaEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 21 ; -] . -', - ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#DataService'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - FALSE, - NULL, - NULL, - NOW(), - NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('2efc8366-541d-493f-8661-69ad8f72dfa1', '9111d436-fe58-4bd5-97ae-e6f86bc2997a', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); - --- Metadata Service -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('36b22b70-6203-4dd2-9fb6-b39a776bf467', - '6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad', - NULL, - '1.0.0', - 'Metadata Service', - '', - '@prefix : . -@prefix fdp: . -@prefix sh: . - -:MetadataServiceShape a sh:NodeShape ; - sh:targetClass fdp:MetadataService . -', - ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#DataService', 'https://w3id.org/fdp/fdp-o#MetadataService'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - FALSE, - NULL, - NULL, - NOW(), - NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('8742361b-cd00-4167-b859-e45fa36d0cb7', '36b22b70-6203-4dd2-9fb6-b39a776bf467', '89d94c1b-f6ff-4545-ba9b-120b2d1921d0', 0); - --- FAIR Data Point -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('a92958ab-a414-47e6-8e17-68ba96ba3a2b', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('4e64208d-f102-45a0-96e3-17b002e6213e', - 'a92958ab-a414-47e6-8e17-68ba96ba3a2b', - NULL, - '1.0.0', - 'FAIR Data Point', - '', - '@prefix : . -@prefix dash: . -@prefix dct: . -@prefix fdp: . -@prefix sh: . -@prefix xsd: . - -:FDPShape a sh:NodeShape ; - sh:targetClass fdp:FAIRDataPoint ; - sh:property [ - sh:path fdp:startDate ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 40 ; - ] , [ - sh:path fdp:endDate ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 41 ; - ] , [ - sh:path fdp:uiLanguage ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - sh:defaultValue ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 42 ; - ] , [ - sh:path fdp:metadataIdentifier ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 43 ; - ] , [ - sh:path fdp:metadataIssued ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:viewer dash:LiteralViewer ; - sh:order 44 ; - ] , [ - sh:path fdp:metadataModified ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:viewer dash:LiteralViewer ; - sh:order 45 ; - ] . - ', - ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#DataService', 'https://w3id.org/fdp/fdp-o#MetadataService', 'https://w3id.org/fdp/fdp-o#FAIRDataPoint'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - FALSE, - NULL, - NULL, - NOW(), - NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('afebd441-8aa5-464d-bc3c-033f175449b4', '4e64208d-f102-45a0-96e3-17b002e6213e', '6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad', 0); - --- Catalog -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('c9640671-945d-4114-88fb-e81314cb7ab2', - '2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660', - NULL, - '1.0.0', - 'Catalog', - '', - '@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix foaf: . -@prefix sh: . -@prefix xsd: . - -:CatalogShape a sh:NodeShape ; - sh:targetClass dcat:Catalog ; - sh:property [ - sh:path dct:issued ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:viewer dash:LiteralViewer ; - sh:order 20 ; - ], [ - sh:path dct:modified ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:viewer dash:LiteralViewer ; - sh:order 21 ; - ], [ - sh:path foaf:homePage ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 22 ; - ], [ - sh:path dcat:themeTaxonomy ; - sh:nodeKind sh:IRI ; - dash:viewer dash:LabelViewer ; - sh:order 23 ; - ] . -', - ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#Catalog'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - FALSE, - NULL, - NULL, - NOW(), - NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('e75cb601-318d-41ea-9a8b-32e0749c80a7', 'c9640671-945d-4114-88fb-e81314cb7ab2', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); - --- Dataset -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('866d7fb8-5982-4215-9c7c-18d0ed1bd5f3', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('9cc3c89a-76cf-4639-a71f-652627af51db', - '866d7fb8-5982-4215-9c7c-18d0ed1bd5f3', - NULL, - '1.0.0', - 'Dataset', - '', - '@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix sh: . -@prefix xsd: . - -:DatasetShape a sh:NodeShape ; - sh:targetClass dcat:Dataset ; - sh:property [ - sh:path dct:issued ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 20 ; - ], [ - sh:path dct:modified ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 21 ; - ], [ - sh:path dcat:theme ; - sh:nodeKind sh:IRI ; - sh:minCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 22 ; - ], [ - sh:path dcat:contactPoint ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 23 ; - ], [ - sh:path dcat:keyword ; - sh:nodeKind sh:Literal ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 24 ; - ], [ - sh:path dcat:landingPage ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 25 ; - ] . -', - ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#Dataset'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - FALSE, - NULL, - NULL, - NOW(), - NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('da13ba37-09f8-4937-9055-e3ee3aefc57c', '9cc3c89a-76cf-4639-a71f-652627af51db', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); - --- Distribution -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('ebacbf83-cd4f-4113-8738-d73c0735b0ab', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('3cda8cd3-b08b-4797-822d-d3f3e83c466a', - 'ebacbf83-cd4f-4113-8738-d73c0735b0ab', - NULL, - '1.0.0', - 'Distribution', - '', - '@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix sh: . -@prefix xsd: . - -:DistributionShape a sh:NodeShape ; - sh:targetClass dcat:Distribution ; - sh:property [ - sh:path dct:issued ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 20 ; - ] , [ - sh:path dct:modified ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 21 ; - ] , [ - sh:path dcat:accessURL ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - sh:order 22 ; - ] , [ - sh:path dcat:downloadURL ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - sh:order 23 ; - ] , [ - sh:path dcat:mediaType ; - sh:nodeKind sh:Literal ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 24 ; - ] , [ - sh:path dcat:format ; - sh:nodeKind sh:Literal ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 25 ; - ] , [ - sh:path dcat:byteSize ; - sh:nodeKind sh:Literal ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 26 ; - ] . -', - ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#Distribution'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - FALSE, - NULL, - NULL, - NOW(), - NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('a3b16a4e-cac7-4b71-a3de-94bb86714b5b', '3cda8cd3-b08b-4797-822d-d3f3e83c466a', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); diff --git a/src/test/resources/test/db/migration/V0001.3__dev-data-rds.sql b/src/test/resources/test/db/migration/V0001.3__dev-data-rds.sql deleted file mode 100644 index ed4f047ff..000000000 --- a/src/test/resources/test/db/migration/V0001.3__dev-data-rds.sql +++ /dev/null @@ -1,68 +0,0 @@ --- --- The MIT License --- Copyright © 2016-2024 FAIR Data Team --- --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- - --- Distribution -INSERT INTO resource_definition (uuid, name, url_prefix, created_at, updated_at) -VALUES ('02c649de-c579-43bb-b470-306abdc808c7', 'Distribution', 'distribution', now(), now()); - -INSERT INTO resource_definition_link (uuid, resource_definition_id, title, property_uri, order_priority, created_at, updated_at) -VALUES ('660a1821-a5d2-48d0-a26b-0c6d5bac3de4', '02c649de-c579-43bb-b470-306abdc808c7', 'Access online', 'http://www.w3.org/ns/dcat#accessURL', 1, now(), now()); - -INSERT INTO resource_definition_link (uuid, resource_definition_id, title, property_uri, order_priority, created_at, updated_at) -VALUES ('c2eaebb8-4d8d-469d-8736-269adeded996', '02c649de-c579-43bb-b470-306abdc808c7', 'Download', 'http://www.w3.org/ns/dcat#downloadURL', 2, now(), now()); - -INSERT INTO metadata_schema_usage (uuid, resource_definition_id, metadata_schema_id, order_priority) -VALUES ('bbf4ecb3-c529-4c02-955c-7160755debf5', '02c649de-c579-43bb-b470-306abdc808c7', 'ebacbf83-cd4f-4113-8738-d73c0735b0ab', 1); - --- Dataset -INSERT INTO resource_definition (uuid, name, url_prefix, created_at, updated_at) -VALUES ('2f08228e-1789-40f8-84cd-28e3288c3604', 'Dataset', 'dataset', now(), now()); - -INSERT INTO resource_definition_child (uuid, source_resource_definition_id, target_resource_definition_id, relation_uri, title, tags_uri, order_priority, created_at, updated_at) -VALUES ('9f138a13-9d45-4371-b763-0a3b9e0ec912', '2f08228e-1789-40f8-84cd-28e3288c3604', '02c649de-c579-43bb-b470-306abdc808c7', 'http://www.w3.org/ns/dcat#distribution', 'Distributions', NULL, 1, now(), now()); - -INSERT INTO resource_definition_child_metadata (uuid, resource_definition_child_id, title, property_uri, order_priority, created_at, updated_at) -VALUES ('723e95d3-1696-45e2-9429-f6e98e3fb893', '9f138a13-9d45-4371-b763-0a3b9e0ec912', 'Media Type', 'http://www.w3.org/ns/dcat#mediaType', 1, now(), now()); - -INSERT INTO metadata_schema_usage (uuid, resource_definition_id, metadata_schema_id, order_priority) -VALUES ('b8a0ed37-42a1-487e-8842-09fe082c4cc6', '2f08228e-1789-40f8-84cd-28e3288c3604', '866d7fb8-5982-4215-9c7c-18d0ed1bd5f3', 1); - --- Catalog -INSERT INTO resource_definition (uuid, name, url_prefix, created_at, updated_at) -VALUES ('a0949e72-4466-4d53-8900-9436d1049a4b', 'Catalog', 'catalog', now(), now()); - -INSERT INTO resource_definition_child (uuid, source_resource_definition_id, target_resource_definition_id, relation_uri, title, tags_uri, order_priority, created_at, updated_at) -VALUES ('e9f0f5d3-2a93-4aa3-9dd0-acb1d76f54fc', 'a0949e72-4466-4d53-8900-9436d1049a4b', '2f08228e-1789-40f8-84cd-28e3288c3604', 'http://www.w3.org/ns/dcat#dataset', 'Datasets', 'http://www.w3.org/ns/dcat#theme', 1, now(), now()); - -INSERT INTO metadata_schema_usage (uuid, resource_definition_id, metadata_schema_id, order_priority) -VALUES ('e4df9510-a3ad-4e3b-a1a9-5fc330d8b1f0', 'a0949e72-4466-4d53-8900-9436d1049a4b', '2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660', 1); - --- FAIR Data Point -INSERT INTO resource_definition (uuid, name, url_prefix, created_at, updated_at) -VALUES ('77aaad6a-0136-4c6e-88b9-07ffccd0ee4c', 'FAIR Data Point', '', now(), now()); - -INSERT INTO resource_definition_child (uuid, source_resource_definition_id, target_resource_definition_id, relation_uri, title, tags_uri, order_priority, created_at, updated_at) -VALUES ('b8648597-8fbd-4b89-9e30-5eab82675e42', '77aaad6a-0136-4c6e-88b9-07ffccd0ee4c', 'a0949e72-4466-4d53-8900-9436d1049a4b', 'https://w3id.org/fdp/fdp-o#metadataCatalog', 'Catalogs', 'http://www.w3.org/ns/dcat#themeTaxonomy', 1, now(), now()); - -INSERT INTO metadata_schema_usage (uuid, resource_definition_id, metadata_schema_id, order_priority) -VALUES ('9b3a32a8-a14c-4eb0-ba02-3aa8e13a8f11', '77aaad6a-0136-4c6e-88b9-07ffccd0ee4c', 'a92958ab-a414-47e6-8e17-68ba96ba3a2b', 1); diff --git a/src/test/resources/test/db/migration/V0001.4__dev-data-membership.sql b/src/test/resources/test/db/migration/V0001.4__dev-data-membership.sql deleted file mode 100644 index 8240e0bfe..000000000 --- a/src/test/resources/test/db/migration/V0001.4__dev-data-membership.sql +++ /dev/null @@ -1,43 +0,0 @@ --- --- The MIT License --- Copyright © 2016-2024 FAIR Data Team --- --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- - -INSERT INTO membership (uuid, name, allowed_entities, created_at, updated_at) -VALUES ('49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 'Owner', ARRAY ['a0949e72-4466-4d53-8900-9436d1049a4b', '2f08228e-1789-40f8-84cd-28e3288c3604', '02c649de-c579-43bb-b470-306abdc808c7'], NOW(), NOW()); - -INSERT INTO membership (uuid, name, allowed_entities, created_at, updated_at) -VALUES ('87a2d984-7db2-43f6-805c-6b0040afead5', 'Data Provider', ARRAY ['a0949e72-4466-4d53-8900-9436d1049a4b'], NOW(), NOW()); - -INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) -VALUES ('e0d9f853-637b-4c50-9ad9-07b6349bf76f', '49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 2, 'W', NOW(), NOW()); - -INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) -VALUES ('de4e4f85-f11d-475b-b6f0-33bdfe5f923a', '49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 4, 'C', NOW(), NOW()); - -INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) -VALUES ('60bebbf0-210d-4b05-af85-ca1b58546261', '49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 8, 'D', NOW(), NOW()); - -INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) -VALUES ('36c3b6e9-f2e3-48b7-bae1-4dc3196a3657', '49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 16, 'A', NOW(), NOW()); - -INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) -VALUES ('589d09d3-1c29-4c6f-97fc-6ea4e007fb85', '87a2d984-7db2-43f6-805c-6b0040afead5', 4, 'C', NOW(), NOW()); diff --git a/src/test/resources/test/db/migration/V0001.5__dev-settings.sql b/src/test/resources/test/db/migration/V0001.5__dev-settings.sql deleted file mode 100644 index 75496e02a..000000000 --- a/src/test/resources/test/db/migration/V0001.5__dev-settings.sql +++ /dev/null @@ -1,73 +0,0 @@ --- --- The MIT License --- Copyright © 2016-2024 FAIR Data Team --- --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- - --- Settings -INSERT INTO settings (uuid, app_title, app_subtitle, ping_enabled, ping_endpoints, autocomplete_search_ns, created_at, updated_at) -VALUES ('00000000-0000-0000-0000-000000000000', 'FAIR Data Point', 'FDP Development Instance', False, ARRAY ['https://home.fairdatapoint.org'], True, now(), now()); - --- Autocomplete Sources -INSERT INTO settings_autocomplete_source (uuid, settings_id, rdf_type, sparql_endpoint, sparql_query, order_priority, created_at, updated_at) -VALUES ('d4045a98-dd25-493e-a0b1-d704921c0930', '00000000-0000-0000-0000-000000000000', 'http://www.w3.org/2000/01/rdf-schema#Class', 'http://localhost:3030/ds/query', -'SELECT DISTINCT ?uri ?label -WHERE { ?uri a . -?uri ?label . -FILTER regex(?label, ".*%s.*", "i") } -ORDER BY ?label', - 1, now(), now()); - --- Search Filters: Type -INSERT INTO settings_search_filter (uuid, settings_id, type, label, predicate, query_records, order_priority, created_at, updated_at) -VALUES ('57a98728-ce8c-4e7f-b0f8-94e2668b44d3', '00000000-0000-0000-0000-000000000000', 'IRI', 'Type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', False, 1, now(), now()); - -INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) -VALUES ('b48c2c7f-d7fb-47ae-a72c-b1b360e16f6e', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Catalog', 'http://www.w3.org/ns/dcat#Catalog', 1, now(), now()); - -INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) -VALUES ('3e1598ac-9d29-47f0-8e7b-3c26ca0134a0', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Dataset', 'http://www.w3.org/ns/dcat#Dataset', 2, now(), now()); - -INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) -VALUES ('5697d8d9-f09d-4ebe-b834-b37eb0624c3f', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Distribution', 'http://www.w3.org/ns/dcat#Distribution', 3, now(), now()); - -INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) -VALUES ('022c3bc6-0598-408c-8d2e-b486dafb73dd', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Data Service', 'http://www.w3.org/ns/dcat#DataService', 4, now(), now()); - -INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) -VALUES ('7cee5591-8620-4fea-b883-a94285012b8d', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Metadata Service', 'https://w3id.org/fdp/fdp-o#MetadataService', 5, now(), now()); - -INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) -VALUES ('9d661dca-8017-4dba-b930-cd2834ea59e8', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'FAIR Data Point', 'https://w3id.org/fdp/fdp-o#FAIRDataPoint', 6, now(), now()); - --- Search Filters: License -INSERT INTO settings_search_filter (uuid, settings_id, type, label, predicate, query_records, order_priority, created_at, updated_at) -VALUES ('26913eb3-67dd-45c9-b8ff-4c97e8162a9b', '00000000-0000-0000-0000-000000000000', 'IRI', 'License', 'http://purl.org/dc/terms/license', True, 2, now(), now()); - --- Search Filters: License -INSERT INTO settings_search_filter (uuid, settings_id, type, label, predicate, query_records, order_priority, created_at, updated_at) -VALUES ('cb25afb4-6169-42f8-bde5-181c803773a8', '00000000-0000-0000-0000-000000000000', 'IRI', 'Version', 'http://www.w3.org/ns/dcat#version', True, 3, now(), now()); - --- Metrics -INSERT INTO settings_metric (uuid, settings_id, metric_uri, resource_uri, order_priority, created_at, updated_at) -VALUES ('8435491b-c16c-4457-ae94-e0f4128603d5', '00000000-0000-0000-0000-000000000000', 'https://purl.org/fair-metrics/FM_F1A', 'https://www.ietf.org/rfc/rfc3986.txt', 1, now(), now()); - -INSERT INTO settings_metric (uuid, settings_id, metric_uri, resource_uri, order_priority, created_at, updated_at) -VALUES ('af93d36a-0af0-4054-8c00-2675d460b231', '00000000-0000-0000-0000-000000000000', 'https://purl.org/fair-metrics/FM_A1.1', 'https://www.wikidata.org/wiki/Q8777', 2, now(), now()); diff --git a/src/test/resources/test/db/migration/V0001.6__test-schemas.sql b/src/test/resources/test/db/migration/V0001.6__test-schemas.sql deleted file mode 100644 index b340329e8..000000000 --- a/src/test/resources/test/db/migration/V0001.6__test-schemas.sql +++ /dev/null @@ -1,161 +0,0 @@ --- --- The MIT License --- Copyright © 2016-2024 FAIR Data Team --- --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- - --- Custom with one version -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('e8b34158-3858-45c7-8e3e-d1e671dd9929', NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('53619e58-2bb0-4baf-afd8-00c5d01ff8a8', 'e8b34158-3858-45c7-8e3e-d1e671dd9929', NULL, '0.1.0', 'Custom schema', - 'Custom schema V1', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LATEST', TRUE, FALSE, NULL, - NULL, NOW(), NOW()); - --- Custom with one draft -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('bfa79edf-00b7-4a04-b5a6-a5144f1a77b7', NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('cb9f6cd7-97af-45d0-b23d-d0aab23607d8', 'bfa79edf-00b7-4a04-b5a6-a5144f1a77b7', NULL, '0.1.0', 'Custom schema', - 'Custom schema V1', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'DRAFT', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); - - --- Custom with one version INTERNAL -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('fe98adbb-6a2c-4c7a-b2b2-a72db5140c61', NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('f0a4b358-69a3-44e6-9436-c68a56a9f2f2', 'fe98adbb-6a2c-4c7a-b2b2-a72db5140c61', NULL, '0.1.0', 'Custom schema', - 'Custom schema V1', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'INTERNAL', NULL, NULL, 'LATEST', TRUE, FALSE, NULL, - NULL, NOW(), NOW()); - --- Custom with multiple versions -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('978e5c1c-268d-4822-b60b-07d3eccc6896', NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('d7acec53-5ac9-4502-9bfa-92d1e9f79a24', '978e5c1c-268d-4822-b60b-07d3eccc6896', NULL, '0.1.0', 'Custom schema', - 'Custom schema V1', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LEGACY', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('67896adc-b431-431d-8296-f0b80d8de412', '978e5c1c-268d-4822-b60b-07d3eccc6896', 'd7acec53-5ac9-4502-9bfa-92d1e9f79a24', '0.2.0', 'Custom schema', - 'Custom schema V2', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LEGACY', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('c62d4a97-baac-40b8-b6ea-e43b06ec78bd', '978e5c1c-268d-4822-b60b-07d3eccc6896', '67896adc-b431-431d-8296-f0b80d8de412', '0.3.0', 'Custom schema', - 'Custom schema V3', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LATEST', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); - --- Custom with draft -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('e7078309-cb4c-47b9-9ef8-057487b3da58', NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('a17c25ad-e8d3-4338-bb3e-eda76d2fc32c', 'e7078309-cb4c-47b9-9ef8-057487b3da58', NULL, '0.0.0', 'Custom schema', - 'Custom schema draft', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'DRAFT', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); - --- Custom with multiple versions and draft -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('123e48d2-9995-4b44-8b2c-9c81bdbf2dd2', NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('fb24f92b-187f-4d53-b744-73024b537f30', '123e48d2-9995-4b44-8b2c-9c81bdbf2dd2', NULL, '0.1.0', 'Custom schema', - 'Custom schema V1', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LEGACY', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('6011adfa-f8da-478d-86ea-84bb644b458b', '123e48d2-9995-4b44-8b2c-9c81bdbf2dd2', 'fb24f92b-187f-4d53-b744-73024b537f30', '0.2.0', 'Custom schema', - 'Custom schema V2', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LATEST', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('6b84ec86-2096-48db-bfc7-23506b8c080c', '123e48d2-9995-4b44-8b2c-9c81bdbf2dd2', '6011adfa-f8da-478d-86ea-84bb644b458b', '0.0.0', 'Custom schema', - 'Custom schema draft', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'DRAFT', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); - --- Custom with multiple versions and draft and extends -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('7c8b8699-ca9f-4d14-86e2-2299b27c5711', NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('4e44fb19-b9e0-46e9-957a-e7aa3adac7bf', '7c8b8699-ca9f-4d14-86e2-2299b27c5711', NULL, '0.1.0', 'Custom schema', - 'Custom schema V1', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LEGACY', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('abcf3a21-6f9a-45dc-a71a-4dde4440c81a', '7c8b8699-ca9f-4d14-86e2-2299b27c5711', '4e44fb19-b9e0-46e9-957a-e7aa3adac7bf', '0.2.0', 'Custom schema', - 'Custom schema V2', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LATEST', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('1bdca611-c96e-4304-b1f3-030d282ef529', 'abcf3a21-6f9a-45dc-a71a-4dde4440c81a', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('1bdca611-c96e-4304-b1f3-030d282ef530', 'abcf3a21-6f9a-45dc-a71a-4dde4440c81a', '123e48d2-9995-4b44-8b2c-9c81bdbf2dd2', 1); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('a6d609ff-905f-4edd-bdb1-2dce000c9a45', '7c8b8699-ca9f-4d14-86e2-2299b27c5711', 'abcf3a21-6f9a-45dc-a71a-4dde4440c81a', '0.0.0', 'Custom schema', - 'Custom schema draft', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'DRAFT', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('53e3db46-8fe4-47ce-873e-ed7db94e73b3', 'a6d609ff-905f-4edd-bdb1-2dce000c9a45', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); From 6ab040ddbafc5d60b89e1edd7b69b7442c0302ff Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Thu, 13 Nov 2025 09:33:04 +0100 Subject: [PATCH 26/53] remove reference to test data migrations from test config --- src/test/resources/application-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/application-testing.yml b/src/test/resources/application-testing.yml index 5e9440e60..f6453d199 100644 --- a/src/test/resources/application-testing.yml +++ b/src/test/resources/application-testing.yml @@ -17,7 +17,7 @@ spring: username: ${FDP_POSTGRES_USERNAME:fdp} password: ${FDP_POSTGRES_PASSWORD:fdp} flyway: - locations: classpath:test/db/migration,classpath:db/migration + locations: classpath:db/migration fail-on-missing-locations: true clean-disabled: false From ac0e0ae2c5c898e8aa727318f4f7602f01b86dcb Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Thu, 13 Nov 2025 09:42:58 +0100 Subject: [PATCH 27/53] explicitly enable bootstrap in test config --- src/test/resources/application-testing.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/resources/application-testing.yml b/src/test/resources/application-testing.yml index f6453d199..ab955a459 100644 --- a/src/test/resources/application-testing.yml +++ b/src/test/resources/application-testing.yml @@ -23,3 +23,6 @@ spring: ping: enabled: false + +bootstrap: + enabled: true From d5915b1b37d179aaf6b26ec82700b0c061a6875d Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Thu, 13 Nov 2025 10:24:03 +0100 Subject: [PATCH 28/53] add test-fixtures location to bootstrap config --- src/test/resources/application-testing.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/resources/application-testing.yml b/src/test/resources/application-testing.yml index ab955a459..0e0cc011d 100644 --- a/src/test/resources/application-testing.yml +++ b/src/test/resources/application-testing.yml @@ -26,3 +26,6 @@ ping: bootstrap: enabled: true + db-fixtures-dirs: + - fixtures + - test-fixtures From a86092a78e645676ff90afc47bd03af437146465 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Fri, 14 Nov 2025 16:06:10 +0100 Subject: [PATCH 29/53] rename 'db-fixtures-dirs' property to 'locations' this is more consistent with e.g. the 'locations' option for flyway --- src/main/java/org/fairdatapoint/config/BootstrapConfig.java | 6 +++--- .../config/properties/BootstrapProperties.java | 4 ++-- src/main/resources/application.yml | 2 +- src/test/resources/application-testing.yml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java index cd1beeb01..0afd4eb61 100644 --- a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -75,9 +75,9 @@ public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { log.info("Bootstrap repository populator enabled"); try { // collect fixture resources - log.info("Looking for db fixtures in the following directories: {}", - String.join(", ", this.bootstrap.getDbFixturesDirs())); - for (String fixturesDir : this.bootstrap.getDbFixturesDirs()) { + log.info("Looking for db fixtures in the following locations: {}", + String.join(", ", this.bootstrap.getLocations())); + for (String fixturesDir : this.bootstrap.getLocations()) { // Path.of() removes trailing slashes, so it is safe to concatenate "/*.json". // Note that Path.of(fixturesDir).resolve("*.json") could work on unix but fails on windows. final String locationPattern = "file:" + Path.of(fixturesDir) + "/*.json"; diff --git a/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java b/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java index a7dd4810a..c6e383b58 100644 --- a/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java +++ b/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java @@ -38,6 +38,6 @@ public class BootstrapProperties { // boolean defaults to false private boolean enabled; - // directories relative to project root - private List dbFixturesDirs; + // locations to search for fixtures + private List locations; } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index c58e969cf..f91578bb6 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -114,5 +114,5 @@ server: bootstrap: enabled: true - db-fixtures-dirs: + locations: - "fixtures" diff --git a/src/test/resources/application-testing.yml b/src/test/resources/application-testing.yml index 0e0cc011d..5e5713c23 100644 --- a/src/test/resources/application-testing.yml +++ b/src/test/resources/application-testing.yml @@ -26,6 +26,6 @@ ping: bootstrap: enabled: true - db-fixtures-dirs: + locations: - fixtures - test-fixtures From f5abb80e7231bd2a435802cf64c3063f38cc1ea9 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Fri, 14 Nov 2025 16:09:16 +0100 Subject: [PATCH 30/53] rename fixturesDir loop variable to location --- src/main/java/org/fairdatapoint/config/BootstrapConfig.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java index 0afd4eb61..f5955aa08 100644 --- a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -77,10 +77,10 @@ public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { // collect fixture resources log.info("Looking for db fixtures in the following locations: {}", String.join(", ", this.bootstrap.getLocations())); - for (String fixturesDir : this.bootstrap.getLocations()) { + for (String location : this.bootstrap.getLocations()) { // Path.of() removes trailing slashes, so it is safe to concatenate "/*.json". - // Note that Path.of(fixturesDir).resolve("*.json") could work on unix but fails on windows. - final String locationPattern = "file:" + Path.of(fixturesDir) + "/*.json"; + // Note that Path.of(location).resolve("*.json") could work on unix but fails on windows. + final String locationPattern = "file:" + Path.of(location) + "/*.json"; resources.addAll(List.of(resourceResolver.getResources(locationPattern))); } // remove resources that have been applied already From 4618d917d44df8d110358e937e6f53f1a1d5f9b4 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Fri, 14 Nov 2025 16:14:26 +0100 Subject: [PATCH 31/53] remove 'file:' prefix from fixture location pattern This allows us to include the prefix in the config, which is more flexible. For example, we can set file:fixtures for the default fixtures, which need to be overridable in the docker container, and we can set classpath:test-fixtures for the test fixtures, which can then be included in the test/resources dir. Moreover, this approach is similar to the way flyway.locations are specified. --- src/main/java/org/fairdatapoint/config/BootstrapConfig.java | 3 +-- .../fairdatapoint/config/properties/BootstrapProperties.java | 3 ++- src/main/resources/application.yml | 2 +- src/test/resources/application-testing.yml | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java index f5955aa08..f86a25d43 100644 --- a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -80,8 +80,7 @@ public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { for (String location : this.bootstrap.getLocations()) { // Path.of() removes trailing slashes, so it is safe to concatenate "/*.json". // Note that Path.of(location).resolve("*.json") could work on unix but fails on windows. - final String locationPattern = "file:" + Path.of(location) + "/*.json"; - resources.addAll(List.of(resourceResolver.getResources(locationPattern))); + resources.addAll(List.of(resourceResolver.getResources(Path.of(location) + "/*.json"))); } // remove resources that have been applied already final List appliedFixtures = fixtureHistoryRepository.findAll().stream() diff --git a/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java b/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java index c6e383b58..ded768b2d 100644 --- a/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java +++ b/src/main/java/org/fairdatapoint/config/properties/BootstrapProperties.java @@ -38,6 +38,7 @@ public class BootstrapProperties { // boolean defaults to false private boolean enabled; - // locations to search for fixtures + // locations to search for fixtures, for example, file:fixtures, relative to project root, + // or classpath:fixtures (see PathMatchingResourcePatternResolver docs for valid patterns) private List locations; } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f91578bb6..ed84c0b13 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -115,4 +115,4 @@ server: bootstrap: enabled: true locations: - - "fixtures" + - file:fixtures diff --git a/src/test/resources/application-testing.yml b/src/test/resources/application-testing.yml index 5e5713c23..24e2b209a 100644 --- a/src/test/resources/application-testing.yml +++ b/src/test/resources/application-testing.yml @@ -27,5 +27,5 @@ ping: bootstrap: enabled: true locations: - - fixtures - - test-fixtures + - file:fixtures + - classpath:test-fixtures From e647d94d180fae19b292cf22f502ee9ec792a65e Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Fri, 14 Nov 2025 16:27:50 +0100 Subject: [PATCH 32/53] clarify RepositoriesPopulatedEvent log message the populator is done, but that does not necessarily mean any repositories were actually populated --- src/main/java/org/fairdatapoint/config/BootstrapConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java index f86a25d43..d3e2d8c95 100644 --- a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -110,7 +110,7 @@ public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { public class RepositoriesPopulatedEventListener implements ApplicationListener { @Override public void onApplicationEvent(@NotNull RepositoriesPopulatedEvent event) { - log.info("Repositories populated"); + log.info("Repository populator finished."); // Create fixture history records for all resources that have been applied. // Note: This assumes that all items in the resources list have been *successfully* applied. However, I'm // not sure if this can be guaranteed. If it does turn out to be a problem, we could try e.g. extending the From 049eeb20f8d0e86c727d1b27ac074013404152d8 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Fri, 14 Nov 2025 17:01:46 +0100 Subject: [PATCH 33/53] Revert "remove data migrations from src/test/resources/test/db" This reverts commit 1ac2639ae2dad18f3a277bee7da0135b25543eab. --- .../db/migration/V0001.1__dev-data-users.sql | 61 +++ .../migration/V0001.2__dev-data-schemas.sql | 505 ++++++++++++++++++ .../db/migration/V0001.3__dev-data-rds.sql | 68 +++ .../V0001.4__dev-data-membership.sql | 43 ++ .../db/migration/V0001.5__dev-settings.sql | 73 +++ .../db/migration/V0001.6__test-schemas.sql | 161 ++++++ 6 files changed, 911 insertions(+) create mode 100644 src/test/resources/test/db/migration/V0001.1__dev-data-users.sql create mode 100644 src/test/resources/test/db/migration/V0001.2__dev-data-schemas.sql create mode 100644 src/test/resources/test/db/migration/V0001.3__dev-data-rds.sql create mode 100644 src/test/resources/test/db/migration/V0001.4__dev-data-membership.sql create mode 100644 src/test/resources/test/db/migration/V0001.5__dev-settings.sql create mode 100644 src/test/resources/test/db/migration/V0001.6__test-schemas.sql diff --git a/src/test/resources/test/db/migration/V0001.1__dev-data-users.sql b/src/test/resources/test/db/migration/V0001.1__dev-data-users.sql new file mode 100644 index 000000000..cd8e0a967 --- /dev/null +++ b/src/test/resources/test/db/migration/V0001.1__dev-data-users.sql @@ -0,0 +1,61 @@ +-- +-- The MIT License +-- Copyright © 2016-2024 FAIR Data Team +-- +-- Permission is hereby granted, free of charge, to any person obtaining a copy +-- of this software and associated documentation files (the "Software"), to deal +-- in the Software without restriction, including without limitation the rights +-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +-- copies of the Software, and to permit persons to whom the Software is +-- furnished to do so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in +-- all copies or substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +-- THE SOFTWARE. +-- + +-- User Accounts +INSERT INTO public.user_account (uuid, first_name, last_name, email, password_hash, user_role, created_at, updated_at) +VALUES ('95589e50-d261-492b-8852-9324e9a66a42', 'Admin', 'von Universe', 'admin@example.com', '$2a$10$L.0OZ8QjV3yLhoCDvU04gu.WP1wGQih41MsBdvtQOshJJntaugBxe', 'ADMIN', NOW(), NOW()); + +INSERT INTO public.user_account (uuid, first_name, last_name, email, password_hash, user_role, created_at, updated_at) +VALUES ('7e64818d-6276-46fb-8bb1-732e6e09f7e9', 'Albert', 'Einstein', 'albert.einstein@example.com', '$2a$10$hZF1abbZ48Tf.3RndC9W6OlDt6gnBoD/2HbzJayTs6be7d.5DbpnW', 'USER', NOW(), NOW()); + +INSERT INTO public.user_account (uuid, first_name, last_name, email, password_hash, user_role, created_at, updated_at) +VALUES ('b5b92c69-5ed9-4054-954d-0121c29b6800', 'Nikola', 'Tesla', 'nikola.tesla@example.com', '$2a$10$tMbZUZg9AbYL514R.hZ0tuzvfZJR5NQhSVeJPTQhNwPf6gv/cvrna', 'USER', NOW(), NOW()); + +INSERT INTO public.user_account (uuid, first_name, last_name, email, password_hash, user_role, created_at, updated_at) +VALUES ('8d1a4c06-bb0e-4d03-a01f-14fa49bbc152', 'Isaac', 'Newton', 'isaac.newton@example.com', '$2a$10$DLkI7NAZDzWVaKG1lVtloeoPNLPoAgDDBqQKQiSAYDZXrf2QKkuHC', 'USER', NOW(), NOW()); + +-- API Keys +INSERT INTO public.api_key (uuid, token, user_account_id, created_at, updated_at) +VALUES ('a1c00673-24c5-4e0a-bdbe-22e961ee7548', 'a274793046e34a219fd0ea6362fcca61a001500b71724f4c973a017031653c20', '7e64818d-6276-46fb-8bb1-732e6e09f7e9', NOW(), NOW()); + +INSERT INTO public.api_key (uuid, token, user_account_id, created_at, updated_at) +VALUES ('62657760-21fe-488c-a0ea-f612a70493da', 'dd5dc3b53b6145cfa9f6c58b72ebad21cd2f860ace62451ba4e3c74a0e63540a', 'b5b92c69-5ed9-4054-954d-0121c29b6800', NOW(), NOW()); + +-- Saved Search Queries +INSERT INTO public.search_saved_query (uuid, name, description, type, var_prefixes, var_graph_pattern, var_ordering, user_account_id, created_at, updated_at) +VALUES ('d31e3da1-2cfa-4b55-a8cb-71d1acf01aef', 'All datasets', 'Quickly query all datasets (DCAT)', 'PUBLIC', + 'PREFIX dcat: ', '?entity rdf:type dcat:Dataset .', 'ASC(?title)', '7e64818d-6276-46fb-8bb1-732e6e09f7e9', + NOW(), NOW()); + +INSERT INTO public.search_saved_query (uuid, name, description, type, var_prefixes, var_graph_pattern, var_ordering, user_account_id, created_at, updated_at) +VALUES ('c7d0b6a0-5b0a-4b0e-9b0a-9b0a9b0a9b0a', 'All distributions', 'Quickly query all distributions (DCAT)', 'INTERNAL', + 'PREFIX dcat: ', '?entity rdf:type dcat:Distribution .', 'ASC(?title)', '7e64818d-6276-46fb-8bb1-732e6e09f7e9', + NOW(), NOW()); + +INSERT INTO public.search_saved_query (uuid, name, description, type, var_prefixes, var_graph_pattern, var_ordering, user_account_id, created_at, updated_at) +VALUES ('97da9119-834e-4687-8321-3df157547178', 'Things with data', 'This is private query of Nikola Tesla!', 'PRIVATE', + 'PREFIX dcat: ', +'?entity ?relationPredicate ?relationObject . +FILTER isLiteral(?relationObject) +FILTER CONTAINS(LCASE(str(?relationObject)), LCASE("data"))', + 'ASC(?title)', '7e64818d-6276-46fb-8bb1-732e6e09f7e9', NOW(), NOW()); diff --git a/src/test/resources/test/db/migration/V0001.2__dev-data-schemas.sql b/src/test/resources/test/db/migration/V0001.2__dev-data-schemas.sql new file mode 100644 index 000000000..310c8377f --- /dev/null +++ b/src/test/resources/test/db/migration/V0001.2__dev-data-schemas.sql @@ -0,0 +1,505 @@ +-- +-- The MIT License +-- Copyright © 2016-2024 FAIR Data Team +-- +-- Permission is hereby granted, free of charge, to any person obtaining a copy +-- of this software and associated documentation files (the "Software"), to deal +-- in the Software without restriction, including without limitation the rights +-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +-- copies of the Software, and to permit persons to whom the Software is +-- furnished to do so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in +-- all copies or substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +-- THE SOFTWARE. +-- + +-- Resource +INSERT INTO metadata_schema (uuid, created_at, updated_at) +VALUES ('6a668323-3936-4b53-8380-a4fd2ed082ee', NOW(), NOW()); +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('71d77460-f919-4f72-b265-ed26567fe361', + '6a668323-3936-4b53-8380-a4fd2ed082ee', + NULL, + '1.0.0', + 'Resource', + '', + '@prefix : . + @prefix dash: . + @prefix dcat: . + @prefix dct: . + @prefix foaf: . + @prefix sh: . + @prefix xsd: . + + :ResourceShape a sh:NodeShape ; + sh:targetClass dcat:Resource ; + sh:property [ + sh:path dct:title ; + sh:nodeKind sh:Literal ; + sh:minCount 1 ; + sh:maxCount 1 ; + dash:editor dash:TextFieldEditor ; + sh:order 1 ; + ], [ + sh:path dct:description ; + sh:nodeKind sh:Literal ; + sh:maxCount 1 ; + dash:editor dash:TextAreaEditor ; + sh:order 2 ; + ], [ + sh:path dct:publisher ; + sh:node :AgentShape ; + sh:minCount 1 ; + sh:maxCount 1 ; + dash:editor dash:BlankNodeEditor ; + sh:order 3 ; + ], [ + sh:path dcat:version ; + sh:name "version" ; + sh:nodeKind sh:Literal ; + sh:minCount 1 ; + sh:maxCount 1 ; + dash:editor dash:TextFieldEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 4 ; + ], [ + sh:path dct:language ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + dash:editor dash:URIEditor ; + dash:viewer dash:LabelViewer ; + sh:defaultValue ; + sh:order 5 ; + ], [ + sh:path dct:license ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + dash:editor dash:URIEditor ; + dash:viewer dash:LabelViewer ; + sh:defaultValue ; + sh:order 6 ; + ], [ + sh:path dct:rights ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + dash:editor dash:URIEditor ; + dash:viewer dash:LabelViewer ; + sh:order 7 ; + ] . + + :AgentShape a sh:NodeShape ; + sh:targetClass foaf:Agent ; + sh:property [ + sh:path foaf:name ; + sh:nodeKind sh:Literal ; + sh:minCount 1 ; + sh:maxCount 1 ; + dash:editor dash:TextFieldEditor ; + ] . + ', + ARRAY ['http://www.w3.org/ns/dcat#Resource'], + 'INTERNAL', + NULL, + NULL, + 'LATEST', + FALSE, + TRUE, + NULL, + NULL, + NOW(), + NOW()); + +-- Data Service +INSERT INTO metadata_schema (uuid, created_at, updated_at) +VALUES ('89d94c1b-f6ff-4545-ba9b-120b2d1921d0', NOW(), NOW()); +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('9111d436-fe58-4bd5-97ae-e6f86bc2997a', + '89d94c1b-f6ff-4545-ba9b-120b2d1921d0', + NULL, + '1.0.0', + 'Data Service', + '', + '@prefix : . +@prefix dash: . +@prefix dcat: . +@prefix dct: . +@prefix sh: . +@prefix xsd: . + +:DataServiceShape a sh:NodeShape ; + sh:targetClass dcat:DataService ; + sh:property [ + sh:path dcat:endpointURL ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + sh:order 20 ; + ] , [ + sh:path dcat:endpointDescription ; + sh:nodeKind sh:Literal ; + sh:maxCount 1 ; + dash:editor dash:TextAreaEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 21 ; +] . +', + ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#DataService'], + 'INTERNAL', + NULL, + NULL, + 'LATEST', + FALSE, + FALSE, + NULL, + NULL, + NOW(), + NOW()); +INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) +VALUES ('2efc8366-541d-493f-8661-69ad8f72dfa1', '9111d436-fe58-4bd5-97ae-e6f86bc2997a', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); + +-- Metadata Service +INSERT INTO metadata_schema (uuid, created_at, updated_at) +VALUES ('6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad', NOW(), NOW()); +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('36b22b70-6203-4dd2-9fb6-b39a776bf467', + '6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad', + NULL, + '1.0.0', + 'Metadata Service', + '', + '@prefix : . +@prefix fdp: . +@prefix sh: . + +:MetadataServiceShape a sh:NodeShape ; + sh:targetClass fdp:MetadataService . +', + ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#DataService', 'https://w3id.org/fdp/fdp-o#MetadataService'], + 'INTERNAL', + NULL, + NULL, + 'LATEST', + FALSE, + FALSE, + NULL, + NULL, + NOW(), + NOW()); +INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) +VALUES ('8742361b-cd00-4167-b859-e45fa36d0cb7', '36b22b70-6203-4dd2-9fb6-b39a776bf467', '89d94c1b-f6ff-4545-ba9b-120b2d1921d0', 0); + +-- FAIR Data Point +INSERT INTO metadata_schema (uuid, created_at, updated_at) +VALUES ('a92958ab-a414-47e6-8e17-68ba96ba3a2b', NOW(), NOW()); +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('4e64208d-f102-45a0-96e3-17b002e6213e', + 'a92958ab-a414-47e6-8e17-68ba96ba3a2b', + NULL, + '1.0.0', + 'FAIR Data Point', + '', + '@prefix : . +@prefix dash: . +@prefix dct: . +@prefix fdp: . +@prefix sh: . +@prefix xsd: . + +:FDPShape a sh:NodeShape ; + sh:targetClass fdp:FAIRDataPoint ; + sh:property [ + sh:path fdp:startDate ; + sh:datatype xsd:dateTime ; + sh:maxCount 1 ; + dash:editor dash:DatePickerEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 40 ; + ] , [ + sh:path fdp:endDate ; + sh:datatype xsd:dateTime ; + sh:maxCount 1 ; + dash:editor dash:DatePickerEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 41 ; + ] , [ + sh:path fdp:uiLanguage ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + sh:defaultValue ; + dash:editor dash:URIEditor ; + dash:viewer dash:LabelViewer ; + sh:order 42 ; + ] , [ + sh:path fdp:metadataIdentifier ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + dash:editor dash:URIEditor ; + dash:viewer dash:LabelViewer ; + sh:order 43 ; + ] , [ + sh:path fdp:metadataIssued ; + sh:datatype xsd:dateTime ; + sh:maxCount 1 ; + dash:viewer dash:LiteralViewer ; + sh:order 44 ; + ] , [ + sh:path fdp:metadataModified ; + sh:datatype xsd:dateTime ; + sh:maxCount 1 ; + dash:viewer dash:LiteralViewer ; + sh:order 45 ; + ] . + ', + ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#DataService', 'https://w3id.org/fdp/fdp-o#MetadataService', 'https://w3id.org/fdp/fdp-o#FAIRDataPoint'], + 'INTERNAL', + NULL, + NULL, + 'LATEST', + FALSE, + FALSE, + NULL, + NULL, + NOW(), + NOW()); +INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) +VALUES ('afebd441-8aa5-464d-bc3c-033f175449b4', '4e64208d-f102-45a0-96e3-17b002e6213e', '6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad', 0); + +-- Catalog +INSERT INTO metadata_schema (uuid, created_at, updated_at) +VALUES ('2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660', NOW(), NOW()); +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('c9640671-945d-4114-88fb-e81314cb7ab2', + '2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660', + NULL, + '1.0.0', + 'Catalog', + '', + '@prefix : . +@prefix dash: . +@prefix dcat: . +@prefix dct: . +@prefix foaf: . +@prefix sh: . +@prefix xsd: . + +:CatalogShape a sh:NodeShape ; + sh:targetClass dcat:Catalog ; + sh:property [ + sh:path dct:issued ; + sh:datatype xsd:dateTime ; + sh:maxCount 1 ; + dash:viewer dash:LiteralViewer ; + sh:order 20 ; + ], [ + sh:path dct:modified ; + sh:datatype xsd:dateTime ; + sh:maxCount 1 ; + dash:viewer dash:LiteralViewer ; + sh:order 21 ; + ], [ + sh:path foaf:homePage ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + dash:editor dash:URIEditor ; + dash:viewer dash:LabelViewer ; + sh:order 22 ; + ], [ + sh:path dcat:themeTaxonomy ; + sh:nodeKind sh:IRI ; + dash:viewer dash:LabelViewer ; + sh:order 23 ; + ] . +', + ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#Catalog'], + 'INTERNAL', + NULL, + NULL, + 'LATEST', + FALSE, + FALSE, + NULL, + NULL, + NOW(), + NOW()); +INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) +VALUES ('e75cb601-318d-41ea-9a8b-32e0749c80a7', 'c9640671-945d-4114-88fb-e81314cb7ab2', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); + +-- Dataset +INSERT INTO metadata_schema (uuid, created_at, updated_at) +VALUES ('866d7fb8-5982-4215-9c7c-18d0ed1bd5f3', NOW(), NOW()); +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('9cc3c89a-76cf-4639-a71f-652627af51db', + '866d7fb8-5982-4215-9c7c-18d0ed1bd5f3', + NULL, + '1.0.0', + 'Dataset', + '', + '@prefix : . +@prefix dash: . +@prefix dcat: . +@prefix dct: . +@prefix sh: . +@prefix xsd: . + +:DatasetShape a sh:NodeShape ; + sh:targetClass dcat:Dataset ; + sh:property [ + sh:path dct:issued ; + sh:datatype xsd:dateTime ; + sh:maxCount 1 ; + dash:editor dash:DatePickerEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 20 ; + ], [ + sh:path dct:modified ; + sh:datatype xsd:dateTime ; + sh:maxCount 1 ; + dash:editor dash:DatePickerEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 21 ; + ], [ + sh:path dcat:theme ; + sh:nodeKind sh:IRI ; + sh:minCount 1 ; + dash:editor dash:URIEditor ; + dash:viewer dash:LabelViewer ; + sh:order 22 ; + ], [ + sh:path dcat:contactPoint ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + dash:editor dash:URIEditor ; + dash:viewer dash:LabelViewer ; + sh:order 23 ; + ], [ + sh:path dcat:keyword ; + sh:nodeKind sh:Literal ; + dash:editor dash:TextFieldEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 24 ; + ], [ + sh:path dcat:landingPage ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + dash:editor dash:URIEditor ; + dash:viewer dash:LabelViewer ; + sh:order 25 ; + ] . +', + ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#Dataset'], + 'INTERNAL', + NULL, + NULL, + 'LATEST', + FALSE, + FALSE, + NULL, + NULL, + NOW(), + NOW()); +INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) +VALUES ('da13ba37-09f8-4937-9055-e3ee3aefc57c', '9cc3c89a-76cf-4639-a71f-652627af51db', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); + +-- Distribution +INSERT INTO metadata_schema (uuid, created_at, updated_at) +VALUES ('ebacbf83-cd4f-4113-8738-d73c0735b0ab', NOW(), NOW()); +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('3cda8cd3-b08b-4797-822d-d3f3e83c466a', + 'ebacbf83-cd4f-4113-8738-d73c0735b0ab', + NULL, + '1.0.0', + 'Distribution', + '', + '@prefix : . +@prefix dash: . +@prefix dcat: . +@prefix dct: . +@prefix sh: . +@prefix xsd: . + +:DistributionShape a sh:NodeShape ; + sh:targetClass dcat:Distribution ; + sh:property [ + sh:path dct:issued ; + sh:datatype xsd:dateTime ; + sh:maxCount 1 ; + dash:editor dash:DatePickerEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 20 ; + ] , [ + sh:path dct:modified ; + sh:datatype xsd:dateTime ; + sh:maxCount 1 ; + dash:editor dash:DatePickerEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 21 ; + ] , [ + sh:path dcat:accessURL ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + dash:editor dash:URIEditor ; + sh:order 22 ; + ] , [ + sh:path dcat:downloadURL ; + sh:nodeKind sh:IRI ; + sh:maxCount 1 ; + dash:editor dash:URIEditor ; + sh:order 23 ; + ] , [ + sh:path dcat:mediaType ; + sh:nodeKind sh:Literal ; + sh:minCount 1 ; + sh:maxCount 1 ; + dash:editor dash:TextFieldEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 24 ; + ] , [ + sh:path dcat:format ; + sh:nodeKind sh:Literal ; + sh:maxCount 1 ; + dash:editor dash:TextFieldEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 25 ; + ] , [ + sh:path dcat:byteSize ; + sh:nodeKind sh:Literal ; + sh:maxCount 1 ; + dash:editor dash:TextFieldEditor ; + dash:viewer dash:LiteralViewer ; + sh:order 26 ; + ] . +', + ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#Distribution'], + 'INTERNAL', + NULL, + NULL, + 'LATEST', + FALSE, + FALSE, + NULL, + NULL, + NOW(), + NOW()); +INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) +VALUES ('a3b16a4e-cac7-4b71-a3de-94bb86714b5b', '3cda8cd3-b08b-4797-822d-d3f3e83c466a', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); diff --git a/src/test/resources/test/db/migration/V0001.3__dev-data-rds.sql b/src/test/resources/test/db/migration/V0001.3__dev-data-rds.sql new file mode 100644 index 000000000..ed4f047ff --- /dev/null +++ b/src/test/resources/test/db/migration/V0001.3__dev-data-rds.sql @@ -0,0 +1,68 @@ +-- +-- The MIT License +-- Copyright © 2016-2024 FAIR Data Team +-- +-- Permission is hereby granted, free of charge, to any person obtaining a copy +-- of this software and associated documentation files (the "Software"), to deal +-- in the Software without restriction, including without limitation the rights +-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +-- copies of the Software, and to permit persons to whom the Software is +-- furnished to do so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in +-- all copies or substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +-- THE SOFTWARE. +-- + +-- Distribution +INSERT INTO resource_definition (uuid, name, url_prefix, created_at, updated_at) +VALUES ('02c649de-c579-43bb-b470-306abdc808c7', 'Distribution', 'distribution', now(), now()); + +INSERT INTO resource_definition_link (uuid, resource_definition_id, title, property_uri, order_priority, created_at, updated_at) +VALUES ('660a1821-a5d2-48d0-a26b-0c6d5bac3de4', '02c649de-c579-43bb-b470-306abdc808c7', 'Access online', 'http://www.w3.org/ns/dcat#accessURL', 1, now(), now()); + +INSERT INTO resource_definition_link (uuid, resource_definition_id, title, property_uri, order_priority, created_at, updated_at) +VALUES ('c2eaebb8-4d8d-469d-8736-269adeded996', '02c649de-c579-43bb-b470-306abdc808c7', 'Download', 'http://www.w3.org/ns/dcat#downloadURL', 2, now(), now()); + +INSERT INTO metadata_schema_usage (uuid, resource_definition_id, metadata_schema_id, order_priority) +VALUES ('bbf4ecb3-c529-4c02-955c-7160755debf5', '02c649de-c579-43bb-b470-306abdc808c7', 'ebacbf83-cd4f-4113-8738-d73c0735b0ab', 1); + +-- Dataset +INSERT INTO resource_definition (uuid, name, url_prefix, created_at, updated_at) +VALUES ('2f08228e-1789-40f8-84cd-28e3288c3604', 'Dataset', 'dataset', now(), now()); + +INSERT INTO resource_definition_child (uuid, source_resource_definition_id, target_resource_definition_id, relation_uri, title, tags_uri, order_priority, created_at, updated_at) +VALUES ('9f138a13-9d45-4371-b763-0a3b9e0ec912', '2f08228e-1789-40f8-84cd-28e3288c3604', '02c649de-c579-43bb-b470-306abdc808c7', 'http://www.w3.org/ns/dcat#distribution', 'Distributions', NULL, 1, now(), now()); + +INSERT INTO resource_definition_child_metadata (uuid, resource_definition_child_id, title, property_uri, order_priority, created_at, updated_at) +VALUES ('723e95d3-1696-45e2-9429-f6e98e3fb893', '9f138a13-9d45-4371-b763-0a3b9e0ec912', 'Media Type', 'http://www.w3.org/ns/dcat#mediaType', 1, now(), now()); + +INSERT INTO metadata_schema_usage (uuid, resource_definition_id, metadata_schema_id, order_priority) +VALUES ('b8a0ed37-42a1-487e-8842-09fe082c4cc6', '2f08228e-1789-40f8-84cd-28e3288c3604', '866d7fb8-5982-4215-9c7c-18d0ed1bd5f3', 1); + +-- Catalog +INSERT INTO resource_definition (uuid, name, url_prefix, created_at, updated_at) +VALUES ('a0949e72-4466-4d53-8900-9436d1049a4b', 'Catalog', 'catalog', now(), now()); + +INSERT INTO resource_definition_child (uuid, source_resource_definition_id, target_resource_definition_id, relation_uri, title, tags_uri, order_priority, created_at, updated_at) +VALUES ('e9f0f5d3-2a93-4aa3-9dd0-acb1d76f54fc', 'a0949e72-4466-4d53-8900-9436d1049a4b', '2f08228e-1789-40f8-84cd-28e3288c3604', 'http://www.w3.org/ns/dcat#dataset', 'Datasets', 'http://www.w3.org/ns/dcat#theme', 1, now(), now()); + +INSERT INTO metadata_schema_usage (uuid, resource_definition_id, metadata_schema_id, order_priority) +VALUES ('e4df9510-a3ad-4e3b-a1a9-5fc330d8b1f0', 'a0949e72-4466-4d53-8900-9436d1049a4b', '2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660', 1); + +-- FAIR Data Point +INSERT INTO resource_definition (uuid, name, url_prefix, created_at, updated_at) +VALUES ('77aaad6a-0136-4c6e-88b9-07ffccd0ee4c', 'FAIR Data Point', '', now(), now()); + +INSERT INTO resource_definition_child (uuid, source_resource_definition_id, target_resource_definition_id, relation_uri, title, tags_uri, order_priority, created_at, updated_at) +VALUES ('b8648597-8fbd-4b89-9e30-5eab82675e42', '77aaad6a-0136-4c6e-88b9-07ffccd0ee4c', 'a0949e72-4466-4d53-8900-9436d1049a4b', 'https://w3id.org/fdp/fdp-o#metadataCatalog', 'Catalogs', 'http://www.w3.org/ns/dcat#themeTaxonomy', 1, now(), now()); + +INSERT INTO metadata_schema_usage (uuid, resource_definition_id, metadata_schema_id, order_priority) +VALUES ('9b3a32a8-a14c-4eb0-ba02-3aa8e13a8f11', '77aaad6a-0136-4c6e-88b9-07ffccd0ee4c', 'a92958ab-a414-47e6-8e17-68ba96ba3a2b', 1); diff --git a/src/test/resources/test/db/migration/V0001.4__dev-data-membership.sql b/src/test/resources/test/db/migration/V0001.4__dev-data-membership.sql new file mode 100644 index 000000000..8240e0bfe --- /dev/null +++ b/src/test/resources/test/db/migration/V0001.4__dev-data-membership.sql @@ -0,0 +1,43 @@ +-- +-- The MIT License +-- Copyright © 2016-2024 FAIR Data Team +-- +-- Permission is hereby granted, free of charge, to any person obtaining a copy +-- of this software and associated documentation files (the "Software"), to deal +-- in the Software without restriction, including without limitation the rights +-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +-- copies of the Software, and to permit persons to whom the Software is +-- furnished to do so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in +-- all copies or substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +-- THE SOFTWARE. +-- + +INSERT INTO membership (uuid, name, allowed_entities, created_at, updated_at) +VALUES ('49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 'Owner', ARRAY ['a0949e72-4466-4d53-8900-9436d1049a4b', '2f08228e-1789-40f8-84cd-28e3288c3604', '02c649de-c579-43bb-b470-306abdc808c7'], NOW(), NOW()); + +INSERT INTO membership (uuid, name, allowed_entities, created_at, updated_at) +VALUES ('87a2d984-7db2-43f6-805c-6b0040afead5', 'Data Provider', ARRAY ['a0949e72-4466-4d53-8900-9436d1049a4b'], NOW(), NOW()); + +INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) +VALUES ('e0d9f853-637b-4c50-9ad9-07b6349bf76f', '49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 2, 'W', NOW(), NOW()); + +INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) +VALUES ('de4e4f85-f11d-475b-b6f0-33bdfe5f923a', '49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 4, 'C', NOW(), NOW()); + +INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) +VALUES ('60bebbf0-210d-4b05-af85-ca1b58546261', '49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 8, 'D', NOW(), NOW()); + +INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) +VALUES ('36c3b6e9-f2e3-48b7-bae1-4dc3196a3657', '49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 16, 'A', NOW(), NOW()); + +INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) +VALUES ('589d09d3-1c29-4c6f-97fc-6ea4e007fb85', '87a2d984-7db2-43f6-805c-6b0040afead5', 4, 'C', NOW(), NOW()); diff --git a/src/test/resources/test/db/migration/V0001.5__dev-settings.sql b/src/test/resources/test/db/migration/V0001.5__dev-settings.sql new file mode 100644 index 000000000..75496e02a --- /dev/null +++ b/src/test/resources/test/db/migration/V0001.5__dev-settings.sql @@ -0,0 +1,73 @@ +-- +-- The MIT License +-- Copyright © 2016-2024 FAIR Data Team +-- +-- Permission is hereby granted, free of charge, to any person obtaining a copy +-- of this software and associated documentation files (the "Software"), to deal +-- in the Software without restriction, including without limitation the rights +-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +-- copies of the Software, and to permit persons to whom the Software is +-- furnished to do so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in +-- all copies or substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +-- THE SOFTWARE. +-- + +-- Settings +INSERT INTO settings (uuid, app_title, app_subtitle, ping_enabled, ping_endpoints, autocomplete_search_ns, created_at, updated_at) +VALUES ('00000000-0000-0000-0000-000000000000', 'FAIR Data Point', 'FDP Development Instance', False, ARRAY ['https://home.fairdatapoint.org'], True, now(), now()); + +-- Autocomplete Sources +INSERT INTO settings_autocomplete_source (uuid, settings_id, rdf_type, sparql_endpoint, sparql_query, order_priority, created_at, updated_at) +VALUES ('d4045a98-dd25-493e-a0b1-d704921c0930', '00000000-0000-0000-0000-000000000000', 'http://www.w3.org/2000/01/rdf-schema#Class', 'http://localhost:3030/ds/query', +'SELECT DISTINCT ?uri ?label +WHERE { ?uri a . +?uri ?label . +FILTER regex(?label, ".*%s.*", "i") } +ORDER BY ?label', + 1, now(), now()); + +-- Search Filters: Type +INSERT INTO settings_search_filter (uuid, settings_id, type, label, predicate, query_records, order_priority, created_at, updated_at) +VALUES ('57a98728-ce8c-4e7f-b0f8-94e2668b44d3', '00000000-0000-0000-0000-000000000000', 'IRI', 'Type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', False, 1, now(), now()); + +INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) +VALUES ('b48c2c7f-d7fb-47ae-a72c-b1b360e16f6e', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Catalog', 'http://www.w3.org/ns/dcat#Catalog', 1, now(), now()); + +INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) +VALUES ('3e1598ac-9d29-47f0-8e7b-3c26ca0134a0', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Dataset', 'http://www.w3.org/ns/dcat#Dataset', 2, now(), now()); + +INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) +VALUES ('5697d8d9-f09d-4ebe-b834-b37eb0624c3f', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Distribution', 'http://www.w3.org/ns/dcat#Distribution', 3, now(), now()); + +INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) +VALUES ('022c3bc6-0598-408c-8d2e-b486dafb73dd', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Data Service', 'http://www.w3.org/ns/dcat#DataService', 4, now(), now()); + +INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) +VALUES ('7cee5591-8620-4fea-b883-a94285012b8d', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Metadata Service', 'https://w3id.org/fdp/fdp-o#MetadataService', 5, now(), now()); + +INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) +VALUES ('9d661dca-8017-4dba-b930-cd2834ea59e8', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'FAIR Data Point', 'https://w3id.org/fdp/fdp-o#FAIRDataPoint', 6, now(), now()); + +-- Search Filters: License +INSERT INTO settings_search_filter (uuid, settings_id, type, label, predicate, query_records, order_priority, created_at, updated_at) +VALUES ('26913eb3-67dd-45c9-b8ff-4c97e8162a9b', '00000000-0000-0000-0000-000000000000', 'IRI', 'License', 'http://purl.org/dc/terms/license', True, 2, now(), now()); + +-- Search Filters: License +INSERT INTO settings_search_filter (uuid, settings_id, type, label, predicate, query_records, order_priority, created_at, updated_at) +VALUES ('cb25afb4-6169-42f8-bde5-181c803773a8', '00000000-0000-0000-0000-000000000000', 'IRI', 'Version', 'http://www.w3.org/ns/dcat#version', True, 3, now(), now()); + +-- Metrics +INSERT INTO settings_metric (uuid, settings_id, metric_uri, resource_uri, order_priority, created_at, updated_at) +VALUES ('8435491b-c16c-4457-ae94-e0f4128603d5', '00000000-0000-0000-0000-000000000000', 'https://purl.org/fair-metrics/FM_F1A', 'https://www.ietf.org/rfc/rfc3986.txt', 1, now(), now()); + +INSERT INTO settings_metric (uuid, settings_id, metric_uri, resource_uri, order_priority, created_at, updated_at) +VALUES ('af93d36a-0af0-4054-8c00-2675d460b231', '00000000-0000-0000-0000-000000000000', 'https://purl.org/fair-metrics/FM_A1.1', 'https://www.wikidata.org/wiki/Q8777', 2, now(), now()); diff --git a/src/test/resources/test/db/migration/V0001.6__test-schemas.sql b/src/test/resources/test/db/migration/V0001.6__test-schemas.sql new file mode 100644 index 000000000..b340329e8 --- /dev/null +++ b/src/test/resources/test/db/migration/V0001.6__test-schemas.sql @@ -0,0 +1,161 @@ +-- +-- The MIT License +-- Copyright © 2016-2024 FAIR Data Team +-- +-- Permission is hereby granted, free of charge, to any person obtaining a copy +-- of this software and associated documentation files (the "Software"), to deal +-- in the Software without restriction, including without limitation the rights +-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +-- copies of the Software, and to permit persons to whom the Software is +-- furnished to do so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in +-- all copies or substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +-- THE SOFTWARE. +-- + +-- Custom with one version +INSERT INTO metadata_schema (uuid, created_at, updated_at) +VALUES ('e8b34158-3858-45c7-8e3e-d1e671dd9929', NOW(), NOW()); + +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('53619e58-2bb0-4baf-afd8-00c5d01ff8a8', 'e8b34158-3858-45c7-8e3e-d1e671dd9929', NULL, '0.1.0', 'Custom schema', + 'Custom schema V1', + '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LATEST', TRUE, FALSE, NULL, + NULL, NOW(), NOW()); + +-- Custom with one draft +INSERT INTO metadata_schema (uuid, created_at, updated_at) +VALUES ('bfa79edf-00b7-4a04-b5a6-a5144f1a77b7', NOW(), NOW()); + +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('cb9f6cd7-97af-45d0-b23d-d0aab23607d8', 'bfa79edf-00b7-4a04-b5a6-a5144f1a77b7', NULL, '0.1.0', 'Custom schema', + 'Custom schema V1', + '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'DRAFT', FALSE, FALSE, NULL, + NULL, NOW(), NOW()); + + +-- Custom with one version INTERNAL +INSERT INTO metadata_schema (uuid, created_at, updated_at) +VALUES ('fe98adbb-6a2c-4c7a-b2b2-a72db5140c61', NOW(), NOW()); + +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('f0a4b358-69a3-44e6-9436-c68a56a9f2f2', 'fe98adbb-6a2c-4c7a-b2b2-a72db5140c61', NULL, '0.1.0', 'Custom schema', + 'Custom schema V1', + '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'INTERNAL', NULL, NULL, 'LATEST', TRUE, FALSE, NULL, + NULL, NOW(), NOW()); + +-- Custom with multiple versions +INSERT INTO metadata_schema (uuid, created_at, updated_at) +VALUES ('978e5c1c-268d-4822-b60b-07d3eccc6896', NOW(), NOW()); + +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('d7acec53-5ac9-4502-9bfa-92d1e9f79a24', '978e5c1c-268d-4822-b60b-07d3eccc6896', NULL, '0.1.0', 'Custom schema', + 'Custom schema V1', + '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LEGACY', FALSE, FALSE, NULL, + NULL, NOW(), NOW()); + +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('67896adc-b431-431d-8296-f0b80d8de412', '978e5c1c-268d-4822-b60b-07d3eccc6896', 'd7acec53-5ac9-4502-9bfa-92d1e9f79a24', '0.2.0', 'Custom schema', + 'Custom schema V2', + '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LEGACY', FALSE, FALSE, NULL, + NULL, NOW(), NOW()); + +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('c62d4a97-baac-40b8-b6ea-e43b06ec78bd', '978e5c1c-268d-4822-b60b-07d3eccc6896', '67896adc-b431-431d-8296-f0b80d8de412', '0.3.0', 'Custom schema', + 'Custom schema V3', + '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LATEST', FALSE, FALSE, NULL, + NULL, NOW(), NOW()); + +-- Custom with draft +INSERT INTO metadata_schema (uuid, created_at, updated_at) +VALUES ('e7078309-cb4c-47b9-9ef8-057487b3da58', NOW(), NOW()); + +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('a17c25ad-e8d3-4338-bb3e-eda76d2fc32c', 'e7078309-cb4c-47b9-9ef8-057487b3da58', NULL, '0.0.0', 'Custom schema', + 'Custom schema draft', + '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'DRAFT', FALSE, FALSE, NULL, + NULL, NOW(), NOW()); + +-- Custom with multiple versions and draft +INSERT INTO metadata_schema (uuid, created_at, updated_at) +VALUES ('123e48d2-9995-4b44-8b2c-9c81bdbf2dd2', NOW(), NOW()); + +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('fb24f92b-187f-4d53-b744-73024b537f30', '123e48d2-9995-4b44-8b2c-9c81bdbf2dd2', NULL, '0.1.0', 'Custom schema', + 'Custom schema V1', + '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LEGACY', FALSE, FALSE, NULL, + NULL, NOW(), NOW()); + +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('6011adfa-f8da-478d-86ea-84bb644b458b', '123e48d2-9995-4b44-8b2c-9c81bdbf2dd2', 'fb24f92b-187f-4d53-b744-73024b537f30', '0.2.0', 'Custom schema', + 'Custom schema V2', + '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LATEST', FALSE, FALSE, NULL, + NULL, NOW(), NOW()); + +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('6b84ec86-2096-48db-bfc7-23506b8c080c', '123e48d2-9995-4b44-8b2c-9c81bdbf2dd2', '6011adfa-f8da-478d-86ea-84bb644b458b', '0.0.0', 'Custom schema', + 'Custom schema draft', + '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'DRAFT', FALSE, FALSE, NULL, + NULL, NOW(), NOW()); + +-- Custom with multiple versions and draft and extends +INSERT INTO metadata_schema (uuid, created_at, updated_at) +VALUES ('7c8b8699-ca9f-4d14-86e2-2299b27c5711', NOW(), NOW()); + +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('4e44fb19-b9e0-46e9-957a-e7aa3adac7bf', '7c8b8699-ca9f-4d14-86e2-2299b27c5711', NULL, '0.1.0', 'Custom schema', + 'Custom schema V1', + '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LEGACY', FALSE, FALSE, NULL, + NULL, NOW(), NOW()); + +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('abcf3a21-6f9a-45dc-a71a-4dde4440c81a', '7c8b8699-ca9f-4d14-86e2-2299b27c5711', '4e44fb19-b9e0-46e9-957a-e7aa3adac7bf', '0.2.0', 'Custom schema', + 'Custom schema V2', + '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LATEST', FALSE, FALSE, NULL, + NULL, NOW(), NOW()); +INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) +VALUES ('1bdca611-c96e-4304-b1f3-030d282ef529', 'abcf3a21-6f9a-45dc-a71a-4dde4440c81a', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); +INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) +VALUES ('1bdca611-c96e-4304-b1f3-030d282ef530', 'abcf3a21-6f9a-45dc-a71a-4dde4440c81a', '123e48d2-9995-4b44-8b2c-9c81bdbf2dd2', 1); + +INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, + definition, target_classes, type, origin, imported_from, state, published, + abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) +VALUES ('a6d609ff-905f-4edd-bdb1-2dce000c9a45', '7c8b8699-ca9f-4d14-86e2-2299b27c5711', 'abcf3a21-6f9a-45dc-a71a-4dde4440c81a', '0.0.0', 'Custom schema', + 'Custom schema draft', + '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'DRAFT', FALSE, FALSE, NULL, + NULL, NOW(), NOW()); +INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) +VALUES ('53e3db46-8fe4-47ce-873e-ed7db94e73b3', 'a6d609ff-905f-4edd-bdb1-2dce000c9a45', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); From f3e49cbcb5412d4eab515348dcb59214870ea2a6 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Fri, 14 Nov 2025 17:23:13 +0100 Subject: [PATCH 34/53] replace V0001.1__dev-data-users.sql test data migration by json fixture file --- ...users-with-api-keys-and-saved-queries.json | 93 +++++++++++++++++++ .../db/migration/V0001.1__dev-data-users.sql | 61 ------------ 2 files changed, 93 insertions(+), 61 deletions(-) create mode 100644 src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json delete mode 100644 src/test/resources/test/db/migration/V0001.1__dev-data-users.sql diff --git a/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json b/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json new file mode 100644 index 000000000..eb1249f67 --- /dev/null +++ b/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json @@ -0,0 +1,93 @@ +[ + { + "_class": "org.fairdatapoint.entity.user.UserAccount", + "uuid": "7e64818d-6276-46fb-8bb1-732e6e09f7e9", + "firstName": "Albert", + "lastName": "Einstein", + "email": "albert.einstein@example.org", + "passwordHash": "$2a$10$hZF1abbZ48Tf.3RndC9W6OlDt6gnBoD/2HbzJayTs6be7d.5DbpnW", + "role": "USER" + }, + { + "_class": "org.fairdatapoint.entity.user.UserAccount", + "uuid": "b5b92c69-5ed9-4054-954d-0121c29b6800", + "firstName": "Nikola", + "lastName": "Tesla", + "email": "nikola.tesla@example.org", + "passwordHash": "$2a$10$tMbZUZg9AbYL514R.hZ0tuzvfZJR5NQhSVeJPTQhNwPf6gv/cvrna", + "role": "USER" + }, + { + "_class": "org.fairdatapoint.entity.user.UserAccount", + "uuid": "8d1a4c06-bb0e-4d03-a01f-14fa49bbc152", + "firstName": "Isaac", + "lastName": "Newton", + "email": "isaac.newton@example.org", + "passwordHash": "$2a$10$DLkI7NAZDzWVaKG1lVtloeoPNLPoAgDDBqQKQiSAYDZXrf2QKkuHC", + "role": "USER" + }, + { + "_class": "org.fairdatapoint.entity.user.UserAccount", + "uuid": "95589e50-d261-492b-8852-9324e9a66a42", + "firstName": "Admin", + "lastName": "von Universe", + "email": "admin@example.org", + "passwordHash": "$2a$10$L.0OZ8QjV3yLhoCDvU04gu.WP1wGQih41MsBdvtQOshJJntaugBxe", + "role": "ADMIN" + }, + { + "_class": "org.fairdatapoint.entity.apikey.ApiKey", + "uuid": "a1c00673-24c5-4e0a-bdbe-22e961ee7548", + "token": "a274793046e34a219fd0ea6362fcca61a001500b71724f4c973a017031653c20", + "userAccount": { + "uuid": "7e64818d-6276-46fb-8bb1-732e6e09f7e9" + } + }, + { + "_class": "org.fairdatapoint.entity.apikey.ApiKey", + "uuid": "62657760-21fe-488c-a0ea-f612a70493da", + "token": "dd5dc3b53b6145cfa9f6c58b72ebad21cd2f860ace62451ba4e3c74a0e63540a", + "userAccount": { + "uuid": "b5b92c69-5ed9-4054-954d-0121c29b6800" + } + }, + { + "_class" : "org.fairdatapoint.entity.search.SearchSavedQuery", + "uuid": "d31e3da1-2cfa-4b55-a8cb-71d1acf01aef", + "name": "All datasets", + "description": "Quickly query all datasets (DCAT)", + "type": "PUBLIC", + "varPrefixes": "PREFIX dcat: ", + "varGraphPattern": "?entity rdf:type dcat:Dataset .", + "varOrdering": "ASC(?title)", + "userAccount": { + "uuid": "7e64818d-6276-46fb-8bb1-732e6e09f7e9" + } + }, + { + "_class" : "org.fairdatapoint.entity.search.SearchSavedQuery", + "uuid": "c7d0b6a0-5b0a-4b0e-9b0a-9b0a9b0a9b0a", + "name": "All distributions", + "description": "Quickly query all distributions (DCAT)", + "type": "INTERNAL", + "varPrefixes": "PREFIX dcat: ", + "varGraphPattern": "?entity rdf:type dcat:Distribution .", + "varOrdering": "ASC(?title)", + "userAccount": { + "uuid": "7e64818d-6276-46fb-8bb1-732e6e09f7e9" + } + }, + { + "_class" : "org.fairdatapoint.entity.search.SearchSavedQuery", + "uuid": "97da9119-834e-4687-8321-3df157547178", + "name": "Things with data", + "description": "This is private query of Nikola Tesla!", + "type": "PRIVATE", + "varPrefixes": "PREFIX dcat: ", + "varGraphPattern": "?entity ?relationPredicate ?relationObject .\nFILTER isLiteral(?relationObject)\nFILTER CONTAINS(LCASE(str(?relationObject)), LCASE(\"data\"))", + "varOrdering": "ASC(?title)", + "userAccount": { + "uuid": "7e64818d-6276-46fb-8bb1-732e6e09f7e9" + } + } +] \ No newline at end of file diff --git a/src/test/resources/test/db/migration/V0001.1__dev-data-users.sql b/src/test/resources/test/db/migration/V0001.1__dev-data-users.sql deleted file mode 100644 index cd8e0a967..000000000 --- a/src/test/resources/test/db/migration/V0001.1__dev-data-users.sql +++ /dev/null @@ -1,61 +0,0 @@ --- --- The MIT License --- Copyright © 2016-2024 FAIR Data Team --- --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- - --- User Accounts -INSERT INTO public.user_account (uuid, first_name, last_name, email, password_hash, user_role, created_at, updated_at) -VALUES ('95589e50-d261-492b-8852-9324e9a66a42', 'Admin', 'von Universe', 'admin@example.com', '$2a$10$L.0OZ8QjV3yLhoCDvU04gu.WP1wGQih41MsBdvtQOshJJntaugBxe', 'ADMIN', NOW(), NOW()); - -INSERT INTO public.user_account (uuid, first_name, last_name, email, password_hash, user_role, created_at, updated_at) -VALUES ('7e64818d-6276-46fb-8bb1-732e6e09f7e9', 'Albert', 'Einstein', 'albert.einstein@example.com', '$2a$10$hZF1abbZ48Tf.3RndC9W6OlDt6gnBoD/2HbzJayTs6be7d.5DbpnW', 'USER', NOW(), NOW()); - -INSERT INTO public.user_account (uuid, first_name, last_name, email, password_hash, user_role, created_at, updated_at) -VALUES ('b5b92c69-5ed9-4054-954d-0121c29b6800', 'Nikola', 'Tesla', 'nikola.tesla@example.com', '$2a$10$tMbZUZg9AbYL514R.hZ0tuzvfZJR5NQhSVeJPTQhNwPf6gv/cvrna', 'USER', NOW(), NOW()); - -INSERT INTO public.user_account (uuid, first_name, last_name, email, password_hash, user_role, created_at, updated_at) -VALUES ('8d1a4c06-bb0e-4d03-a01f-14fa49bbc152', 'Isaac', 'Newton', 'isaac.newton@example.com', '$2a$10$DLkI7NAZDzWVaKG1lVtloeoPNLPoAgDDBqQKQiSAYDZXrf2QKkuHC', 'USER', NOW(), NOW()); - --- API Keys -INSERT INTO public.api_key (uuid, token, user_account_id, created_at, updated_at) -VALUES ('a1c00673-24c5-4e0a-bdbe-22e961ee7548', 'a274793046e34a219fd0ea6362fcca61a001500b71724f4c973a017031653c20', '7e64818d-6276-46fb-8bb1-732e6e09f7e9', NOW(), NOW()); - -INSERT INTO public.api_key (uuid, token, user_account_id, created_at, updated_at) -VALUES ('62657760-21fe-488c-a0ea-f612a70493da', 'dd5dc3b53b6145cfa9f6c58b72ebad21cd2f860ace62451ba4e3c74a0e63540a', 'b5b92c69-5ed9-4054-954d-0121c29b6800', NOW(), NOW()); - --- Saved Search Queries -INSERT INTO public.search_saved_query (uuid, name, description, type, var_prefixes, var_graph_pattern, var_ordering, user_account_id, created_at, updated_at) -VALUES ('d31e3da1-2cfa-4b55-a8cb-71d1acf01aef', 'All datasets', 'Quickly query all datasets (DCAT)', 'PUBLIC', - 'PREFIX dcat: ', '?entity rdf:type dcat:Dataset .', 'ASC(?title)', '7e64818d-6276-46fb-8bb1-732e6e09f7e9', - NOW(), NOW()); - -INSERT INTO public.search_saved_query (uuid, name, description, type, var_prefixes, var_graph_pattern, var_ordering, user_account_id, created_at, updated_at) -VALUES ('c7d0b6a0-5b0a-4b0e-9b0a-9b0a9b0a9b0a', 'All distributions', 'Quickly query all distributions (DCAT)', 'INTERNAL', - 'PREFIX dcat: ', '?entity rdf:type dcat:Distribution .', 'ASC(?title)', '7e64818d-6276-46fb-8bb1-732e6e09f7e9', - NOW(), NOW()); - -INSERT INTO public.search_saved_query (uuid, name, description, type, var_prefixes, var_graph_pattern, var_ordering, user_account_id, created_at, updated_at) -VALUES ('97da9119-834e-4687-8321-3df157547178', 'Things with data', 'This is private query of Nikola Tesla!', 'PRIVATE', - 'PREFIX dcat: ', -'?entity ?relationPredicate ?relationObject . -FILTER isLiteral(?relationObject) -FILTER CONTAINS(LCASE(str(?relationObject)), LCASE("data"))', - 'ASC(?title)', '7e64818d-6276-46fb-8bb1-732e6e09f7e9', NOW(), NOW()); From caddb3d415be0897239c27f42ab9a519aa790366 Mon Sep 17 00:00:00 2001 From: Dennis <29799340+dennisvang@users.noreply.github.com> Date: Fri, 14 Nov 2025 17:33:24 +0100 Subject: [PATCH 35/53] cherry-pick: Make test logging config easier to use (#806) * include root logger AppenderRef, so we only need to change the log level, when required * rename test logging config file for clarity and conformance to log4j2 best practices --- src/test/resources/{log4j2.xml => log4j2-test.xml} | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) rename src/test/resources/{log4j2.xml => log4j2-test.xml} (60%) diff --git a/src/test/resources/log4j2.xml b/src/test/resources/log4j2-test.xml similarity index 60% rename from src/test/resources/log4j2.xml rename to src/test/resources/log4j2-test.xml index 77fa02165..580d6530a 100644 --- a/src/test/resources/log4j2.xml +++ b/src/test/resources/log4j2-test.xml @@ -6,8 +6,11 @@ - + - + + + + From d14ce0ff50376b23ebff1b34648e00b1abf45f22 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Mon, 8 Dec 2025 16:19:18 +0100 Subject: [PATCH 36/53] adapt bootstrap.locations for DatabaseBootstrapTests --- .../db/repository/bootstrap/DatabaseBootstrapTests.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java b/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java index 0a8cedff4..fa3f78e3d 100644 --- a/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java +++ b/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java @@ -43,12 +43,7 @@ @AutoConfigureTestEntityManager @Transactional -@TestPropertySource( - properties = """ - bootstrap.enabled=true - bootstrap.db-fixtures-dirs=src/test/resources/fixtures - """ -) +@TestPropertySource(properties = "bootstrap.locations[0]=file:src/test/resources/fixtures") public class DatabaseBootstrapTests extends BaseIntegrationTest { @Autowired private UserAccountRepository userAccountRepository; From a1e6c8c801203d4fe8d9429ddd105c2fe922b19d Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Mon, 8 Dec 2025 17:00:16 +0100 Subject: [PATCH 37/53] re-populate db from fixtures after flyway clean in WebIntegrationTest.setup --- .../org/fairdatapoint/WebIntegrationTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/java/org/fairdatapoint/WebIntegrationTest.java b/src/test/java/org/fairdatapoint/WebIntegrationTest.java index 6fe2e758a..79a357ce8 100644 --- a/src/test/java/org/fairdatapoint/WebIntegrationTest.java +++ b/src/test/java/org/fairdatapoint/WebIntegrationTest.java @@ -30,6 +30,9 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.context.ApplicationContext; +import org.springframework.data.repository.init.ResourceReaderRepositoryPopulator; +import org.springframework.data.repository.support.Repositories; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -64,10 +67,22 @@ public abstract class WebIntegrationTest { @Autowired protected AclMigration aclMigration; + @Autowired + private ApplicationContext applicationContext; + + @Autowired + private ResourceReaderRepositoryPopulator populator; + @BeforeEach public void setup() { + // drop test database content flyway.clean(); + // re-migrate schemas flyway.migrate(); + // re-populate the database using fixtures + populator.populate(new Repositories(applicationContext)); + // re-migrate acl data + // (TODO: AclMigration is in a subfolder of rdf/migration, but is it even related to rdf? Looks relational...) aclMigration.runMigration(); } } From 636c38cf260e0fc39f0dd80bbe6d0b6f521c73ea Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Mon, 8 Dec 2025 20:09:25 +0100 Subject: [PATCH 38/53] delete V0001.2__dev-data-schemas.sql because it is covered by the default 02xx fixtures --- .../migration/V0001.2__dev-data-schemas.sql | 505 ------------------ 1 file changed, 505 deletions(-) delete mode 100644 src/test/resources/test/db/migration/V0001.2__dev-data-schemas.sql diff --git a/src/test/resources/test/db/migration/V0001.2__dev-data-schemas.sql b/src/test/resources/test/db/migration/V0001.2__dev-data-schemas.sql deleted file mode 100644 index 310c8377f..000000000 --- a/src/test/resources/test/db/migration/V0001.2__dev-data-schemas.sql +++ /dev/null @@ -1,505 +0,0 @@ --- --- The MIT License --- Copyright © 2016-2024 FAIR Data Team --- --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- - --- Resource -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('6a668323-3936-4b53-8380-a4fd2ed082ee', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('71d77460-f919-4f72-b265-ed26567fe361', - '6a668323-3936-4b53-8380-a4fd2ed082ee', - NULL, - '1.0.0', - 'Resource', - '', - '@prefix : . - @prefix dash: . - @prefix dcat: . - @prefix dct: . - @prefix foaf: . - @prefix sh: . - @prefix xsd: . - - :ResourceShape a sh:NodeShape ; - sh:targetClass dcat:Resource ; - sh:property [ - sh:path dct:title ; - sh:nodeKind sh:Literal ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - sh:order 1 ; - ], [ - sh:path dct:description ; - sh:nodeKind sh:Literal ; - sh:maxCount 1 ; - dash:editor dash:TextAreaEditor ; - sh:order 2 ; - ], [ - sh:path dct:publisher ; - sh:node :AgentShape ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:BlankNodeEditor ; - sh:order 3 ; - ], [ - sh:path dcat:version ; - sh:name "version" ; - sh:nodeKind sh:Literal ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 4 ; - ], [ - sh:path dct:language ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:defaultValue ; - sh:order 5 ; - ], [ - sh:path dct:license ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:defaultValue ; - sh:order 6 ; - ], [ - sh:path dct:rights ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 7 ; - ] . - - :AgentShape a sh:NodeShape ; - sh:targetClass foaf:Agent ; - sh:property [ - sh:path foaf:name ; - sh:nodeKind sh:Literal ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - ] . - ', - ARRAY ['http://www.w3.org/ns/dcat#Resource'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - TRUE, - NULL, - NULL, - NOW(), - NOW()); - --- Data Service -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('89d94c1b-f6ff-4545-ba9b-120b2d1921d0', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('9111d436-fe58-4bd5-97ae-e6f86bc2997a', - '89d94c1b-f6ff-4545-ba9b-120b2d1921d0', - NULL, - '1.0.0', - 'Data Service', - '', - '@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix sh: . -@prefix xsd: . - -:DataServiceShape a sh:NodeShape ; - sh:targetClass dcat:DataService ; - sh:property [ - sh:path dcat:endpointURL ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - sh:order 20 ; - ] , [ - sh:path dcat:endpointDescription ; - sh:nodeKind sh:Literal ; - sh:maxCount 1 ; - dash:editor dash:TextAreaEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 21 ; -] . -', - ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#DataService'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - FALSE, - NULL, - NULL, - NOW(), - NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('2efc8366-541d-493f-8661-69ad8f72dfa1', '9111d436-fe58-4bd5-97ae-e6f86bc2997a', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); - --- Metadata Service -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('36b22b70-6203-4dd2-9fb6-b39a776bf467', - '6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad', - NULL, - '1.0.0', - 'Metadata Service', - '', - '@prefix : . -@prefix fdp: . -@prefix sh: . - -:MetadataServiceShape a sh:NodeShape ; - sh:targetClass fdp:MetadataService . -', - ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#DataService', 'https://w3id.org/fdp/fdp-o#MetadataService'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - FALSE, - NULL, - NULL, - NOW(), - NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('8742361b-cd00-4167-b859-e45fa36d0cb7', '36b22b70-6203-4dd2-9fb6-b39a776bf467', '89d94c1b-f6ff-4545-ba9b-120b2d1921d0', 0); - --- FAIR Data Point -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('a92958ab-a414-47e6-8e17-68ba96ba3a2b', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('4e64208d-f102-45a0-96e3-17b002e6213e', - 'a92958ab-a414-47e6-8e17-68ba96ba3a2b', - NULL, - '1.0.0', - 'FAIR Data Point', - '', - '@prefix : . -@prefix dash: . -@prefix dct: . -@prefix fdp: . -@prefix sh: . -@prefix xsd: . - -:FDPShape a sh:NodeShape ; - sh:targetClass fdp:FAIRDataPoint ; - sh:property [ - sh:path fdp:startDate ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 40 ; - ] , [ - sh:path fdp:endDate ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 41 ; - ] , [ - sh:path fdp:uiLanguage ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - sh:defaultValue ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 42 ; - ] , [ - sh:path fdp:metadataIdentifier ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 43 ; - ] , [ - sh:path fdp:metadataIssued ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:viewer dash:LiteralViewer ; - sh:order 44 ; - ] , [ - sh:path fdp:metadataModified ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:viewer dash:LiteralViewer ; - sh:order 45 ; - ] . - ', - ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#DataService', 'https://w3id.org/fdp/fdp-o#MetadataService', 'https://w3id.org/fdp/fdp-o#FAIRDataPoint'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - FALSE, - NULL, - NULL, - NOW(), - NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('afebd441-8aa5-464d-bc3c-033f175449b4', '4e64208d-f102-45a0-96e3-17b002e6213e', '6f7a5a76-6185-4bd0-9fe9-62ecc90c9bad', 0); - --- Catalog -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('c9640671-945d-4114-88fb-e81314cb7ab2', - '2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660', - NULL, - '1.0.0', - 'Catalog', - '', - '@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix foaf: . -@prefix sh: . -@prefix xsd: . - -:CatalogShape a sh:NodeShape ; - sh:targetClass dcat:Catalog ; - sh:property [ - sh:path dct:issued ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:viewer dash:LiteralViewer ; - sh:order 20 ; - ], [ - sh:path dct:modified ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:viewer dash:LiteralViewer ; - sh:order 21 ; - ], [ - sh:path foaf:homePage ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 22 ; - ], [ - sh:path dcat:themeTaxonomy ; - sh:nodeKind sh:IRI ; - dash:viewer dash:LabelViewer ; - sh:order 23 ; - ] . -', - ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#Catalog'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - FALSE, - NULL, - NULL, - NOW(), - NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('e75cb601-318d-41ea-9a8b-32e0749c80a7', 'c9640671-945d-4114-88fb-e81314cb7ab2', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); - --- Dataset -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('866d7fb8-5982-4215-9c7c-18d0ed1bd5f3', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('9cc3c89a-76cf-4639-a71f-652627af51db', - '866d7fb8-5982-4215-9c7c-18d0ed1bd5f3', - NULL, - '1.0.0', - 'Dataset', - '', - '@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix sh: . -@prefix xsd: . - -:DatasetShape a sh:NodeShape ; - sh:targetClass dcat:Dataset ; - sh:property [ - sh:path dct:issued ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 20 ; - ], [ - sh:path dct:modified ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 21 ; - ], [ - sh:path dcat:theme ; - sh:nodeKind sh:IRI ; - sh:minCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 22 ; - ], [ - sh:path dcat:contactPoint ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 23 ; - ], [ - sh:path dcat:keyword ; - sh:nodeKind sh:Literal ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 24 ; - ], [ - sh:path dcat:landingPage ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - dash:viewer dash:LabelViewer ; - sh:order 25 ; - ] . -', - ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#Dataset'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - FALSE, - NULL, - NULL, - NOW(), - NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('da13ba37-09f8-4937-9055-e3ee3aefc57c', '9cc3c89a-76cf-4639-a71f-652627af51db', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); - --- Distribution -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('ebacbf83-cd4f-4113-8738-d73c0735b0ab', NOW(), NOW()); -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('3cda8cd3-b08b-4797-822d-d3f3e83c466a', - 'ebacbf83-cd4f-4113-8738-d73c0735b0ab', - NULL, - '1.0.0', - 'Distribution', - '', - '@prefix : . -@prefix dash: . -@prefix dcat: . -@prefix dct: . -@prefix sh: . -@prefix xsd: . - -:DistributionShape a sh:NodeShape ; - sh:targetClass dcat:Distribution ; - sh:property [ - sh:path dct:issued ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 20 ; - ] , [ - sh:path dct:modified ; - sh:datatype xsd:dateTime ; - sh:maxCount 1 ; - dash:editor dash:DatePickerEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 21 ; - ] , [ - sh:path dcat:accessURL ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - sh:order 22 ; - ] , [ - sh:path dcat:downloadURL ; - sh:nodeKind sh:IRI ; - sh:maxCount 1 ; - dash:editor dash:URIEditor ; - sh:order 23 ; - ] , [ - sh:path dcat:mediaType ; - sh:nodeKind sh:Literal ; - sh:minCount 1 ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 24 ; - ] , [ - sh:path dcat:format ; - sh:nodeKind sh:Literal ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 25 ; - ] , [ - sh:path dcat:byteSize ; - sh:nodeKind sh:Literal ; - sh:maxCount 1 ; - dash:editor dash:TextFieldEditor ; - dash:viewer dash:LiteralViewer ; - sh:order 26 ; - ] . -', - ARRAY ['http://www.w3.org/ns/dcat#Resource', 'http://www.w3.org/ns/dcat#Distribution'], - 'INTERNAL', - NULL, - NULL, - 'LATEST', - FALSE, - FALSE, - NULL, - NULL, - NOW(), - NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('a3b16a4e-cac7-4b71-a3de-94bb86714b5b', '3cda8cd3-b08b-4797-822d-d3f3e83c466a', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); From 1aa0b160d97cc8bce248b31c135b05bf5d9c122b Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Mon, 8 Dec 2025 20:10:43 +0100 Subject: [PATCH 39/53] delete V0001.3__dev-data-rds.sql because it is covered by the 03xx fixtures --- .../db/migration/V0001.3__dev-data-rds.sql | 68 ------------------- 1 file changed, 68 deletions(-) delete mode 100644 src/test/resources/test/db/migration/V0001.3__dev-data-rds.sql diff --git a/src/test/resources/test/db/migration/V0001.3__dev-data-rds.sql b/src/test/resources/test/db/migration/V0001.3__dev-data-rds.sql deleted file mode 100644 index ed4f047ff..000000000 --- a/src/test/resources/test/db/migration/V0001.3__dev-data-rds.sql +++ /dev/null @@ -1,68 +0,0 @@ --- --- The MIT License --- Copyright © 2016-2024 FAIR Data Team --- --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- - --- Distribution -INSERT INTO resource_definition (uuid, name, url_prefix, created_at, updated_at) -VALUES ('02c649de-c579-43bb-b470-306abdc808c7', 'Distribution', 'distribution', now(), now()); - -INSERT INTO resource_definition_link (uuid, resource_definition_id, title, property_uri, order_priority, created_at, updated_at) -VALUES ('660a1821-a5d2-48d0-a26b-0c6d5bac3de4', '02c649de-c579-43bb-b470-306abdc808c7', 'Access online', 'http://www.w3.org/ns/dcat#accessURL', 1, now(), now()); - -INSERT INTO resource_definition_link (uuid, resource_definition_id, title, property_uri, order_priority, created_at, updated_at) -VALUES ('c2eaebb8-4d8d-469d-8736-269adeded996', '02c649de-c579-43bb-b470-306abdc808c7', 'Download', 'http://www.w3.org/ns/dcat#downloadURL', 2, now(), now()); - -INSERT INTO metadata_schema_usage (uuid, resource_definition_id, metadata_schema_id, order_priority) -VALUES ('bbf4ecb3-c529-4c02-955c-7160755debf5', '02c649de-c579-43bb-b470-306abdc808c7', 'ebacbf83-cd4f-4113-8738-d73c0735b0ab', 1); - --- Dataset -INSERT INTO resource_definition (uuid, name, url_prefix, created_at, updated_at) -VALUES ('2f08228e-1789-40f8-84cd-28e3288c3604', 'Dataset', 'dataset', now(), now()); - -INSERT INTO resource_definition_child (uuid, source_resource_definition_id, target_resource_definition_id, relation_uri, title, tags_uri, order_priority, created_at, updated_at) -VALUES ('9f138a13-9d45-4371-b763-0a3b9e0ec912', '2f08228e-1789-40f8-84cd-28e3288c3604', '02c649de-c579-43bb-b470-306abdc808c7', 'http://www.w3.org/ns/dcat#distribution', 'Distributions', NULL, 1, now(), now()); - -INSERT INTO resource_definition_child_metadata (uuid, resource_definition_child_id, title, property_uri, order_priority, created_at, updated_at) -VALUES ('723e95d3-1696-45e2-9429-f6e98e3fb893', '9f138a13-9d45-4371-b763-0a3b9e0ec912', 'Media Type', 'http://www.w3.org/ns/dcat#mediaType', 1, now(), now()); - -INSERT INTO metadata_schema_usage (uuid, resource_definition_id, metadata_schema_id, order_priority) -VALUES ('b8a0ed37-42a1-487e-8842-09fe082c4cc6', '2f08228e-1789-40f8-84cd-28e3288c3604', '866d7fb8-5982-4215-9c7c-18d0ed1bd5f3', 1); - --- Catalog -INSERT INTO resource_definition (uuid, name, url_prefix, created_at, updated_at) -VALUES ('a0949e72-4466-4d53-8900-9436d1049a4b', 'Catalog', 'catalog', now(), now()); - -INSERT INTO resource_definition_child (uuid, source_resource_definition_id, target_resource_definition_id, relation_uri, title, tags_uri, order_priority, created_at, updated_at) -VALUES ('e9f0f5d3-2a93-4aa3-9dd0-acb1d76f54fc', 'a0949e72-4466-4d53-8900-9436d1049a4b', '2f08228e-1789-40f8-84cd-28e3288c3604', 'http://www.w3.org/ns/dcat#dataset', 'Datasets', 'http://www.w3.org/ns/dcat#theme', 1, now(), now()); - -INSERT INTO metadata_schema_usage (uuid, resource_definition_id, metadata_schema_id, order_priority) -VALUES ('e4df9510-a3ad-4e3b-a1a9-5fc330d8b1f0', 'a0949e72-4466-4d53-8900-9436d1049a4b', '2aa7ba63-d27a-4c0e-bfa6-3a4e250f4660', 1); - --- FAIR Data Point -INSERT INTO resource_definition (uuid, name, url_prefix, created_at, updated_at) -VALUES ('77aaad6a-0136-4c6e-88b9-07ffccd0ee4c', 'FAIR Data Point', '', now(), now()); - -INSERT INTO resource_definition_child (uuid, source_resource_definition_id, target_resource_definition_id, relation_uri, title, tags_uri, order_priority, created_at, updated_at) -VALUES ('b8648597-8fbd-4b89-9e30-5eab82675e42', '77aaad6a-0136-4c6e-88b9-07ffccd0ee4c', 'a0949e72-4466-4d53-8900-9436d1049a4b', 'https://w3id.org/fdp/fdp-o#metadataCatalog', 'Catalogs', 'http://www.w3.org/ns/dcat#themeTaxonomy', 1, now(), now()); - -INSERT INTO metadata_schema_usage (uuid, resource_definition_id, metadata_schema_id, order_priority) -VALUES ('9b3a32a8-a14c-4eb0-ba02-3aa8e13a8f11', '77aaad6a-0136-4c6e-88b9-07ffccd0ee4c', 'a92958ab-a414-47e6-8e17-68ba96ba3a2b', 1); From 79ec86fd2c9f0e025a9a4ff6b678a7d87fa16c10 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Mon, 8 Dec 2025 20:12:03 +0100 Subject: [PATCH 40/53] delete V0001.4__dev-data-membership.sql because it is covered by the 04xx fixtures --- .../V0001.4__dev-data-membership.sql | 43 ------------------- 1 file changed, 43 deletions(-) delete mode 100644 src/test/resources/test/db/migration/V0001.4__dev-data-membership.sql diff --git a/src/test/resources/test/db/migration/V0001.4__dev-data-membership.sql b/src/test/resources/test/db/migration/V0001.4__dev-data-membership.sql deleted file mode 100644 index 8240e0bfe..000000000 --- a/src/test/resources/test/db/migration/V0001.4__dev-data-membership.sql +++ /dev/null @@ -1,43 +0,0 @@ --- --- The MIT License --- Copyright © 2016-2024 FAIR Data Team --- --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- - -INSERT INTO membership (uuid, name, allowed_entities, created_at, updated_at) -VALUES ('49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 'Owner', ARRAY ['a0949e72-4466-4d53-8900-9436d1049a4b', '2f08228e-1789-40f8-84cd-28e3288c3604', '02c649de-c579-43bb-b470-306abdc808c7'], NOW(), NOW()); - -INSERT INTO membership (uuid, name, allowed_entities, created_at, updated_at) -VALUES ('87a2d984-7db2-43f6-805c-6b0040afead5', 'Data Provider', ARRAY ['a0949e72-4466-4d53-8900-9436d1049a4b'], NOW(), NOW()); - -INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) -VALUES ('e0d9f853-637b-4c50-9ad9-07b6349bf76f', '49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 2, 'W', NOW(), NOW()); - -INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) -VALUES ('de4e4f85-f11d-475b-b6f0-33bdfe5f923a', '49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 4, 'C', NOW(), NOW()); - -INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) -VALUES ('60bebbf0-210d-4b05-af85-ca1b58546261', '49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 8, 'D', NOW(), NOW()); - -INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) -VALUES ('36c3b6e9-f2e3-48b7-bae1-4dc3196a3657', '49f2bcfd-ef0a-4a3a-a1a3-0fc72a6892a8', 16, 'A', NOW(), NOW()); - -INSERT INTO membership_permission (uuid, membership_id, mask, code, created_at, updated_at) -VALUES ('589d09d3-1c29-4c6f-97fc-6ea4e007fb85', '87a2d984-7db2-43f6-805c-6b0040afead5', 4, 'C', NOW(), NOW()); From ec5711ac424171ae617fd7eb01822e2b6484a2ef Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Mon, 8 Dec 2025 20:34:10 +0100 Subject: [PATCH 41/53] replace V0001.5__dev-settings.sql by 0500_test-settings.json --- .../test-fixtures/0500_test-settings.json | 140 ++++++++++++++++++ .../db/migration/V0001.5__dev-settings.sql | 73 --------- 2 files changed, 140 insertions(+), 73 deletions(-) create mode 100644 src/test/resources/test-fixtures/0500_test-settings.json delete mode 100644 src/test/resources/test/db/migration/V0001.5__dev-settings.sql diff --git a/src/test/resources/test-fixtures/0500_test-settings.json b/src/test/resources/test-fixtures/0500_test-settings.json new file mode 100644 index 000000000..18e51cff0 --- /dev/null +++ b/src/test/resources/test-fixtures/0500_test-settings.json @@ -0,0 +1,140 @@ +[ + { + "_class": "org.fairdatapoint.entity.settings.Settings", + "uuid": "00000000-0000-0000-0000-000000000000", + "appTitle": "FAIR Data Point", + "appSubtitle": "FDP Development Instance", + "pingEnabled": false, + "pingEndpoints": [ + "https://home.fairdatapoint.org" + ], + "autocompleteSearchNamespace": true + }, + { + "_class": "org.fairdatapoint.entity.settings.SettingsAutocompleteSource", + "uuid": "d4045a98-dd25-493e-a0b1-d704921c0930", + "settings": { + "uuid": "00000000-0000-0000-0000-000000000000" + }, + "rdfType": "http://www.w3.org/2000/01/rdf-schema#Class", + "sparqlEndpoint": "http://localhost:3030/ds/query", + "sparqlQuery": "SELECT DISTINCT ?uri ?label\nWHERE { ?uri a .\n?uri ?label .\nFILTER regex(?label, \".*%s.*\", \"i\") }\nORDER BY ?label", + "orderPriority": 1 + }, + { + "_class": "org.fairdatapoint.entity.settings.SettingsMetric", + "uuid": "8435491b-c16c-4457-ae94-e0f4128603d5", + "settings": { + "uuid": "00000000-0000-0000-0000-000000000000" + }, + "metricUri": "https://purl.org/fair-metrics/FM_F1A", + "resourceUri": "https://www.ietf.org/rfc/rfc3986.txt", + "orderPriority": 1 + }, + { + "_class": "org.fairdatapoint.entity.settings.SettingsMetric", + "uuid": "af93d36a-0af0-4054-8c00-2675d460b231", + "settings": { + "uuid": "00000000-0000-0000-0000-000000000000" + }, + "metricUri": "https://purl.org/fair-metrics/FM_A1.1", + "resourceUri": "https://www.wikidata.org/wiki/Q8777", + "orderPriority": 2 + }, + { + "_class": "org.fairdatapoint.entity.settings.SettingsSearchFilter", + "uuid": "57a98728-ce8c-4e7f-b0f8-94e2668b44d3", + "settings": { + "uuid": "00000000-0000-0000-0000-000000000000" + }, + "type": "IRI", + "label": "Type", + "predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", + "queryRecords": false, + "orderPriority": 1 + }, + { + "_class": "org.fairdatapoint.entity.settings.SettingsSearchFilterItem", + "uuid": "b48c2c7f-d7fb-47ae-a72c-b1b360e16f6e", + "filter": { + "uuid": "57a98728-ce8c-4e7f-b0f8-94e2668b44d3" + }, + "label": "Catalog", + "value": "http://www.w3.org/ns/dcat#Catalog", + "orderPriority": 1 + }, + { + "_class": "org.fairdatapoint.entity.settings.SettingsSearchFilterItem", + "uuid": "3e1598ac-9d29-47f0-8e7b-3c26ca0134a0", + "filter": { + "uuid": "57a98728-ce8c-4e7f-b0f8-94e2668b44d3" + }, + "label": "Dataset", + "value": "http://www.w3.org/ns/dcat#Dataset", + "orderPriority": 2 + }, + { + "_class": "org.fairdatapoint.entity.settings.SettingsSearchFilterItem", + "uuid": "5697d8d9-f09d-4ebe-b834-b37eb0624c3f", + "filter": { + "uuid": "57a98728-ce8c-4e7f-b0f8-94e2668b44d3" + }, + "label": "Distribution", + "value": "http://www.w3.org/ns/dcat#Distribution", + "orderPriority": 3 + }, + { + "_class": "org.fairdatapoint.entity.settings.SettingsSearchFilterItem", + "uuid": "022c3bc6-0598-408c-8d2e-b486dafb73dd", + "filter": { + "uuid": "57a98728-ce8c-4e7f-b0f8-94e2668b44d3" + }, + "label": "Data Service", + "value": "http://www.w3.org/ns/dcat#DataService", + "orderPriority": 4 + }, + { + "_class": "org.fairdatapoint.entity.settings.SettingsSearchFilterItem", + "uuid": "7cee5591-8620-4fea-b883-a94285012b8d", + "filter": { + "uuid": "57a98728-ce8c-4e7f-b0f8-94e2668b44d3" + }, + "label": "Metadata Service", + "value": "https://w3id.org/fdp/fdp-o#MetadataService", + "orderPriority": 5 + }, + { + "_class": "org.fairdatapoint.entity.settings.SettingsSearchFilterItem", + "uuid": "9d661dca-8017-4dba-b930-cd2834ea59e8", + "filter": { + "uuid": "57a98728-ce8c-4e7f-b0f8-94e2668b44d3" + }, + "label": "FAIR Data Point", + "value": "https://w3id.org/fdp/fdp-o#FAIRDataPoint", + "orderPriority": 6 + }, + { + "_class": "org.fairdatapoint.entity.settings.SettingsSearchFilter", + "uuid": "26913eb3-67dd-45c9-b8ff-4c97e8162a9b", + "settings": { + "uuid": "00000000-0000-0000-0000-000000000000" + }, + "type": "IRI", + "label": "License", + "predicate": "http://purl.org/dc/terms/license", + "queryRecords": true, + "orderPriority": 2 + }, + { + "_class": "org.fairdatapoint.entity.settings.SettingsSearchFilter", + "uuid": "cb25afb4-6169-42f8-bde5-181c803773a8", + "settings": { + "uuid": "00000000-0000-0000-0000-000000000000" + }, + "type": "IRI", + "label": "Version", + "predicate": "http://www.w3.org/ns/dcat#version", + "queryRecords": true, + "orderPriority": 3 + } +] diff --git a/src/test/resources/test/db/migration/V0001.5__dev-settings.sql b/src/test/resources/test/db/migration/V0001.5__dev-settings.sql deleted file mode 100644 index 75496e02a..000000000 --- a/src/test/resources/test/db/migration/V0001.5__dev-settings.sql +++ /dev/null @@ -1,73 +0,0 @@ --- --- The MIT License --- Copyright © 2016-2024 FAIR Data Team --- --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- - --- Settings -INSERT INTO settings (uuid, app_title, app_subtitle, ping_enabled, ping_endpoints, autocomplete_search_ns, created_at, updated_at) -VALUES ('00000000-0000-0000-0000-000000000000', 'FAIR Data Point', 'FDP Development Instance', False, ARRAY ['https://home.fairdatapoint.org'], True, now(), now()); - --- Autocomplete Sources -INSERT INTO settings_autocomplete_source (uuid, settings_id, rdf_type, sparql_endpoint, sparql_query, order_priority, created_at, updated_at) -VALUES ('d4045a98-dd25-493e-a0b1-d704921c0930', '00000000-0000-0000-0000-000000000000', 'http://www.w3.org/2000/01/rdf-schema#Class', 'http://localhost:3030/ds/query', -'SELECT DISTINCT ?uri ?label -WHERE { ?uri a . -?uri ?label . -FILTER regex(?label, ".*%s.*", "i") } -ORDER BY ?label', - 1, now(), now()); - --- Search Filters: Type -INSERT INTO settings_search_filter (uuid, settings_id, type, label, predicate, query_records, order_priority, created_at, updated_at) -VALUES ('57a98728-ce8c-4e7f-b0f8-94e2668b44d3', '00000000-0000-0000-0000-000000000000', 'IRI', 'Type', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', False, 1, now(), now()); - -INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) -VALUES ('b48c2c7f-d7fb-47ae-a72c-b1b360e16f6e', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Catalog', 'http://www.w3.org/ns/dcat#Catalog', 1, now(), now()); - -INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) -VALUES ('3e1598ac-9d29-47f0-8e7b-3c26ca0134a0', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Dataset', 'http://www.w3.org/ns/dcat#Dataset', 2, now(), now()); - -INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) -VALUES ('5697d8d9-f09d-4ebe-b834-b37eb0624c3f', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Distribution', 'http://www.w3.org/ns/dcat#Distribution', 3, now(), now()); - -INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) -VALUES ('022c3bc6-0598-408c-8d2e-b486dafb73dd', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Data Service', 'http://www.w3.org/ns/dcat#DataService', 4, now(), now()); - -INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) -VALUES ('7cee5591-8620-4fea-b883-a94285012b8d', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'Metadata Service', 'https://w3id.org/fdp/fdp-o#MetadataService', 5, now(), now()); - -INSERT INTO settings_search_filter_item (uuid, filter_id, label, value, order_priority, created_at, updated_at) -VALUES ('9d661dca-8017-4dba-b930-cd2834ea59e8', '57a98728-ce8c-4e7f-b0f8-94e2668b44d3', 'FAIR Data Point', 'https://w3id.org/fdp/fdp-o#FAIRDataPoint', 6, now(), now()); - --- Search Filters: License -INSERT INTO settings_search_filter (uuid, settings_id, type, label, predicate, query_records, order_priority, created_at, updated_at) -VALUES ('26913eb3-67dd-45c9-b8ff-4c97e8162a9b', '00000000-0000-0000-0000-000000000000', 'IRI', 'License', 'http://purl.org/dc/terms/license', True, 2, now(), now()); - --- Search Filters: License -INSERT INTO settings_search_filter (uuid, settings_id, type, label, predicate, query_records, order_priority, created_at, updated_at) -VALUES ('cb25afb4-6169-42f8-bde5-181c803773a8', '00000000-0000-0000-0000-000000000000', 'IRI', 'Version', 'http://www.w3.org/ns/dcat#version', True, 3, now(), now()); - --- Metrics -INSERT INTO settings_metric (uuid, settings_id, metric_uri, resource_uri, order_priority, created_at, updated_at) -VALUES ('8435491b-c16c-4457-ae94-e0f4128603d5', '00000000-0000-0000-0000-000000000000', 'https://purl.org/fair-metrics/FM_F1A', 'https://www.ietf.org/rfc/rfc3986.txt', 1, now(), now()); - -INSERT INTO settings_metric (uuid, settings_id, metric_uri, resource_uri, order_priority, created_at, updated_at) -VALUES ('af93d36a-0af0-4054-8c00-2675d460b231', '00000000-0000-0000-0000-000000000000', 'https://purl.org/fair-metrics/FM_A1.1', 'https://www.wikidata.org/wiki/Q8777', 2, now(), now()); From 883e34152d6b009a7724170e8107a9e90ebe5b0f Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Mon, 8 Dec 2025 20:45:56 +0100 Subject: [PATCH 42/53] replace V0001.6__test-schemas.sql by 0600_test-schemas.json --- .../test-fixtures/0600_test-schemas.json | 271 ++++++++++++++++++ .../db/migration/V0001.6__test-schemas.sql | 161 ----------- 2 files changed, 271 insertions(+), 161 deletions(-) create mode 100644 src/test/resources/test-fixtures/0600_test-schemas.json delete mode 100644 src/test/resources/test/db/migration/V0001.6__test-schemas.sql diff --git a/src/test/resources/test-fixtures/0600_test-schemas.json b/src/test/resources/test-fixtures/0600_test-schemas.json new file mode 100644 index 000000000..75bf756d4 --- /dev/null +++ b/src/test/resources/test-fixtures/0600_test-schemas.json @@ -0,0 +1,271 @@ +[ + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchema", + "uuid": "e8b34158-3858-45c7-8e3e-d1e671dd9929" + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "53619e58-2bb0-4baf-afd8-00c5d01ff8a8", + "schema": { "uuid": "e8b34158-3858-45c7-8e3e-d1e671dd9929" }, + "version": "0.1.0", + "name": "Custom schema", + "description": "Custom schema V1", + "definition": "", + "targetClasses": [ + "http://www.w3.org/2000/01/rdf-schema#Class" + ], + "type": "CUSTOM", + "state": "LATEST", + "published": true, + "abstractSchema": false + }, + + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchema", + "uuid": "bfa79edf-00b7-4a04-b5a6-a5144f1a77b7" + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "cb9f6cd7-97af-45d0-b23d-d0aab23607d8", + "schema": { "uuid": "bfa79edf-00b7-4a04-b5a6-a5144f1a77b7" }, + "version": "0.1.0", + "name": "Custom schema", + "description": "Custom schema V1", + "definition": "", + "targetClasses": [ + "http://www.w3.org/2000/01/rdf-schema#Class" + ], + "type": "CUSTOM", + "state": "DRAFT", + "published": false, + "abstractSchema": false + }, + + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchema", + "uuid": "fe98adbb-6a2c-4c7a-b2b2-a72db5140c61" + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "f0a4b358-69a3-44e6-9436-c68a56a9f2f2", + "schema": { "uuid": "fe98adbb-6a2c-4c7a-b2b2-a72db5140c61" }, + "version": "0.1.0", + "name": "Custom schema", + "description": "Custom schema V1", + "definition": "", + "targetClasses": [ + "http://www.w3.org/2000/01/rdf-schema#Class" + ], + "type": "INTERNAL", + "state": "LATEST", + "published": true, + "abstractSchema": false + }, + + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchema", + "uuid": "978e5c1c-268d-4822-b60b-07d3eccc6896" + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "d7acec53-5ac9-4502-9bfa-92d1e9f79a24", + "schema": { "uuid": "978e5c1c-268d-4822-b60b-07d3eccc6896" }, + "version": "0.1.0", + "name": "Custom schema", + "description": "Custom schema V1", + "definition": "", + "targetClasses": [ + "http://www.w3.org/2000/01/rdf-schema#Class" + ], + "type": "CUSTOM", + "state": "LEGACY", + "published": false, + "abstractSchema": false + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "67896adc-b431-431d-8296-f0b80d8de412", + "schema": { "uuid": "978e5c1c-268d-4822-b60b-07d3eccc6896" }, + "previousVersion": { "uuid": "d7acec53-5ac9-4502-9bfa-92d1e9f79a24" }, + "version": "0.2.0", + "name": "Custom schema", + "description": "Custom schema V2", + "definition": "", + "targetClasses": [ + "http://www.w3.org/2000/01/rdf-schema#Class" + ], + "type": "CUSTOM", + "state": "LEGACY", + "published": false, + "abstractSchema": false + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "c62d4a97-baac-40b8-b6ea-e43b06ec78bd", + "schema": { "uuid": "978e5c1c-268d-4822-b60b-07d3eccc6896" }, + "previousVersion": { "uuid": "67896adc-b431-431d-8296-f0b80d8de412" }, + "version": "0.3.0", + "name": "Custom schema", + "description": "Custom schema V3", + "definition": "", + "targetClasses": [ + "http://www.w3.org/2000/01/rdf-schema#Class" + ], + "type": "CUSTOM", + "state": "LATEST", + "published": false, + "abstractSchema": false + }, + + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchema", + "uuid": "e7078309-cb4c-47b9-9ef8-057487b3da58" + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "a17c25ad-e8d3-4338-bb3e-eda76d2fc32c", + "schema": { "uuid": "e7078309-cb4c-47b9-9ef8-057487b3da58" }, + "version": "0.0.0", + "name": "Custom schema", + "description": "Custom schema draft", + "definition": "", + "targetClasses": [ + "http://www.w3.org/2000/01/rdf-schema#Class" + ], + "type": "CUSTOM", + "state": "DRAFT", + "published": false, + "abstractSchema": false + }, + + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchema", + "uuid": "123e48d2-9995-4b44-8b2c-9c81bdbf2dd2" + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "fb24f92b-187f-4d53-b744-73024b537f30", + "schema": { "uuid": "123e48d2-9995-4b44-8b2c-9c81bdbf2dd2" }, + "version": "0.1.0", + "name": "Custom schema", + "description": "Custom schema V1", + "definition": "", + "targetClasses": [ + "http://www.w3.org/2000/01/rdf-schema#Class" + ], + "type": "CUSTOM", + "state": "LEGACY", + "published": false, + "abstractSchema": false + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "6011adfa-f8da-478d-86ea-84bb644b458b", + "schema": { "uuid": "123e48d2-9995-4b44-8b2c-9c81bdbf2dd2" }, + "previousVersion": { "uuid": "fb24f92b-187f-4d53-b744-73024b537f30" }, + "version": "0.2.0", + "name": "Custom schema", + "description": "Custom schema V2", + "definition": "", + "targetClasses": [ + "http://www.w3.org/2000/01/rdf-schema#Class" + ], + "type": "CUSTOM", + "state": "LATEST", + "published": false, + "abstractSchema": false + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "6b84ec86-2096-48db-bfc7-23506b8c080c", + "schema": { "uuid": "123e48d2-9995-4b44-8b2c-9c81bdbf2dd2" }, + "previousVersion": { "uuid": "6011adfa-f8da-478d-86ea-84bb644b458b" }, + "version": "0.0.0", + "name": "Custom schema", + "description": "Custom schema draft", + "definition": "", + "targetClasses": [ + "http://www.w3.org/2000/01/rdf-schema#Class" + ], + "type": "CUSTOM", + "state": "DRAFT", + "published": false, + "abstractSchema": false + }, + + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchema", + "uuid": "7c8b8699-ca9f-4d14-86e2-2299b27c5711" + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "4e44fb19-b9e0-46e9-957a-e7aa3adac7bf", + "schema": { "uuid": "7c8b8699-ca9f-4d14-86e2-2299b27c5711" }, + "version": "0.1.0", + "name": "Custom schema", + "description": "Custom schema V1", + "definition": "", + "targetClasses": [ + "http://www.w3.org/2000/01/rdf-schema#Class" + ], + "type": "CUSTOM", + "state": "LEGACY", + "published": false, + "abstractSchema": false + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "abcf3a21-6f9a-45dc-a71a-4dde4440c81a", + "schema": { "uuid": "7c8b8699-ca9f-4d14-86e2-2299b27c5711" }, + "previousVersion": { "uuid": "4e44fb19-b9e0-46e9-957a-e7aa3adac7bf" }, + "version": "0.2.0", + "name": "Custom schema", + "description": "Custom schema V2", + "definition": "", + "targetClasses": [ + "http://www.w3.org/2000/01/rdf-schema#Class" + ], + "type": "CUSTOM", + "state": "LATEST", + "published": false, + "abstractSchema": false + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaExtension", + "uuid": "1bdca611-c96e-4304-b1f3-030d282ef529", + "metadataSchemaVersion": { "uuid": "abcf3a21-6f9a-45dc-a71a-4dde4440c81a" }, + "extendedMetadataSchema": { "uuid": "6a668323-3936-4b53-8380-a4fd2ed082ee" }, + "orderPriority": 0 + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaExtension", + "uuid": "1bdca611-c96e-4304-b1f3-030d282ef530", + "metadataSchemaVersion": { "uuid": "abcf3a21-6f9a-45dc-a71a-4dde4440c81a" }, + "extendedMetadataSchema": { "uuid": "123e48d2-9995-4b44-8b2c-9c81bdbf2dd2" }, + "orderPriority": 1 + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaVersion", + "uuid": "a6d609ff-905f-4edd-bdb1-2dce000c9a45", + "schema": { "uuid": "7c8b8699-ca9f-4d14-86e2-2299b27c5711" }, + "previousVersion": { "uuid": "abcf3a21-6f9a-45dc-a71a-4dde4440c81a" }, + "version": "0.0.0", + "name": "Custom schema", + "description": "Custom schema draft", + "definition": "", + "targetClasses": [ + "http://www.w3.org/2000/01/rdf-schema#Class" + ], + "type": "CUSTOM", + "state": "DRAFT", + "published": false, + "abstractSchema": false + }, + { + "_class": "org.fairdatapoint.entity.schema.MetadataSchemaExtension", + "uuid": "53e3db46-8fe4-47ce-873e-ed7db94e73b3", + "metadataSchemaVersion": { "uuid": "a6d609ff-905f-4edd-bdb1-2dce000c9a45" }, + "extendedMetadataSchema": { "uuid": "6a668323-3936-4b53-8380-a4fd2ed082ee" }, + "orderPriority": 0 + } +] diff --git a/src/test/resources/test/db/migration/V0001.6__test-schemas.sql b/src/test/resources/test/db/migration/V0001.6__test-schemas.sql deleted file mode 100644 index b340329e8..000000000 --- a/src/test/resources/test/db/migration/V0001.6__test-schemas.sql +++ /dev/null @@ -1,161 +0,0 @@ --- --- The MIT License --- Copyright © 2016-2024 FAIR Data Team --- --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- - --- Custom with one version -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('e8b34158-3858-45c7-8e3e-d1e671dd9929', NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('53619e58-2bb0-4baf-afd8-00c5d01ff8a8', 'e8b34158-3858-45c7-8e3e-d1e671dd9929', NULL, '0.1.0', 'Custom schema', - 'Custom schema V1', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LATEST', TRUE, FALSE, NULL, - NULL, NOW(), NOW()); - --- Custom with one draft -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('bfa79edf-00b7-4a04-b5a6-a5144f1a77b7', NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('cb9f6cd7-97af-45d0-b23d-d0aab23607d8', 'bfa79edf-00b7-4a04-b5a6-a5144f1a77b7', NULL, '0.1.0', 'Custom schema', - 'Custom schema V1', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'DRAFT', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); - - --- Custom with one version INTERNAL -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('fe98adbb-6a2c-4c7a-b2b2-a72db5140c61', NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('f0a4b358-69a3-44e6-9436-c68a56a9f2f2', 'fe98adbb-6a2c-4c7a-b2b2-a72db5140c61', NULL, '0.1.0', 'Custom schema', - 'Custom schema V1', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'INTERNAL', NULL, NULL, 'LATEST', TRUE, FALSE, NULL, - NULL, NOW(), NOW()); - --- Custom with multiple versions -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('978e5c1c-268d-4822-b60b-07d3eccc6896', NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('d7acec53-5ac9-4502-9bfa-92d1e9f79a24', '978e5c1c-268d-4822-b60b-07d3eccc6896', NULL, '0.1.0', 'Custom schema', - 'Custom schema V1', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LEGACY', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('67896adc-b431-431d-8296-f0b80d8de412', '978e5c1c-268d-4822-b60b-07d3eccc6896', 'd7acec53-5ac9-4502-9bfa-92d1e9f79a24', '0.2.0', 'Custom schema', - 'Custom schema V2', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LEGACY', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('c62d4a97-baac-40b8-b6ea-e43b06ec78bd', '978e5c1c-268d-4822-b60b-07d3eccc6896', '67896adc-b431-431d-8296-f0b80d8de412', '0.3.0', 'Custom schema', - 'Custom schema V3', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LATEST', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); - --- Custom with draft -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('e7078309-cb4c-47b9-9ef8-057487b3da58', NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('a17c25ad-e8d3-4338-bb3e-eda76d2fc32c', 'e7078309-cb4c-47b9-9ef8-057487b3da58', NULL, '0.0.0', 'Custom schema', - 'Custom schema draft', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'DRAFT', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); - --- Custom with multiple versions and draft -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('123e48d2-9995-4b44-8b2c-9c81bdbf2dd2', NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('fb24f92b-187f-4d53-b744-73024b537f30', '123e48d2-9995-4b44-8b2c-9c81bdbf2dd2', NULL, '0.1.0', 'Custom schema', - 'Custom schema V1', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LEGACY', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('6011adfa-f8da-478d-86ea-84bb644b458b', '123e48d2-9995-4b44-8b2c-9c81bdbf2dd2', 'fb24f92b-187f-4d53-b744-73024b537f30', '0.2.0', 'Custom schema', - 'Custom schema V2', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LATEST', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('6b84ec86-2096-48db-bfc7-23506b8c080c', '123e48d2-9995-4b44-8b2c-9c81bdbf2dd2', '6011adfa-f8da-478d-86ea-84bb644b458b', '0.0.0', 'Custom schema', - 'Custom schema draft', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'DRAFT', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); - --- Custom with multiple versions and draft and extends -INSERT INTO metadata_schema (uuid, created_at, updated_at) -VALUES ('7c8b8699-ca9f-4d14-86e2-2299b27c5711', NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('4e44fb19-b9e0-46e9-957a-e7aa3adac7bf', '7c8b8699-ca9f-4d14-86e2-2299b27c5711', NULL, '0.1.0', 'Custom schema', - 'Custom schema V1', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LEGACY', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('abcf3a21-6f9a-45dc-a71a-4dde4440c81a', '7c8b8699-ca9f-4d14-86e2-2299b27c5711', '4e44fb19-b9e0-46e9-957a-e7aa3adac7bf', '0.2.0', 'Custom schema', - 'Custom schema V2', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'LATEST', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('1bdca611-c96e-4304-b1f3-030d282ef529', 'abcf3a21-6f9a-45dc-a71a-4dde4440c81a', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('1bdca611-c96e-4304-b1f3-030d282ef530', 'abcf3a21-6f9a-45dc-a71a-4dde4440c81a', '123e48d2-9995-4b44-8b2c-9c81bdbf2dd2', 1); - -INSERT INTO metadata_schema_version (uuid, metadata_schema_id, previous_version_id, version, name, description, - definition, target_classes, type, origin, imported_from, state, published, - abstract, suggested_resource_name, suggested_url_prefix, created_at, updated_at) -VALUES ('a6d609ff-905f-4edd-bdb1-2dce000c9a45', '7c8b8699-ca9f-4d14-86e2-2299b27c5711', 'abcf3a21-6f9a-45dc-a71a-4dde4440c81a', '0.0.0', 'Custom schema', - 'Custom schema draft', - '', ARRAY ['http://www.w3.org/2000/01/rdf-schema#Class'], 'CUSTOM', NULL, NULL, 'DRAFT', FALSE, FALSE, NULL, - NULL, NOW(), NOW()); -INSERT INTO metadata_schema_extension (uuid, metadata_schema_version_id, extended_metadata_schema_id, order_priority) -VALUES ('53e3db46-8fe4-47ce-873e-ed7db94e73b3', 'a6d609ff-905f-4edd-bdb1-2dce000c9a45', '6a668323-3936-4b53-8380-a4fd2ed082ee', 0); From e067b091403ed0bc3fad40cd5ed9e9688f569991 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Tue, 9 Dec 2025 10:08:40 +0100 Subject: [PATCH 43/53] allow full ant-style location patterns for populator resources this enables us to specify simple directories, specific files, filters like 'fixtures/02*.json', and wildcards like 'fixtures/**/*.json' --- .../java/org/fairdatapoint/config/BootstrapConfig.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java index d3e2d8c95..532269130 100644 --- a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -78,9 +78,11 @@ public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { log.info("Looking for db fixtures in the following locations: {}", String.join(", ", this.bootstrap.getLocations())); for (String location : this.bootstrap.getLocations()) { - // Path.of() removes trailing slashes, so it is safe to concatenate "/*.json". - // Note that Path.of(location).resolve("*.json") could work on unix but fails on windows. - resources.addAll(List.of(resourceResolver.getResources(Path.of(location) + "/*.json"))); + // Only look for JSON files. Notes: + // - Path.of() removes trailing slashes, so it is safe to concatenate "/*.json". + // - Path.of(location).resolve("*.json") could work on Unix but fails on Windows. + final String pattern = location.endsWith(".json") ? location : Path.of(location) + "/*.json"; + resources.addAll(List.of(resourceResolver.getResources(pattern))); } // remove resources that have been applied already final List appliedFixtures = fixtureHistoryRepository.findAll().stream() From 10e7a18bd9f450dcc62590e302f3e603c6266cbe Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Tue, 9 Dec 2025 17:12:22 +0100 Subject: [PATCH 44/53] adapt DatabaseBootstrapTests to use the default fixtures --- .../bootstrap/DatabaseBootstrapTests.java | 33 +++++++++++-------- .../fixtures/0100_user-accounts.json | 11 ------- .../resources/fixtures/0110_api-keys.json | 10 ------ .../fixtures/0120_saved-queries.json | 28 ---------------- ...users-with-api-keys-and-saved-queries.json | 28 ++++++++++++++++ 5 files changed, 47 insertions(+), 63 deletions(-) delete mode 100644 src/test/resources/fixtures/0100_user-accounts.json delete mode 100644 src/test/resources/fixtures/0110_api-keys.json delete mode 100644 src/test/resources/fixtures/0120_saved-queries.json diff --git a/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java b/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java index fa3f78e3d..1ec33c133 100644 --- a/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java +++ b/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java @@ -31,19 +31,19 @@ import org.fairdatapoint.entity.apikey.ApiKey; import org.fairdatapoint.entity.search.SearchSavedQuery; import org.fairdatapoint.entity.user.UserAccount; +import org.fairdatapoint.util.KnownUUIDs; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestEntityManager; -import org.springframework.test.context.TestPropertySource; import java.util.Optional; import java.util.UUID; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; @AutoConfigureTestEntityManager @Transactional -@TestPropertySource(properties = "bootstrap.locations[0]=file:src/test/resources/fixtures") public class DatabaseBootstrapTests extends BaseIntegrationTest { @Autowired private UserAccountRepository userAccountRepository; @@ -54,28 +54,33 @@ public class DatabaseBootstrapTests extends BaseIntegrationTest { @Autowired private SearchSavedQueryRepository searchSavedQueryRepository; + private final String einsteinEmail = "albert.einstein@example.org"; + @Test public void testSingleEntityBootstrap() { - final Optional userAccount = userAccountRepository.findByEmail("john.doe@example.org"); - assertEquals(true, userAccount.isPresent()); - assertEquals("John", userAccount.get().getFirstName()); - assertEquals("Doe", userAccount.get().getLastName()); - assertEquals(UUID.fromString("e8f98d8e-0c4f-4a4b-9cc7-dd884f0c75ee"), userAccount.get().getUuid()); + final Optional userAccount = userAccountRepository.findByEmail(einsteinEmail); + assertTrue(userAccount.isPresent()); + assertEquals("Albert", userAccount.get().getFirstName()); + assertEquals("Einstein", userAccount.get().getLastName()); + assertEquals(KnownUUIDs.USER_ALBERT_UUID, userAccount.get().getUuid()); } @Test public void testRelatedEntityBootstrap() { - final Optional apiKey = apiKeyRepository.findByToken("testing-token"); - assertEquals(true, apiKey.isPresent()); - assertEquals("john.doe@example.org", apiKey.get().getUserAccount().getEmail()); - assertEquals(UUID.fromString("9d734008-91bb-47e3-97aa-2f537e67d9e6"), apiKey.get().getUuid()); + final UUID einsteinApiKeyUuid = UUID.fromString("a1c00673-24c5-4e0a-bdbe-22e961ee7548"); + final String einsteinApiKeyToken = "a274793046e34a219fd0ea6362fcca61a001500b71724f4c973a017031653c20"; + final Optional apiKey = apiKeyRepository.findByToken(einsteinApiKeyToken); + assertTrue(apiKey.isPresent()); + assertEquals(einsteinEmail, apiKey.get().getUserAccount().getEmail()); + assertEquals(einsteinApiKeyUuid, apiKey.get().getUuid()); } @Test public void testDuplicateIdEntityOverwriteBootstrap() { - final Optional savedQuery = searchSavedQueryRepository.findByUuid(UUID.fromString("4c57eff3-4608-40ae-85af-b442cfea0746")); - assertEquals(true, savedQuery.isPresent()); - assertEquals("john.doe@example.org", savedQuery.get().getUserAccount().getEmail()); + final Optional savedQuery = searchSavedQueryRepository.findByUuid( + UUID.fromString("4c57eff3-4608-40ae-85af-b442cfea0746")); + assertTrue(savedQuery.isPresent()); + assertEquals(einsteinEmail, savedQuery.get().getUserAccount().getEmail()); assertEquals("Some query 2", savedQuery.get().getName()); } } diff --git a/src/test/resources/fixtures/0100_user-accounts.json b/src/test/resources/fixtures/0100_user-accounts.json deleted file mode 100644 index 1b33940a0..000000000 --- a/src/test/resources/fixtures/0100_user-accounts.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "_class" : "org.fairdatapoint.entity.user.UserAccount", - "uuid": "e8f98d8e-0c4f-4a4b-9cc7-dd884f0c75ee", - "firstName": "John", - "lastName": "Doe", - "email": "john.doe@example.org", - "passwordHash": "$2a$10$hZF1abbZ48Tf.3RndC9W6OlDt6gnBoD/2HbzJayTs6be7d.5DbpnW", - "role": "USER" - } -] diff --git a/src/test/resources/fixtures/0110_api-keys.json b/src/test/resources/fixtures/0110_api-keys.json deleted file mode 100644 index 3a4f9bbdc..000000000 --- a/src/test/resources/fixtures/0110_api-keys.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "_class" : "org.fairdatapoint.entity.apikey.ApiKey", - "uuid": "9d734008-91bb-47e3-97aa-2f537e67d9e6", - "token": "testing-token", - "userAccount": { - "uuid": "e8f98d8e-0c4f-4a4b-9cc7-dd884f0c75ee" - } - } -] diff --git a/src/test/resources/fixtures/0120_saved-queries.json b/src/test/resources/fixtures/0120_saved-queries.json deleted file mode 100644 index 5fe68c721..000000000 --- a/src/test/resources/fixtures/0120_saved-queries.json +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "_class" : "org.fairdatapoint.entity.search.SearchSavedQuery", - "uuid": "4c57eff3-4608-40ae-85af-b442cfea0746", - "name": "Some query 1", - "description": "Example query", - "type": "PUBLIC", - "varPrefixes": "PREFIX dcat: ", - "varGraphPattern": "?entity rdf:type dcat:Dataset .", - "varOrdering": "ASC(?title)", - "userAccount": { - "uuid": "e8f98d8e-0c4f-4a4b-9cc7-dd884f0c75ee" - } - }, - { - "_class" : "org.fairdatapoint.entity.search.SearchSavedQuery", - "uuid": "4c57eff3-4608-40ae-85af-b442cfea0746", - "name": "Some query 2", - "description": "Example query (with same UUID as previous)", - "type": "PUBLIC", - "varPrefixes": "PREFIX dcat: ", - "varGraphPattern": "?entity rdf:type dcat:Dataset .", - "varOrdering": "ASC(?title)", - "userAccount": { - "uuid": "e8f98d8e-0c4f-4a4b-9cc7-dd884f0c75ee" - } - } -] diff --git a/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json b/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json index eb1249f67..2d2365ad4 100644 --- a/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json +++ b/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json @@ -35,6 +35,7 @@ "passwordHash": "$2a$10$L.0OZ8QjV3yLhoCDvU04gu.WP1wGQih41MsBdvtQOshJJntaugBxe", "role": "ADMIN" }, + { "_class": "org.fairdatapoint.entity.apikey.ApiKey", "uuid": "a1c00673-24c5-4e0a-bdbe-22e961ee7548", @@ -51,6 +52,7 @@ "uuid": "b5b92c69-5ed9-4054-954d-0121c29b6800" } }, + { "_class" : "org.fairdatapoint.entity.search.SearchSavedQuery", "uuid": "d31e3da1-2cfa-4b55-a8cb-71d1acf01aef", @@ -89,5 +91,31 @@ "userAccount": { "uuid": "7e64818d-6276-46fb-8bb1-732e6e09f7e9" } + }, + { + "_class" : "org.fairdatapoint.entity.search.SearchSavedQuery", + "uuid": "4c57eff3-4608-40ae-85af-b442cfea0746", + "name": "Some query 1", + "description": "Example query", + "type": "PUBLIC", + "varPrefixes": "PREFIX dcat: ", + "varGraphPattern": "?entity rdf:type dcat:Dataset .", + "varOrdering": "ASC(?title)", + "userAccount": { + "uuid": "7e64818d-6276-46fb-8bb1-732e6e09f7e9" + } + }, + { + "_class" : "org.fairdatapoint.entity.search.SearchSavedQuery", + "uuid": "4c57eff3-4608-40ae-85af-b442cfea0746", + "name": "Some query 2", + "description": "Example query (with same UUID as previous)", + "type": "PUBLIC", + "varPrefixes": "PREFIX dcat: ", + "varGraphPattern": "?entity rdf:type dcat:Dataset .", + "varOrdering": "ASC(?title)", + "userAccount": { + "uuid": "7e64818d-6276-46fb-8bb1-732e6e09f7e9" + } } ] \ No newline at end of file From 86225f268c8821835f908b107215cef059ee1951 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Tue, 9 Dec 2025 17:55:17 +0100 Subject: [PATCH 45/53] simplify resource location pattern for Windows compatibility the Path methods caused errors on windows if the location included ':' or '*' characters --- .../org/fairdatapoint/config/BootstrapConfig.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java index 532269130..3a26265ec 100644 --- a/src/main/java/org/fairdatapoint/config/BootstrapConfig.java +++ b/src/main/java/org/fairdatapoint/config/BootstrapConfig.java @@ -38,7 +38,6 @@ import org.springframework.stereotype.Component; import java.io.IOException; -import java.nio.file.Path; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -78,11 +77,13 @@ public Jackson2RepositoryPopulatorFactoryBean repositoryPopulator() { log.info("Looking for db fixtures in the following locations: {}", String.join(", ", this.bootstrap.getLocations())); for (String location : this.bootstrap.getLocations()) { - // Only look for JSON files. Notes: - // - Path.of() removes trailing slashes, so it is safe to concatenate "/*.json". - // - Path.of(location).resolve("*.json") could work on Unix but fails on Windows. - final String pattern = location.endsWith(".json") ? location : Path.of(location) + "/*.json"; - resources.addAll(List.of(resourceResolver.getResources(pattern))); + // Only look for JSON files + String locationPattern = location; + if (!locationPattern.endsWith(".json")) { + // naive append may lead to redundant slashes, but the OS ignores those + locationPattern += "/*.json"; + } + resources.addAll(List.of(resourceResolver.getResources(locationPattern))); } // remove resources that have been applied already final List appliedFixtures = fixtureHistoryRepository.findAll().stream() From 0dd277641675e199038728eed21c402badc3b7e4 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Wed, 10 Dec 2025 11:48:53 +0100 Subject: [PATCH 46/53] catch all exceptions in RdfMetadataMigration.runMigration (dev only) --- .../development/metadata/RdfMetadataMigration.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/fairdatapoint/database/rdf/migration/development/metadata/RdfMetadataMigration.java b/src/main/java/org/fairdatapoint/database/rdf/migration/development/metadata/RdfMetadataMigration.java index 4a6d39946..afcd88236 100644 --- a/src/main/java/org/fairdatapoint/database/rdf/migration/development/metadata/RdfMetadataMigration.java +++ b/src/main/java/org/fairdatapoint/database/rdf/migration/development/metadata/RdfMetadataMigration.java @@ -22,6 +22,7 @@ */ package org.fairdatapoint.database.rdf.migration.development.metadata; +import lombok.extern.slf4j.Slf4j; import org.fairdatapoint.api.dto.metadata.MetaStateChangeDTO; import org.fairdatapoint.database.common.migration.Migration; import org.fairdatapoint.database.db.repository.ResourceDefinitionRepository; @@ -49,6 +50,7 @@ import static org.fairdatapoint.entity.metadata.MetadataGetter.getUri; import static org.fairdatapoint.util.ValueFactoryHelper.i; +@Slf4j @Service public class RdfMetadataMigration implements Migration { @@ -104,8 +106,8 @@ public void runMigration() { // Load metadata fixtures importDefaultFixtures(persistentUrl); } - catch (MetadataServiceException exception) { - exception.printStackTrace(); + catch (Exception exception) { + log.warn("Failed to run RDF development migration:", exception); } } From a531516215e1c48cb768198dfd461a3621a1bbfc Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Wed, 10 Dec 2025 13:06:57 +0100 Subject: [PATCH 47/53] fix test data description to match user account uuid description said Nikola Tesla, but uuid was for Albert Einstein --- .../0130_test-users-with-api-keys-and-saved-queries.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json b/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json index 2d2365ad4..b0ed4238d 100644 --- a/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json +++ b/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json @@ -83,7 +83,7 @@ "_class" : "org.fairdatapoint.entity.search.SearchSavedQuery", "uuid": "97da9119-834e-4687-8321-3df157547178", "name": "Things with data", - "description": "This is private query of Nikola Tesla!", + "description": "This is a private query of Albert Einstein", "type": "PRIVATE", "varPrefixes": "PREFIX dcat: ", "varGraphPattern": "?entity ?relationPredicate ?relationObject .\nFILTER isLiteral(?relationObject)\nFILTER CONTAINS(LCASE(str(?relationObject)), LCASE(\"data\"))", From 249379105061fdf0886fd6fbeed66a0399f3a54d Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Wed, 10 Dec 2025 13:08:21 +0100 Subject: [PATCH 48/53] modify testDuplicateIdEntityOverwriteBootstrap and corresponding fixture data changed uuid and type for SearchSavedQuery objects to minimize interference with the existing acceptance tests --- .../db/repository/bootstrap/DatabaseBootstrapTests.java | 2 +- .../0130_test-users-with-api-keys-and-saved-queries.json | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java b/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java index 1ec33c133..d078af0ad 100644 --- a/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java +++ b/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java @@ -80,7 +80,7 @@ public void testDuplicateIdEntityOverwriteBootstrap() { final Optional savedQuery = searchSavedQueryRepository.findByUuid( UUID.fromString("4c57eff3-4608-40ae-85af-b442cfea0746")); assertTrue(savedQuery.isPresent()); - assertEquals(einsteinEmail, savedQuery.get().getUserAccount().getEmail()); + assertEquals("isaac.newton@example.org", savedQuery.get().getUserAccount().getEmail()); assertEquals("Some query 2", savedQuery.get().getName()); } } diff --git a/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json b/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json index b0ed4238d..d184b9b31 100644 --- a/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json +++ b/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json @@ -97,12 +97,12 @@ "uuid": "4c57eff3-4608-40ae-85af-b442cfea0746", "name": "Some query 1", "description": "Example query", - "type": "PUBLIC", + "type": "PRIVATE", "varPrefixes": "PREFIX dcat: ", "varGraphPattern": "?entity rdf:type dcat:Dataset .", "varOrdering": "ASC(?title)", "userAccount": { - "uuid": "7e64818d-6276-46fb-8bb1-732e6e09f7e9" + "uuid": "8d1a4c06-bb0e-4d03-a01f-14fa49bbc152" } }, { @@ -110,12 +110,12 @@ "uuid": "4c57eff3-4608-40ae-85af-b442cfea0746", "name": "Some query 2", "description": "Example query (with same UUID as previous)", - "type": "PUBLIC", + "type": "PRIVATE", "varPrefixes": "PREFIX dcat: ", "varGraphPattern": "?entity rdf:type dcat:Dataset .", "varOrdering": "ASC(?title)", "userAccount": { - "uuid": "7e64818d-6276-46fb-8bb1-732e6e09f7e9" + "uuid": "8d1a4c06-bb0e-4d03-a01f-14fa49bbc152" } } ] \ No newline at end of file From ce810ea916dcfa2210697fc688d652688631aaa5 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Wed, 10 Dec 2025 13:16:31 +0100 Subject: [PATCH 49/53] adapt search/query/saved test expectations to updated test data Due to the addition of DatabaseBootstrapTests, fixture 0130_test-users-with-api-keys-and-saved-queries.json now includes two new SearchSavedQuery objects. One of these new objects replaces the other, so the total number of SearchSavedQuery objects expected in the test database is increased by one. --- .../acceptance/search/query/saved/Detail_DELETE.java | 8 ++++---- .../acceptance/search/query/saved/List_GET.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/fairdatapoint/acceptance/search/query/saved/Detail_DELETE.java b/src/test/java/org/fairdatapoint/acceptance/search/query/saved/Detail_DELETE.java index cf49de7c9..5bab2be6d 100644 --- a/src/test/java/org/fairdatapoint/acceptance/search/query/saved/Detail_DELETE.java +++ b/src/test/java/org/fairdatapoint/acceptance/search/query/saved/Detail_DELETE.java @@ -70,7 +70,7 @@ public void res403_anonymousUser() { // THEN: assertThat(result.getStatusCode(), is(equalTo(HttpStatus.FORBIDDEN))); - assertThat(searchSavedQueryRepository.count(), is(equalTo(3L))); + assertThat(searchSavedQueryRepository.count(), is(equalTo(4L))); } @Test @@ -92,7 +92,7 @@ public void res403_nonOwnerUser() { // THEN: assertThat(result.getStatusCode(), is(equalTo(HttpStatus.FORBIDDEN))); - assertThat(searchSavedQueryRepository.count(), is(equalTo(3L))); + assertThat(searchSavedQueryRepository.count(), is(equalTo(4L))); } @Test @@ -114,7 +114,7 @@ public void res200_owner() { // THEN: assertThat(result.getStatusCode(), is(equalTo(HttpStatus.NO_CONTENT))); - assertThat(searchSavedQueryRepository.count(), is(equalTo(2L))); + assertThat(searchSavedQueryRepository.count(), is(equalTo(3L))); } @Test @@ -136,6 +136,6 @@ public void res200_admin() { // THEN: assertThat(result.getStatusCode(), is(equalTo(HttpStatus.NO_CONTENT))); - assertThat(searchSavedQueryRepository.count(), is(equalTo(2L))); + assertThat(searchSavedQueryRepository.count(), is(equalTo(3L))); } } diff --git a/src/test/java/org/fairdatapoint/acceptance/search/query/saved/List_GET.java b/src/test/java/org/fairdatapoint/acceptance/search/query/saved/List_GET.java index 90f4ea1b0..fd650b5dc 100644 --- a/src/test/java/org/fairdatapoint/acceptance/search/query/saved/List_GET.java +++ b/src/test/java/org/fairdatapoint/acceptance/search/query/saved/List_GET.java @@ -155,7 +155,7 @@ public void res200_admin() { // THEN: assertThat(result.getStatusCode(), is(equalTo(HttpStatus.OK))); List body = result.getBody(); - assertThat(body.size(), is(equalTo(3))); + assertThat(body.size(), is(equalTo(4))); assertThat(body.get(0).getUuid(), is(equalTo(q1.getUuid()))); assertThat(body.get(1).getUuid(), is(equalTo(q2.getUuid()))); assertThat(body.get(2).getUuid(), is(equalTo(q3.getUuid()))); From 79cde975f80149dbf0fa9dbef4e3153df10a33f5 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Wed, 10 Dec 2025 13:39:17 +0100 Subject: [PATCH 50/53] revert default user emails from example.org to example.com Although I prefer .org, existing docs and tests expect .com. Also it will likely lead to confusion because people will keep trying to log in using the .com addresses. --- fixtures/0100_user-accounts.json | 4 ++-- .../db/repository/bootstrap/DatabaseBootstrapTests.java | 4 ++-- .../0130_test-users-with-api-keys-and-saved-queries.json | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fixtures/0100_user-accounts.json b/fixtures/0100_user-accounts.json index 4b5f3d3b1..14a3bd05f 100644 --- a/fixtures/0100_user-accounts.json +++ b/fixtures/0100_user-accounts.json @@ -4,7 +4,7 @@ "uuid": "7e64818d-6276-46fb-8bb1-732e6e09f7e9", "firstName": "Albert", "lastName": "Einstein", - "email": "albert.einstein@example.org", + "email": "albert.einstein@example.com", "passwordHash": "$2a$10$hZF1abbZ48Tf.3RndC9W6OlDt6gnBoD/2HbzJayTs6be7d.5DbpnW", "role": "ADMIN" }, @@ -13,7 +13,7 @@ "uuid": "b5b92c69-5ed9-4054-954d-0121c29b6800", "firstName": "Nikola", "lastName": "Tesla", - "email": "nikola.tesla@example.org", + "email": "nikola.tesla@example.com", "passwordHash": "$2a$10$tMbZUZg9AbYL514R.hZ0tuzvfZJR5NQhSVeJPTQhNwPf6gv/cvrna", "role": "USER" } diff --git a/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java b/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java index d078af0ad..ec1c50517 100644 --- a/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java +++ b/src/test/java/org/fairdatapoint/database/db/repository/bootstrap/DatabaseBootstrapTests.java @@ -54,7 +54,7 @@ public class DatabaseBootstrapTests extends BaseIntegrationTest { @Autowired private SearchSavedQueryRepository searchSavedQueryRepository; - private final String einsteinEmail = "albert.einstein@example.org"; + private final String einsteinEmail = "albert.einstein@example.com"; @Test public void testSingleEntityBootstrap() { @@ -80,7 +80,7 @@ public void testDuplicateIdEntityOverwriteBootstrap() { final Optional savedQuery = searchSavedQueryRepository.findByUuid( UUID.fromString("4c57eff3-4608-40ae-85af-b442cfea0746")); assertTrue(savedQuery.isPresent()); - assertEquals("isaac.newton@example.org", savedQuery.get().getUserAccount().getEmail()); + assertEquals("isaac.newton@example.com", savedQuery.get().getUserAccount().getEmail()); assertEquals("Some query 2", savedQuery.get().getName()); } } diff --git a/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json b/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json index d184b9b31..a58ae0af3 100644 --- a/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json +++ b/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json @@ -4,7 +4,7 @@ "uuid": "7e64818d-6276-46fb-8bb1-732e6e09f7e9", "firstName": "Albert", "lastName": "Einstein", - "email": "albert.einstein@example.org", + "email": "albert.einstein@example.com", "passwordHash": "$2a$10$hZF1abbZ48Tf.3RndC9W6OlDt6gnBoD/2HbzJayTs6be7d.5DbpnW", "role": "USER" }, @@ -13,7 +13,7 @@ "uuid": "b5b92c69-5ed9-4054-954d-0121c29b6800", "firstName": "Nikola", "lastName": "Tesla", - "email": "nikola.tesla@example.org", + "email": "nikola.tesla@example.com", "passwordHash": "$2a$10$tMbZUZg9AbYL514R.hZ0tuzvfZJR5NQhSVeJPTQhNwPf6gv/cvrna", "role": "USER" }, @@ -22,7 +22,7 @@ "uuid": "8d1a4c06-bb0e-4d03-a01f-14fa49bbc152", "firstName": "Isaac", "lastName": "Newton", - "email": "isaac.newton@example.org", + "email": "isaac.newton@example.com", "passwordHash": "$2a$10$DLkI7NAZDzWVaKG1lVtloeoPNLPoAgDDBqQKQiSAYDZXrf2QKkuHC", "role": "USER" }, @@ -31,7 +31,7 @@ "uuid": "95589e50-d261-492b-8852-9324e9a66a42", "firstName": "Admin", "lastName": "von Universe", - "email": "admin@example.org", + "email": "admin@example.com", "passwordHash": "$2a$10$L.0OZ8QjV3yLhoCDvU04gu.WP1wGQih41MsBdvtQOshJJntaugBxe", "role": "ADMIN" }, From 65f641f8400cec998d263003613669f6a7d66618 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Wed, 10 Dec 2025 13:49:54 +0100 Subject: [PATCH 51/53] adapt order of test users to match the original expectation --- ...-users-with-api-keys-and-saved-queries.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json b/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json index a58ae0af3..a7d28cf9b 100644 --- a/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json +++ b/src/test/resources/test-fixtures/0130_test-users-with-api-keys-and-saved-queries.json @@ -1,4 +1,13 @@ [ + { + "_class": "org.fairdatapoint.entity.user.UserAccount", + "uuid": "95589e50-d261-492b-8852-9324e9a66a42", + "firstName": "Admin", + "lastName": "von Universe", + "email": "admin@example.com", + "passwordHash": "$2a$10$L.0OZ8QjV3yLhoCDvU04gu.WP1wGQih41MsBdvtQOshJJntaugBxe", + "role": "ADMIN" + }, { "_class": "org.fairdatapoint.entity.user.UserAccount", "uuid": "7e64818d-6276-46fb-8bb1-732e6e09f7e9", @@ -26,15 +35,6 @@ "passwordHash": "$2a$10$DLkI7NAZDzWVaKG1lVtloeoPNLPoAgDDBqQKQiSAYDZXrf2QKkuHC", "role": "USER" }, - { - "_class": "org.fairdatapoint.entity.user.UserAccount", - "uuid": "95589e50-d261-492b-8852-9324e9a66a42", - "firstName": "Admin", - "lastName": "von Universe", - "email": "admin@example.com", - "passwordHash": "$2a$10$L.0OZ8QjV3yLhoCDvU04gu.WP1wGQih41MsBdvtQOshJJntaugBxe", - "role": "ADMIN" - }, { "_class": "org.fairdatapoint.entity.apikey.ApiKey", From 2341d09cf5fc394f4e468fc61604fae1e4631020 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Wed, 10 Dec 2025 13:57:52 +0100 Subject: [PATCH 52/53] repopulate test database after flyway.clean in ResourceDefinitionCacheTest --- .../service/resource/ResourceDefinitionCacheTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/org/fairdatapoint/service/resource/ResourceDefinitionCacheTest.java b/src/test/java/org/fairdatapoint/service/resource/ResourceDefinitionCacheTest.java index 4800c2d54..07db33f84 100644 --- a/src/test/java/org/fairdatapoint/service/resource/ResourceDefinitionCacheTest.java +++ b/src/test/java/org/fairdatapoint/service/resource/ResourceDefinitionCacheTest.java @@ -32,6 +32,9 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; +import org.springframework.data.repository.init.ResourceReaderRepositoryPopulator; +import org.springframework.data.repository.support.Repositories; import org.springframework.test.context.ActiveProfiles; import static org.hamcrest.MatcherAssert.assertThat; @@ -53,10 +56,18 @@ public class ResourceDefinitionCacheTest extends BaseIntegrationTest { @Autowired protected Flyway flyway; + @Autowired + private ApplicationContext applicationContext; + + @Autowired + private ResourceReaderRepositoryPopulator populator; + @BeforeEach public void setup() { flyway.clean(); flyway.migrate(); + // re-populate the database using default fixtures + populator.populate(new Repositories(applicationContext)); } @Test From 5f8fd38c8c341924fde43c3a10f0289c3e921ecd Mon Sep 17 00:00:00 2001 From: Dennis <29799340+dennisvang@users.noreply.github.com> Date: Fri, 19 Dec 2025 13:28:44 +0100 Subject: [PATCH 53/53] Handle optionals in MembershipService (#820) --- .../service/membership/MembershipService.java | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/fairdatapoint/service/membership/MembershipService.java b/src/main/java/org/fairdatapoint/service/membership/MembershipService.java index 34f8606fb..5488d82ad 100644 --- a/src/main/java/org/fairdatapoint/service/membership/MembershipService.java +++ b/src/main/java/org/fairdatapoint/service/membership/MembershipService.java @@ -56,35 +56,39 @@ public void addToMembership(ResourceDefinition resourceDefinition) { final UUID uuid = resourceDefinition.getUuid(); // Add to owner - final Membership owner = - membershipRepository.findByUuid(KnownUUIDs.MEMBERSHIP_OWNER_UUID).get(); - addEntityIfMissing(owner, uuid.toString()); - membershipRepository.save(owner); + membershipRepository.findByUuid(KnownUUIDs.MEMBERSHIP_OWNER_UUID) + .ifPresent(owner -> { + addEntityIfMissing(owner, uuid.toString()); + membershipRepository.save(owner); + }); // Add to data provider if (resourceDefinition.isCatalog()) { - final Membership dataProvider = - membershipRepository.findByUuid(KnownUUIDs.MEMBERSHIP_DATAPROVIDER_UUID).get(); - addEntityIfMissing(dataProvider, uuid.toString()); - membershipRepository.save(dataProvider); + membershipRepository.findByUuid(KnownUUIDs.MEMBERSHIP_DATAPROVIDER_UUID) + .ifPresent(dataProvider -> { + addEntityIfMissing(dataProvider, uuid.toString()); + membershipRepository.save(dataProvider); + }); } } public void removeFromMembership(ResourceDefinition resourceDefinition) { final UUID uuid = resourceDefinition.getUuid(); - // Add to owner - final Membership owner = - membershipRepository.findByUuid(KnownUUIDs.MEMBERSHIP_OWNER_UUID).get(); - removeEntityIfPresent(owner, uuid.toString()); - membershipRepository.save(owner); + // Remove from owner + membershipRepository.findByUuid(KnownUUIDs.MEMBERSHIP_OWNER_UUID) + .ifPresent(owner -> { + removeEntityIfPresent(owner, uuid.toString()); + membershipRepository.save(owner); + }); - // Add to data provider + // Remove from data provider if (resourceDefinition.isCatalog()) { - final Membership dataProvider = - membershipRepository.findByUuid(KnownUUIDs.MEMBERSHIP_DATAPROVIDER_UUID).get(); - removeEntityIfPresent(dataProvider, uuid.toString()); - membershipRepository.save(dataProvider); + membershipRepository.findByUuid(KnownUUIDs.MEMBERSHIP_DATAPROVIDER_UUID) + .ifPresent(dataProvider -> { + removeEntityIfPresent(dataProvider, uuid.toString()); + membershipRepository.save(dataProvider); + }); } }