Skip to content

Commit

Permalink
Fix migration code
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomanguinhas committed May 14, 2024
1 parent 209ed37 commit cf56bfe
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 46 deletions.
90 changes: 48 additions & 42 deletions record-api-migration/pom.xml
Original file line number Diff line number Diff line change
@@ -1,52 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/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">
<parent>
<artifactId>record-api</artifactId>
<groupId>eu.europeana.api</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
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">
<parent>
<artifactId>record-api</artifactId>
<groupId>eu.europeana.api</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>record-api-migration</artifactId>
<description> This is a temporary module to migrate all the data from the DB</description>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<spring.boot.mainclass>eu.europeana.api.record.migration.RunMigration</spring.boot.mainclass>
</properties>
<artifactId>record-api-migration</artifactId>
<description> This is a temporary module to migrate all the data from the DB</description>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<spring.boot.mainclass>eu.europeana.api.record.migration.RunMigration</spring.boot.mainclass>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<!-- use log4j2 instead -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<!-- use log4j2 instead -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>


<!-- StringUtils -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${apache.commomLang3.version}</version>
</dependency>
<dependency>
<groupId>eu.europeana.api</groupId>
<artifactId>record-api-model</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- StringUtils -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${apache.commomLang3.version}</version>
</dependency>
<dependency>
<groupId>eu.europeana.api</groupId>
<artifactId>record-api-model</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.europeana.api</groupId>
<artifactId>record-api-mongo</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- jackson time module-->
<dependency>
<groupId>eu.europeana.api</groupId>
<artifactId>record-api-mongo</artifactId>
<version>1.0-SNAPSHOT</version>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,8 @@ public RecordApiTemplateLibrary(CodecRegistry codecRegistry, NamespaceResolver n

LOG.info("RecordApiTemplateLibrary configuration added ....");
}

public MediaTypes getMediaTypes() {
return this.mediaTypes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 extends Collection<Statement>> T copy(StmtIterator iter
Expand Down

0 comments on commit cf56bfe

Please sign in to comment.