diff --git a/kubernetes-biocase.yaml b/kubernetes-biocase.yaml
deleted file mode 100644
index 7adfacb..0000000
--- a/kubernetes-biocase.yaml
+++ /dev/null
@@ -1,53 +0,0 @@
-apiVersion: batch/v1
-kind: Job
-metadata:
- name: biocase-huq-s1j-ay4-translator-service
-spec:
- backoffLimit: 2
- template:
- spec:
- restartPolicy: Never
- containers:
- - name: biocase-huq-s1j-ay4-translator-service
- image: public.ecr.aws/dissco/dissco-core-translator
- resources:
- requests:
- memory: 2G
- limits:
- memory: 2G
- env:
- - name: spring.profiles.active
- value: biocase
- - name: webclient.sourceSystemId
- value: 20.5000.1025/HUQ-S1J-AY4
- - name: dwca.download-file
- value: /temp/darwin.zip
- - name: dwca.temp-folder
- value: /temp/darwin
- - name: kafka.host
- value: kafka.kafka.svc.cluster.local:9092
- - name: kafka.topic
- value: digital-specimen
- - name: spring.datasource.url
- value: jdbc:postgresql://database-1.cbppwfnjypll.eu-west-2.rds.amazonaws.com/dissco
- - name: spring.datasource.username
- valueFrom:
- secretKeyRef:
- name: db-user-pass
- key: username
- - name: spring.datasource.password
- valueFrom:
- secretKeyRef:
- name: db-user-pass
- key: password
- - name: JAVA_OPTS
- value: -server -XX:+useContainerSupport -XX:MaxRAMPercentage=75 --illegal-access=deny
- securityContext:
- runAsNonRoot: true
- allowPrivilegeEscalation: false
- volumeMounts:
- - mountPath: /temp
- name: temp-volume
- volumes:
- - name: temp-volume
- emptyDir: { }
\ No newline at end of file
diff --git a/kubernetes-dwca.yaml b/kubernetes-dwca.yaml
deleted file mode 100644
index c012213..0000000
--- a/kubernetes-dwca.yaml
+++ /dev/null
@@ -1,53 +0,0 @@
-apiVersion: batch/v1
-kind: Job
-metadata:
- name: dwca-qdf-v40-810-translator-service
-spec:
- backoffLimit: 2
- template:
- spec:
- restartPolicy: Never
- containers:
- - name: dwca-qdf-v40-810-translator-service
- image: public.ecr.aws/dissco/dissco-core-translator
- resources:
- requests:
- memory: 2G
- limits:
- memory: 2G
- env:
- - name: spring.profiles.active
- value: dwca
- - name: webclient.sourceSystemId
- value: 20.5000.1025/QDF-V40-810
- - name: dwca.download-file
- value: /temp/darwin.zip
- - name: dwca.temp-folder
- value: /temp/darwin
- - name: kafka.host
- value: kafka-cluster-kafka-bootstrap.kafka.svc.cluster.local:9092
- - name: kafka.topic
- value: digital-specimen
- - name: spring.datasource.url
- value: jdbc:postgresql://database-1.cbppwfnjypll.eu-west-2.rds.amazonaws.com/dissco
- - name: spring.datasource.username
- valueFrom:
- secretKeyRef:
- name: db-user-pass
- key: username
- - name: spring.datasource.password
- valueFrom:
- secretKeyRef:
- name: db-user-pass
- key: password
- - name: JAVA_OPTS
- value: -server -XX:+useContainerSupport -XX:MaxRAMPercentage=75 --illegal-access=deny
- securityContext:
- runAsNonRoot: true
- allowPrivilegeEscalation: false
- volumeMounts:
- - mountPath: /temp
- name: temp-volume
- volumes:
- - name: temp-volume
- emptyDir: { }
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 328880c..a0c32ad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
org.springframework.boot
spring-boot-starter-parent
- 3.1.2
+ 3.1.4
eu.dissco.core
@@ -19,11 +19,11 @@
2.16
1.9.4
3.1.0
- 2.1.0
- 4.0.0
- 3.0.10
+ 2.1.2
+ 4.0.1
+ 1.1.10.5
5.2.0
- 1.17.5
+ 1.19.0
dissco
https://sonarcloud.io
../app-it/target/site/jacoco-aggregate/jacoco.xml
@@ -80,11 +80,11 @@
org.springframework.kafka
spring-kafka
-
+
org.xerial.snappy
snappy-java
- 1.1.10.3
+ ${snappy-java.version}
org.springframework.boot
@@ -273,6 +273,27 @@
+
+ org.jsonschema2pojo
+ jsonschema2pojo-maven-plugin
+ 1.2.1
+
+ ${basedir}/src/main/resources/json-schema/
+ eu.dissco.core.translator.schema
+ true
+ true
+ false
+
+
+
+
+
+ generate
+
+
+
+
+
diff --git a/src/main/java/eu/dissco/core/translator/Profiles.java b/src/main/java/eu/dissco/core/translator/Profiles.java
index 5986f43..a410304 100644
--- a/src/main/java/eu/dissco/core/translator/Profiles.java
+++ b/src/main/java/eu/dissco/core/translator/Profiles.java
@@ -1,6 +1,7 @@
package eu.dissco.core.translator;
public class Profiles {
+
public static final String BIOCASE = "biocase";
public static final String DWCA = "dwca";
diff --git a/src/main/java/eu/dissco/core/translator/component/MappingComponent.java b/src/main/java/eu/dissco/core/translator/component/MappingComponent.java
index 807d216..3439752 100644
--- a/src/main/java/eu/dissco/core/translator/component/MappingComponent.java
+++ b/src/main/java/eu/dissco/core/translator/component/MappingComponent.java
@@ -6,6 +6,7 @@
import jakarta.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
+import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -18,14 +19,16 @@ public class MappingComponent {
private final WebClientProperties properties;
private final MappingRepository repository;
+ @Getter
private final Map fieldMappings = new HashMap<>();
+ @Getter
private final Map defaults = new HashMap<>();
@PostConstruct
void setup() throws DisscoRepositoryException {
var objectNode = repository.retrieveMapping(properties.getSourceSystemId());
var mappingObject = objectNode.get("mapping");
- if (mappingObject != null){
+ if (mappingObject != null) {
mappingObject.iterator().forEachRemaining(node -> node.fields()
.forEachRemaining(field -> fieldMappings.put(field.getKey(), field.getValue().asText())));
}
@@ -34,12 +37,4 @@ void setup() throws DisscoRepositoryException {
.forEachRemaining(field -> defaults.put(field.getKey(), field.getValue().asText())));
}
- public Map getFieldMappings() {
- return fieldMappings;
- }
-
- public Map getDefaultMappings() {
- return defaults;
- }
-
}
diff --git a/src/main/java/eu/dissco/core/translator/component/RorComponent.java b/src/main/java/eu/dissco/core/translator/component/RorComponent.java
index 36534fe..25c132f 100644
--- a/src/main/java/eu/dissco/core/translator/component/RorComponent.java
+++ b/src/main/java/eu/dissco/core/translator/component/RorComponent.java
@@ -17,7 +17,7 @@ public class RorComponent {
private final WebClient webClient;
@Cacheable("ror")
- public String getRoRId(String ror) {
+ public String getRorName(String ror) {
log.info("Requesting organisation details for organisation: {} with ror", ror);
String url = "https://api.ror.org/organizations/" + ror;
var response = webClient.get().uri(url).retrieve().bodyToMono(JsonNode.class)
diff --git a/src/main/java/eu/dissco/core/translator/configuration/ApplicationConfiguration.java b/src/main/java/eu/dissco/core/translator/configuration/ApplicationConfiguration.java
index f3cc2c6..059ac1c 100644
--- a/src/main/java/eu/dissco/core/translator/configuration/ApplicationConfiguration.java
+++ b/src/main/java/eu/dissco/core/translator/configuration/ApplicationConfiguration.java
@@ -9,6 +9,7 @@
@Configuration
public class ApplicationConfiguration {
+
public static final String DATE_STRING = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
@Bean
diff --git a/src/main/java/eu/dissco/core/translator/database/jooq/DefaultCatalog.java b/src/main/java/eu/dissco/core/translator/database/jooq/DefaultCatalog.java
index 27f8100..cc26e9e 100644
--- a/src/main/java/eu/dissco/core/translator/database/jooq/DefaultCatalog.java
+++ b/src/main/java/eu/dissco/core/translator/database/jooq/DefaultCatalog.java
@@ -6,7 +6,6 @@
import java.util.Arrays;
import java.util.List;
-
import org.jooq.Constants;
import org.jooq.Schema;
import org.jooq.impl.CatalogImpl;
@@ -15,40 +14,37 @@
/**
* This class is generated by jOOQ.
*/
-@SuppressWarnings({ "all", "unchecked", "rawtypes" })
+@SuppressWarnings({"all", "unchecked", "rawtypes"})
public class DefaultCatalog extends CatalogImpl {
- private static final long serialVersionUID = 1L;
-
- /**
- * The reference instance of DEFAULT_CATALOG
- */
- public static final DefaultCatalog DEFAULT_CATALOG = new DefaultCatalog();
-
- /**
- * The schema public
.
- */
- public final Public PUBLIC = Public.PUBLIC;
-
- /**
- * No further instances allowed
- */
- private DefaultCatalog() {
- super("");
- }
-
- @Override
- public final List getSchemas() {
- return Arrays.asList(
- Public.PUBLIC
- );
- }
-
- /**
- * A reference to the 3.18 minor release of the code generator. If this
- * doesn't compile, it's because the runtime library uses an older minor
- * release, namely: 3.18. You can turn off the generation of this reference
- * by specifying /configuration/generator/generate/jooqVersionReference
- */
- private static final String REQUIRE_RUNTIME_JOOQ_VERSION = Constants.VERSION_3_18;
+ /**
+ * The reference instance of DEFAULT_CATALOG
+ */
+ public static final DefaultCatalog DEFAULT_CATALOG = new DefaultCatalog();
+ private static final long serialVersionUID = 1L;
+ /**
+ * A reference to the 3.18 minor release of the code generator. If this doesn't compile, it's
+ * because the runtime library uses an older minor release, namely: 3.18. You can turn off the
+ * generation of this reference by specifying
+ * /configuration/generator/generate/jooqVersionReference
+ */
+ private static final String REQUIRE_RUNTIME_JOOQ_VERSION = Constants.VERSION_3_18;
+ /**
+ * The schema public
.
+ */
+ public final Public PUBLIC = Public.PUBLIC;
+
+ /**
+ * No further instances allowed
+ */
+ private DefaultCatalog() {
+ super("");
+ }
+
+ @Override
+ public final List getSchemas() {
+ return Arrays.asList(
+ Public.PUBLIC
+ );
+ }
}
diff --git a/src/main/java/eu/dissco/core/translator/database/jooq/Keys.java b/src/main/java/eu/dissco/core/translator/database/jooq/Keys.java
index 8da3a3d..c94a65a 100644
--- a/src/main/java/eu/dissco/core/translator/database/jooq/Keys.java
+++ b/src/main/java/eu/dissco/core/translator/database/jooq/Keys.java
@@ -8,7 +8,6 @@
import eu.dissco.core.translator.database.jooq.tables.SourceSystem;
import eu.dissco.core.translator.database.jooq.tables.records.MappingRecord;
import eu.dissco.core.translator.database.jooq.tables.records.SourceSystemRecord;
-
import org.jooq.TableField;
import org.jooq.UniqueKey;
import org.jooq.impl.DSL;
@@ -16,16 +15,19 @@
/**
- * A class modelling foreign key relationships and constraints of tables in
- * public.
+ * A class modelling foreign key relationships and constraints of tables in public.
*/
-@SuppressWarnings({ "all", "unchecked", "rawtypes" })
+@SuppressWarnings({"all", "unchecked", "rawtypes"})
public class Keys {
- // -------------------------------------------------------------------------
- // UNIQUE and PRIMARY KEY definitions
- // -------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
+ // UNIQUE and PRIMARY KEY definitions
+ // -------------------------------------------------------------------------
- public static final UniqueKey NEW_MAPPING_PK = Internal.createUniqueKey(Mapping.MAPPING, DSL.name("new_mapping_pk"), new TableField[] { Mapping.MAPPING.ID, Mapping.MAPPING.VERSION }, true);
- public static final UniqueKey NEW_SOURCE_SYSTEM_PKEY = Internal.createUniqueKey(SourceSystem.SOURCE_SYSTEM, DSL.name("new_source_system_pkey"), new TableField[] { SourceSystem.SOURCE_SYSTEM.ID }, true);
+ public static final UniqueKey NEW_MAPPING_PK = Internal.createUniqueKey(
+ Mapping.MAPPING, DSL.name("new_mapping_pk"),
+ new TableField[]{Mapping.MAPPING.ID, Mapping.MAPPING.VERSION}, true);
+ public static final UniqueKey NEW_SOURCE_SYSTEM_PKEY = Internal.createUniqueKey(
+ SourceSystem.SOURCE_SYSTEM, DSL.name("new_source_system_pkey"),
+ new TableField[]{SourceSystem.SOURCE_SYSTEM.ID}, true);
}
diff --git a/src/main/java/eu/dissco/core/translator/database/jooq/Public.java b/src/main/java/eu/dissco/core/translator/database/jooq/Public.java
index 1c3fdff..662c659 100644
--- a/src/main/java/eu/dissco/core/translator/database/jooq/Public.java
+++ b/src/main/java/eu/dissco/core/translator/database/jooq/Public.java
@@ -6,7 +6,6 @@
import eu.dissco.core.translator.database.jooq.tables.Mapping;
import eu.dissco.core.translator.database.jooq.tables.SourceSystem;
-
import java.util.Arrays;
import java.util.List;
@@ -18,44 +17,42 @@
/**
* This class is generated by jOOQ.
*/
-@SuppressWarnings({ "all", "unchecked", "rawtypes" })
+@SuppressWarnings({"all", "unchecked", "rawtypes"})
public class Public extends SchemaImpl {
- private static final long serialVersionUID = 1L;
-
- /**
- * The reference instance of public
- */
- public static final Public PUBLIC = new Public();
-
- /**
- * The table public.mapping
.
- */
- public final Mapping MAPPING = Mapping.MAPPING;
-
- /**
- * The table public.source_system
.
- */
- public final SourceSystem SOURCE_SYSTEM = SourceSystem.SOURCE_SYSTEM;
-
- /**
- * No further instances allowed
- */
- private Public() {
- super("public", null);
- }
-
-
- @Override
- public Catalog getCatalog() {
- return DefaultCatalog.DEFAULT_CATALOG;
- }
-
- @Override
- public final List> getTables() {
- return Arrays.asList(
- Mapping.MAPPING,
- SourceSystem.SOURCE_SYSTEM
- );
- }
+ /**
+ * The reference instance of public
+ */
+ public static final Public PUBLIC = new Public();
+ private static final long serialVersionUID = 1L;
+ /**
+ * The table public.mapping
.
+ */
+ public final Mapping MAPPING = Mapping.MAPPING;
+
+ /**
+ * The table public.source_system
.
+ */
+ public final SourceSystem SOURCE_SYSTEM = SourceSystem.SOURCE_SYSTEM;
+
+ /**
+ * No further instances allowed
+ */
+ private Public() {
+ super("public", null);
+ }
+
+
+ @Override
+ public Catalog getCatalog() {
+ return DefaultCatalog.DEFAULT_CATALOG;
+ }
+
+ @Override
+ public final List> getTables() {
+ return Arrays.asList(
+ Mapping.MAPPING,
+ SourceSystem.SOURCE_SYSTEM
+ );
+ }
}
diff --git a/src/main/java/eu/dissco/core/translator/database/jooq/Tables.java b/src/main/java/eu/dissco/core/translator/database/jooq/Tables.java
index 035a641..9e8654d 100644
--- a/src/main/java/eu/dissco/core/translator/database/jooq/Tables.java
+++ b/src/main/java/eu/dissco/core/translator/database/jooq/Tables.java
@@ -11,16 +11,16 @@
/**
* Convenience access to all tables in public.
*/
-@SuppressWarnings({ "all", "unchecked", "rawtypes" })
+@SuppressWarnings({"all", "unchecked", "rawtypes"})
public class Tables {
- /**
- * The table public.mapping
.
- */
- public static final Mapping MAPPING = Mapping.MAPPING;
+ /**
+ * The table public.mapping
.
+ */
+ public static final Mapping MAPPING = Mapping.MAPPING;
- /**
- * The table public.source_system
.
- */
- public static final SourceSystem SOURCE_SYSTEM = SourceSystem.SOURCE_SYSTEM;
+ /**
+ * The table public.source_system
.
+ */
+ public static final SourceSystem SOURCE_SYSTEM = SourceSystem.SOURCE_SYSTEM;
}
diff --git a/src/main/java/eu/dissco/core/translator/database/jooq/tables/Mapping.java b/src/main/java/eu/dissco/core/translator/database/jooq/tables/Mapping.java
index f42d163..eca9599 100644
--- a/src/main/java/eu/dissco/core/translator/database/jooq/tables/Mapping.java
+++ b/src/main/java/eu/dissco/core/translator/database/jooq/tables/Mapping.java
@@ -7,10 +7,8 @@
import eu.dissco.core.translator.database.jooq.Keys;
import eu.dissco.core.translator.database.jooq.Public;
import eu.dissco.core.translator.database.jooq.tables.records.MappingRecord;
-
import java.time.Instant;
import java.util.function.Function;
-
import org.jooq.Field;
import org.jooq.ForeignKey;
import org.jooq.Function9;
@@ -33,172 +31,172 @@
/**
* This class is generated by jOOQ.
*/
-@SuppressWarnings({ "all", "unchecked", "rawtypes" })
+@SuppressWarnings({"all", "unchecked", "rawtypes"})
public class Mapping extends TableImpl {
- private static final long serialVersionUID = 1L;
-
- /**
- * The reference instance of public.mapping
- */
- public static final Mapping MAPPING = new Mapping();
-
- /**
- * The class holding records for this type
- */
- @Override
- public Class getRecordType() {
- return MappingRecord.class;
- }
-
- /**
- * The column public.mapping.id
.
- */
- public final TableField ID = createField(DSL.name("id"), SQLDataType.CLOB.nullable(false), this, "");
-
- /**
- * The column public.mapping.version
.
- */
- public final TableField VERSION = createField(DSL.name("version"), SQLDataType.INTEGER.nullable(false), this, "");
-
- /**
- * The column public.mapping.name
.
- */
- public final TableField NAME = createField(DSL.name("name"), SQLDataType.CLOB.nullable(false), this, "");
-
- /**
- * The column public.mapping.description
.
- */
- public final TableField DESCRIPTION = createField(DSL.name("description"), SQLDataType.CLOB, this, "");
-
- /**
- * The column public.mapping.mapping
.
- */
- public final TableField MAPPING_ = createField(DSL.name("mapping"), SQLDataType.JSONB.nullable(false), this, "");
-
- /**
- * The column public.mapping.created
.
- */
- public final TableField CREATED = createField(DSL.name("created"), SQLDataType.INSTANT.nullable(false), this, "");
-
- /**
- * The column public.mapping.creator
.
- */
- public final TableField CREATOR = createField(DSL.name("creator"), SQLDataType.CLOB.nullable(false), this, "");
-
- /**
- * The column public.mapping.deleted
.
- */
- public final TableField DELETED = createField(DSL.name("deleted"), SQLDataType.INSTANT, this, "");
-
- /**
- * The column public.mapping.sourcedatastandard
.
- */
- public final TableField SOURCEDATASTANDARD = createField(DSL.name("sourcedatastandard"), SQLDataType.VARCHAR.nullable(false), this, "");
-
- private Mapping(Name alias, Table aliased) {
- this(alias, aliased, null);
- }
-
- private Mapping(Name alias, Table aliased, Field>[] parameters) {
- super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table());
- }
-
- /**
- * Create an aliased public.mapping
table reference
- */
- public Mapping(String alias) {
- this(DSL.name(alias), MAPPING);
- }
-
- /**
- * Create an aliased public.mapping
table reference
- */
- public Mapping(Name alias) {
- this(alias, MAPPING);
- }
-
- /**
- * Create a public.mapping
table reference
- */
- public Mapping() {
- this(DSL.name("mapping"), null);
- }
-
- public Mapping(Table child, ForeignKey key) {
- super(child, key, MAPPING);
- }
-
- @Override
- public Schema getSchema() {
- return aliased() ? null : Public.PUBLIC;
- }
-
- @Override
- public UniqueKey getPrimaryKey() {
- return Keys.NEW_MAPPING_PK;
- }
-
- @Override
- public Mapping as(String alias) {
- return new Mapping(DSL.name(alias), this);
- }
-
- @Override
- public Mapping as(Name alias) {
- return new Mapping(alias, this);
- }
-
- @Override
- public Mapping as(Table> alias) {
- return new Mapping(alias.getQualifiedName(), this);
- }
-
- /**
- * Rename this table
- */
- @Override
- public Mapping rename(String name) {
- return new Mapping(DSL.name(name), null);
- }
-
- /**
- * Rename this table
- */
- @Override
- public Mapping rename(Name name) {
- return new Mapping(name, null);
- }
-
- /**
- * Rename this table
- */
- @Override
- public Mapping rename(Table> name) {
- return new Mapping(name.getQualifiedName(), null);
- }
-
- // -------------------------------------------------------------------------
- // Row9 type methods
- // -------------------------------------------------------------------------
-
- @Override
- public Row9 fieldsRow() {
- return (Row9) super.fieldsRow();
- }
-
- /**
- * Convenience mapping calling {@link SelectField#convertFrom(Function)}.
- */
- public SelectField mapping(Function9 super String, ? super Integer, ? super String, ? super String, ? super JSONB, ? super Instant, ? super String, ? super Instant, ? super String, ? extends U> from) {
- return convertFrom(Records.mapping(from));
- }
-
- /**
- * Convenience mapping calling {@link SelectField#convertFrom(Class,
- * Function)}.
- */
- public SelectField mapping(Class toType, Function9 super String, ? super Integer, ? super String, ? super String, ? super JSONB, ? super Instant, ? super String, ? super Instant, ? super String, ? extends U> from) {
- return convertFrom(toType, Records.mapping(from));
- }
+ /**
+ * The reference instance of public.mapping
+ */
+ public static final Mapping MAPPING = new Mapping();
+ private static final long serialVersionUID = 1L;
+ /**
+ * The column public.mapping.id
.
+ */
+ public final TableField ID = createField(DSL.name("id"),
+ SQLDataType.CLOB.nullable(false), this, "");
+ /**
+ * The column public.mapping.version
.
+ */
+ public final TableField VERSION = createField(DSL.name("version"),
+ SQLDataType.INTEGER.nullable(false), this, "");
+ /**
+ * The column public.mapping.name
.
+ */
+ public final TableField NAME = createField(DSL.name("name"),
+ SQLDataType.CLOB.nullable(false), this, "");
+ /**
+ * The column public.mapping.description
.
+ */
+ public final TableField DESCRIPTION = createField(DSL.name("description"),
+ SQLDataType.CLOB, this, "");
+ /**
+ * The column public.mapping.mapping
.
+ */
+ public final TableField MAPPING_ = createField(DSL.name("mapping"),
+ SQLDataType.JSONB.nullable(false), this, "");
+ /**
+ * The column public.mapping.created
.
+ */
+ public final TableField CREATED = createField(DSL.name("created"),
+ SQLDataType.INSTANT.nullable(false), this, "");
+ /**
+ * The column public.mapping.creator
.
+ */
+ public final TableField CREATOR = createField(DSL.name("creator"),
+ SQLDataType.CLOB.nullable(false), this, "");
+ /**
+ * The column public.mapping.deleted
.
+ */
+ public final TableField DELETED = createField(DSL.name("deleted"),
+ SQLDataType.INSTANT, this, "");
+ /**
+ * The column public.mapping.sourcedatastandard
.
+ */
+ public final TableField SOURCEDATASTANDARD = createField(
+ DSL.name("sourcedatastandard"), SQLDataType.VARCHAR.nullable(false), this, "");
+
+ private Mapping(Name alias, Table aliased) {
+ this(alias, aliased, null);
+ }
+
+ private Mapping(Name alias, Table aliased, Field>[] parameters) {
+ super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table());
+ }
+
+ /**
+ * Create an aliased public.mapping
table reference
+ */
+ public Mapping(String alias) {
+ this(DSL.name(alias), MAPPING);
+ }
+
+ /**
+ * Create an aliased public.mapping
table reference
+ */
+ public Mapping(Name alias) {
+ this(alias, MAPPING);
+ }
+
+ /**
+ * Create a public.mapping
table reference
+ */
+ public Mapping() {
+ this(DSL.name("mapping"), null);
+ }
+
+ public Mapping(Table child, ForeignKey key) {
+ super(child, key, MAPPING);
+ }
+
+ /**
+ * The class holding records for this type
+ */
+ @Override
+ public Class getRecordType() {
+ return MappingRecord.class;
+ }
+
+ @Override
+ public Schema getSchema() {
+ return aliased() ? null : Public.PUBLIC;
+ }
+
+ @Override
+ public UniqueKey getPrimaryKey() {
+ return Keys.NEW_MAPPING_PK;
+ }
+
+ @Override
+ public Mapping as(String alias) {
+ return new Mapping(DSL.name(alias), this);
+ }
+
+ @Override
+ public Mapping as(Name alias) {
+ return new Mapping(alias, this);
+ }
+
+ @Override
+ public Mapping as(Table> alias) {
+ return new Mapping(alias.getQualifiedName(), this);
+ }
+
+ /**
+ * Rename this table
+ */
+ @Override
+ public Mapping rename(String name) {
+ return new Mapping(DSL.name(name), null);
+ }
+
+ /**
+ * Rename this table
+ */
+ @Override
+ public Mapping rename(Name name) {
+ return new Mapping(name, null);
+ }
+
+ /**
+ * Rename this table
+ */
+ @Override
+ public Mapping rename(Table> name) {
+ return new Mapping(name.getQualifiedName(), null);
+ }
+
+ // -------------------------------------------------------------------------
+ // Row9 type methods
+ // -------------------------------------------------------------------------
+
+ @Override
+ public Row9 fieldsRow() {
+ return (Row9) super.fieldsRow();
+ }
+
+ /**
+ * Convenience mapping calling {@link SelectField#convertFrom(Function)}.
+ */
+ public SelectField mapping(
+ Function9 super String, ? super Integer, ? super String, ? super String, ? super JSONB, ? super Instant, ? super String, ? super Instant, ? super String, ? extends U> from) {
+ return convertFrom(Records.mapping(from));
+ }
+
+ /**
+ * Convenience mapping calling {@link SelectField#convertFrom(Class, Function)}.
+ */
+ public SelectField mapping(Class toType,
+ Function9 super String, ? super Integer, ? super String, ? super String, ? super JSONB, ? super Instant, ? super String, ? super Instant, ? super String, ? extends U> from) {
+ return convertFrom(toType, Records.mapping(from));
+ }
}
diff --git a/src/main/java/eu/dissco/core/translator/database/jooq/tables/SourceSystem.java b/src/main/java/eu/dissco/core/translator/database/jooq/tables/SourceSystem.java
index 4b3529e..d45d64c 100644
--- a/src/main/java/eu/dissco/core/translator/database/jooq/tables/SourceSystem.java
+++ b/src/main/java/eu/dissco/core/translator/database/jooq/tables/SourceSystem.java
@@ -7,10 +7,8 @@
import eu.dissco.core.translator.database.jooq.Keys;
import eu.dissco.core.translator.database.jooq.Public;
import eu.dissco.core.translator.database.jooq.tables.records.SourceSystemRecord;
-
import java.time.Instant;
import java.util.function.Function;
-
import org.jooq.Field;
import org.jooq.ForeignKey;
import org.jooq.Function9;
@@ -32,172 +30,175 @@
/**
* This class is generated by jOOQ.
*/
-@SuppressWarnings({ "all", "unchecked", "rawtypes" })
+@SuppressWarnings({"all", "unchecked", "rawtypes"})
public class SourceSystem extends TableImpl {
- private static final long serialVersionUID = 1L;
-
- /**
- * The reference instance of public.source_system
- */
- public static final SourceSystem SOURCE_SYSTEM = new SourceSystem();
-
- /**
- * The class holding records for this type
- */
- @Override
- public Class getRecordType() {
- return SourceSystemRecord.class;
- }
-
- /**
- * The column public.source_system.id
.
- */
- public final TableField ID = createField(DSL.name("id"), SQLDataType.CLOB.nullable(false), this, "");
-
- /**
- * The column public.source_system.name
.
- */
- public final TableField NAME = createField(DSL.name("name"), SQLDataType.CLOB.nullable(false), this, "");
-
- /**
- * The column public.source_system.endpoint
.
- */
- public final TableField ENDPOINT = createField(DSL.name("endpoint"), SQLDataType.CLOB.nullable(false), this, "");
-
- /**
- * The column public.source_system.description
.
- */
- public final TableField DESCRIPTION = createField(DSL.name("description"), SQLDataType.CLOB, this, "");
-
- /**
- * The column public.source_system.created
.
- */
- public final TableField CREATED = createField(DSL.name("created"), SQLDataType.INSTANT.nullable(false), this, "");
-
- /**
- * The column public.source_system.deleted
.
- */
- public final TableField DELETED = createField(DSL.name("deleted"), SQLDataType.INSTANT, this, "");
-
- /**
- * The column public.source_system.mapping_id
.
- */
- public final TableField MAPPING_ID = createField(DSL.name("mapping_id"), SQLDataType.CLOB.nullable(false), this, "");
-
- /**
- * The column public.source_system.version
.
- */
- public final TableField VERSION = createField(DSL.name("version"), SQLDataType.INTEGER.nullable(false).defaultValue(DSL.field(DSL.raw("1"), SQLDataType.INTEGER)), this, "");
-
- /**
- * The column public.source_system.creator
.
- */
- public final TableField CREATOR = createField(DSL.name("creator"), SQLDataType.CLOB.nullable(false).defaultValue(DSL.field(DSL.raw("'0000-0002-5669-2769'::text"), SQLDataType.CLOB)), this, "");
-
- private SourceSystem(Name alias, Table aliased) {
- this(alias, aliased, null);
- }
-
- private SourceSystem(Name alias, Table aliased, Field>[] parameters) {
- super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table());
- }
-
- /**
- * Create an aliased public.source_system
table reference
- */
- public SourceSystem(String alias) {
- this(DSL.name(alias), SOURCE_SYSTEM);
- }
-
- /**
- * Create an aliased public.source_system
table reference
- */
- public SourceSystem(Name alias) {
- this(alias, SOURCE_SYSTEM);
- }
-
- /**
- * Create a public.source_system
table reference
- */
- public SourceSystem() {
- this(DSL.name("source_system"), null);
- }
-
- public SourceSystem(Table child, ForeignKey key) {
- super(child, key, SOURCE_SYSTEM);
- }
-
- @Override
- public Schema getSchema() {
- return aliased() ? null : Public.PUBLIC;
- }
-
- @Override
- public UniqueKey getPrimaryKey() {
- return Keys.NEW_SOURCE_SYSTEM_PKEY;
- }
-
- @Override
- public SourceSystem as(String alias) {
- return new SourceSystem(DSL.name(alias), this);
- }
-
- @Override
- public SourceSystem as(Name alias) {
- return new SourceSystem(alias, this);
- }
-
- @Override
- public SourceSystem as(Table> alias) {
- return new SourceSystem(alias.getQualifiedName(), this);
- }
-
- /**
- * Rename this table
- */
- @Override
- public SourceSystem rename(String name) {
- return new SourceSystem(DSL.name(name), null);
- }
-
- /**
- * Rename this table
- */
- @Override
- public SourceSystem rename(Name name) {
- return new SourceSystem(name, null);
- }
-
- /**
- * Rename this table
- */
- @Override
- public SourceSystem rename(Table> name) {
- return new SourceSystem(name.getQualifiedName(), null);
- }
-
- // -------------------------------------------------------------------------
- // Row9 type methods
- // -------------------------------------------------------------------------
-
- @Override
- public Row9 fieldsRow() {
- return (Row9) super.fieldsRow();
- }
-
- /**
- * Convenience mapping calling {@link SelectField#convertFrom(Function)}.
- */
- public SelectField mapping(Function9 super String, ? super String, ? super String, ? super String, ? super Instant, ? super Instant, ? super String, ? super Integer, ? super String, ? extends U> from) {
- return convertFrom(Records.mapping(from));
- }
-
- /**
- * Convenience mapping calling {@link SelectField#convertFrom(Class,
- * Function)}.
- */
- public SelectField mapping(Class toType, Function9 super String, ? super String, ? super String, ? super String, ? super Instant, ? super Instant, ? super String, ? super Integer, ? super String, ? extends U> from) {
- return convertFrom(toType, Records.mapping(from));
- }
+ /**
+ * The reference instance of public.source_system
+ */
+ public static final SourceSystem SOURCE_SYSTEM = new SourceSystem();
+ private static final long serialVersionUID = 1L;
+ /**
+ * The column public.source_system.id
.
+ */
+ public final TableField ID = createField(DSL.name("id"),
+ SQLDataType.CLOB.nullable(false), this, "");
+ /**
+ * The column public.source_system.name
.
+ */
+ public final TableField NAME = createField(DSL.name("name"),
+ SQLDataType.CLOB.nullable(false), this, "");
+ /**
+ * The column public.source_system.endpoint
.
+ */
+ public final TableField ENDPOINT = createField(DSL.name("endpoint"),
+ SQLDataType.CLOB.nullable(false), this, "");
+ /**
+ * The column public.source_system.description
.
+ */
+ public final TableField DESCRIPTION = createField(
+ DSL.name("description"), SQLDataType.CLOB, this, "");
+ /**
+ * The column public.source_system.created
.
+ */
+ public final TableField CREATED = createField(DSL.name("created"),
+ SQLDataType.INSTANT.nullable(false), this, "");
+ /**
+ * The column public.source_system.deleted
.
+ */
+ public final TableField DELETED = createField(DSL.name("deleted"),
+ SQLDataType.INSTANT, this, "");
+ /**
+ * The column public.source_system.mapping_id
.
+ */
+ public final TableField MAPPING_ID = createField(
+ DSL.name("mapping_id"), SQLDataType.CLOB.nullable(false), this, "");
+ /**
+ * The column public.source_system.version
.
+ */
+ public final TableField VERSION = createField(DSL.name("version"),
+ SQLDataType.INTEGER.nullable(false)
+ .defaultValue(DSL.field(DSL.raw("1"), SQLDataType.INTEGER)), this, "");
+ /**
+ * The column public.source_system.creator
.
+ */
+ public final TableField CREATOR = createField(DSL.name("creator"),
+ SQLDataType.CLOB.nullable(false)
+ .defaultValue(DSL.field(DSL.raw("'0000-0002-5669-2769'::text"), SQLDataType.CLOB)), this,
+ "");
+
+ private SourceSystem(Name alias, Table aliased) {
+ this(alias, aliased, null);
+ }
+
+ private SourceSystem(Name alias, Table aliased, Field>[] parameters) {
+ super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table());
+ }
+
+ /**
+ * Create an aliased public.source_system
table reference
+ */
+ public SourceSystem(String alias) {
+ this(DSL.name(alias), SOURCE_SYSTEM);
+ }
+
+ /**
+ * Create an aliased public.source_system
table reference
+ */
+ public SourceSystem(Name alias) {
+ this(alias, SOURCE_SYSTEM);
+ }
+
+ /**
+ * Create a public.source_system
table reference
+ */
+ public SourceSystem() {
+ this(DSL.name("source_system"), null);
+ }
+
+ public SourceSystem(Table child, ForeignKey key) {
+ super(child, key, SOURCE_SYSTEM);
+ }
+
+ /**
+ * The class holding records for this type
+ */
+ @Override
+ public Class getRecordType() {
+ return SourceSystemRecord.class;
+ }
+
+ @Override
+ public Schema getSchema() {
+ return aliased() ? null : Public.PUBLIC;
+ }
+
+ @Override
+ public UniqueKey getPrimaryKey() {
+ return Keys.NEW_SOURCE_SYSTEM_PKEY;
+ }
+
+ @Override
+ public SourceSystem as(String alias) {
+ return new SourceSystem(DSL.name(alias), this);
+ }
+
+ @Override
+ public SourceSystem as(Name alias) {
+ return new SourceSystem(alias, this);
+ }
+
+ @Override
+ public SourceSystem as(Table> alias) {
+ return new SourceSystem(alias.getQualifiedName(), this);
+ }
+
+ /**
+ * Rename this table
+ */
+ @Override
+ public SourceSystem rename(String name) {
+ return new SourceSystem(DSL.name(name), null);
+ }
+
+ /**
+ * Rename this table
+ */
+ @Override
+ public SourceSystem rename(Name name) {
+ return new SourceSystem(name, null);
+ }
+
+ /**
+ * Rename this table
+ */
+ @Override
+ public SourceSystem rename(Table> name) {
+ return new SourceSystem(name.getQualifiedName(), null);
+ }
+
+ // -------------------------------------------------------------------------
+ // Row9 type methods
+ // -------------------------------------------------------------------------
+
+ @Override
+ public Row9 fieldsRow() {
+ return (Row9) super.fieldsRow();
+ }
+
+ /**
+ * Convenience mapping calling {@link SelectField#convertFrom(Function)}.
+ */
+ public SelectField mapping(
+ Function9 super String, ? super String, ? super String, ? super String, ? super Instant, ? super Instant, ? super String, ? super Integer, ? super String, ? extends U> from) {
+ return convertFrom(Records.mapping(from));
+ }
+
+ /**
+ * Convenience mapping calling {@link SelectField#convertFrom(Class, Function)}.
+ */
+ public SelectField mapping(Class toType,
+ Function9 super String, ? super String, ? super String, ? super String, ? super Instant, ? super Instant, ? super String, ? super Integer, ? super String, ? extends U> from) {
+ return convertFrom(toType, Records.mapping(from));
+ }
}
diff --git a/src/main/java/eu/dissco/core/translator/database/jooq/tables/records/MappingRecord.java b/src/main/java/eu/dissco/core/translator/database/jooq/tables/records/MappingRecord.java
index 574b600..7ab0435 100644
--- a/src/main/java/eu/dissco/core/translator/database/jooq/tables/records/MappingRecord.java
+++ b/src/main/java/eu/dissco/core/translator/database/jooq/tables/records/MappingRecord.java
@@ -5,9 +5,7 @@
import eu.dissco.core.translator.database.jooq.tables.Mapping;
-
import java.time.Instant;
-
import org.jooq.Field;
import org.jooq.JSONB;
import org.jooq.Record2;
@@ -19,389 +17,392 @@
/**
* This class is generated by jOOQ.
*/
-@SuppressWarnings({ "all", "unchecked", "rawtypes" })
-public class MappingRecord extends UpdatableRecordImpl implements Record9 {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Setter for public.mapping.id
.
- */
- public void setId(String value) {
- set(0, value);
- }
-
- /**
- * Getter for public.mapping.id
.
- */
- public String getId() {
- return (String) get(0);
- }
-
- /**
- * Setter for public.mapping.version
.
- */
- public void setVersion(Integer value) {
- set(1, value);
- }
-
- /**
- * Getter for public.mapping.version
.
- */
- public Integer getVersion() {
- return (Integer) get(1);
- }
-
- /**
- * Setter for public.mapping.name
.
- */
- public void setName(String value) {
- set(2, value);
- }
-
- /**
- * Getter for public.mapping.name
.
- */
- public String getName() {
- return (String) get(2);
- }
-
- /**
- * Setter for public.mapping.description
.
- */
- public void setDescription(String value) {
- set(3, value);
- }
-
- /**
- * Getter for public.mapping.description
.
- */
- public String getDescription() {
- return (String) get(3);
- }
-
- /**
- * Setter for public.mapping.mapping
.
- */
- public void setMapping(JSONB value) {
- set(4, value);
- }
-
- /**
- * Getter for public.mapping.mapping
.
- */
- public JSONB getMapping() {
- return (JSONB) get(4);
- }
-
- /**
- * Setter for public.mapping.created
.
- */
- public void setCreated(Instant value) {
- set(5, value);
- }
-
- /**
- * Getter for public.mapping.created
.
- */
- public Instant getCreated() {
- return (Instant) get(5);
- }
-
- /**
- * Setter for public.mapping.creator
.
- */
- public void setCreator(String value) {
- set(6, value);
- }
-
- /**
- * Getter for public.mapping.creator
.
- */
- public String getCreator() {
- return (String) get(6);
- }
-
- /**
- * Setter for public.mapping.deleted
.
- */
- public void setDeleted(Instant value) {
- set(7, value);
- }
-
- /**
- * Getter for public.mapping.deleted
.
- */
- public Instant getDeleted() {
- return (Instant) get(7);
- }
-
- /**
- * Setter for public.mapping.sourcedatastandard
.
- */
- public void setSourcedatastandard(String value) {
- set(8, value);
- }
-
- /**
- * Getter for public.mapping.sourcedatastandard
.
- */
- public String getSourcedatastandard() {
- return (String) get(8);
- }
-
- // -------------------------------------------------------------------------
- // Primary key information
- // -------------------------------------------------------------------------
-
- @Override
- public Record2 key() {
- return (Record2) super.key();
- }
-
- // -------------------------------------------------------------------------
- // Record9 type implementation
- // -------------------------------------------------------------------------
-
- @Override
- public Row9 fieldsRow() {
- return (Row9) super.fieldsRow();
- }
-
- @Override
- public Row9 valuesRow() {
- return (Row9) super.valuesRow();
- }
-
- @Override
- public Field field1() {
- return Mapping.MAPPING.ID;
- }
-
- @Override
- public Field field2() {
- return Mapping.MAPPING.VERSION;
- }
-
- @Override
- public Field field3() {
- return Mapping.MAPPING.NAME;
- }
-
- @Override
- public Field field4() {
- return Mapping.MAPPING.DESCRIPTION;
- }
-
- @Override
- public Field field5() {
- return Mapping.MAPPING.MAPPING_;
- }
-
- @Override
- public Field field6() {
- return Mapping.MAPPING.CREATED;
- }
-
- @Override
- public Field field7() {
- return Mapping.MAPPING.CREATOR;
- }
-
- @Override
- public Field field8() {
- return Mapping.MAPPING.DELETED;
- }
-
- @Override
- public Field field9() {
- return Mapping.MAPPING.SOURCEDATASTANDARD;
- }
-
- @Override
- public String component1() {
- return getId();
- }
-
- @Override
- public Integer component2() {
- return getVersion();
- }
-
- @Override
- public String component3() {
- return getName();
- }
-
- @Override
- public String component4() {
- return getDescription();
- }
-
- @Override
- public JSONB component5() {
- return getMapping();
- }
-
- @Override
- public Instant component6() {
- return getCreated();
- }
-
- @Override
- public String component7() {
- return getCreator();
- }
-
- @Override
- public Instant component8() {
- return getDeleted();
- }
-
- @Override
- public String component9() {
- return getSourcedatastandard();
- }
-
- @Override
- public String value1() {
- return getId();
- }
-
- @Override
- public Integer value2() {
- return getVersion();
- }
-
- @Override
- public String value3() {
- return getName();
- }
-
- @Override
- public String value4() {
- return getDescription();
- }
-
- @Override
- public JSONB value5() {
- return getMapping();
- }
-
- @Override
- public Instant value6() {
- return getCreated();
- }
-
- @Override
- public String value7() {
- return getCreator();
- }
-
- @Override
- public Instant value8() {
- return getDeleted();
- }
-
- @Override
- public String value9() {
- return getSourcedatastandard();
- }
-
- @Override
- public MappingRecord value1(String value) {
- setId(value);
- return this;
- }
-
- @Override
- public MappingRecord value2(Integer value) {
- setVersion(value);
- return this;
- }
-
- @Override
- public MappingRecord value3(String value) {
- setName(value);
- return this;
- }
-
- @Override
- public MappingRecord value4(String value) {
- setDescription(value);
- return this;
- }
-
- @Override
- public MappingRecord value5(JSONB value) {
- setMapping(value);
- return this;
- }
-
- @Override
- public MappingRecord value6(Instant value) {
- setCreated(value);
- return this;
- }
-
- @Override
- public MappingRecord value7(String value) {
- setCreator(value);
- return this;
- }
-
- @Override
- public MappingRecord value8(Instant value) {
- setDeleted(value);
- return this;
- }
-
- @Override
- public MappingRecord value9(String value) {
- setSourcedatastandard(value);
- return this;
- }
-
- @Override
- public MappingRecord values(String value1, Integer value2, String value3, String value4, JSONB value5, Instant value6, String value7, Instant value8, String value9) {
- value1(value1);
- value2(value2);
- value3(value3);
- value4(value4);
- value5(value5);
- value6(value6);
- value7(value7);
- value8(value8);
- value9(value9);
- return this;
- }
-
- // -------------------------------------------------------------------------
- // Constructors
- // -------------------------------------------------------------------------
-
- /**
- * Create a detached MappingRecord
- */
- public MappingRecord() {
- super(Mapping.MAPPING);
- }
-
- /**
- * Create a detached, initialised MappingRecord
- */
- public MappingRecord(String id, Integer version, String name, String description, JSONB mapping, Instant created, String creator, Instant deleted, String sourcedatastandard) {
- super(Mapping.MAPPING);
-
- setId(id);
- setVersion(version);
- setName(name);
- setDescription(description);
- setMapping(mapping);
- setCreated(created);
- setCreator(creator);
- setDeleted(deleted);
- setSourcedatastandard(sourcedatastandard);
- resetChangedOnNotNull();
- }
+@SuppressWarnings({"all", "unchecked", "rawtypes"})
+public class MappingRecord extends UpdatableRecordImpl implements
+ Record9 {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Create a detached MappingRecord
+ */
+ public MappingRecord() {
+ super(Mapping.MAPPING);
+ }
+
+ /**
+ * Create a detached, initialised MappingRecord
+ */
+ public MappingRecord(String id, Integer version, String name, String description, JSONB mapping,
+ Instant created, String creator, Instant deleted, String sourcedatastandard) {
+ super(Mapping.MAPPING);
+
+ setId(id);
+ setVersion(version);
+ setName(name);
+ setDescription(description);
+ setMapping(mapping);
+ setCreated(created);
+ setCreator(creator);
+ setDeleted(deleted);
+ setSourcedatastandard(sourcedatastandard);
+ resetChangedOnNotNull();
+ }
+
+ /**
+ * Getter for public.mapping.id
.
+ */
+ public String getId() {
+ return (String) get(0);
+ }
+
+ /**
+ * Setter for public.mapping.id
.
+ */
+ public void setId(String value) {
+ set(0, value);
+ }
+
+ /**
+ * Getter for public.mapping.version
.
+ */
+ public Integer getVersion() {
+ return (Integer) get(1);
+ }
+
+ /**
+ * Setter for public.mapping.version
.
+ */
+ public void setVersion(Integer value) {
+ set(1, value);
+ }
+
+ /**
+ * Getter for public.mapping.name
.
+ */
+ public String getName() {
+ return (String) get(2);
+ }
+
+ /**
+ * Setter for public.mapping.name
.
+ */
+ public void setName(String value) {
+ set(2, value);
+ }
+
+ /**
+ * Getter for public.mapping.description
.
+ */
+ public String getDescription() {
+ return (String) get(3);
+ }
+
+ /**
+ * Setter for public.mapping.description
.
+ */
+ public void setDescription(String value) {
+ set(3, value);
+ }
+
+ /**
+ * Getter for public.mapping.mapping
.
+ */
+ public JSONB getMapping() {
+ return (JSONB) get(4);
+ }
+
+ /**
+ * Setter for public.mapping.mapping
.
+ */
+ public void setMapping(JSONB value) {
+ set(4, value);
+ }
+
+ /**
+ * Getter for public.mapping.created
.
+ */
+ public Instant getCreated() {
+ return (Instant) get(5);
+ }
+
+ /**
+ * Setter for public.mapping.created
.
+ */
+ public void setCreated(Instant value) {
+ set(5, value);
+ }
+
+ /**
+ * Getter for public.mapping.creator
.
+ */
+ public String getCreator() {
+ return (String) get(6);
+ }
+
+ /**
+ * Setter for public.mapping.creator
.
+ */
+ public void setCreator(String value) {
+ set(6, value);
+ }
+
+ /**
+ * Getter for public.mapping.deleted
.
+ */
+ public Instant getDeleted() {
+ return (Instant) get(7);
+ }
+
+ /**
+ * Setter for public.mapping.deleted
.
+ */
+ public void setDeleted(Instant value) {
+ set(7, value);
+ }
+
+ // -------------------------------------------------------------------------
+ // Primary key information
+ // -------------------------------------------------------------------------
+
+ /**
+ * Getter for public.mapping.sourcedatastandard
.
+ */
+ public String getSourcedatastandard() {
+ return (String) get(8);
+ }
+
+ // -------------------------------------------------------------------------
+ // Record9 type implementation
+ // -------------------------------------------------------------------------
+
+ /**
+ * Setter for public.mapping.sourcedatastandard
.
+ */
+ public void setSourcedatastandard(String value) {
+ set(8, value);
+ }
+
+ @Override
+ public Record2 key() {
+ return (Record2) super.key();
+ }
+
+ @Override
+ public Row9 fieldsRow() {
+ return (Row9) super.fieldsRow();
+ }
+
+ @Override
+ public Row9 valuesRow() {
+ return (Row9) super.valuesRow();
+ }
+
+ @Override
+ public Field field1() {
+ return Mapping.MAPPING.ID;
+ }
+
+ @Override
+ public Field field2() {
+ return Mapping.MAPPING.VERSION;
+ }
+
+ @Override
+ public Field field3() {
+ return Mapping.MAPPING.NAME;
+ }
+
+ @Override
+ public Field field4() {
+ return Mapping.MAPPING.DESCRIPTION;
+ }
+
+ @Override
+ public Field field5() {
+ return Mapping.MAPPING.MAPPING_;
+ }
+
+ @Override
+ public Field field6() {
+ return Mapping.MAPPING.CREATED;
+ }
+
+ @Override
+ public Field field7() {
+ return Mapping.MAPPING.CREATOR;
+ }
+
+ @Override
+ public Field field8() {
+ return Mapping.MAPPING.DELETED;
+ }
+
+ @Override
+ public Field field9() {
+ return Mapping.MAPPING.SOURCEDATASTANDARD;
+ }
+
+ @Override
+ public String component1() {
+ return getId();
+ }
+
+ @Override
+ public Integer component2() {
+ return getVersion();
+ }
+
+ @Override
+ public String component3() {
+ return getName();
+ }
+
+ @Override
+ public String component4() {
+ return getDescription();
+ }
+
+ @Override
+ public JSONB component5() {
+ return getMapping();
+ }
+
+ @Override
+ public Instant component6() {
+ return getCreated();
+ }
+
+ @Override
+ public String component7() {
+ return getCreator();
+ }
+
+ @Override
+ public Instant component8() {
+ return getDeleted();
+ }
+
+ @Override
+ public String component9() {
+ return getSourcedatastandard();
+ }
+
+ @Override
+ public String value1() {
+ return getId();
+ }
+
+ @Override
+ public Integer value2() {
+ return getVersion();
+ }
+
+ @Override
+ public String value3() {
+ return getName();
+ }
+
+ @Override
+ public String value4() {
+ return getDescription();
+ }
+
+ @Override
+ public JSONB value5() {
+ return getMapping();
+ }
+
+ @Override
+ public Instant value6() {
+ return getCreated();
+ }
+
+ @Override
+ public String value7() {
+ return getCreator();
+ }
+
+ @Override
+ public Instant value8() {
+ return getDeleted();
+ }
+
+ @Override
+ public String value9() {
+ return getSourcedatastandard();
+ }
+
+ @Override
+ public MappingRecord value1(String value) {
+ setId(value);
+ return this;
+ }
+
+ @Override
+ public MappingRecord value2(Integer value) {
+ setVersion(value);
+ return this;
+ }
+
+ @Override
+ public MappingRecord value3(String value) {
+ setName(value);
+ return this;
+ }
+
+ @Override
+ public MappingRecord value4(String value) {
+ setDescription(value);
+ return this;
+ }
+
+ @Override
+ public MappingRecord value5(JSONB value) {
+ setMapping(value);
+ return this;
+ }
+
+ @Override
+ public MappingRecord value6(Instant value) {
+ setCreated(value);
+ return this;
+ }
+
+ @Override
+ public MappingRecord value7(String value) {
+ setCreator(value);
+ return this;
+ }
+
+ @Override
+ public MappingRecord value8(Instant value) {
+ setDeleted(value);
+ return this;
+ }
+
+ // -------------------------------------------------------------------------
+ // Constructors
+ // -------------------------------------------------------------------------
+
+ @Override
+ public MappingRecord value9(String value) {
+ setSourcedatastandard(value);
+ return this;
+ }
+
+ @Override
+ public MappingRecord values(String value1, Integer value2, String value3, String value4,
+ JSONB value5, Instant value6, String value7, Instant value8, String value9) {
+ value1(value1);
+ value2(value2);
+ value3(value3);
+ value4(value4);
+ value5(value5);
+ value6(value6);
+ value7(value7);
+ value8(value8);
+ value9(value9);
+ return this;
+ }
}
diff --git a/src/main/java/eu/dissco/core/translator/database/jooq/tables/records/SourceSystemRecord.java b/src/main/java/eu/dissco/core/translator/database/jooq/tables/records/SourceSystemRecord.java
index 6027359..e8e2816 100644
--- a/src/main/java/eu/dissco/core/translator/database/jooq/tables/records/SourceSystemRecord.java
+++ b/src/main/java/eu/dissco/core/translator/database/jooq/tables/records/SourceSystemRecord.java
@@ -5,9 +5,7 @@
import eu.dissco.core.translator.database.jooq.tables.SourceSystem;
-
import java.time.Instant;
-
import org.jooq.Field;
import org.jooq.Record1;
import org.jooq.Record9;
@@ -18,389 +16,392 @@
/**
* This class is generated by jOOQ.
*/
-@SuppressWarnings({ "all", "unchecked", "rawtypes" })
-public class SourceSystemRecord extends UpdatableRecordImpl implements Record9 {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Setter for public.source_system.id
.
- */
- public void setId(String value) {
- set(0, value);
- }
-
- /**
- * Getter for public.source_system.id
.
- */
- public String getId() {
- return (String) get(0);
- }
-
- /**
- * Setter for public.source_system.name
.
- */
- public void setName(String value) {
- set(1, value);
- }
-
- /**
- * Getter for public.source_system.name
.
- */
- public String getName() {
- return (String) get(1);
- }
-
- /**
- * Setter for public.source_system.endpoint
.
- */
- public void setEndpoint(String value) {
- set(2, value);
- }
-
- /**
- * Getter for public.source_system.endpoint
.
- */
- public String getEndpoint() {
- return (String) get(2);
- }
-
- /**
- * Setter for public.source_system.description
.
- */
- public void setDescription(String value) {
- set(3, value);
- }
-
- /**
- * Getter for public.source_system.description
.
- */
- public String getDescription() {
- return (String) get(3);
- }
-
- /**
- * Setter for public.source_system.created
.
- */
- public void setCreated(Instant value) {
- set(4, value);
- }
-
- /**
- * Getter for public.source_system.created
.
- */
- public Instant getCreated() {
- return (Instant) get(4);
- }
-
- /**
- * Setter for public.source_system.deleted
.
- */
- public void setDeleted(Instant value) {
- set(5, value);
- }
-
- /**
- * Getter for public.source_system.deleted
.
- */
- public Instant getDeleted() {
- return (Instant) get(5);
- }
-
- /**
- * Setter for public.source_system.mapping_id
.
- */
- public void setMappingId(String value) {
- set(6, value);
- }
-
- /**
- * Getter for public.source_system.mapping_id
.
- */
- public String getMappingId() {
- return (String) get(6);
- }
-
- /**
- * Setter for public.source_system.version
.
- */
- public void setVersion(Integer value) {
- set(7, value);
- }
-
- /**
- * Getter for public.source_system.version
.
- */
- public Integer getVersion() {
- return (Integer) get(7);
- }
-
- /**
- * Setter for public.source_system.creator
.
- */
- public void setCreator(String value) {
- set(8, value);
- }
-
- /**
- * Getter for public.source_system.creator
.
- */
- public String getCreator() {
- return (String) get(8);
- }
-
- // -------------------------------------------------------------------------
- // Primary key information
- // -------------------------------------------------------------------------
-
- @Override
- public Record1 key() {
- return (Record1) super.key();
- }
-
- // -------------------------------------------------------------------------
- // Record9 type implementation
- // -------------------------------------------------------------------------
-
- @Override
- public Row9 fieldsRow() {
- return (Row9) super.fieldsRow();
- }
-
- @Override
- public Row9 valuesRow() {
- return (Row9) super.valuesRow();
- }
-
- @Override
- public Field field1() {
- return SourceSystem.SOURCE_SYSTEM.ID;
- }
-
- @Override
- public Field field2() {
- return SourceSystem.SOURCE_SYSTEM.NAME;
- }
-
- @Override
- public Field field3() {
- return SourceSystem.SOURCE_SYSTEM.ENDPOINT;
- }
-
- @Override
- public Field field4() {
- return SourceSystem.SOURCE_SYSTEM.DESCRIPTION;
- }
-
- @Override
- public Field field5() {
- return SourceSystem.SOURCE_SYSTEM.CREATED;
- }
-
- @Override
- public Field field6() {
- return SourceSystem.SOURCE_SYSTEM.DELETED;
- }
-
- @Override
- public Field field7() {
- return SourceSystem.SOURCE_SYSTEM.MAPPING_ID;
- }
-
- @Override
- public Field field8() {
- return SourceSystem.SOURCE_SYSTEM.VERSION;
- }
-
- @Override
- public Field field9() {
- return SourceSystem.SOURCE_SYSTEM.CREATOR;
- }
-
- @Override
- public String component1() {
- return getId();
- }
-
- @Override
- public String component2() {
- return getName();
- }
-
- @Override
- public String component3() {
- return getEndpoint();
- }
-
- @Override
- public String component4() {
- return getDescription();
- }
-
- @Override
- public Instant component5() {
- return getCreated();
- }
-
- @Override
- public Instant component6() {
- return getDeleted();
- }
-
- @Override
- public String component7() {
- return getMappingId();
- }
-
- @Override
- public Integer component8() {
- return getVersion();
- }
-
- @Override
- public String component9() {
- return getCreator();
- }
-
- @Override
- public String value1() {
- return getId();
- }
-
- @Override
- public String value2() {
- return getName();
- }
-
- @Override
- public String value3() {
- return getEndpoint();
- }
-
- @Override
- public String value4() {
- return getDescription();
- }
-
- @Override
- public Instant value5() {
- return getCreated();
- }
-
- @Override
- public Instant value6() {
- return getDeleted();
- }
-
- @Override
- public String value7() {
- return getMappingId();
- }
-
- @Override
- public Integer value8() {
- return getVersion();
- }
-
- @Override
- public String value9() {
- return getCreator();
- }
-
- @Override
- public SourceSystemRecord value1(String value) {
- setId(value);
- return this;
- }
-
- @Override
- public SourceSystemRecord value2(String value) {
- setName(value);
- return this;
- }
-
- @Override
- public SourceSystemRecord value3(String value) {
- setEndpoint(value);
- return this;
- }
-
- @Override
- public SourceSystemRecord value4(String value) {
- setDescription(value);
- return this;
- }
-
- @Override
- public SourceSystemRecord value5(Instant value) {
- setCreated(value);
- return this;
- }
-
- @Override
- public SourceSystemRecord value6(Instant value) {
- setDeleted(value);
- return this;
- }
-
- @Override
- public SourceSystemRecord value7(String value) {
- setMappingId(value);
- return this;
- }
-
- @Override
- public SourceSystemRecord value8(Integer value) {
- setVersion(value);
- return this;
- }
-
- @Override
- public SourceSystemRecord value9(String value) {
- setCreator(value);
- return this;
- }
-
- @Override
- public SourceSystemRecord values(String value1, String value2, String value3, String value4, Instant value5, Instant value6, String value7, Integer value8, String value9) {
- value1(value1);
- value2(value2);
- value3(value3);
- value4(value4);
- value5(value5);
- value6(value6);
- value7(value7);
- value8(value8);
- value9(value9);
- return this;
- }
-
- // -------------------------------------------------------------------------
- // Constructors
- // -------------------------------------------------------------------------
-
- /**
- * Create a detached SourceSystemRecord
- */
- public SourceSystemRecord() {
- super(SourceSystem.SOURCE_SYSTEM);
- }
-
- /**
- * Create a detached, initialised SourceSystemRecord
- */
- public SourceSystemRecord(String id, String name, String endpoint, String description, Instant created, Instant deleted, String mappingId, Integer version, String creator) {
- super(SourceSystem.SOURCE_SYSTEM);
-
- setId(id);
- setName(name);
- setEndpoint(endpoint);
- setDescription(description);
- setCreated(created);
- setDeleted(deleted);
- setMappingId(mappingId);
- setVersion(version);
- setCreator(creator);
- resetChangedOnNotNull();
- }
+@SuppressWarnings({"all", "unchecked", "rawtypes"})
+public class SourceSystemRecord extends UpdatableRecordImpl implements
+ Record9 {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Create a detached SourceSystemRecord
+ */
+ public SourceSystemRecord() {
+ super(SourceSystem.SOURCE_SYSTEM);
+ }
+
+ /**
+ * Create a detached, initialised SourceSystemRecord
+ */
+ public SourceSystemRecord(String id, String name, String endpoint, String description,
+ Instant created, Instant deleted, String mappingId, Integer version, String creator) {
+ super(SourceSystem.SOURCE_SYSTEM);
+
+ setId(id);
+ setName(name);
+ setEndpoint(endpoint);
+ setDescription(description);
+ setCreated(created);
+ setDeleted(deleted);
+ setMappingId(mappingId);
+ setVersion(version);
+ setCreator(creator);
+ resetChangedOnNotNull();
+ }
+
+ /**
+ * Getter for public.source_system.id
.
+ */
+ public String getId() {
+ return (String) get(0);
+ }
+
+ /**
+ * Setter for public.source_system.id
.
+ */
+ public void setId(String value) {
+ set(0, value);
+ }
+
+ /**
+ * Getter for public.source_system.name
.
+ */
+ public String getName() {
+ return (String) get(1);
+ }
+
+ /**
+ * Setter for public.source_system.name
.
+ */
+ public void setName(String value) {
+ set(1, value);
+ }
+
+ /**
+ * Getter for public.source_system.endpoint
.
+ */
+ public String getEndpoint() {
+ return (String) get(2);
+ }
+
+ /**
+ * Setter for public.source_system.endpoint
.
+ */
+ public void setEndpoint(String value) {
+ set(2, value);
+ }
+
+ /**
+ * Getter for public.source_system.description
.
+ */
+ public String getDescription() {
+ return (String) get(3);
+ }
+
+ /**
+ * Setter for public.source_system.description
.
+ */
+ public void setDescription(String value) {
+ set(3, value);
+ }
+
+ /**
+ * Getter for public.source_system.created
.
+ */
+ public Instant getCreated() {
+ return (Instant) get(4);
+ }
+
+ /**
+ * Setter for public.source_system.created
.
+ */
+ public void setCreated(Instant value) {
+ set(4, value);
+ }
+
+ /**
+ * Getter for public.source_system.deleted
.
+ */
+ public Instant getDeleted() {
+ return (Instant) get(5);
+ }
+
+ /**
+ * Setter for public.source_system.deleted
.
+ */
+ public void setDeleted(Instant value) {
+ set(5, value);
+ }
+
+ /**
+ * Getter for public.source_system.mapping_id
.
+ */
+ public String getMappingId() {
+ return (String) get(6);
+ }
+
+ /**
+ * Setter for public.source_system.mapping_id
.
+ */
+ public void setMappingId(String value) {
+ set(6, value);
+ }
+
+ /**
+ * Getter for public.source_system.version
.
+ */
+ public Integer getVersion() {
+ return (Integer) get(7);
+ }
+
+ /**
+ * Setter for public.source_system.version
.
+ */
+ public void setVersion(Integer value) {
+ set(7, value);
+ }
+
+ // -------------------------------------------------------------------------
+ // Primary key information
+ // -------------------------------------------------------------------------
+
+ /**
+ * Getter for public.source_system.creator
.
+ */
+ public String getCreator() {
+ return (String) get(8);
+ }
+
+ // -------------------------------------------------------------------------
+ // Record9 type implementation
+ // -------------------------------------------------------------------------
+
+ /**
+ * Setter for public.source_system.creator
.
+ */
+ public void setCreator(String value) {
+ set(8, value);
+ }
+
+ @Override
+ public Record1 key() {
+ return (Record1) super.key();
+ }
+
+ @Override
+ public Row9 fieldsRow() {
+ return (Row9) super.fieldsRow();
+ }
+
+ @Override
+ public Row9 valuesRow() {
+ return (Row9) super.valuesRow();
+ }
+
+ @Override
+ public Field field1() {
+ return SourceSystem.SOURCE_SYSTEM.ID;
+ }
+
+ @Override
+ public Field field2() {
+ return SourceSystem.SOURCE_SYSTEM.NAME;
+ }
+
+ @Override
+ public Field field3() {
+ return SourceSystem.SOURCE_SYSTEM.ENDPOINT;
+ }
+
+ @Override
+ public Field field4() {
+ return SourceSystem.SOURCE_SYSTEM.DESCRIPTION;
+ }
+
+ @Override
+ public Field field5() {
+ return SourceSystem.SOURCE_SYSTEM.CREATED;
+ }
+
+ @Override
+ public Field field6() {
+ return SourceSystem.SOURCE_SYSTEM.DELETED;
+ }
+
+ @Override
+ public Field field7() {
+ return SourceSystem.SOURCE_SYSTEM.MAPPING_ID;
+ }
+
+ @Override
+ public Field field8() {
+ return SourceSystem.SOURCE_SYSTEM.VERSION;
+ }
+
+ @Override
+ public Field field9() {
+ return SourceSystem.SOURCE_SYSTEM.CREATOR;
+ }
+
+ @Override
+ public String component1() {
+ return getId();
+ }
+
+ @Override
+ public String component2() {
+ return getName();
+ }
+
+ @Override
+ public String component3() {
+ return getEndpoint();
+ }
+
+ @Override
+ public String component4() {
+ return getDescription();
+ }
+
+ @Override
+ public Instant component5() {
+ return getCreated();
+ }
+
+ @Override
+ public Instant component6() {
+ return getDeleted();
+ }
+
+ @Override
+ public String component7() {
+ return getMappingId();
+ }
+
+ @Override
+ public Integer component8() {
+ return getVersion();
+ }
+
+ @Override
+ public String component9() {
+ return getCreator();
+ }
+
+ @Override
+ public String value1() {
+ return getId();
+ }
+
+ @Override
+ public String value2() {
+ return getName();
+ }
+
+ @Override
+ public String value3() {
+ return getEndpoint();
+ }
+
+ @Override
+ public String value4() {
+ return getDescription();
+ }
+
+ @Override
+ public Instant value5() {
+ return getCreated();
+ }
+
+ @Override
+ public Instant value6() {
+ return getDeleted();
+ }
+
+ @Override
+ public String value7() {
+ return getMappingId();
+ }
+
+ @Override
+ public Integer value8() {
+ return getVersion();
+ }
+
+ @Override
+ public String value9() {
+ return getCreator();
+ }
+
+ @Override
+ public SourceSystemRecord value1(String value) {
+ setId(value);
+ return this;
+ }
+
+ @Override
+ public SourceSystemRecord value2(String value) {
+ setName(value);
+ return this;
+ }
+
+ @Override
+ public SourceSystemRecord value3(String value) {
+ setEndpoint(value);
+ return this;
+ }
+
+ @Override
+ public SourceSystemRecord value4(String value) {
+ setDescription(value);
+ return this;
+ }
+
+ @Override
+ public SourceSystemRecord value5(Instant value) {
+ setCreated(value);
+ return this;
+ }
+
+ @Override
+ public SourceSystemRecord value6(Instant value) {
+ setDeleted(value);
+ return this;
+ }
+
+ @Override
+ public SourceSystemRecord value7(String value) {
+ setMappingId(value);
+ return this;
+ }
+
+ @Override
+ public SourceSystemRecord value8(Integer value) {
+ setVersion(value);
+ return this;
+ }
+
+ // -------------------------------------------------------------------------
+ // Constructors
+ // -------------------------------------------------------------------------
+
+ @Override
+ public SourceSystemRecord value9(String value) {
+ setCreator(value);
+ return this;
+ }
+
+ @Override
+ public SourceSystemRecord values(String value1, String value2, String value3, String value4,
+ Instant value5, Instant value6, String value7, Integer value8, String value9) {
+ value1(value1);
+ value2(value2);
+ value3(value3);
+ value4(value4);
+ value5(value5);
+ value6(value6);
+ value7(value7);
+ value8(value8);
+ value9(value9);
+ return this;
+ }
}
diff --git a/src/main/java/eu/dissco/core/translator/domain/DigitalMediaObject.java b/src/main/java/eu/dissco/core/translator/domain/DigitalMediaObject.java
index d088021..dced780 100644
--- a/src/main/java/eu/dissco/core/translator/domain/DigitalMediaObject.java
+++ b/src/main/java/eu/dissco/core/translator/domain/DigitalMediaObject.java
@@ -2,16 +2,16 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
-import eu.dissco.core.translator.terms.media.MediaType;
+import eu.dissco.core.translator.schema.DigitalEntity;
import eu.dissco.core.translator.terms.specimen.PhysicalSpecimenId;
public record DigitalMediaObject(
- @JsonProperty(MediaType.TERM)
+ @JsonProperty("ods:type")
String type,
@JsonProperty(PhysicalSpecimenId.TERM)
String physicalSpecimenId,
@JsonProperty("ods:attributes")
- JsonNode attributes,
+ DigitalEntity attributes,
@JsonProperty("ods:originalAttributes")
JsonNode originalAttributes) {
diff --git a/src/main/java/eu/dissco/core/translator/domain/DigitalSpecimenEvent.java b/src/main/java/eu/dissco/core/translator/domain/DigitalSpecimenEvent.java
index 11b77e7..e35301c 100644
--- a/src/main/java/eu/dissco/core/translator/domain/DigitalSpecimenEvent.java
+++ b/src/main/java/eu/dissco/core/translator/domain/DigitalSpecimenEvent.java
@@ -4,6 +4,7 @@
public record DigitalSpecimenEvent(
List enrichmentList,
- DigitalSpecimen digitalSpecimen) {
+ DigitalSpecimenWrapper digitalSpecimenWrapper,
+ List digitalMediaObjectEvents) {
}
diff --git a/src/main/java/eu/dissco/core/translator/domain/DigitalSpecimen.java b/src/main/java/eu/dissco/core/translator/domain/DigitalSpecimenWrapper.java
similarity index 72%
rename from src/main/java/eu/dissco/core/translator/domain/DigitalSpecimen.java
rename to src/main/java/eu/dissco/core/translator/domain/DigitalSpecimenWrapper.java
index 6bf1a1c..f0eef4d 100644
--- a/src/main/java/eu/dissco/core/translator/domain/DigitalSpecimen.java
+++ b/src/main/java/eu/dissco/core/translator/domain/DigitalSpecimenWrapper.java
@@ -3,16 +3,16 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import eu.dissco.core.translator.terms.specimen.PhysicalSpecimenId;
-import eu.dissco.core.translator.terms.specimen.Type;
+import eu.dissco.core.translator.schema.DigitalSpecimen;
-public record DigitalSpecimen(
+public record DigitalSpecimenWrapper(
@JsonProperty(PhysicalSpecimenId.TERM)
String id,
- @JsonProperty(Type.TERM)
+ @JsonProperty("ods:type")
String type,
@JsonProperty("ods:attributes")
- JsonNode attributes,
+ DigitalSpecimen attributes,
@JsonProperty("ods:originalAttributes")
JsonNode originalAttributes) {
diff --git a/src/main/java/eu/dissco/core/translator/exception/DiSSCoDataException.java b/src/main/java/eu/dissco/core/translator/exception/DiSSCoDataException.java
index 02fe55f..8b88d05 100644
--- a/src/main/java/eu/dissco/core/translator/exception/DiSSCoDataException.java
+++ b/src/main/java/eu/dissco/core/translator/exception/DiSSCoDataException.java
@@ -1,6 +1,6 @@
package eu.dissco.core.translator.exception;
-public class DiSSCoDataException extends Exception{
+public class DiSSCoDataException extends Exception {
public DiSSCoDataException(String message) {
super(message);
diff --git a/src/main/java/eu/dissco/core/translator/exception/DisscoEfgParsingException.java b/src/main/java/eu/dissco/core/translator/exception/DisscoEfgParsingException.java
index 1d6d993..2f3bde9 100644
--- a/src/main/java/eu/dissco/core/translator/exception/DisscoEfgParsingException.java
+++ b/src/main/java/eu/dissco/core/translator/exception/DisscoEfgParsingException.java
@@ -1,6 +1,6 @@
package eu.dissco.core.translator.exception;
-public class DisscoEfgParsingException extends Exception{
+public class DisscoEfgParsingException extends Exception {
public DisscoEfgParsingException(String message) {
super(message);
diff --git a/src/main/java/eu/dissco/core/translator/exception/DisscoRepositoryException.java b/src/main/java/eu/dissco/core/translator/exception/DisscoRepositoryException.java
index a2089cb..05bee47 100644
--- a/src/main/java/eu/dissco/core/translator/exception/DisscoRepositoryException.java
+++ b/src/main/java/eu/dissco/core/translator/exception/DisscoRepositoryException.java
@@ -1,6 +1,6 @@
package eu.dissco.core.translator.exception;
-public class DisscoRepositoryException extends Exception{
+public class DisscoRepositoryException extends Exception {
public DisscoRepositoryException(String message) {
super(message);
diff --git a/src/main/java/eu/dissco/core/translator/properties/FdoProperties.java b/src/main/java/eu/dissco/core/translator/properties/FdoProperties.java
new file mode 100644
index 0000000..2130e92
--- /dev/null
+++ b/src/main/java/eu/dissco/core/translator/properties/FdoProperties.java
@@ -0,0 +1,19 @@
+package eu.dissco.core.translator.properties;
+
+import javax.validation.constraints.NotBlank;
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.validation.annotation.Validated;
+
+@Data
+@Validated
+@ConfigurationProperties(prefix = "fdo")
+public class FdoProperties {
+
+ @NotBlank
+ private String digitalSpecimenType;
+
+ @NotBlank
+ private String digitalMediaObjectType;
+
+}
diff --git a/src/main/java/eu/dissco/core/translator/repository/DwcaRepository.java b/src/main/java/eu/dissco/core/translator/repository/DwcaRepository.java
index 6546187..9673c63 100644
--- a/src/main/java/eu/dissco/core/translator/repository/DwcaRepository.java
+++ b/src/main/java/eu/dissco/core/translator/repository/DwcaRepository.java
@@ -57,7 +57,8 @@ public void postRecords(String tableName, List> dbRecords
private Query recordToQuery(String tableName, Pair dbRecord) {
try {
return context.insertInto(getTable(tableName)).set(idField, dbRecord.getLeft())
- .set(dataField, JSONB.jsonb(mapper.writeValueAsString(dbRecord.getRight())));
+ .set(dataField,
+ JSONB.jsonb(mapper.writeValueAsString(dbRecord.getRight()).replace("\u0000", "")));
} catch (JsonProcessingException e) {
log.error("Unable to map JSON to JSONB, ignoring record: {}", dbRecord.getLeft(), e);
return null;
diff --git a/src/main/java/eu/dissco/core/translator/service/BioCaseService.java b/src/main/java/eu/dissco/core/translator/service/BioCaseService.java
index be20cbd..30052c9 100644
--- a/src/main/java/eu/dissco/core/translator/service/BioCaseService.java
+++ b/src/main/java/eu/dissco/core/translator/service/BioCaseService.java
@@ -1,10 +1,6 @@
package eu.dissco.core.translator.service;
-import static eu.dissco.core.translator.service.IngestionUtility.getPhysicalSpecimenId;
-import static eu.dissco.core.translator.service.IngestionUtility.minifyOrganisationId;
-import static eu.dissco.core.translator.terms.TermMapper.abcdHarmonisedTerms;
-
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
@@ -17,32 +13,19 @@
import efg.MultiMediaObject;
import efg.Unit;
import eu.dissco.core.translator.Profiles;
-import eu.dissco.core.translator.component.RorComponent;
import eu.dissco.core.translator.domain.DigitalMediaObject;
import eu.dissco.core.translator.domain.DigitalMediaObjectEvent;
-import eu.dissco.core.translator.domain.DigitalSpecimen;
import eu.dissco.core.translator.domain.DigitalSpecimenEvent;
+import eu.dissco.core.translator.domain.DigitalSpecimenWrapper;
import eu.dissco.core.translator.domain.Enrichment;
import eu.dissco.core.translator.exception.DiSSCoDataException;
import eu.dissco.core.translator.exception.DisscoEfgParsingException;
import eu.dissco.core.translator.exception.OrganisationNotRorId;
import eu.dissco.core.translator.properties.EnrichmentProperties;
+import eu.dissco.core.translator.properties.FdoProperties;
import eu.dissco.core.translator.properties.WebClientProperties;
import eu.dissco.core.translator.repository.SourceSystemRepository;
-import eu.dissco.core.translator.terms.License;
-import eu.dissco.core.translator.terms.SourceSystemId;
-import eu.dissco.core.translator.terms.Term;
-import eu.dissco.core.translator.terms.TermMapper;
-import eu.dissco.core.translator.terms.media.AccessUri;
-import eu.dissco.core.translator.terms.media.Format;
-import eu.dissco.core.translator.terms.media.MediaType;
-import eu.dissco.core.translator.terms.specimen.DwcaId;
-import eu.dissco.core.translator.terms.specimen.Modified;
-import eu.dissco.core.translator.terms.specimen.OrganisationId;
-import eu.dissco.core.translator.terms.specimen.OrganisationName;
-import eu.dissco.core.translator.terms.specimen.PhysicalSpecimenId;
-import eu.dissco.core.translator.terms.specimen.PhysicalSpecimenIdType;
-import eu.dissco.core.translator.terms.specimen.Type;
+import eu.dissco.core.translator.terms.DigitalObjectDirector;
import freemarker.template.Configuration;
import freemarker.template.TemplateException;
import jakarta.xml.bind.JAXBContext;
@@ -94,10 +77,10 @@ public class BioCaseService implements WebClientService {
private final SourceSystemRepository repository;
private final Configuration configuration;
private final XMLInputFactory xmlFactory;
- private final TermMapper termMapper;
private final KafkaService kafkaService;
private final EnrichmentProperties enrichmentProperties;
- private final RorComponent rorComponent;
+ private final DigitalObjectDirector digitalSpecimenDirector;
+ private final FdoProperties fdoProperties;
private boolean isAcceptedBasisOfRecord(Unit unit) {
var recordBasis = unit.getRecordBasis();
@@ -189,39 +172,32 @@ private void mapABCD206(XMLEventReader xmlEventReader)
private void processUnit(DataSet dataset, Unit unit)
throws JsonProcessingException, DisscoEfgParsingException {
var unitAttributes = parseToJson(unit);
- var datasetAttribute = getData(mapper.valueToTree(dataset));
+ var datasetAttribute = getData(mapper.valueToTree(dataset.getMetadata()));
+ unitAttributes.setAll(datasetAttribute);
if (isAcceptedBasisOfRecord(unit)) {
- var organisationId = termMapper.retrieveFromABCD(new OrganisationId(), unitAttributes);
- var physicalSpecimenIdType = termMapper.retrieveFromABCD(new PhysicalSpecimenIdType(),
- unitAttributes);
- var id = termMapper.retrieveFromABCD(new PhysicalSpecimenId(), unitAttributes);
- if (physicalSpecimenIdType != null) {
- try {
- var physicalSpecimenId = getPhysicalSpecimenId(physicalSpecimenIdType, organisationId,
- id);
- var digitalSpecimen = new DigitalSpecimen(
- physicalSpecimenId,
- termMapper.retrieveFromABCD(new Type(), unitAttributes),
- harmonizeAttributes(datasetAttribute, unitAttributes, physicalSpecimenIdType,
- organisationId),
- cleanupRedundantFields(unitAttributes)
- );
- log.debug("Result digital Specimen: {}", digitalSpecimen);
- kafkaService.sendMessage("digital-specimen",
- mapper.writeValueAsString(
- new DigitalSpecimenEvent(enrichmentServices(false), digitalSpecimen)));
- processDigitalMediaObjects(physicalSpecimenId, unit, organisationId);
- } catch (DiSSCoDataException e) {
- log.error("Encountered data issue with record: {}", unitAttributes, e);
- }
- } else {
- log.warn("Ignoring record with id: {} as we cannot determine the physicalSpecimenIdType",
- termMapper.retrieveFromABCD(new PhysicalSpecimenId(), unitAttributes));
+ try {
+ var attributes = digitalSpecimenDirector.assembleDigitalSpecimenTerm(unitAttributes, false);
+ var digitalSpecimen = new DigitalSpecimenWrapper(
+ attributes.getOdsNormalisedPhysicalSpecimenId(),
+ fdoProperties.getDigitalSpecimenType(),
+ attributes,
+ cleanupRedundantFields(unitAttributes)
+ );
+ var digitalMediaObjects = processDigitalMediaObjects(
+ attributes.getOdsNormalisedPhysicalSpecimenId(), unit,
+ attributes.getDwcInstitutionId());
+ log.debug("Result digital Specimen: {}", digitalSpecimen);
+ kafkaService.sendMessage("digital-specimen",
+ mapper.writeValueAsString(
+ new DigitalSpecimenEvent(
+ enrichmentServices(false),
+ digitalSpecimen,
+ digitalMediaObjects)));
+ } catch (DiSSCoDataException e) {
+ log.error("Encountered data issue with record: {}", unitAttributes, e);
}
} else {
- log.info("Record with id: {} and record basis: {} is ignored ",
- termMapper.retrieveFromABCD(new PhysicalSpecimenId(), unitAttributes),
- unit.getRecordBasis());
+ log.info("Record with record basis: {} is ignored ", unit.getRecordBasis());
}
}
@@ -231,25 +207,6 @@ private ObjectNode parseToJson(Unit unit) throws DisscoEfgParsingException {
return unitData;
}
- private JsonNode harmonizeAttributes(ObjectNode datasetAttributes, ObjectNode unitAttributes,
- String physicalSpecimenIdType, String organisationId) throws OrganisationNotRorId {
- var attributes = mapper.createObjectNode();
- attributes.put(PhysicalSpecimenIdType.TERM, physicalSpecimenIdType);
- attributes.put(OrganisationId.TERM, organisationId);
- attributes.put(OrganisationName.TERM,
- rorComponent.getRoRId(minifyOrganisationId(organisationId)));
- attributes.put(SourceSystemId.TERM, webClientProperties.getSourceSystemId());
- attributes.put(DwcaId.TERM, (String) null);
- attributes.put(License.TERM,
- termMapper.retrieveFromABCD(new License(), datasetAttributes, unitAttributes));
- attributes.put(Modified.TERM,
- termMapper.retrieveFromABCD(new Modified(), datasetAttributes, unitAttributes));
- for (Term term : abcdHarmonisedTerms()) {
- attributes.put(term.getTerm(), termMapper.retrieveFromABCD(term, unitAttributes));
- }
- return attributes;
- }
-
private void extractEfgInformation(Unit unit, ObjectNode unitAttributes)
throws DisscoEfgParsingException {
var efgTaxExtension = getEfgTaxExtension(unit);
@@ -357,9 +314,9 @@ private void addEfgFieldsForExtension(ObjectNode unitData, EarthScienceSpecimenT
unitData.remove("abcd:unitExtension");
}
- private JsonNode cleanupRedundantFields(ObjectNode unitData) {
+ private JsonNode cleanupRedundantFields(JsonNode unitData) {
var multiMediaFields = new ArrayList();
- var data = unitData.deepCopy();
+ var data = (ObjectNode) unitData.deepCopy();
data.remove("ods:taxonIdentificationIndex");
data.fields().forEachRemaining(field -> {
if (field.getKey().startsWith("abcd:multiMediaObjects")) {
@@ -370,39 +327,31 @@ private JsonNode cleanupRedundantFields(ObjectNode unitData) {
return data;
}
- private void processDigitalMediaObjects(String physicalSpecimenId, Unit unit, String organisationId)
- throws JsonProcessingException {
+ private List processDigitalMediaObjects(String physicalSpecimenId,
+ Unit unit, String organisationId) throws OrganisationNotRorId {
+ var digitalMediaObjectEvents = new ArrayList();
if (unit.getMultiMediaObjects() != null && !unit.getMultiMediaObjects().getMultiMediaObject()
.isEmpty()) {
for (MultiMediaObject media : unit.getMultiMediaObjects().getMultiMediaObject()) {
- processDigitalMediaObject(physicalSpecimenId, media, organisationId);
+ digitalMediaObjectEvents.add(
+ processDigitalMediaObject(physicalSpecimenId, media, organisationId));
}
}
+ return digitalMediaObjectEvents;
}
- private void processDigitalMediaObject(String physicalSpecimenId, MultiMediaObject media, String organisationId)
- throws JsonProcessingException {
+ private DigitalMediaObjectEvent processDigitalMediaObject(String physicalSpecimenId,
+ MultiMediaObject media, String organisationId) throws OrganisationNotRorId {
var attributes = getData(mapper.valueToTree(media));
- var digitalMediaObject = new DigitalMediaObject(
- termMapper.retrieveFromABCD(new MediaType(), attributes),
- physicalSpecimenId,
- harmonizeMedia(attributes, organisationId),
- attributes
- );
- log.debug("Result digital media object: {}", digitalMediaObject);
- kafkaService.sendMessage("digital-media-object",
- mapper.writeValueAsString(
- new DigitalMediaObjectEvent(enrichmentServices(true), digitalMediaObject)));
- }
-
- private JsonNode harmonizeMedia(JsonNode mediaAttributes, String organisationId) {
- var attributes = mapper.createObjectNode();
- attributes.put(AccessUri.TERM, termMapper.retrieveFromABCD(new AccessUri(), mediaAttributes));
- attributes.put(SourceSystemId.TERM, webClientProperties.getSourceSystemId());
- attributes.put(Format.TERM, termMapper.retrieveFromABCD(new Format(), mediaAttributes));
- attributes.put(License.TERM, termMapper.retrieveFromABCD(new License(), mediaAttributes));
- attributes.put(OrganisationId.TERM, organisationId);
- return attributes;
+ var digitalMediaObjectEvent = new DigitalMediaObjectEvent(enrichmentServices(true),
+ new DigitalMediaObject(
+ fdoProperties.getDigitalMediaObjectType(),
+ physicalSpecimenId,
+ digitalSpecimenDirector.assembleDigitalMediaObjects(false, attributes, organisationId),
+ attributes
+ ));
+ log.debug("Result digital media object: {}", digitalMediaObjectEvent);
+ return digitalMediaObjectEvent;
}
private List enrichmentServices(boolean multiMediaObject) {
diff --git a/src/main/java/eu/dissco/core/translator/service/DwcaService.java b/src/main/java/eu/dissco/core/translator/service/DwcaService.java
index a45251a..de53a82 100644
--- a/src/main/java/eu/dissco/core/translator/service/DwcaService.java
+++ b/src/main/java/eu/dissco/core/translator/service/DwcaService.java
@@ -1,40 +1,24 @@
package eu.dissco.core.translator.service;
-import static eu.dissco.core.translator.service.IngestionUtility.getPhysicalSpecimenId;
-import static eu.dissco.core.translator.service.IngestionUtility.minifyOrganisationId;
-import static eu.dissco.core.translator.terms.TermMapper.dwcaHarmonisedTerms;
-
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import eu.dissco.core.translator.Profiles;
-import eu.dissco.core.translator.component.RorComponent;
import eu.dissco.core.translator.domain.DigitalMediaObject;
import eu.dissco.core.translator.domain.DigitalMediaObjectEvent;
-import eu.dissco.core.translator.domain.DigitalSpecimen;
import eu.dissco.core.translator.domain.DigitalSpecimenEvent;
+import eu.dissco.core.translator.domain.DigitalSpecimenWrapper;
import eu.dissco.core.translator.domain.Enrichment;
import eu.dissco.core.translator.exception.DiSSCoDataException;
import eu.dissco.core.translator.exception.OrganisationNotRorId;
import eu.dissco.core.translator.properties.DwcaProperties;
import eu.dissco.core.translator.properties.EnrichmentProperties;
+import eu.dissco.core.translator.properties.FdoProperties;
import eu.dissco.core.translator.properties.WebClientProperties;
import eu.dissco.core.translator.repository.DwcaRepository;
import eu.dissco.core.translator.repository.SourceSystemRepository;
-import eu.dissco.core.translator.terms.License;
-import eu.dissco.core.translator.terms.SourceSystemId;
-import eu.dissco.core.translator.terms.Term;
-import eu.dissco.core.translator.terms.TermMapper;
-import eu.dissco.core.translator.terms.media.AccessUri;
-import eu.dissco.core.translator.terms.media.Format;
-import eu.dissco.core.translator.terms.media.MediaType;
-import eu.dissco.core.translator.terms.specimen.DwcaId;
-import eu.dissco.core.translator.terms.specimen.OrganisationId;
-import eu.dissco.core.translator.terms.specimen.OrganisationName;
-import eu.dissco.core.translator.terms.specimen.PhysicalSpecimenId;
-import eu.dissco.core.translator.terms.specimen.PhysicalSpecimenIdType;
-import eu.dissco.core.translator.terms.specimen.Type;
+import eu.dissco.core.translator.terms.DigitalObjectDirector;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
@@ -80,11 +64,11 @@ public class DwcaService implements WebClientService {
private final WebClient webClient;
private final DwcaProperties dwcaProperties;
private final KafkaService kafkaService;
- private final TermMapper termMapper;
private final EnrichmentProperties enrichmentProperties;
private final SourceSystemRepository repository;
private final DwcaRepository dwcaRepository;
- private final RorComponent rorComponent;
+ private final DigitalObjectDirector digitalSpecimenDirector;
+ private final FdoProperties fdoProperties;
private final List allowedBasisOfRecord = List.of("PRESERVEDSPECIMEN", "FOSSIL", "OTHER",
"ROCK", "MINERAL", "METEORITE", "FOSSILSPECIMEN", "LIVINGSPECIMEN", "MATERIALSAMPLE");
@@ -156,13 +140,12 @@ private void processDigitalSpecimen(Collection fullRecords)
var recordId = fullRecord.get(DwcaTerm.ID.prefixedName()).asText();
if (!recordNeedsToBeIgnored(fullRecord, recordId)) {
try {
- var digitalSpecimen = createDigitalSpecimen(fullRecord);
- log.debug("Digital Specimen: {}", digitalSpecimen);
+ var digitalObjects = createDigitalObjects(fullRecord);
+ log.debug("Digital Specimen: {}", digitalObjects);
var translatorEvent = new DigitalSpecimenEvent(enrichmentServices(false),
- digitalSpecimen);
+ digitalObjects.getLeft(), digitalObjects.getRight());
kafkaService.sendMessage("digital-specimen",
mapper.writeValueAsString(translatorEvent));
- processMedia(digitalSpecimen.id(), fullRecord);
} catch (DiSSCoDataException e) {
log.error("Encountered data issue with record: {}", fullRecord, e);
}
@@ -171,74 +154,73 @@ private void processDigitalSpecimen(Collection fullRecords)
}
}
- private void processMedia(String recordId, JsonNode fullDigitalSpecimen)
- throws JsonProcessingException {
+ private List processMedia(String recordId, JsonNode fullDigitalSpecimen,
+ String organisationId) throws OrganisationNotRorId {
var extensions = fullDigitalSpecimen.get(EXTENSIONS);
- var orgId = termMapper.retrieveFromDWCA(new OrganisationId(), fullDigitalSpecimen);
- if (fullDigitalSpecimen.get(DWC_ASSOCIATED_MEDIA) != null) {
- publishAssociatedMedia(recordId, fullDigitalSpecimen.get(DWC_ASSOCIATED_MEDIA).asText(), orgId);
- } else if (extensions != null) {
- if (extensions.get(GBIF_MULTIMEDIA) != null) {
- var imageArray = extensions.get(GBIF_MULTIMEDIA);
- if (imageArray.isArray() && imageArray.size() > 0) {
- extractMultiMedia(recordId, imageArray, orgId);
- }
- } else if (extensions.get(AC_MULTIMEDIA) != null) {
+ if (extensions != null) {
+ if (extensions.get(AC_MULTIMEDIA) != null) {
var imageArray = extensions.get(AC_MULTIMEDIA);
- if (imageArray.isArray() && imageArray.size() > 0) {
- extractMultiMedia(recordId, imageArray, orgId);
+ if (imageArray.isArray() && !imageArray.isEmpty()) {
+ return extractMultiMedia(recordId, imageArray, organisationId);
+ }
+ } else if (extensions.get(GBIF_MULTIMEDIA) != null) {
+ var imageArray = extensions.get(GBIF_MULTIMEDIA);
+ if (imageArray.isArray() && !imageArray.isEmpty()) {
+ return extractMultiMedia(recordId, imageArray, organisationId);
}
}
+ } else if (fullDigitalSpecimen.get(DWC_ASSOCIATED_MEDIA) != null) {
+ return publishAssociatedMedia(recordId,
+ fullDigitalSpecimen.get(DWC_ASSOCIATED_MEDIA).asText(), organisationId);
}
+ return List.of();
}
- private void extractMultiMedia(String recordId, JsonNode imageArray, String orgId)
- throws JsonProcessingException {
+ private List extractMultiMedia(String recordId, JsonNode imageArray,
+ String organisationId) throws OrganisationNotRorId {
+ var digitalMediaObjectEvents = new ArrayList();
for (var image : imageArray) {
- var type = termMapper.retrieveFromDWCA(new MediaType(), image);
- log.debug("Type of digitalMediaObject is: {}", type);
- var digitalMediaObject = new DigitalMediaObject(
- type,
- recordId,
- harmonizeMedia(image, orgId),
- image);
- publishDigitalMediaObject(digitalMediaObject);
+ var digitalMediaObject = new DigitalMediaObjectEvent(enrichmentServices(true),
+ new DigitalMediaObject(
+ fdoProperties.getDigitalMediaObjectType(),
+ recordId,
+ digitalSpecimenDirector.assembleDigitalMediaObjects(true, image, organisationId),
+ image));
+ digitalMediaObjectEvents.add(digitalMediaObject);
}
+ return digitalMediaObjectEvents;
}
- private void publishAssociatedMedia(String recordId, String associatedMedia, String orgId)
- throws JsonProcessingException {
+ private List publishAssociatedMedia(String recordId,
+ String associatedMedia,
+ String organisationId) throws OrganisationNotRorId {
log.debug("Digital Specimen: {}, has associatedMedia {}", recordId,
associatedMedia);
String[] mediaUrls = associatedMedia.split("\\|");
+ var digitalMediaObjects = new ArrayList();
for (var mediaUrl : mediaUrls) {
- var digitalMediaObject = new DigitalMediaObject(
- UNKNOWN,
- recordId,
- harmonizeAssociatedMedia(mediaUrl, orgId),
- null);
- publishDigitalMediaObject(digitalMediaObject);
+ var digitalMediaObject = new DigitalMediaObjectEvent(enrichmentServices(true),
+ new DigitalMediaObject(
+ fdoProperties.getDigitalMediaObjectType(),
+ recordId,
+ digitalSpecimenDirector.assembleDigitalMediaObjects(true,
+ mapper.valueToTree(mediaUrl),
+ organisationId),
+ null));
+ digitalMediaObjects.add(digitalMediaObject);
}
+ return digitalMediaObjects;
}
- private JsonNode harmonizeAssociatedMedia(String mediaUrl, String orgId) {
- var attributes = mapper.createObjectNode();
- attributes.put(AccessUri.TERM, mediaUrl);
- attributes.put(SourceSystemId.TERM, webClientProperties.getSourceSystemId());
- attributes.put(OrganisationId.TERM, orgId);
- return attributes;
- }
-
- private DigitalSpecimen createDigitalSpecimen(JsonNode fullRecord) throws DiSSCoDataException {
- var physicalSpecimenIdType = termMapper.retrieveFromDWCA(new PhysicalSpecimenIdType(),
- fullRecord);
- var organisationId = termMapper.retrieveFromDWCA(new OrganisationId(), fullRecord);
- var physicalSpecimenId = termMapper.retrieveFromDWCA(new PhysicalSpecimenId(), fullRecord);
- return new DigitalSpecimen(
- getPhysicalSpecimenId(physicalSpecimenIdType, organisationId, physicalSpecimenId),
- termMapper.retrieveFromDWCA(new Type(), fullRecord),
- harmonizeSpecimenAttributes(physicalSpecimenIdType, organisationId, fullRecord),
- cleanupRedundantFields(fullRecord)
+ private Pair> createDigitalObjects(
+ JsonNode fullRecord) throws DiSSCoDataException {
+ var ds = digitalSpecimenDirector.assembleDigitalSpecimenTerm(fullRecord, true);
+ return Pair.of(new DigitalSpecimenWrapper(
+ ds.getOdsNormalisedPhysicalSpecimenId(),
+ fdoProperties.getDigitalSpecimenType(),
+ ds,
+ cleanupRedundantFields(fullRecord)),
+ processMedia(ds.getOdsNormalisedPhysicalSpecimenId(), fullRecord, ds.getDwcInstitutionId())
);
}
@@ -246,27 +228,12 @@ private JsonNode cleanupRedundantFields(JsonNode fullRecord) {
var originalData = (ObjectNode) fullRecord.deepCopy();
originalData.remove("ods:taxonIdentificationIndex");
ObjectNode extensions = (ObjectNode) originalData.get(EXTENSIONS);
- if (extensions != null){
+ if (extensions != null) {
extensions.remove(List.of(GBIF_MULTIMEDIA, AC_MULTIMEDIA));
}
return originalData;
}
-
- private JsonNode harmonizeSpecimenAttributes(String physicalSpecimenIdType,
- String organisationId, JsonNode fullRecord) throws OrganisationNotRorId {
- var attributes = mapper.createObjectNode();
- attributes.put(PhysicalSpecimenIdType.TERM, physicalSpecimenIdType);
- attributes.put(OrganisationId.TERM, organisationId);
- attributes.put(OrganisationName.TERM, rorComponent.getRoRId(minifyOrganisationId(organisationId)));
- attributes.put(SourceSystemId.TERM, webClientProperties.getSourceSystemId());
- attributes.put(DwcaId.TERM, fullRecord.get(DwcaTerm.ID.prefixedName()).asText());
- for (Term term : dwcaHarmonisedTerms()) {
- attributes.put(term.getTerm(), termMapper.retrieveFromDWCA(term, fullRecord));
- }
- return attributes;
- }
-
private boolean recordNeedsToBeIgnored(JsonNode fullRecord, String recordId) {
var basisOfRecord = fullRecord.get(DwcTerm.basisOfRecord.prefixedName());
if (basisOfRecord == null) {
@@ -374,25 +341,6 @@ private void postExtensions(Set extensions) {
log.info("Finished posting extensions archive to database");
}
- private JsonNode harmonizeMedia(JsonNode media, String orgId) {
- var attributes = mapper.createObjectNode();
- attributes.put(AccessUri.TERM, termMapper.retrieveFromDWCA(new AccessUri(), media));
- attributes.put(SourceSystemId.TERM, webClientProperties.getSourceSystemId());
- attributes.put(Format.TERM, termMapper.retrieveFromDWCA(new Format(), media));
- attributes.put(License.TERM, termMapper.retrieveFromDWCA(new License(), media));
- attributes.put(OrganisationId.TERM, orgId);
- return attributes;
- }
-
- private void publishDigitalMediaObject(DigitalMediaObject digitalMediaObject)
- throws JsonProcessingException {
- log.debug("MultiMediaObject: {}", digitalMediaObject);
- var digitalMediaObjectEvent = new DigitalMediaObjectEvent(enrichmentServices(true),
- digitalMediaObject);
- kafkaService.sendMessage("digital-media-object",
- mapper.writeValueAsString(digitalMediaObjectEvent));
- }
-
private List enrichmentServices(boolean multiMediaObject) {
if (enrichmentProperties.getList() != null) {
return enrichmentProperties.getList().stream()
diff --git a/src/main/java/eu/dissco/core/translator/service/IngestionUtility.java b/src/main/java/eu/dissco/core/translator/service/IngestionUtility.java
deleted file mode 100644
index d4fda27..0000000
--- a/src/main/java/eu/dissco/core/translator/service/IngestionUtility.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package eu.dissco.core.translator.service;
-
-import eu.dissco.core.translator.exception.DiSSCoDataException;
-import eu.dissco.core.translator.exception.OrganisationNotRorId;
-import eu.dissco.core.translator.exception.UnknownPhysicalSpecimenIdType;
-import lombok.extern.slf4j.Slf4j;
-
-@Slf4j
-public class IngestionUtility {
-
- private IngestionUtility() {
- // Utility class
- }
-
- protected static String getPhysicalSpecimenId(String physicalSpecimenIdType, String organisationId,
- String physicalSpecimenId) throws DiSSCoDataException {
- if (physicalSpecimenIdType.equals("cetaf")) {
- return physicalSpecimenId;
- } else if (physicalSpecimenIdType.equals("combined")) {
- return physicalSpecimenId + ":" + minifyOrganisationId(organisationId);
- } else {
- log.warn("Unknown physicalSpecimenIdType specified");
- throw new UnknownPhysicalSpecimenIdType(physicalSpecimenIdType + " is not a known id type");
- }
- }
-
- protected static String minifyOrganisationId(String organisationId) throws OrganisationNotRorId {
- if (organisationId.startsWith("https://ror.org")) {
- return organisationId.replace("https://ror.org/", "");
- } else {
- throw new OrganisationNotRorId(organisationId + " is not a valid ror");
- }
- }
-}
diff --git a/src/main/java/eu/dissco/core/translator/service/KafkaService.java b/src/main/java/eu/dissco/core/translator/service/KafkaService.java
index 15d6f78..964b209 100644
--- a/src/main/java/eu/dissco/core/translator/service/KafkaService.java
+++ b/src/main/java/eu/dissco/core/translator/service/KafkaService.java
@@ -17,7 +17,7 @@ public class KafkaService {
public void sendMessage(String topic, String event) {
CompletableFuture> future = kafkaTemplate.send(topic, event);
future.whenComplete((result, ex) -> {
- if (ex != null){
+ if (ex != null) {
log.error("Unable to send message: {}", event, ex);
}
});
diff --git a/src/main/java/eu/dissco/core/translator/service/WebClientService.java b/src/main/java/eu/dissco/core/translator/service/WebClientService.java
index 1488001..f323ebe 100644
--- a/src/main/java/eu/dissco/core/translator/service/WebClientService.java
+++ b/src/main/java/eu/dissco/core/translator/service/WebClientService.java
@@ -2,5 +2,5 @@
public interface WebClientService {
- public void retrieveData();
+ void retrieveData();
}
diff --git a/src/main/java/eu/dissco/core/translator/terms/DigitalObjectDirector.java b/src/main/java/eu/dissco/core/translator/terms/DigitalObjectDirector.java
new file mode 100644
index 0000000..741d7ce
--- /dev/null
+++ b/src/main/java/eu/dissco/core/translator/terms/DigitalObjectDirector.java
@@ -0,0 +1,697 @@
+package eu.dissco.core.translator.terms;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import eu.dissco.core.translator.component.RorComponent;
+import eu.dissco.core.translator.exception.OrganisationNotRorId;
+import eu.dissco.core.translator.exception.UnknownPhysicalSpecimenIdType;
+import eu.dissco.core.translator.properties.FdoProperties;
+import eu.dissco.core.translator.properties.WebClientProperties;
+import eu.dissco.core.translator.schema.Citations;
+import eu.dissco.core.translator.schema.DigitalEntity;
+import eu.dissco.core.translator.schema.DigitalEntity.DctermsType;
+import eu.dissco.core.translator.schema.DigitalSpecimen;
+import eu.dissco.core.translator.schema.DigitalSpecimen.OdsLivingOrPreserved;
+import eu.dissco.core.translator.schema.DigitalSpecimen.OdsPhysicalSpecimenIdType;
+import eu.dissco.core.translator.schema.EntityRelationships;
+import eu.dissco.core.translator.schema.Georeference;
+import eu.dissco.core.translator.schema.Identifications;
+import eu.dissco.core.translator.schema.Identifiers;
+import eu.dissco.core.translator.schema.Occurrences;
+import eu.dissco.core.translator.schema.Occurrences.DwcOccurrenceStatus;
+import eu.dissco.core.translator.schema.TaxonIdentification;
+import eu.dissco.core.translator.terms.media.AccessUri;
+import eu.dissco.core.translator.terms.media.Created;
+import eu.dissco.core.translator.terms.media.Creator;
+import eu.dissco.core.translator.terms.media.Description;
+import eu.dissco.core.translator.terms.media.Format;
+import eu.dissco.core.translator.terms.media.MediaAssertions;
+import eu.dissco.core.translator.terms.media.MediaType;
+import eu.dissco.core.translator.terms.media.Rights;
+import eu.dissco.core.translator.terms.media.Source;
+import eu.dissco.core.translator.terms.media.WebStatement;
+import eu.dissco.core.translator.terms.specimen.AccessRights;
+import eu.dissco.core.translator.terms.specimen.BasisOfRecord;
+import eu.dissco.core.translator.terms.specimen.CollectionId;
+import eu.dissco.core.translator.terms.specimen.DatasetName;
+import eu.dissco.core.translator.terms.specimen.Disposition;
+import eu.dissco.core.translator.terms.specimen.HasMedia;
+import eu.dissco.core.translator.terms.specimen.LivingOrPreserved;
+import eu.dissco.core.translator.terms.specimen.MarkedAsType;
+import eu.dissco.core.translator.terms.specimen.Modified;
+import eu.dissco.core.translator.terms.specimen.OrganisationId;
+import eu.dissco.core.translator.terms.specimen.PhysicalSpecimenId;
+import eu.dissco.core.translator.terms.specimen.PhysicalSpecimenIdType;
+import eu.dissco.core.translator.terms.specimen.Preparations;
+import eu.dissco.core.translator.terms.specimen.RecordedBy;
+import eu.dissco.core.translator.terms.specimen.RightsHolder;
+import eu.dissco.core.translator.terms.specimen.SpecimenName;
+import eu.dissco.core.translator.terms.specimen.TopicDiscipline;
+import eu.dissco.core.translator.terms.specimen.TopicDomain;
+import eu.dissco.core.translator.terms.specimen.TopicOrigin;
+import eu.dissco.core.translator.terms.specimen.citation.BibliographicCitation;
+import eu.dissco.core.translator.terms.specimen.citation.CitationRemarks;
+import eu.dissco.core.translator.terms.specimen.citation.Date;
+import eu.dissco.core.translator.terms.specimen.citation.ReferenceIri;
+import eu.dissco.core.translator.terms.specimen.citation.Title;
+import eu.dissco.core.translator.terms.specimen.citation.Type;
+import eu.dissco.core.translator.terms.specimen.identification.DateIdentified;
+import eu.dissco.core.translator.terms.specimen.identification.IdentificationId;
+import eu.dissco.core.translator.terms.specimen.identification.IdentificationRemarks;
+import eu.dissco.core.translator.terms.specimen.identification.IdentificationVerificationStatus;
+import eu.dissco.core.translator.terms.specimen.identification.IdentifiedBy;
+import eu.dissco.core.translator.terms.specimen.identification.TypeStatus;
+import eu.dissco.core.translator.terms.specimen.identification.VerbatimIdentification;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.Class;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.Family;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.Genus;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.Kingdom;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.NameAccordingTo;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.NamePublishedInYear;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.NomenclaturalCode;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.Order;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.Phylum;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.ScientificName;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.ScientificNameAuthorship;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.SpecificEpithet;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.Subfamily;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.Subgenus;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.TaxonId;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.TaxonRank;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.TaxonRemarks;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.TaxonomicStatus;
+import eu.dissco.core.translator.terms.specimen.identification.taxonomy.VernacularName;
+import eu.dissco.core.translator.terms.specimen.location.Continent;
+import eu.dissco.core.translator.terms.specimen.location.Country;
+import eu.dissco.core.translator.terms.specimen.location.CountryCode;
+import eu.dissco.core.translator.terms.specimen.location.County;
+import eu.dissco.core.translator.terms.specimen.location.HigherGeography;
+import eu.dissco.core.translator.terms.specimen.location.Island;
+import eu.dissco.core.translator.terms.specimen.location.IslandGroup;
+import eu.dissco.core.translator.terms.specimen.location.Locality;
+import eu.dissco.core.translator.terms.specimen.location.LocationAccordingTo;
+import eu.dissco.core.translator.terms.specimen.location.LocationRemarks;
+import eu.dissco.core.translator.terms.specimen.location.MaximumDepthInMeters;
+import eu.dissco.core.translator.terms.specimen.location.MaximumDistanceAboveSurfaceInMeters;
+import eu.dissco.core.translator.terms.specimen.location.MaximumElevationInMeters;
+import eu.dissco.core.translator.terms.specimen.location.MinimumDepthInMeters;
+import eu.dissco.core.translator.terms.specimen.location.MinimumDistanceAboveSurfaceInMeters;
+import eu.dissco.core.translator.terms.specimen.location.MinimumElevationInMeters;
+import eu.dissco.core.translator.terms.specimen.location.Municipality;
+import eu.dissco.core.translator.terms.specimen.location.StateProvince;
+import eu.dissco.core.translator.terms.specimen.location.VerticalDatum;
+import eu.dissco.core.translator.terms.specimen.location.WaterBody;
+import eu.dissco.core.translator.terms.specimen.location.georeference.CoordinatePrecision;
+import eu.dissco.core.translator.terms.specimen.location.georeference.CoordinateUncertaintyInMeters;
+import eu.dissco.core.translator.terms.specimen.location.georeference.DecimalLatitude;
+import eu.dissco.core.translator.terms.specimen.location.georeference.DecimalLongitude;
+import eu.dissco.core.translator.terms.specimen.location.georeference.FootprintSpatialFit;
+import eu.dissco.core.translator.terms.specimen.location.georeference.FootprintSrs;
+import eu.dissco.core.translator.terms.specimen.location.georeference.FootprintWkt;
+import eu.dissco.core.translator.terms.specimen.location.georeference.GeodeticDatum;
+import eu.dissco.core.translator.terms.specimen.location.georeference.GeoreferenceProtocol;
+import eu.dissco.core.translator.terms.specimen.location.georeference.GeoreferenceRemarks;
+import eu.dissco.core.translator.terms.specimen.location.georeference.GeoreferenceSources;
+import eu.dissco.core.translator.terms.specimen.location.georeference.GeoreferencedBy;
+import eu.dissco.core.translator.terms.specimen.location.georeference.GeoreferencedDate;
+import eu.dissco.core.translator.terms.specimen.location.georeference.PointRadiusSpatialFit;
+import eu.dissco.core.translator.terms.specimen.occurence.Behavior;
+import eu.dissco.core.translator.terms.specimen.occurence.DataGeneralizations;
+import eu.dissco.core.translator.terms.specimen.occurence.DegreeOfEstablishment;
+import eu.dissco.core.translator.terms.specimen.occurence.EstablishmentMeans;
+import eu.dissco.core.translator.terms.specimen.occurence.EventDate;
+import eu.dissco.core.translator.terms.specimen.occurence.EventRemark;
+import eu.dissco.core.translator.terms.specimen.occurence.FieldNotes;
+import eu.dissco.core.translator.terms.specimen.occurence.FieldNumber;
+import eu.dissco.core.translator.terms.specimen.occurence.GeoreferenceVerificationStatus;
+import eu.dissco.core.translator.terms.specimen.occurence.Habitat;
+import eu.dissco.core.translator.terms.specimen.occurence.InformationWithheld;
+import eu.dissco.core.translator.terms.specimen.occurence.LifeStage;
+import eu.dissco.core.translator.terms.specimen.occurence.OccurrenceAssertions;
+import eu.dissco.core.translator.terms.specimen.occurence.OccurrenceRemarks;
+import eu.dissco.core.translator.terms.specimen.occurence.OccurrenceStatus;
+import eu.dissco.core.translator.terms.specimen.occurence.OrganismQuantity;
+import eu.dissco.core.translator.terms.specimen.occurence.OrganismQuantityType;
+import eu.dissco.core.translator.terms.specimen.occurence.Pathway;
+import eu.dissco.core.translator.terms.specimen.occurence.ReproductiveCondition;
+import eu.dissco.core.translator.terms.specimen.occurence.SampleSizeUnit;
+import eu.dissco.core.translator.terms.specimen.occurence.SampleSizeValue;
+import eu.dissco.core.translator.terms.specimen.occurence.SamplingProtocol;
+import eu.dissco.core.translator.terms.specimen.occurence.Sex;
+import eu.dissco.core.translator.terms.specimen.stratigraphy.biostratigraphic.HighestBiostratigraphicZone;
+import eu.dissco.core.translator.terms.specimen.stratigraphy.biostratigraphic.LowestBiostratigraphicZone;
+import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.EarliestAgeOrLowestStage;
+import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.EarliestEonOrLowestEonothem;
+import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.EarliestEpochOrLowestSeries;
+import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.EarliestEraOrLowestErathem;
+import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.EarliestPeriodOrLowestSystem;
+import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.LatestAgeOrHighestStage;
+import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.LatestEonOrHighestEonothem;
+import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.LatestEpochOrHighestSeries;
+import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.LatestEraOrHighestErathem;
+import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.LatestPeriodOrHighestSystem;
+import eu.dissco.core.translator.terms.specimen.stratigraphy.lithostratigraphic.Bed;
+import eu.dissco.core.translator.terms.specimen.stratigraphy.lithostratigraphic.Formation;
+import eu.dissco.core.translator.terms.specimen.stratigraphy.lithostratigraphic.Group;
+import eu.dissco.core.translator.terms.specimen.stratigraphy.lithostratigraphic.LithostratigraphicTerms;
+import eu.dissco.core.translator.terms.specimen.stratigraphy.lithostratigraphic.Member;
+import java.util.ArrayList;
+import java.util.List;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+@Slf4j
+@Component
+@RequiredArgsConstructor
+public class DigitalObjectDirector {
+
+ private static final String EXTENSION = "extensions";
+
+ private final ObjectMapper mapper;
+ private final TermMapper termMapper;
+ private final RorComponent rorComponent;
+ private final WebClientProperties webClientProperties;
+ private final FdoProperties fdoProperties;
+
+ private static List identifierTerms() {
+ var list = new ArrayList();
+ list.add("dwc:occurrenceID");
+ list.add("dwca:ID");
+ list.add("dwc:catalogNumber");
+ list.add("dwc:otherCatalogNumbers");
+ list.add("abcd:id");
+ list.add("abcd:unitID");
+ list.add("abcd:unitIDNumeric");
+ list.add("abcd:unitGUID");
+ list.add("abcd:recordURI");
+ list.add("dcterms:identifier");
+ return list;
+ }
+
+ public DigitalSpecimen assembleDigitalSpecimenTerm(JsonNode data, boolean dwc)
+ throws OrganisationNotRorId, UnknownPhysicalSpecimenIdType {
+ var ds = assembleDigitalSpecimenTerms(data, dwc);
+ ds.withOccurrences(assembleOccurrenceTerms(data, dwc));
+ ds.withDwcIdentification(assembleIdentifications(data, dwc));
+ ds.withIdentifiers(assembleIdentifiers(data));
+ ds.withCitations(assembleSpecimenCitations(data, dwc));
+ ds.withEntityRelationships(assembleDigitalSpecimenEntityRelationships(ds));
+ setCalculatedFields(ds);
+ return ds;
+ }
+
+ private void setCalculatedFields(eu.dissco.core.translator.schema.DigitalSpecimen ds) {
+ ds.setOdsTopicDiscipline(new TopicDiscipline().calculate(ds));
+ ds.setOdsTopicOrigin(new TopicOrigin().calculate(ds));
+ ds.setOdsTopicDomain(new TopicDomain().calculate(ds));
+ ds.setOdsSpecimenName(new SpecimenName().calculate(ds));
+ ds.setOdsMarkedAsType(new MarkedAsType().calculate(ds));
+ }
+
+ private List assembleSpecimenCitations(JsonNode data, boolean dwc) {
+ List citations;
+ if (dwc) {
+ citations = gatherDwcaCitations(data, dwc);
+ } else {
+ citations = gatherAbcdCitations(data, dwc, "abcd:unitReferences/unitReference/");
+ }
+ return citations;
+ }
+
+ private List assembleIdentificationCitations(JsonNode data, boolean dwc) {
+ List citations = List.of();
+ if (dwc) {
+ log.debug("Reference extension has been added to the occurrence");
+ } else {
+ citations = gatherAbcdCitations(data, dwc, "references/reference/");
+ }
+ return citations;
+ }
+
+ private List gatherAbcdCitations(JsonNode data,
+ boolean dwc, String subpath) {
+ var citations = new ArrayList();
+ var iterateOverElements = true;
+ var count = 0;
+ while (iterateOverElements) {
+ var citationNode = getSubJsonAbcd(data, count, subpath);
+ if (!citationNode.isEmpty()) {
+ citations.add(createCitation(citationNode, dwc));
+ count++;
+ } else {
+ iterateOverElements = false;
+ }
+ }
+ return citations;
+ }
+
+ private Citations createCitation(JsonNode data,
+ boolean dwc) {
+ return new eu.dissco.core.translator.schema.Citations()
+ .withDctermsBibliographicCitation(
+ termMapper.retrieveTerm(new BibliographicCitation(), data, dwc))
+ .withCitationRemarks(termMapper.retrieveTerm(new CitationRemarks(), data, dwc))
+ .withReferenceIri(termMapper.retrieveTerm(new ReferenceIri(), data, dwc))
+ .withDctermsCreator(
+ termMapper.retrieveTerm(new eu.dissco.core.translator.terms.specimen.citation.Creator(),
+ data, dwc))
+ .withDctermsType(termMapper.retrieveTerm(new Type(), data, dwc))
+ .withDctermsDate(termMapper.retrieveTerm(new Date(), data, dwc))
+ .withDctermsTitle(termMapper.retrieveTerm(new Title(), data, dwc));
+ }
+
+ private List gatherDwcaCitations(JsonNode data,
+ boolean dwc) {
+ var citations = new ArrayList();
+ if (data.get(EXTENSION) != null
+ && data.get(EXTENSION).get("gbif:Reference") != null) {
+ var references = data.get(EXTENSION).get("gbif:Reference");
+ for (int i = 0; i < references.size(); i++) {
+ var identification = references.get(i);
+ citations.add(createCitation(identification, dwc));
+ }
+ } else {
+ citations.add(createCitation(data, dwc));
+ }
+ return citations;
+ }
+
+ private DigitalSpecimen assembleDigitalSpecimenTerms(JsonNode data, boolean dwc)
+ throws OrganisationNotRorId, UnknownPhysicalSpecimenIdType {
+ var physicalSpecimenIdTypeHarmonised = convertToPhysicalSpecimenIdTypeEnum(
+ termMapper.retrieveTerm(new PhysicalSpecimenIdType(), data, dwc));
+ var organisationId = termMapper.retrieveTerm(new OrganisationId(), data, dwc);
+ var physicalSpecimenId = termMapper.retrieveTerm(new PhysicalSpecimenId(), data, dwc);
+ var normalisedPhysicalSpecimenId = getNormalisedPhysicalSpecimenId(
+ physicalSpecimenIdTypeHarmonised, organisationId, physicalSpecimenId);
+ return new DigitalSpecimen()
+ .withDctermsLicense(termMapper.retrieveTerm(new License(), data, dwc))
+ .withOdsPhysicalSpecimenId(physicalSpecimenId)
+ .withOdsNormalisedPhysicalSpecimenId(normalisedPhysicalSpecimenId)
+ .withOdsPhysicalSpecimenIdType(physicalSpecimenIdTypeHarmonised)
+ .withDwcInstitutionId(organisationId)
+ .withOdsPhysicalSpecimenId(physicalSpecimenId)
+ .withOdsHasMedia(parseToBoolean(new HasMedia(), data, dwc))
+ .withOdsSourceSystem(
+ "https://hdl.handle.net/" + webClientProperties.getSourceSystemId())
+ .withOdsLivingOrPreserved(
+ retrieveEnum(new LivingOrPreserved(), data, dwc, OdsLivingOrPreserved.class))
+ .withDwcPreparations(termMapper.retrieveTerm(new Preparations(), data, dwc))
+ .withDwcCollectionId(termMapper.retrieveTerm(new CollectionId(), data, dwc))
+ .withDctermsModified(termMapper.retrieveTerm(new Modified(), data, dwc))
+ .withDwcInstitutionName(
+ rorComponent.getRorName(minifyOrganisationId(organisationId)))
+ .withDwcRecordedBy(termMapper.retrieveTerm(new RecordedBy(), data, dwc))
+ .withDwcBasisOfRecord(termMapper.retrieveTerm(new BasisOfRecord(), data, dwc))
+ .withDctermsAccessRights(termMapper.retrieveTerm(new AccessRights(), data, dwc))
+ .withDctermsRightsHolder(termMapper.retrieveTerm(new RightsHolder(), data, dwc))
+ .withDwcDatasetName(termMapper.retrieveTerm(new DatasetName(), data, dwc))
+ .withDwcDisposition(termMapper.retrieveTerm(new Disposition(), data, dwc));
+ }
+
+ private List assembleDigitalSpecimenEntityRelationships(
+ DigitalSpecimen ds) {
+ var relationships = new ArrayList();
+ relationships.add(new EntityRelationships().withEntityRelationshipType("hasOrganisationId")
+ .withObjectEntityIri(ds.getDwcInstitutionId()));
+ relationships.add(new EntityRelationships().withEntityRelationshipType("hasSourceSystemId")
+ .withObjectEntityIri(ds.getOdsSourceSystem()));
+ relationships.add(new EntityRelationships().withEntityRelationshipType("hasFdoType")
+ .withObjectEntityIri(fdoProperties.getDigitalSpecimenType()));
+ if (ds.getOdsPhysicalSpecimenIdType().equals(OdsPhysicalSpecimenIdType.RESOLVABLE)) {
+ relationships.add(
+ new EntityRelationships().withEntityRelationshipType("hasPhysicalIdentifier")
+ .withObjectEntityIri(ds.getOdsPhysicalSpecimenId()));
+ }
+ if (ds.getDctermsLicense() != null && ds.getDctermsLicense().startsWith("http")) {
+ relationships.add(new EntityRelationships().withEntityRelationshipType("hasLicense")
+ .withObjectEntityIri(ds.getDctermsLicense()));
+ }
+ if (ds.getCitations() != null) {
+ for (Citations citation : ds.getCitations()) {
+ if (citation.getReferenceIri() != null) {
+ relationships.add(new EntityRelationships().withEntityRelationshipType("hasReference")
+ .withObjectEntityIri(citation.getReferenceIri()));
+ }
+ }
+ }
+ return relationships;
+ }
+
+ private List assembleIdentifiers(JsonNode data) {
+ var identifiers = new ArrayList();
+ for (String identifierTerm : identifierTerms()) {
+ if (data.get(identifierTerm) != null) {
+ var identifier = new Identifiers()
+ .withIdentifierType(identifierTerm)
+ .withIdentifierValue(data.get(identifierTerm).asText());
+ identifiers.add(identifier);
+ }
+ }
+ return identifiers;
+ }
+
+ private List assembleIdentifications(JsonNode data, boolean dwc) {
+ List identifications = null;
+ if (dwc) {
+ identifications = gatherDwcaIdentifications(data, dwc);
+ } else {
+ identifications = gatherAbcdIdentifications(data, dwc);
+ }
+ return identifications;
+ }
+
+ private List gatherAbcdIdentifications(
+ JsonNode data, boolean dwc) {
+ var identifications = new ArrayList();
+ var iterateOverElements = true;
+ var count = 0;
+ while (iterateOverElements) {
+ var identificationNode = getSubJsonAbcd(data, count, "abcd:identifications/identification/");
+ if (!identificationNode.isEmpty()) {
+ identifications.add(createIdentification(identificationNode, dwc));
+ count++;
+ } else {
+ iterateOverElements = false;
+ }
+ }
+ return identifications;
+ }
+
+ private JsonNode getSubJsonAbcd(JsonNode data, int count, String path) {
+ var identificationNode = mapper.createObjectNode();
+ data.fields().forEachRemaining(field -> {
+ if (field.getKey().startsWith(path + count)) {
+ identificationNode.set(
+ field.getKey().replace(path + count + "/", ""),
+ field.getValue());
+ }
+ });
+ return identificationNode;
+ }
+
+ private List gatherDwcaIdentifications(
+ JsonNode data, boolean dwc) {
+ var mappedIdentifications = new ArrayList();
+ if (data.get(EXTENSION) != null
+ && data.get(EXTENSION).get("dwc:Identification") != null) {
+ var identifications = data.get(EXTENSION).get("dwc:Identification");
+ for (int i = 0; i < identifications.size(); i++) {
+ var identification = identifications.get(i);
+ mappedIdentifications.add(createIdentification(identification, dwc));
+ }
+ } else {
+ mappedIdentifications.add(createIdentification(data, dwc));
+ }
+ return mappedIdentifications;
+ }
+
+ private Identifications createIdentification(JsonNode data, boolean dwc) {
+ var mappedTaxonIdentification = new TaxonIdentification()
+ .withDwcTaxonID(termMapper.retrieveTerm(new TaxonId(), data, dwc))
+ .withDwcKingdom(termMapper.retrieveTerm(new Kingdom(), data, dwc))
+ .withDwcTaxonRank(termMapper.retrieveTerm(new TaxonRank(), data, dwc))
+ .withDwcGenus(termMapper.retrieveTerm(new Genus(), data, dwc))
+ .withDwcSubgenus(termMapper.retrieveTerm(new Subgenus(), data, dwc))
+ .withDwcOrder(termMapper.retrieveTerm(new Order(), data, dwc))
+ .withDwcScientificName(termMapper.retrieveTerm(new ScientificName(), data, dwc))
+ .withDwcScientificNameAuthorship(
+ termMapper.retrieveTerm(new ScientificNameAuthorship(), data, dwc))
+ .withDwcNamePublishedInYear(termMapper.retrieveTerm(new NamePublishedInYear(), data, dwc))
+ .withDwcClass(termMapper.retrieveTerm(new Class(), data, dwc))
+ .withDwcFamily(termMapper.retrieveTerm(new Family(), data, dwc))
+ .withDwcSubfamily(termMapper.retrieveTerm(new Subfamily(), data, dwc))
+ .withDwcPhylum(termMapper.retrieveTerm(new Phylum(), data, dwc))
+ .withDwcNameAccordingTo(termMapper.retrieveTerm(new NameAccordingTo(), data, dwc))
+ .withDwcSpecificEpithet(termMapper.retrieveTerm(new SpecificEpithet(), data, dwc))
+ .withDwcTaxonomicStatus(termMapper.retrieveTerm(new TaxonomicStatus(), data, dwc))
+ .withDwcNomenclaturalCode(termMapper.retrieveTerm(new NomenclaturalCode(), data, dwc))
+ .withDwcTaxonRemarks(termMapper.retrieveTerm(new TaxonRemarks(), data, dwc))
+ .withDwcVernacularName(termMapper.retrieveTerm(new VernacularName(), data, dwc));
+ return new Identifications()
+ .withDwcIdentificationID(termMapper.retrieveTerm(new IdentificationId(), data, dwc))
+ .withDwcIdentificationVerificationStatus(Boolean.valueOf(
+ termMapper.retrieveTerm(new IdentificationVerificationStatus(), data, dwc)))
+ .withDwcTypeStatus(termMapper.retrieveTerm(new TypeStatus(), data, dwc))
+ .withDwcDateIdentified(termMapper.retrieveTerm(new DateIdentified(), data, dwc))
+ .withDwcIdentifiedBy(termMapper.retrieveTerm(new IdentifiedBy(), data, dwc))
+ .withDwcIdentificationRemarks(
+ termMapper.retrieveTerm(new IdentificationRemarks(), data, dwc))
+ .withDwcVerbatimIdentification(
+ termMapper.retrieveTerm(new VerbatimIdentification(), data, dwc))
+ .withTaxonIdentifications(List.of(mappedTaxonIdentification))
+ .withCitations(assembleIdentificationCitations(data, dwc));
+ }
+
+
+ private List assembleOccurrenceTerms(JsonNode data,
+ boolean dwc) {
+ var georeference = new Georeference()
+ .withDwcDecimalLatitude(
+ parseToDouble(new DecimalLatitude(), data, dwc))
+ .withDwcDecimalLongitude(parseToDouble(new DecimalLongitude(), data, dwc))
+ .withDwcGeodeticDatum(termMapper.retrieveTerm(new GeodeticDatum(), data, dwc))
+ .withDwcGeoreferenceProtocol(termMapper.retrieveTerm(new GeoreferenceProtocol(), data, dwc))
+ .withDwcCoordinatePrecision(parseToDouble(new CoordinatePrecision(), data, dwc))
+ .withDwcCoordinateUncertaintyInMeters(
+ parseToDouble(new CoordinateUncertaintyInMeters(), data, dwc))
+ .withDwcFootprintSrs(termMapper.retrieveTerm(new FootprintSrs(), data, dwc))
+ .withDwcFootprintSpatialFit(parseToInteger(new FootprintSpatialFit(), data, dwc))
+ .withDwcGeoreferencedBy(termMapper.retrieveTerm(new GeoreferencedBy(), data, dwc))
+ .withDwcFootprintWkt(termMapper.retrieveTerm(new FootprintWkt(), data, dwc))
+ .withDwcGeoreferencedDate(termMapper.retrieveTerm(new GeoreferencedDate(), data, dwc))
+ .withDwcGeoreferenceRemarks(termMapper.retrieveTerm(new GeoreferenceRemarks(), data, dwc))
+ .withDwcGeoreferenceSources(termMapper.retrieveTerm(new GeoreferenceSources(), data, dwc))
+ .withDwcPointRadiusSpatialFit(parseToDouble(new PointRadiusSpatialFit(), data, dwc));
+ var geologicalContext = new eu.dissco.core.translator.schema.GeologicalContext()
+ .withDwcLowestBiostratigraphicZone(
+ termMapper.retrieveTerm(new LowestBiostratigraphicZone(), data, dwc))
+ .withDwcHighestBiostratigraphicZone(
+ termMapper.retrieveTerm(new HighestBiostratigraphicZone(), data, dwc))
+ .withDwcEarliestAgeOrLowestStage(
+ termMapper.retrieveTerm(new EarliestAgeOrLowestStage(), data, dwc))
+ .withDwcLatestAgeOrHighestStage(
+ termMapper.retrieveTerm(new LatestAgeOrHighestStage(), data, dwc))
+ .withDwcEarliestEpochOrLowestSeries(
+ termMapper.retrieveTerm(new EarliestEpochOrLowestSeries(), data, dwc))
+ .withDwcLatestEpochOrHighestSeries(
+ termMapper.retrieveTerm(new LatestEpochOrHighestSeries(), data, dwc))
+ .withDwcEarliestEraOrLowestErathem(
+ termMapper.retrieveTerm(new EarliestEraOrLowestErathem(), data, dwc))
+ .withDwcLatestEraOrHighestErathem(
+ termMapper.retrieveTerm(new LatestEraOrHighestErathem(), data, dwc))
+ .withDwcEarliestPeriodOrLowestSystem(
+ termMapper.retrieveTerm(new EarliestPeriodOrLowestSystem(), data, dwc))
+ .withDwcLatestPeriodOrHighestSystem(
+ termMapper.retrieveTerm(new LatestPeriodOrHighestSystem(), data, dwc))
+ .withDwcLatestEonOrHighestEonothem(
+ termMapper.retrieveTerm(new LatestEonOrHighestEonothem(), data, dwc))
+ .withDwcEarliestEonOrLowestEonothem(
+ termMapper.retrieveTerm(new EarliestEonOrLowestEonothem(), data, dwc))
+ .withDwcLithostratigraphicTerms(
+ termMapper.retrieveTerm(new LithostratigraphicTerms(), data, dwc))
+ .withDwcBed(termMapper.retrieveTerm(new Bed(), data, dwc))
+ .withDwcFormation(termMapper.retrieveTerm(new Formation(), data, dwc))
+ .withDwcGroup(termMapper.retrieveTerm(new Group(), data, dwc))
+ .withDwcMember(termMapper.retrieveTerm(new Member(), data, dwc));
+ var location = new eu.dissco.core.translator.schema.Location()
+ .withDwcContinent(termMapper.retrieveTerm(new Continent(), data, dwc))
+ .withDwcCountry(termMapper.retrieveTerm(new Country(), data, dwc))
+ .withDwcCountryCode(termMapper.retrieveTerm(new CountryCode(), data, dwc))
+ .withDwcCounty(termMapper.retrieveTerm(new County(), data, dwc))
+ .withDwcIsland(termMapper.retrieveTerm(new Island(), data, dwc))
+ .withDwcIslandGroup(termMapper.retrieveTerm(new IslandGroup(), data, dwc))
+ .withDwcMunicipality(termMapper.retrieveTerm(new Municipality(), data, dwc))
+ .withDwcLocality(termMapper.retrieveTerm(new Locality(), data, dwc))
+ .withDwcStateProvince(termMapper.retrieveTerm(new StateProvince(), data, dwc))
+ .withDwcWaterBody(termMapper.retrieveTerm(new WaterBody(), data, dwc))
+ .withDwcHigherGeography(termMapper.retrieveTerm(new HigherGeography(), data, dwc))
+ .withDwcMaximumDepthInMeters(parseToDouble(new MaximumDepthInMeters(), data, dwc))
+ .withDwcMaximumDistanceAboveSurfaceInMeters(
+ parseToDouble(new MaximumDistanceAboveSurfaceInMeters(), data, dwc))
+ .withDwcMaximumElevationInMeters(parseToDouble(new MaximumElevationInMeters(), data, dwc))
+ .withDwcMinimumDepthInMeters(parseToDouble(new MinimumDepthInMeters(), data, dwc))
+ .withDwcMinimumDistanceAboveSurfaceInMeters(
+ parseToDouble(new MinimumDistanceAboveSurfaceInMeters(), data, dwc))
+ .withDwcMinimumElevationInMeters(parseToDouble(new MinimumElevationInMeters(), data, dwc))
+ .withDwcVerticalDatum(termMapper.retrieveTerm(new VerticalDatum(), data, dwc))
+ .withDwcLocationAccordingTo(termMapper.retrieveTerm(new LocationAccordingTo(), data, dwc))
+ .withDwcLocationRemarks(termMapper.retrieveTerm(new LocationRemarks(), data, dwc))
+ .withGeoreference(georeference)
+ .withGeologicalContext(geologicalContext);
+ var assertions = new OccurrenceAssertions().gatherOccurrenceAssertions(mapper, data, dwc);
+ var occurrence = new eu.dissco.core.translator.schema.Occurrences()
+ .withDwcFieldNumber(termMapper.retrieveTerm(new FieldNumber(), data, dwc))
+ .withDwcEventDate(termMapper.retrieveTerm(new EventDate(), data, dwc))
+ .withDwcSex(termMapper.retrieveTerm(new Sex(), data, dwc))
+ .withDwcOrganismQuantity(termMapper.retrieveTerm(new OrganismQuantity(), data, dwc))
+ .withDwcOrganismQuantityType(termMapper.retrieveTerm(new OrganismQuantityType(), data, dwc))
+ .withDwcSamplingProtocol(termMapper.retrieveTerm(new SamplingProtocol(), data, dwc))
+ .withDwcLifeStage(termMapper.retrieveTerm(new LifeStage(), data, dwc))
+ .withDwcEventRemarks(termMapper.retrieveTerm(new EventRemark(), data, dwc))
+ .withDwcFieldNumber(termMapper.retrieveTerm(new FieldNumber(), data, dwc))
+ .withDwcFieldNotes(termMapper.retrieveTerm(new FieldNotes(), data, dwc))
+ .withDwcHabitat(termMapper.retrieveTerm(new Habitat(), data, dwc))
+ .withDwcReproductiveCondition(
+ termMapper.retrieveTerm(new ReproductiveCondition(), data, dwc))
+ .withDwcBehavior(termMapper.retrieveTerm(new Behavior(), data, dwc))
+ .withDwcEstablishmentMeans(termMapper.retrieveTerm(new EstablishmentMeans(), data, dwc))
+ .withDwcPathway(termMapper.retrieveTerm(new Pathway(), data, dwc))
+ .withDwcDegreeOfEstablishment(
+ termMapper.retrieveTerm(new DegreeOfEstablishment(), data, dwc))
+ .withDwcGeoreferenceVerificationStatus(
+ termMapper.retrieveTerm(new GeoreferenceVerificationStatus(), data, dwc))
+ .withDwcOccurrenceStatus(
+ retrieveEnum(new OccurrenceStatus(), data, dwc, DwcOccurrenceStatus.class))
+ .withDwcOccurrenceRemarks(termMapper.retrieveTerm(new OccurrenceRemarks(), data, dwc))
+ .withDwcInformationWithheld(termMapper.retrieveTerm(new InformationWithheld(), data, dwc))
+ .withDwcDataGeneralizations(termMapper.retrieveTerm(new DataGeneralizations(), data, dwc))
+ .withDwcSampleSizeUnit(termMapper.retrieveTerm(new SampleSizeUnit(), data, dwc))
+ .withDwcSampleSizeValue(termMapper.retrieveTerm(new SampleSizeValue(), data, dwc))
+ .withLocation(location)
+ .withAssertions(assertions);
+
+ return List.of(occurrence);
+ }
+
+ private > T retrieveEnum(Term term, JsonNode data, boolean dwc,
+ java.lang.Class enumClass) {
+ var value = termMapper.retrieveTerm(new OccurrenceStatus(), data, dwc);
+ try {
+ if (value != null) {
+ return Enum.valueOf(enumClass, value.toUpperCase());
+ }
+ } catch (IllegalArgumentException ex) {
+ log.warn("Unable to parse value: {} to an enum for term: {}", value, term.getTerm());
+ }
+ return null;
+ }
+
+ private Integer parseToInteger(Term term, JsonNode data, boolean dwc) {
+ var value = termMapper.retrieveTerm(term, data, dwc);
+ try {
+ if (value != null) {
+ return Integer.valueOf(value);
+ }
+ } catch (NumberFormatException ex) {
+ log.warn("Unable to parse value: {} to an integer for term: {}", value, term.getTerm());
+ }
+ return null;
+ }
+
+ private Double parseToDouble(Term term, JsonNode data, boolean dwc) {
+ var value = termMapper.retrieveTerm(term, data, dwc);
+ try {
+ if (value != null) {
+ return Double.valueOf(value);
+ }
+ } catch (NumberFormatException ex) {
+ log.warn("Unable to parse value: {} to a double for term: {}", value, term.getTerm());
+ }
+ return null;
+ }
+
+ private Boolean parseToBoolean(Term term, JsonNode data, boolean dwc) {
+ var value = termMapper.retrieveTerm(term, data, dwc);
+ try {
+ if (value != null) {
+ return Boolean.valueOf(value);
+ }
+ } catch (NumberFormatException ex) {
+ log.warn("Unable to parse value: {} to a boolean for term: {}", value, term.getTerm());
+ }
+ return null;
+ }
+
+ private String minifyOrganisationId(String organisationId) throws OrganisationNotRorId {
+ if (organisationId.startsWith("https://ror.org")) {
+ return organisationId.replace("https://ror.org/", "");
+ } else {
+ throw new OrganisationNotRorId(organisationId + " is not a valid ror");
+ }
+ }
+
+ public DigitalEntity assembleDigitalMediaObjects(boolean dwc,
+ JsonNode mediaRecord, String organisationId) throws OrganisationNotRorId {
+ var digitalMedioObject = new DigitalEntity()
+ .withDwcInstitutionId(organisationId)
+ .withDwcInstitutionName(rorComponent.getRorName(minifyOrganisationId(organisationId)))
+ .withAcAccessUri(termMapper.retrieveTerm(new AccessUri(), mediaRecord, dwc))
+ .withDctermsLicense(termMapper.retrieveTerm(new License(), mediaRecord, dwc))
+ .withDctermsFormat(termMapper.retrieveTerm(new Format(), mediaRecord, dwc))
+ .withDctermsType(retrieveEnum(new MediaType(), mediaRecord, dwc, DctermsType.class))
+ .withXmpRightsWebStatement(termMapper.retrieveTerm(new WebStatement(), mediaRecord, dwc))
+ .withDctermsRights(termMapper.retrieveTerm(new Rights(), mediaRecord, dwc))
+ .withDctermsAccessRights(
+ termMapper.retrieveTerm(new eu.dissco.core.translator.terms.media.AccessRights(),
+ mediaRecord, dwc))
+ .withDctermsRightsHolder(
+ termMapper.retrieveTerm(new eu.dissco.core.translator.terms.media.RightsHolder(),
+ mediaRecord, dwc))
+ .withDctermsSource(termMapper.retrieveTerm(new Source(), mediaRecord, dwc))
+ .withDctermsCreator(termMapper.retrieveTerm(new Creator(), mediaRecord, dwc))
+ .withDctermsCreated(termMapper.retrieveTerm(new Created(), mediaRecord, dwc))
+ .withDctermsModified(
+ termMapper.retrieveTerm(new eu.dissco.core.translator.terms.media.Modified(),
+ mediaRecord, dwc))
+ .withDctermsDescription(termMapper.retrieveTerm(new Description(), mediaRecord, dwc))
+ .withIdentifiers(assembleIdentifiers(mediaRecord))
+ .withAssertions(new MediaAssertions().gatherAssertions(mediaRecord, dwc));
+ digitalMedioObject.withEntityRelationships(
+ assembleDigitalMediaObjectEntityRelationships(digitalMedioObject));
+ return digitalMedioObject;
+ }
+
+ private List assembleDigitalMediaObjectEntityRelationships(
+ eu.dissco.core.translator.schema.DigitalEntity digitalMediaObject) {
+ var relationships = new ArrayList();
+ relationships.add(new EntityRelationships().withEntityRelationshipType("hasUrl")
+ .withObjectEntityIri(digitalMediaObject.getAcAccessUri()));
+ relationships.add(new EntityRelationships().withEntityRelationshipType("hasOrganisationId")
+ .withObjectEntityIri(digitalMediaObject.getDwcInstitutionId()));
+ relationships.add(new EntityRelationships().withEntityRelationshipType("hasFdoType")
+ .withObjectEntityIri(fdoProperties.getDigitalMediaObjectType()));
+ if (digitalMediaObject.getDctermsLicense() != null && digitalMediaObject.getDctermsLicense()
+ .startsWith("http")) {
+ relationships.add(
+ new EntityRelationships().withEntityRelationshipType("hasLicense")
+ .withObjectEntityIri(digitalMediaObject.getDctermsLicense()));
+ }
+ if (digitalMediaObject.getDctermsSource() != null && digitalMediaObject.getDctermsSource()
+ .startsWith("http")) {
+ relationships.add(new EntityRelationships().withEntityRelationshipType("hasSource")
+ .withObjectEntityIri(digitalMediaObject.getDctermsLicense()));
+ }
+ return relationships;
+ }
+
+ private String getNormalisedPhysicalSpecimenId(OdsPhysicalSpecimenIdType physicalSpecimenIdType,
+ String sourceSystemId, String physicalSpecimenId) {
+ if (physicalSpecimenIdType.equals(OdsPhysicalSpecimenIdType.GLOBAL)
+ || physicalSpecimenIdType.equals(OdsPhysicalSpecimenIdType.RESOLVABLE)) {
+ return physicalSpecimenId;
+ } else {
+ var minifiedSourceSystemId = sourceSystemId.substring(sourceSystemId.indexOf('/') + 1);
+ return physicalSpecimenId + ":" + minifiedSourceSystemId;
+ }
+ }
+
+ private OdsPhysicalSpecimenIdType convertToPhysicalSpecimenIdTypeEnum(
+ String physicalSpecimenIdType) throws UnknownPhysicalSpecimenIdType {
+ try {
+ return OdsPhysicalSpecimenIdType.valueOf(physicalSpecimenIdType.toUpperCase());
+ } catch (IllegalArgumentException e) {
+ log.warn("Unknown physicalSpecimenIdType specified");
+ throw new UnknownPhysicalSpecimenIdType(
+ "Physical specimen ID type is: " + physicalSpecimenIdType
+ + " which is not a known id type");
+ } catch (NullPointerException e) {
+ log.warn("No physicalSpecimenIdType specified");
+ throw new UnknownPhysicalSpecimenIdType("Physical specimen ID type is empty");
+ }
+ }
+
+}
+
+
diff --git a/src/main/java/eu/dissco/core/translator/terms/License.java b/src/main/java/eu/dissco/core/translator/terms/License.java
index c3b2792..825e2ea 100644
--- a/src/main/java/eu/dissco/core/translator/terms/License.java
+++ b/src/main/java/eu/dissco/core/translator/terms/License.java
@@ -7,26 +7,17 @@
@Slf4j
public class License extends Term {
- public static final String TERM = "dcterms:license";
+ public static final String TERM = DCTERMS_PREFIX + "license";
private final List dwcaTerms = List.of(TERM, "dc:license");
- private final List abcdUnitTerms = List.of("abcd:iprstatements/licenses/license/0/uri",
- "abcd:iprstatements/licenses/license/0/text");
- private final List abcdMetaTerms = List.of(
- "abcd:metadata/iprstatements/licenses/license/0/uri",
- "abcd:metadata/iprstatements/licenses/license/0/text");
+ private final List abcdUnitTerms = List.of(
+ "abcd:iprstatements/licenses/license/0/uri",
+ "abcd:iprstatements/licenses/license/0/text",
+ "abcd:ipr/licenses/license/0/uri",
+ "abcd:ipr/licenses/license/0/text");
@Override
public String retrieveFromDWCA(JsonNode unit) {
- return super.searchJsonForStringTerm(unit, dwcaTerms);
- }
-
- @Override
- public String retrieveFromABCD(JsonNode dataset, JsonNode unit) {
- var license = searchJsonForStringTerm(unit, abcdUnitTerms);
- if (license == null) {
- license = searchJsonForStringTerm(dataset, abcdMetaTerms);
- }
- return license;
+ return super.searchJsonForTerm(unit, dwcaTerms);
}
@Override
@@ -34,4 +25,8 @@ public String getTerm() {
return TERM;
}
+ @Override
+ public String retrieveFromABCD(JsonNode unit) {
+ return searchJsonForTerm(unit, abcdUnitTerms);
+ }
}
diff --git a/src/main/java/eu/dissco/core/translator/terms/Term.java b/src/main/java/eu/dissco/core/translator/terms/Term.java
index 46f760b..8a8a1cd 100644
--- a/src/main/java/eu/dissco/core/translator/terms/Term.java
+++ b/src/main/java/eu/dissco/core/translator/terms/Term.java
@@ -2,6 +2,7 @@
import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Pair;
@@ -11,25 +12,37 @@ public abstract class Term {
protected static final String ODS_PREFIX = "ods:";
protected static final String DWC_PREFIX = "dwc:";
+ protected static final String DCTERMS_PREFIX = "dcterms:";
+ protected static final String ABCD_PREFIX = "abcd:";
+ protected static final Pair ABCD_NAMED_AREA_KEY =
+ Pair.of(
+ "abcd:gathering/namedAreas/namedArea/",
+ "/areaClass/value");
+ protected static final Pair ABCD_NAMED_AREA_VALUE =
+ Pair.of(
+ "abcd:gathering/namedAreas/namedArea/",
+ "/areaName/value");
private static final String MESSAGE = "No specific attributes retrieve specified for field: {}";
- protected String searchJsonForStringTerm(JsonNode attributes, List originalTerms) {
+ protected String searchJsonForTerm(JsonNode attributes, List originalTerms) {
for (var originalTerm : originalTerms) {
var valueNode = attributes.get(originalTerm);
- if (valueNode != null && valueNode.isTextual()) {
- return attributes.get(originalTerm).asText();
- }
- }
- log.debug("Term not found in any of these search fields: {}", originalTerms);
- return null;
- }
-
- protected String searchJsonForLongTerm(JsonNode attributes, List originalTerms) {
- for (var originalTerm : originalTerms) {
- var valueNode = attributes.get(originalTerm);
- if (valueNode != null && valueNode.isLong()) {
- var longValue = attributes.get(originalTerm).asLong();
- return String.valueOf(longValue);
+ if (valueNode != null) {
+ if (valueNode.isTextual()) {
+ return attributes.get(originalTerm).asText();
+ } else if (valueNode.isLong()) {
+ var longValue = attributes.get(originalTerm).asLong();
+ return String.valueOf(longValue);
+ } else if (valueNode.isBoolean()) {
+ var boolValue = attributes.get(originalTerm).asBoolean();
+ return String.valueOf(boolValue);
+ } else if (valueNode.isDouble() || valueNode.isBigDecimal()) {
+ var doubleValue = attributes.get(originalTerm).asDouble();
+ return String.valueOf(doubleValue);
+ } else if (valueNode.isInt() || valueNode.isBigInteger()) {
+ var intValue = attributes.get(originalTerm).asInt();
+ return String.valueOf(intValue);
+ }
}
}
log.debug("Term not found in any of these search fields: {}", originalTerms);
@@ -40,7 +53,7 @@ protected String combineABCDTerms(JsonNode unit, List abcdTerms) {
var builder = new StringBuilder();
for (var abcdTerm : abcdTerms) {
if (unit.get(abcdTerm) != null) {
- if (builder.length() != 0) {
+ if (!builder.isEmpty()) {
builder.append(" | ");
}
builder.append(unit.get(abcdTerm).asText());
@@ -53,6 +66,18 @@ protected String combineABCDTerms(JsonNode unit, List abcdTerms) {
}
}
+ protected JsonNode getSubJsonAbcd(ObjectMapper mapper, JsonNode data, int count, String path) {
+ var identificationNode = mapper.createObjectNode();
+ data.fields().forEachRemaining(field -> {
+ if (field.getKey().startsWith(path + count)) {
+ identificationNode.set(
+ field.getKey().replace(path + count + "/", ""),
+ field.getValue());
+ }
+ });
+ return identificationNode;
+ }
+
public abstract String getTerm();
public String retrieveFromABCD(JsonNode unit) {
@@ -60,11 +85,6 @@ public String retrieveFromABCD(JsonNode unit) {
return null;
}
- public String retrieveFromABCD(JsonNode dataset, JsonNode unit) {
- log.debug(MESSAGE, getTerm());
- return null;
- }
-
public String retrieveFromDWCA(JsonNode unit) {
log.debug(MESSAGE, getTerm());
return null;
@@ -90,7 +110,19 @@ protected String searchABCDSplitTerms(JsonNode unit, List searchTerms,
}
}
}
- log.debug("No stratigraphy found for division: {}", searchTerms);
+ log.debug("No value found for division: {}", searchTerms);
+ return null;
+ }
+
+ protected eu.dissco.core.translator.schema.Identifications retrieveAcceptedIdentification(
+ eu.dissco.core.translator.schema.DigitalSpecimen ds) {
+ if (ds.getDwcIdentification() != null && !ds.getDwcIdentification().isEmpty()) {
+ for (var identification : ds.getDwcIdentification()) {
+ if (Boolean.TRUE.equals(identification.getDwcIdentificationVerificationStatus())) {
+ return identification;
+ }
+ }
+ }
return null;
}
}
diff --git a/src/main/java/eu/dissco/core/translator/terms/TermMapper.java b/src/main/java/eu/dissco/core/translator/terms/TermMapper.java
index 195f9ce..134e5c5 100644
--- a/src/main/java/eu/dissco/core/translator/terms/TermMapper.java
+++ b/src/main/java/eu/dissco/core/translator/terms/TermMapper.java
@@ -2,59 +2,6 @@
import com.fasterxml.jackson.databind.JsonNode;
import eu.dissco.core.translator.component.MappingComponent;
-import eu.dissco.core.translator.terms.specimen.BasisOfRecord;
-import eu.dissco.core.translator.terms.specimen.CollectingNumber;
-import eu.dissco.core.translator.terms.specimen.Collector;
-import eu.dissco.core.translator.terms.specimen.DatasetId;
-import eu.dissco.core.translator.terms.specimen.DateCollected;
-import eu.dissco.core.translator.terms.specimen.HasMedia;
-import eu.dissco.core.translator.terms.specimen.LivingOrPreserved;
-import eu.dissco.core.translator.terms.specimen.Modified;
-import eu.dissco.core.translator.terms.specimen.ObjectType;
-import eu.dissco.core.translator.terms.specimen.PhysicalSpecimenCollection;
-import eu.dissco.core.translator.terms.specimen.TopicDiscipline;
-import eu.dissco.core.translator.terms.specimen.location.Continent;
-import eu.dissco.core.translator.terms.specimen.location.Country;
-import eu.dissco.core.translator.terms.specimen.location.CountryCode;
-import eu.dissco.core.translator.terms.specimen.location.County;
-import eu.dissco.core.translator.terms.specimen.location.DecimalLatitude;
-import eu.dissco.core.translator.terms.specimen.location.DecimalLongitude;
-import eu.dissco.core.translator.terms.specimen.location.GeodeticDatum;
-import eu.dissco.core.translator.terms.specimen.location.Island;
-import eu.dissco.core.translator.terms.specimen.location.IslandGroup;
-import eu.dissco.core.translator.terms.specimen.location.Locality;
-import eu.dissco.core.translator.terms.specimen.location.StateProvince;
-import eu.dissco.core.translator.terms.specimen.location.WaterBody;
-import eu.dissco.core.translator.terms.specimen.stratigraphy.biostratigraphic.HighestBiostratigraphicZone;
-import eu.dissco.core.translator.terms.specimen.stratigraphy.biostratigraphic.LowestBiostratigraphicZone;
-import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.EarliestAgeOrLowestStage;
-import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.EarliestEonOrLowestEonothem;
-import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.EarliestEpochOrLowestSeries;
-import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.EarliestEraOrLowestErathem;
-import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.EarliestPeriodOrLowestSystem;
-import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.LatestAgeOrHighestStage;
-import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.LatestEonOrHighestEonothem;
-import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.LatestEpochOrHighestSeries;
-import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.LatestEraOrHighestErathem;
-import eu.dissco.core.translator.terms.specimen.stratigraphy.chronostratigraphic.LatestPeriodOrHighestSystem;
-import eu.dissco.core.translator.terms.specimen.stratigraphy.lithostratigraphic.Bed;
-import eu.dissco.core.translator.terms.specimen.stratigraphy.lithostratigraphic.Formation;
-import eu.dissco.core.translator.terms.specimen.stratigraphy.lithostratigraphic.Group;
-import eu.dissco.core.translator.terms.specimen.stratigraphy.lithostratigraphic.Member;
-import eu.dissco.core.translator.terms.specimen.taxonomy.Class;
-import eu.dissco.core.translator.terms.specimen.taxonomy.Family;
-import eu.dissco.core.translator.terms.specimen.taxonomy.Genus;
-import eu.dissco.core.translator.terms.specimen.taxonomy.InfraspecificEpithet;
-import eu.dissco.core.translator.terms.specimen.taxonomy.Kingdom;
-import eu.dissco.core.translator.terms.specimen.taxonomy.Order;
-import eu.dissco.core.translator.terms.specimen.taxonomy.Phylum;
-import eu.dissco.core.translator.terms.specimen.taxonomy.ScientificNameAuthorship;
-import eu.dissco.core.translator.terms.specimen.taxonomy.SpecificEpithet;
-import eu.dissco.core.translator.terms.specimen.taxonomy.SpecimenName;
-import eu.dissco.core.translator.terms.specimen.taxonomy.TaxonRank;
-import eu.dissco.core.translator.terms.specimen.taxonomy.TypeStatus;
-import java.util.ArrayList;
-import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -66,117 +13,24 @@ public class TermMapper {
private final MappingComponent mapping;
- public static List locationTerms() {
- var list = new ArrayList();
- list.add(new Continent());
- list.add(new Country());
- list.add(new CountryCode());
- list.add(new County());
- list.add(new DecimalLatitude());
- list.add(new DecimalLongitude());
- list.add(new GeodeticDatum());
- list.add(new Island());
- list.add(new IslandGroup());
- list.add(new Locality());
- list.add(new StateProvince());
- list.add(new WaterBody());
- return list;
- }
-
- private static List stratigraphyTerms() {
- var list = new ArrayList();
- list.add(new EarliestAgeOrLowestStage());
- list.add(new EarliestEonOrLowestEonothem());
- list.add(new EarliestEpochOrLowestSeries());
- list.add(new EarliestEraOrLowestErathem());
- list.add(new EarliestPeriodOrLowestSystem());
- list.add(new LatestAgeOrHighestStage());
- list.add(new LatestEonOrHighestEonothem());
- list.add(new LatestEpochOrHighestSeries());
- list.add(new LatestEraOrHighestErathem());
- list.add(new LatestPeriodOrHighestSystem());
- list.add(new Bed());
- list.add(new Formation());
- list.add(new Group());
- list.add(new Member());
- list.add(new HighestBiostratigraphicZone());
- list.add(new LowestBiostratigraphicZone());
- return list;
- }
-
- public static List harmonisedTerms() {
- var list = new ArrayList();
- list.add(new PhysicalSpecimenCollection());
- list.add(new DatasetId());
- list.add(new ObjectType());
- list.add(new DateCollected());
- list.add(new CollectingNumber());
- list.add(new Collector());
- list.add(new TypeStatus());
- list.add(new HasMedia());
- list.add(new BasisOfRecord());
- list.add(new LivingOrPreserved());
- list.add(new TopicDiscipline());
- list.addAll(locationTerms());
- list.addAll(stratigraphyTerms());
- list.addAll(taxonomyTerms());
- return list;
- }
-
- public static List taxonomyTerms() {
- var list = new ArrayList();
- list.add(new SpecimenName());
- list.add(new Class());
- list.add(new Family());
- list.add(new Genus());
- list.add(new InfraspecificEpithet());
- list.add(new Kingdom());
- list.add(new Order());
- list.add(new Phylum());
- list.add(new ScientificNameAuthorship());
- list.add(new SpecificEpithet());
- list.add(new TaxonRank());
- return list;
- }
-
- public static List abcdHarmonisedTerms() {
- return harmonisedTerms();
- }
-
- public static List dwcaHarmonisedTerms() {
- var terms = harmonisedTerms();
- terms.add(new License());
- terms.add(new Modified());
- return terms;
- }
-
- public String retrieveFromDWCA(Term term, JsonNode unit) {
+ public String retrieveTerm(Term term, JsonNode unit, boolean dwc) {
var termName = term.getTerm();
- if (mapping.getDefaultMappings().containsKey(termName)) {
- return mapping.getDefaultMappings().get(termName);
+ if (mapping.getDefaults().containsKey(termName)) {
+ return mapping.getDefaults().get(termName);
} else if (mapping.getFieldMappings().containsKey(termName)) {
var value = unit.get(mapping.getFieldMappings().get(termName));
if (value != null && value.isTextual()) {
return value.asText();
+ } else {
+ log.info("No value for the specific field mapping for term: {} with mapping: {}",
+ term.getTerm(), value);
}
}
- return term.retrieveFromDWCA(unit);
- }
-
- public String retrieveFromABCD(Term term, JsonNode unit) {
- var termName = term.getTerm();
- if (mapping.getDefaultMappings().containsKey(termName)) {
- return mapping.getDefaultMappings().get(termName);
- } else if (mapping.getFieldMappings().containsKey(termName)) {
- var value = unit.get(mapping.getFieldMappings().get(termName));
- if (value != null && value.isTextual()) {
- return value.asText();
- }
+ if (dwc) {
+ return term.retrieveFromDWCA(unit);
+ } else {
+ return term.retrieveFromABCD(unit);
}
- return term.retrieveFromABCD(unit);
}
- public String retrieveFromABCD(Term term, JsonNode dataset, JsonNode unit) {
- return term.retrieveFromABCD(dataset, unit);
- }
}
diff --git a/src/main/java/eu/dissco/core/translator/terms/media/AccessRights.java b/src/main/java/eu/dissco/core/translator/terms/media/AccessRights.java
new file mode 100644
index 0000000..715eea9
--- /dev/null
+++ b/src/main/java/eu/dissco/core/translator/terms/media/AccessRights.java
@@ -0,0 +1,22 @@
+package eu.dissco.core.translator.terms.media;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import eu.dissco.core.translator.terms.Term;
+import java.util.List;
+
+public class AccessRights extends Term {
+
+ public static final String TERM = DCTERMS_PREFIX + "accessRights";
+
+ private final List dwcaTerms = List.of(TERM);
+
+ @Override
+ public String retrieveFromDWCA(JsonNode unit) {
+ return super.searchJsonForTerm(unit, dwcaTerms);
+ }
+
+ @Override
+ public String getTerm() {
+ return TERM;
+ }
+}
diff --git a/src/main/java/eu/dissco/core/translator/terms/media/AccessUri.java b/src/main/java/eu/dissco/core/translator/terms/media/AccessUri.java
index 62a2f1b..7588a8e 100644
--- a/src/main/java/eu/dissco/core/translator/terms/media/AccessUri.java
+++ b/src/main/java/eu/dissco/core/translator/terms/media/AccessUri.java
@@ -12,12 +12,12 @@ public class AccessUri extends Term {
@Override
public String retrieveFromDWCA(JsonNode unit) {
- return super.searchJsonForStringTerm(unit, dwcaTerms);
+ return super.searchJsonForTerm(unit, dwcaTerms);
}
@Override
public String retrieveFromABCD(JsonNode unit) {
- return super.searchJsonForStringTerm(unit, abcdTerms);
+ return super.searchJsonForTerm(unit, abcdTerms);
}
@Override
diff --git a/src/main/java/eu/dissco/core/translator/terms/media/Created.java b/src/main/java/eu/dissco/core/translator/terms/media/Created.java
new file mode 100644
index 0000000..37de421
--- /dev/null
+++ b/src/main/java/eu/dissco/core/translator/terms/media/Created.java
@@ -0,0 +1,27 @@
+package eu.dissco.core.translator.terms.media;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import eu.dissco.core.translator.terms.Term;
+import java.util.List;
+
+public class Created extends Term {
+
+ public static final String TERM = "dcterms:created";
+ private final List dwcaTerms = List.of(TERM);
+ private final List abcdTerms = List.of("abcd:createdDate");
+
+ @Override
+ public String retrieveFromDWCA(JsonNode unit) {
+ return super.searchJsonForTerm(unit, dwcaTerms);
+ }
+
+ @Override
+ public String retrieveFromABCD(JsonNode unit) {
+ return super.searchJsonForTerm(unit, abcdTerms);
+ }
+
+ @Override
+ public String getTerm() {
+ return TERM;
+ }
+}
diff --git a/src/main/java/eu/dissco/core/translator/terms/media/Creator.java b/src/main/java/eu/dissco/core/translator/terms/media/Creator.java
new file mode 100644
index 0000000..c41dd7e
--- /dev/null
+++ b/src/main/java/eu/dissco/core/translator/terms/media/Creator.java
@@ -0,0 +1,27 @@
+package eu.dissco.core.translator.terms.media;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import eu.dissco.core.translator.terms.Term;
+import java.util.List;
+
+public class Creator extends Term {
+
+ public static final String TERM = "dcterms:creator";
+ private final List dwcaTerms = List.of(TERM);
+ private final List abcdTerms = List.of("abcd:creator");
+
+ @Override
+ public String retrieveFromDWCA(JsonNode unit) {
+ return super.searchJsonForTerm(unit, dwcaTerms);
+ }
+
+ @Override
+ public String retrieveFromABCD(JsonNode unit) {
+ return super.searchJsonForTerm(unit, abcdTerms);
+ }
+
+ @Override
+ public String getTerm() {
+ return TERM;
+ }
+}
diff --git a/src/main/java/eu/dissco/core/translator/terms/media/Description.java b/src/main/java/eu/dissco/core/translator/terms/media/Description.java
new file mode 100644
index 0000000..7becd47
--- /dev/null
+++ b/src/main/java/eu/dissco/core/translator/terms/media/Description.java
@@ -0,0 +1,27 @@
+package eu.dissco.core.translator.terms.media;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import eu.dissco.core.translator.terms.Term;
+import java.util.List;
+
+public class Description extends Term {
+
+ public static final String TERM = "dcterms:description";
+ private final List dwcaTerms = List.of(TERM);
+ private final List abcdTerms = List.of("abcd:context/value", "abcd:comment/value");
+
+ @Override
+ public String retrieveFromDWCA(JsonNode unit) {
+ return super.searchJsonForTerm(unit, dwcaTerms);
+ }
+
+ @Override
+ public String retrieveFromABCD(JsonNode unit) {
+ return super.searchJsonForTerm(unit, abcdTerms);
+ }
+
+ @Override
+ public String getTerm() {
+ return TERM;
+ }
+}
diff --git a/src/main/java/eu/dissco/core/translator/terms/media/FileSize.java b/src/main/java/eu/dissco/core/translator/terms/media/FileSize.java
new file mode 100644
index 0000000..fab63b7
--- /dev/null
+++ b/src/main/java/eu/dissco/core/translator/terms/media/FileSize.java
@@ -0,0 +1,27 @@
+package eu.dissco.core.translator.terms.media;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import eu.dissco.core.translator.terms.Term;
+import java.util.List;
+
+public class FileSize extends Term {
+
+ public static final String TERM = "dcterms:extent";
+ private final List dwcaTerms = List.of(TERM);
+ private final List abcdTerms = List.of("abcd:fileSize");
+
+ @Override
+ public String retrieveFromDWCA(JsonNode unit) {
+ return super.searchJsonForTerm(unit, dwcaTerms);
+ }
+
+ @Override
+ public String retrieveFromABCD(JsonNode unit) {
+ return super.searchJsonForTerm(unit, abcdTerms);
+ }
+
+ @Override
+ public String getTerm() {
+ return TERM;
+ }
+}
diff --git a/src/main/java/eu/dissco/core/translator/terms/media/Format.java b/src/main/java/eu/dissco/core/translator/terms/media/Format.java
index 1d7fb3f..b97c204 100644
--- a/src/main/java/eu/dissco/core/translator/terms/media/Format.java
+++ b/src/main/java/eu/dissco/core/translator/terms/media/Format.java
@@ -14,12 +14,12 @@ public class Format extends Term {
@Override
public String retrieveFromDWCA(JsonNode unit) {
- return super.searchJsonForStringTerm(unit, dwcaTerms);
+ return super.searchJsonForTerm(unit, dwcaTerms);
}
@Override
public String retrieveFromABCD(JsonNode unit) {
- return super.searchJsonForStringTerm(unit, abcdTerms);
+ return super.searchJsonForTerm(unit, abcdTerms);
}
@Override
diff --git a/src/main/java/eu/dissco/core/translator/terms/media/MediaAssertions.java b/src/main/java/eu/dissco/core/translator/terms/media/MediaAssertions.java
new file mode 100644
index 0000000..1b38740
--- /dev/null
+++ b/src/main/java/eu/dissco/core/translator/terms/media/MediaAssertions.java
@@ -0,0 +1,38 @@
+package eu.dissco.core.translator.terms.media;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import eu.dissco.core.translator.terms.Term;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang3.tuple.Pair;
+
+public class MediaAssertions {
+
+ private final List> abcdMediaAssertions = List.of(
+ Pair.of(new FileSize(), "kb"),
+ Pair.of(new PixelXDimension(), "pixel"), Pair.of(new PixelYDimension(), "pixel"));
+
+ public List gatherAssertions(JsonNode data,
+ boolean dwc) {
+ if (!dwc) {
+ return gatherOccurrenceAssertionsForABCD(data);
+ }
+ return List.of();
+ }
+
+ private List gatherOccurrenceAssertionsForABCD(
+ JsonNode data) {
+ var assertions = new ArrayList();
+ for (var abcdMediaAssertion : abcdMediaAssertions) {
+ var value = abcdMediaAssertion.getLeft().retrieveFromABCD(data);
+ if (value != null) {
+ var assertion = new eu.dissco.core.translator.schema.Assertions()
+ .withAssertionValue(abcdMediaAssertion.getLeft().retrieveFromABCD(data))
+ .withAssertionType(abcdMediaAssertion.getLeft().getTerm())
+ .withAssertionUnit(abcdMediaAssertion.getRight());
+ assertions.add(assertion);
+ }
+ }
+ return assertions;
+ }
+}
diff --git a/src/main/java/eu/dissco/core/translator/terms/media/MediaType.java b/src/main/java/eu/dissco/core/translator/terms/media/MediaType.java
index 5943c69..9554414 100644
--- a/src/main/java/eu/dissco/core/translator/terms/media/MediaType.java
+++ b/src/main/java/eu/dissco/core/translator/terms/media/MediaType.java
@@ -9,15 +9,16 @@
public class MediaType extends Term {
public static final String TERM = "dcterms:type";
- private static final String IMAGE_OBJECT = "2DImageObject";
-
+ private static final String STILL_IMAGE = "StillImage";
+ private static final String SOUND = "Sound";
+ private static final String MOVING_IMAGE = "MovingImage";
private final List dwcaTerms = List.of(TERM, "dc:type");
private final List imageFormats = List.of("IMAGE/JPG", "JPG", "IMAGE/JPEG",
"JPEG", "IMAGE/PNG", "PNG", "IMAGE/TIF", "TIF");
@Override
public String retrieveFromDWCA(JsonNode unit) {
- var recoveredType = super.searchJsonForStringTerm(unit, dwcaTerms);
+ var recoveredType = super.searchJsonForTerm(unit, dwcaTerms);
if (recoveredType == null) {
var format = new Format().retrieveFromDWCA(unit);
return checkFormat(format);
@@ -28,14 +29,14 @@ public String retrieveFromDWCA(JsonNode unit) {
private String parseToOdsType(String recoveredType) {
switch (recoveredType) {
- case "StillImage", "Image" -> {
- return IMAGE_OBJECT;
+ case STILL_IMAGE, "Image" -> {
+ return STILL_IMAGE;
}
- case "Sound" -> {
- return "AudioObject";
+ case SOUND -> {
+ return SOUND;
}
- case "MovingImage" -> {
- return "VideoObject";
+ case MOVING_IMAGE -> {
+ return MOVING_IMAGE;
}
default -> {
return null;
@@ -49,7 +50,7 @@ public String retrieveFromABCD(JsonNode unit) {
if (format != null) {
format = format.toUpperCase();
if (imageFormats.contains(format)) {
- return IMAGE_OBJECT;
+ return STILL_IMAGE;
} else {
log.warn("Unable to determine media type of digital media object");
return null;
@@ -62,13 +63,13 @@ public String retrieveFromABCD(JsonNode unit) {
private String checkFormat(String format) {
if (format != null) {
if (imageFormats.contains(format) || format.startsWith("image")) {
- return IMAGE_OBJECT;
+ return STILL_IMAGE;
}
if (format.startsWith("audio")) {
- return "AudioObject";
+ return SOUND;
}
if (format.startsWith("video")) {
- return "VideoObject";
+ return MOVING_IMAGE;
}
}
log.info("Unable to determine type based on format");
diff --git a/src/main/java/eu/dissco/core/translator/terms/media/Modified.java b/src/main/java/eu/dissco/core/translator/terms/media/Modified.java
new file mode 100644
index 0000000..83735cf
--- /dev/null
+++ b/src/main/java/eu/dissco/core/translator/terms/media/Modified.java
@@ -0,0 +1,21 @@
+package eu.dissco.core.translator.terms.media;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import eu.dissco.core.translator.terms.Term;
+import java.util.List;
+
+public class Modified extends Term {
+
+ public static final String TERM = "dcterms:modified";
+ private final List dwcaTerms = List.of(TERM);
+
+ @Override
+ public String retrieveFromDWCA(JsonNode unit) {
+ return super.searchJsonForTerm(unit, dwcaTerms);
+ }
+
+ @Override
+ public String getTerm() {
+ return TERM;
+ }
+}
diff --git a/src/main/java/eu/dissco/core/translator/terms/media/PixelXDimension.java b/src/main/java/eu/dissco/core/translator/terms/media/PixelXDimension.java
new file mode 100644
index 0000000..543c43e
--- /dev/null
+++ b/src/main/java/eu/dissco/core/translator/terms/media/PixelXDimension.java
@@ -0,0 +1,27 @@
+package eu.dissco.core.translator.terms.media;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import eu.dissco.core.translator.terms.Term;
+import java.util.List;
+
+public class PixelXDimension extends Term {
+
+ public static final String TERM = "exif:PixelXDimension";
+ private final List dwcaTerms = List.of(TERM);
+ private final List abcdTerms = List.of("abcd:imageSize/width");
+
+ @Override
+ public String retrieveFromDWCA(JsonNode unit) {
+ return super.searchJsonForTerm(unit, dwcaTerms);
+ }
+
+ @Override
+ public String retrieveFromABCD(JsonNode unit) {
+ return super.searchJsonForTerm(unit, abcdTerms);
+ }
+
+ @Override
+ public String getTerm() {
+ return TERM;
+ }
+}
diff --git a/src/main/java/eu/dissco/core/translator/terms/media/PixelYDimension.java b/src/main/java/eu/dissco/core/translator/terms/media/PixelYDimension.java
new file mode 100644
index 0000000..6d719a8
--- /dev/null
+++ b/src/main/java/eu/dissco/core/translator/terms/media/PixelYDimension.java
@@ -0,0 +1,27 @@
+package eu.dissco.core.translator.terms.media;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import eu.dissco.core.translator.terms.Term;
+import java.util.List;
+
+public class PixelYDimension extends Term {
+
+ public static final String TERM = "exif:PixelYDimension";
+ private final List dwcaTerms = List.of(TERM);
+ private final List abcdTerms = List.of("abcd:imageSize/height");
+
+ @Override
+ public String retrieveFromDWCA(JsonNode unit) {
+ return super.searchJsonForTerm(unit, dwcaTerms);
+ }
+
+ @Override
+ public String retrieveFromABCD(JsonNode unit) {
+ return super.searchJsonForTerm(unit, abcdTerms);
+ }
+
+ @Override
+ public String getTerm() {
+ return TERM;
+ }
+}
diff --git a/src/main/java/eu/dissco/core/translator/terms/media/Rights.java b/src/main/java/eu/dissco/core/translator/terms/media/Rights.java
new file mode 100644
index 0000000..167440e
--- /dev/null
+++ b/src/main/java/eu/dissco/core/translator/terms/media/Rights.java
@@ -0,0 +1,21 @@
+package eu.dissco.core.translator.terms.media;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import eu.dissco.core.translator.terms.Term;
+import java.util.List;
+
+public class Rights extends Term {
+
+ public static final String TERM = "dcterms:rights";
+ private final List dwcaTerms = List.of(TERM, "dc:rights");
+
+ @Override
+ public String retrieveFromDWCA(JsonNode unit) {
+ return super.searchJsonForTerm(unit, dwcaTerms);
+ }
+
+ @Override
+ public String getTerm() {
+ return TERM;
+ }
+}
diff --git a/src/main/java/eu/dissco/core/translator/terms/media/RightsHolder.java b/src/main/java/eu/dissco/core/translator/terms/media/RightsHolder.java
new file mode 100644
index 0000000..d3e0124
--- /dev/null
+++ b/src/main/java/eu/dissco/core/translator/terms/media/RightsHolder.java
@@ -0,0 +1,22 @@
+package eu.dissco.core.translator.terms.media;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import eu.dissco.core.translator.terms.Term;
+import java.util.List;
+
+public class RightsHolder extends Term {
+
+ public static final String TERM = "dcterms:rightsHolder";
+
+ private final List dwcaTerms = List.of(TERM);
+
+ @Override
+ public String retrieveFromDWCA(JsonNode unit) {
+ return super.searchJsonForTerm(unit, dwcaTerms);
+ }
+
+ @Override
+ public String getTerm() {
+ return TERM;
+ }
+}
diff --git a/src/main/java/eu/dissco/core/translator/terms/media/Source.java b/src/main/java/eu/dissco/core/translator/terms/media/Source.java
new file mode 100644
index 0000000..e8e5da7
--- /dev/null
+++ b/src/main/java/eu/dissco/core/translator/terms/media/Source.java
@@ -0,0 +1,27 @@
+package eu.dissco.core.translator.terms.media;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import eu.dissco.core.translator.terms.Term;
+import java.util.List;
+
+public class Source extends Term {
+
+ public static final String TERM = "dcterms:source";
+ private final List dwcaTerms = List.of(TERM, "dc:source");
+ private final List abcdTerms = List.of("abcd:productURI");
+
+ @Override
+ public String retrieveFromDWCA(JsonNode unit) {
+ return super.searchJsonForTerm(unit, dwcaTerms);
+ }
+
+ @Override
+ public String retrieveFromABCD(JsonNode unit) {
+ return super.searchJsonForTerm(unit, abcdTerms);
+ }
+
+ @Override
+ public String getTerm() {
+ return TERM;
+ }
+}
diff --git a/src/main/java/eu/dissco/core/translator/terms/media/WebStatement.java b/src/main/java/eu/dissco/core/translator/terms/media/WebStatement.java
new file mode 100644
index 0000000..c38af15
--- /dev/null
+++ b/src/main/java/eu/dissco/core/translator/terms/media/WebStatement.java
@@ -0,0 +1,21 @@
+package eu.dissco.core.translator.terms.media;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import eu.dissco.core.translator.terms.Term;
+import java.util.List;
+
+public class WebStatement extends Term {
+
+ public static final String TERM = "xmpRights:webStatement";
+ private final List dwcaTerms = List.of(TERM);
+
+ @Override
+ public String retrieveFromDWCA(JsonNode unit) {
+ return super.searchJsonForTerm(unit, dwcaTerms);
+ }
+
+ @Override
+ public String getTerm() {
+ return TERM;
+ }
+}
diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/DatasetId.java b/src/main/java/eu/dissco/core/translator/terms/specimen/AccessRights.java
similarity index 57%
rename from src/main/java/eu/dissco/core/translator/terms/specimen/DatasetId.java
rename to src/main/java/eu/dissco/core/translator/terms/specimen/AccessRights.java
index fecfc70..a7a2a07 100644
--- a/src/main/java/eu/dissco/core/translator/terms/specimen/DatasetId.java
+++ b/src/main/java/eu/dissco/core/translator/terms/specimen/AccessRights.java
@@ -4,15 +4,15 @@
import eu.dissco.core.translator.terms.Term;
import java.util.List;
-public class DatasetId extends Term {
+public class AccessRights extends Term {
- public static final String TERM = ODS_PREFIX + "datasetId";
+ public static final String TERM = "dcterms:accessRights";
- private final List dwcaTerms = List.of("dwc:datasetID");
+ private final List dwcaTerms = List.of(TERM);
@Override
public String retrieveFromDWCA(JsonNode unit) {
- return super.searchJsonForStringTerm(unit, dwcaTerms);
+ return super.searchJsonForTerm(unit, dwcaTerms);
}
@Override
diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/BasisOfRecord.java b/src/main/java/eu/dissco/core/translator/terms/specimen/BasisOfRecord.java
index cb8de85..27e5dfd 100644
--- a/src/main/java/eu/dissco/core/translator/terms/specimen/BasisOfRecord.java
+++ b/src/main/java/eu/dissco/core/translator/terms/specimen/BasisOfRecord.java
@@ -13,12 +13,12 @@ public class BasisOfRecord extends Term {
@Override
public String retrieveFromDWCA(JsonNode unit) {
- return super.searchJsonForStringTerm(unit, dwcaTerms);
+ return super.searchJsonForTerm(unit, dwcaTerms);
}
@Override
public String retrieveFromABCD(JsonNode unit) {
- return super.searchJsonForStringTerm(unit, abcdTerms);
+ return super.searchJsonForTerm(unit, abcdTerms);
}
@Override
diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/PhysicalSpecimenCollection.java b/src/main/java/eu/dissco/core/translator/terms/specimen/CollectionId.java
similarity index 51%
rename from src/main/java/eu/dissco/core/translator/terms/specimen/PhysicalSpecimenCollection.java
rename to src/main/java/eu/dissco/core/translator/terms/specimen/CollectionId.java
index e128b27..38916a3 100644
--- a/src/main/java/eu/dissco/core/translator/terms/specimen/PhysicalSpecimenCollection.java
+++ b/src/main/java/eu/dissco/core/translator/terms/specimen/CollectionId.java
@@ -4,15 +4,15 @@
import eu.dissco.core.translator.terms.Term;
import java.util.List;
-public class PhysicalSpecimenCollection extends Term {
+public class CollectionId extends Term {
- public static final String TERM = ODS_PREFIX + "physicalSpecimenCollection";
+ public static final String TERM = DWC_PREFIX + "collectionID";
- private final List dwcaTerms = List.of("dwc:collectionID", "dwc:collectionCode");
+ private final List