Skip to content

Commit cf56bfe

Browse files
Fix migration code
1 parent 209ed37 commit cf56bfe

File tree

4 files changed

+62
-46
lines changed

4 files changed

+62
-46
lines changed

record-api-migration/pom.xml

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,58 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5-
<parent>
6-
<artifactId>record-api</artifactId>
7-
<groupId>eu.europeana.api</groupId>
8-
<version>1.0-SNAPSHOT</version>
9-
</parent>
10-
<modelVersion>4.0.0</modelVersion>
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>record-api</artifactId>
7+
<groupId>eu.europeana.api</groupId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
1111

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

20-
<dependencies>
21-
<dependency>
22-
<groupId>org.springframework.boot</groupId>
23-
<artifactId>spring-boot-starter-web</artifactId>
24-
<exclusions>
25-
<!-- use log4j2 instead -->
26-
<exclusion>
27-
<groupId>org.springframework.boot</groupId>
28-
<artifactId>spring-boot-starter-logging</artifactId>
29-
</exclusion>
30-
</exclusions>
31-
</dependency>
20+
<dependencies>
21+
<dependency>
22+
<groupId>org.springframework.boot</groupId>
23+
<artifactId>spring-boot-starter-web</artifactId>
24+
<exclusions>
25+
<!-- use log4j2 instead -->
26+
<exclusion>
27+
<groupId>org.springframework.boot</groupId>
28+
<artifactId>spring-boot-starter-logging</artifactId>
29+
</exclusion>
30+
</exclusions>
31+
</dependency>
3232

3333

34-
<!-- StringUtils -->
35-
<dependency>
36-
<groupId>org.apache.commons</groupId>
37-
<artifactId>commons-lang3</artifactId>
38-
<version>${apache.commomLang3.version}</version>
39-
</dependency>
40-
<dependency>
41-
<groupId>eu.europeana.api</groupId>
42-
<artifactId>record-api-model</artifactId>
43-
<version>1.0-SNAPSHOT</version>
44-
</dependency>
34+
<!-- StringUtils -->
35+
<dependency>
36+
<groupId>org.apache.commons</groupId>
37+
<artifactId>commons-lang3</artifactId>
38+
<version>${apache.commomLang3.version}</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>eu.europeana.api</groupId>
42+
<artifactId>record-api-model</artifactId>
43+
<version>1.0-SNAPSHOT</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>eu.europeana.api</groupId>
47+
<artifactId>record-api-mongo</artifactId>
48+
<version>1.0-SNAPSHOT</version>
49+
</dependency>
50+
<!-- jackson time module-->
4551
<dependency>
46-
<groupId>eu.europeana.api</groupId>
47-
<artifactId>record-api-mongo</artifactId>
48-
<version>1.0-SNAPSHOT</version>
52+
<groupId>com.fasterxml.jackson.datatype</groupId>
53+
<artifactId>jackson-datatype-jsr310</artifactId>
54+
<version>${jackson.version}</version>
4955
</dependency>
50-
</dependencies>
56+
</dependencies>
5157

5258
</project>

record-api-migration/src/main/java/eu/europeana/api/record/migration/RecordJenaProcessor.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import static org.apache.jena.rdf.model.ResourceFactory.*;
44

5+
import java.time.OffsetDateTime;
6+
import java.time.format.DateTimeFormatter;
57
import java.util.*;
68

79
import eu.europeana.api.config.AppConfigConstants;
@@ -44,7 +46,7 @@
4446
import eu.europeana.jena.edm.ORE;
4547
import eu.europeana.jena.edm.RDAGR2;
4648
import eu.europeana.jena.edm.SVCS;
47-
import eu.europeana.jena.utils.JenaUtils;
49+
import eu.europeana.jena.encoder.utils.JenaUtils;
4850

4951
import static eu.europeana.api.record.migration.MigrationHandler.log;
5052

@@ -114,8 +116,8 @@ public class RecordJenaProcessor {
114116

115117
private MediaTypes mediaTypes = null;
116118

117-
public RecordJenaProcessor() {
118-
mediaTypes = RecordApiTemplateLibrary.getMediaTypes();
119+
public RecordJenaProcessor(MediaTypes mediaTypes) {
120+
this.mediaTypes = mediaTypes;
119121
}
120122

121123
public Resource upgrade(Resource cho) {

record-api-model/src/main/java/eu/europeana/api/record/io/jena/RecordApiTemplateLibrary.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,8 @@ public RecordApiTemplateLibrary(CodecRegistry codecRegistry, NamespaceResolver n
7575

7676
LOG.info("RecordApiTemplateLibrary configuration added ....");
7777
}
78+
79+
public MediaTypes getMediaTypes() {
80+
return this.mediaTypes;
81+
}
7882
}

record-api-model/src/main/java/eu/europeana/jena/encoder/utils/JenaUtils.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,16 @@ public static void disableRiotValidation() {
5252
}
5353
}
5454

55+
public static boolean hasDatatype(Literal l) {
56+
return hasDatatype(l.getDatatype());
57+
}
58+
5559
public static boolean hasDatatype(RDFDatatype dt) {
5660
return ( dt != null && !ignoredDatatypes.contains(dt.getURI()));
5761
}
5862

5963
public static boolean hasLanguage(Literal literal) {
60-
return ( !StringUtils.isBlank(literal.getLanguage()) );
64+
return ( StringUtils.isNotBlank(literal.getLanguage()) );
6165
}
6266

6367
public static <T extends Collection<Statement>> T copy(StmtIterator iter

0 commit comments

Comments
 (0)