Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
10 changes: 10 additions & 0 deletions data/records/records.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"records": [
{
"file": "repository.ttl",
"repository": "main",
"uri": "{{ persistentUrl }}"
}
],
"persistentUrlVar": "{{ persistentUrl }}"
}
28 changes: 28 additions & 0 deletions data/records/repository.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix dcat: <http://www.w3.org/ns/dcat#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix ldp: <http://www.w3.org/ns/ldp#> .

<{{ persistentUrl }}> a dcat:Resource, dcat:DataService, <https://w3id.org/fdp/fdp-o#MetadataService>,
<https://w3id.org/fdp/fdp-o#FAIRDataPoint>;
dcterms:title "My FAIR Data Point";
<http://www.w3.org/2000/01/rdf-schema#label> "My FAIR Data Point";
dcat:version "1.0";
dcterms:license <http://purl.org/NET/rdflicense/cc-zero1.0>;
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 <http://id.loc.gov/vocabulary/iso639-1/en>;
<https://w3id.org/fdp/fdp-o#metadataIdentifier> <{{ persistentUrl }}#identifier>;
<http://www.re3data.org/schema/3-0#repositoryIdentifier> <{{ persistentUrl }}#identifier>;
dcterms:accessRights <{{ persistentUrl }}#accessRights>;
dcterms:publisher <{{ persistentUrl }}#publisher>;
dcat:endpointURL <{{ persistentUrl }}> .

<{{ persistentUrl }}#identifier> a <http://purl.org/spar/datacite/Identifier>;
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" .
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
<maven.compiler.target>21</maven.compiler.target>

<!-- Project related -->
<spring.rdf.migration.version>2.0.0</spring.rdf.migration.version>
<rdf-resolver.version>0.2.0</rdf-resolver.version>

<!-- Core -->
Expand Down Expand Up @@ -81,11 +80,6 @@
<!-- ////////////////// -->
<!-- Project related -->
<!-- ////////////////// -->
<dependency>
<groupId>org.fairdatateam.rdf</groupId>
<artifactId>spring-rdf-migration</artifactId>
<version>${spring.rdf.migration.version}</version>
</dependency>
<dependency>
<groupId>org.fairdatateam.rdf</groupId>
<artifactId>rdf-resource-resolver-core</artifactId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
@ConfigurationProperties(prefix = "bootstrap")
public class BootstrapProperties {
private boolean enabled;
private String dataPath;
// directories relative to project root
private String dbFixturesDir;
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

/**
* Loads initial RDF data for development.
* TODO: remove all classes and files related to RDF migration, in favor of the fixtures-based approach.
* @deprecated use RDF fixtures instead, see {@link org.fairdatapoint.service.bootstrap bootstrap package}
*/
@Deprecated(forRemoval = true, since = "1")
@Service
@Profile(Profiles.NON_PRODUCTION)
public class RdfDevelopmentMigrationRunner {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,24 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.fairdatapoint.database.rdf.migration.production;
package org.fairdatapoint.service.bootstrap;

import lombok.extern.slf4j.Slf4j;
import org.fairdatateam.rdf.migration.entity.RdfMigrationAnnotation;
import org.fairdatateam.rdf.migration.runner.RdfProductionMigration;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
import org.fairdatapoint.config.properties.BootstrapProperties;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@RdfMigrationAnnotation(
number = 5,
name = "Fix Metadata Version",
description = "Use dcat:version instead of dcterms:hasVersion")
@Slf4j
@Service
public class Rdf_Migration_0005_FixMetadataVersion implements RdfProductionMigration {
// TODO: remove (use seed)
@Component
@RequiredArgsConstructor
public class BootstrapRunner implements ApplicationRunner {
private final BootstrapProperties bootstrapProperties;
private final BootstrapService bootstrapService;

public void runMigration() {
@Override
public void run(final org.springframework.boot.ApplicationArguments args) {
if (bootstrapProperties.isEnabled()) {
bootstrapService.bootstrapFromDir(bootstrapProperties.getDataPath());
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* 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");
}
}
Loading