From cf56bfe423ff87bdeb7d18aae89b0cd60308eb30 Mon Sep 17 00:00:00 2001 From: Hugo Manguinhas Date: Tue, 14 May 2024 16:28:50 +0200 Subject: [PATCH] Fix migration code --- record-api-migration/pom.xml | 90 ++++++++++--------- .../record/migration/RecordJenaProcessor.java | 8 +- .../io/jena/RecordApiTemplateLibrary.java | 4 + .../jena/encoder/utils/JenaUtils.java | 6 +- 4 files changed, 62 insertions(+), 46 deletions(-) diff --git a/record-api-migration/pom.xml b/record-api-migration/pom.xml index 4fb4ccc..22dfb1c 100644 --- a/record-api-migration/pom.xml +++ b/record-api-migration/pom.xml @@ -1,52 +1,58 @@ - - record-api - eu.europeana.api - 1.0-SNAPSHOT - - 4.0.0 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + record-api + eu.europeana.api + 1.0-SNAPSHOT + + 4.0.0 - record-api-migration - This is a temporary module to migrate all the data from the DB - - 17 - 17 - eu.europeana.api.record.migration.RunMigration - + record-api-migration + This is a temporary module to migrate all the data from the DB + + 17 + 17 + eu.europeana.api.record.migration.RunMigration + - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-logging - - - + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-logging + + + - - - org.apache.commons - commons-lang3 - ${apache.commomLang3.version} - - - eu.europeana.api - record-api-model - 1.0-SNAPSHOT - + + + org.apache.commons + commons-lang3 + ${apache.commomLang3.version} + + + eu.europeana.api + record-api-model + 1.0-SNAPSHOT + + + eu.europeana.api + record-api-mongo + 1.0-SNAPSHOT + + - eu.europeana.api - record-api-mongo - 1.0-SNAPSHOT + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson.version} - + \ No newline at end of file diff --git a/record-api-migration/src/main/java/eu/europeana/api/record/migration/RecordJenaProcessor.java b/record-api-migration/src/main/java/eu/europeana/api/record/migration/RecordJenaProcessor.java index 88e788d..e3d3071 100755 --- a/record-api-migration/src/main/java/eu/europeana/api/record/migration/RecordJenaProcessor.java +++ b/record-api-migration/src/main/java/eu/europeana/api/record/migration/RecordJenaProcessor.java @@ -2,6 +2,8 @@ import static org.apache.jena.rdf.model.ResourceFactory.*; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; import eu.europeana.api.config.AppConfigConstants; @@ -44,7 +46,7 @@ import eu.europeana.jena.edm.ORE; import eu.europeana.jena.edm.RDAGR2; import eu.europeana.jena.edm.SVCS; -import eu.europeana.jena.utils.JenaUtils; +import eu.europeana.jena.encoder.utils.JenaUtils; import static eu.europeana.api.record.migration.MigrationHandler.log; @@ -114,8 +116,8 @@ public class RecordJenaProcessor { private MediaTypes mediaTypes = null; - public RecordJenaProcessor() { - mediaTypes = RecordApiTemplateLibrary.getMediaTypes(); + public RecordJenaProcessor(MediaTypes mediaTypes) { + this.mediaTypes = mediaTypes; } public Resource upgrade(Resource cho) { diff --git a/record-api-model/src/main/java/eu/europeana/api/record/io/jena/RecordApiTemplateLibrary.java b/record-api-model/src/main/java/eu/europeana/api/record/io/jena/RecordApiTemplateLibrary.java index dc689ad..e799674 100755 --- a/record-api-model/src/main/java/eu/europeana/api/record/io/jena/RecordApiTemplateLibrary.java +++ b/record-api-model/src/main/java/eu/europeana/api/record/io/jena/RecordApiTemplateLibrary.java @@ -75,4 +75,8 @@ public RecordApiTemplateLibrary(CodecRegistry codecRegistry, NamespaceResolver n LOG.info("RecordApiTemplateLibrary configuration added ...."); } + + public MediaTypes getMediaTypes() { + return this.mediaTypes; + } } diff --git a/record-api-model/src/main/java/eu/europeana/jena/encoder/utils/JenaUtils.java b/record-api-model/src/main/java/eu/europeana/jena/encoder/utils/JenaUtils.java index 7029043..a3b8330 100755 --- a/record-api-model/src/main/java/eu/europeana/jena/encoder/utils/JenaUtils.java +++ b/record-api-model/src/main/java/eu/europeana/jena/encoder/utils/JenaUtils.java @@ -52,12 +52,16 @@ public static void disableRiotValidation() { } } + public static boolean hasDatatype(Literal l) { + return hasDatatype(l.getDatatype()); + } + public static boolean hasDatatype(RDFDatatype dt) { return ( dt != null && !ignoredDatatypes.contains(dt.getURI())); } public static boolean hasLanguage(Literal literal) { - return ( !StringUtils.isBlank(literal.getLanguage()) ); + return ( StringUtils.isNotBlank(literal.getLanguage()) ); } public static > T copy(StmtIterator iter