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 from) { - return convertFrom(Records.mapping(from)); - } - - /** - * Convenience mapping calling {@link SelectField#convertFrom(Class, - * Function)}. - */ - public SelectField mapping(Class toType, Function9 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 from) { + return convertFrom(Records.mapping(from)); + } + + /** + * Convenience mapping calling {@link SelectField#convertFrom(Class, Function)}. + */ + public SelectField mapping(Class toType, + Function9 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 from) { - return convertFrom(Records.mapping(from)); - } - - /** - * Convenience mapping calling {@link SelectField#convertFrom(Class, - * Function)}. - */ - public SelectField mapping(Class toType, Function9 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 from) { + return convertFrom(Records.mapping(from)); + } + + /** + * Convenience mapping calling {@link SelectField#convertFrom(Class, Function)}. + */ + public SelectField mapping(Class toType, + Function9 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 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/DatasetName.java b/src/main/java/eu/dissco/core/translator/terms/specimen/DatasetName.java new file mode 100644 index 0000000..bed305e --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/DatasetName.java @@ -0,0 +1,28 @@ +package eu.dissco.core.translator.terms.specimen; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class DatasetName extends Term { + + public static final String TERM = DWC_PREFIX + "datasetName"; + + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of("abcd:description/representation/0/title"); + + @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/specimen/Disposition.java b/src/main/java/eu/dissco/core/translator/terms/specimen/Disposition.java new file mode 100644 index 0000000..a0d5f49 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/Disposition.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class Disposition extends Term { + + public static final String TERM = DWC_PREFIX + "disposition"; + + 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/HasMedia.java b/src/main/java/eu/dissco/core/translator/terms/specimen/HasMedia.java index aba236c..876f73c 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/HasMedia.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/HasMedia.java @@ -17,7 +17,7 @@ private static String toBoolean(String result) { @Override public String retrieveFromDWCA(JsonNode unit) { - var result = super.searchJsonForStringTerm(unit, dwcaTerms); + var result = super.searchJsonForTerm(unit, dwcaTerms); if (result != null) { return String.valueOf(true); } else if (unit.get("extensions") != null) { @@ -36,7 +36,7 @@ public String retrieveFromDWCA(JsonNode unit) { @Override public String retrieveFromABCD(JsonNode unit) { - var result = super.searchJsonForStringTerm(unit, abcdTerms); + var result = super.searchJsonForTerm(unit, abcdTerms); return toBoolean(result); } diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/MarkedAsType.java b/src/main/java/eu/dissco/core/translator/terms/specimen/MarkedAsType.java new file mode 100644 index 0000000..14bcccf --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/MarkedAsType.java @@ -0,0 +1,30 @@ +package eu.dissco.core.translator.terms.specimen; + +import eu.dissco.core.translator.schema.DigitalSpecimen; +import eu.dissco.core.translator.terms.Term; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +public class MarkedAsType extends Term { + + public static final String TERM = ODS_PREFIX + "markedAsType"; + private static final Set NOT_TYPE_STATUS = new HashSet<>( + Arrays.asList("false", "specimen", "")); + + public Boolean calculate(DigitalSpecimen ds) { + var acceptedIdentification = retrieveAcceptedIdentification(ds); + if (acceptedIdentification != null) { + var dcwTypeStatus = acceptedIdentification.getDwcTypeStatus(); + if (dcwTypeStatus != null) { + return !NOT_TYPE_STATUS.contains(dcwTypeStatus.trim().toLowerCase()); + } + } + return null; + } + + @Override + public String getTerm() { + return TERM; + } +} diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/Modified.java b/src/main/java/eu/dissco/core/translator/terms/specimen/Modified.java index b4b04ba..3776bef 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/Modified.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/Modified.java @@ -8,27 +8,17 @@ public class Modified extends Term { public static final String TERM = "dcterms:modified"; private final List dwcaTerms = List.of(TERM); - private final List abcdMetaTerms = List.of("abcd:metadata/revisionData/dateModified"); - private final List abcdUnitTerms = List.of("abcd:hasDateModified", "abcd:dateLastEdited"); + private final List abcdUnitTerms = List.of("abcd:hasDateModified", "abcd:dateLastEdited", + "abcd:revisionData/dateModified"); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override - public String retrieveFromABCD(JsonNode dataset, JsonNode unit) { - var modified = searchJsonForStringTerm(unit, abcdUnitTerms); - if (modified == null) { - modified = searchJsonForLongTerm(unit, abcdUnitTerms); - } - if (modified == null) { - modified = searchJsonForStringTerm(dataset, abcdMetaTerms); - } - if (modified == null) { - modified = searchJsonForLongTerm(dataset, abcdMetaTerms); - } - return modified; + public String retrieveFromABCD(JsonNode unit) { + return searchJsonForTerm(unit, abcdUnitTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/PhysicalSpecimenId.java b/src/main/java/eu/dissco/core/translator/terms/specimen/PhysicalSpecimenId.java index fcbb216..1e06d0a 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/PhysicalSpecimenId.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/PhysicalSpecimenId.java @@ -8,17 +8,17 @@ public class PhysicalSpecimenId extends Term { public static final String TERM = ODS_PREFIX + "physicalSpecimenId"; - private final List dwcaTerms = List.of("dwc:occurrenceID"); - private final List abcdTerms = List.of("abcd:unitID"); + private final List dwcaTerms = List.of("dwc:catalogNumber", "dwc:occurrenceID"); + private final List abcdTerms = List.of("abcd:unitGUID", "abcd:unitID"); @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/ObjectType.java b/src/main/java/eu/dissco/core/translator/terms/specimen/Preparations.java similarity index 70% rename from src/main/java/eu/dissco/core/translator/terms/specimen/ObjectType.java rename to src/main/java/eu/dissco/core/translator/terms/specimen/Preparations.java index f96cd10..90438a0 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/ObjectType.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/Preparations.java @@ -4,20 +4,20 @@ import eu.dissco.core.translator.terms.Term; import java.util.List; -public class ObjectType extends Term { +public class Preparations extends Term { - public static final String TERM = ODS_PREFIX + "objectType"; + public static final String TERM = DWC_PREFIX + "preparations"; private final List dwcaTerms = List.of("dwc:preparations"); private final List abcdTerms = List.of("abcd:kindOfUnit/0/value"); @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/Collector.java b/src/main/java/eu/dissco/core/translator/terms/specimen/RecordedBy.java similarity index 85% rename from src/main/java/eu/dissco/core/translator/terms/specimen/Collector.java rename to src/main/java/eu/dissco/core/translator/terms/specimen/RecordedBy.java index 71be0ec..261e1aa 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/Collector.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/RecordedBy.java @@ -5,9 +5,9 @@ import java.util.List; import org.apache.commons.lang3.tuple.Pair; -public class Collector extends Term { +public class RecordedBy extends Term { - public static final String TERM = ODS_PREFIX + "collector"; + public static final String TERM = DWC_PREFIX + "recordedBy"; private final List dwcaTerms = List.of("dwc:recordedBy", "dwc:recordedByID"); private final List> abcdTerms = List.of( @@ -16,15 +16,15 @@ public class Collector extends Term { @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { var value = combinePossibleValues(unit); if (value == null) { - if (unit.get("abcd:gathering/agents/gatheringAgentsText") != null) { - return unit.get("abcd:gathering/agents/gatheringAgentsText").asText(); + if (unit.get("abcd:gathering/agents/gatheringAgentsText/value") != null) { + return unit.get("abcd:gathering/agents/gatheringAgentsText/value").asText(); } else { return null; } @@ -57,7 +57,7 @@ private String combinePossibleValues(JsonNode unit) { iterateOverElements = false; } } - if (builder.length() != 0) { + if (!builder.isEmpty()) { return builder.toString(); } else { return null; diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/RightsHolder.java b/src/main/java/eu/dissco/core/translator/terms/specimen/RightsHolder.java new file mode 100644 index 0000000..dd59921 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/RightsHolder.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen; + +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/specimen/SpecimenName.java b/src/main/java/eu/dissco/core/translator/terms/specimen/SpecimenName.java new file mode 100644 index 0000000..de5c5b6 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/SpecimenName.java @@ -0,0 +1,23 @@ +package eu.dissco.core.translator.terms.specimen; + +import eu.dissco.core.translator.schema.DigitalSpecimen; +import eu.dissco.core.translator.terms.Term; + +public class SpecimenName extends Term { + + public static final String TERM = ODS_PREFIX + "specimenName"; + + public String calculate(DigitalSpecimen ds) { + var acceptedIdentification = retrieveAcceptedIdentification(ds); + if (acceptedIdentification != null && acceptedIdentification.getTaxonIdentifications() != null + && !acceptedIdentification.getTaxonIdentifications().isEmpty()) { + return acceptedIdentification.getTaxonIdentifications().get(0).getDwcScientificName(); + } + return null; + } + + @Override + public String getTerm() { + return TERM; + } +} diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/TopicDiscipline.java b/src/main/java/eu/dissco/core/translator/terms/specimen/TopicDiscipline.java index 0208369..4f85054 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/TopicDiscipline.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/TopicDiscipline.java @@ -1,14 +1,13 @@ package eu.dissco.core.translator.terms.specimen; -import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.schema.DigitalSpecimen; +import eu.dissco.core.translator.schema.DigitalSpecimen.OdsTopicDiscipline; import eu.dissco.core.translator.terms.Term; -import eu.dissco.core.translator.terms.specimen.taxonomy.Kingdom; import java.util.List; public class TopicDiscipline extends Term { public static final String TERM = ODS_PREFIX + "topicDiscipline"; - private static final String UNCLASSIFIED = "Unclassified"; private static final List FOSSIL_BASIS_OF_RECORD = List.of("FOSSILSPECIMEN", "FOSSIL SPECIMEN", "FOSSIL"); @@ -17,50 +16,47 @@ public class TopicDiscipline extends Term { private static final List EARTH_SYSTEM_BASIS_OF_RECORD = List.of("ROCK", "MINERAL", "ROCKSPECIMEN", "ROCK SPECIMEN", "MINERALSPECIMEN", "MINERAL SPECIMEN"); - @Override - public String retrieveFromDWCA(JsonNode unit) { - var basisOfRecord = new BasisOfRecord().retrieveFromDWCA(unit); - var kingdom = new Kingdom().retrieveFromDWCA(unit); - return getDiscipline(basisOfRecord, kingdom); - } - - @Override - public String retrieveFromABCD(JsonNode unit) { - var basisOfRecord = new BasisOfRecord().retrieveFromABCD(unit); - var kingdom = new Kingdom().retrieveFromABCD(unit); - return getDiscipline(basisOfRecord, kingdom); + public OdsTopicDiscipline calculate(DigitalSpecimen ds) { + var basisOfRecord = ds.getDwcBasisOfRecord(); + var acceptedIdentification = retrieveAcceptedIdentification(ds); + if (acceptedIdentification != null && acceptedIdentification.getTaxonIdentifications() != null + && !acceptedIdentification.getTaxonIdentifications().isEmpty()) { + return getDiscipline(basisOfRecord, + acceptedIdentification.getTaxonIdentifications().get(0).getDwcKingdom()); + } + return getDiscipline(basisOfRecord, null); } - private static String getDiscipline(String basisOfRecord, String kingdom) { + private OdsTopicDiscipline getDiscipline(String basisOfRecord, String kingdom) { if (basisOfRecord != null) { var harBasisOfRecord = basisOfRecord.trim().toUpperCase(); if (FOSSIL_BASIS_OF_RECORD.contains(harBasisOfRecord)) { - return "Palaeontology"; + return OdsTopicDiscipline.PALAEONTOLOGY; } else if (EXTRATERRESTRIAL_BASIS_OF_RECORD.contains(harBasisOfRecord)) { - return "Astrogeology"; - } else if (EARTH_SYSTEM_BASIS_OF_RECORD.contains(harBasisOfRecord)){ - return "Geology"; - } else if (kingdom != null){ - var harKingdom = kingdom.trim().toUpperCase(); - switch (harKingdom) { + return OdsTopicDiscipline.ASTROGEOLOGY; + } else if (EARTH_SYSTEM_BASIS_OF_RECORD.contains(harBasisOfRecord)) { + return OdsTopicDiscipline.GEOLOGY; + } else if (kingdom != null) { + var harmonisedKingdom = kingdom.trim().toUpperCase(); + switch (harmonisedKingdom) { case "ANIMALIA" -> { - return "Zoology"; + return OdsTopicDiscipline.ZOOLOGY; } case "PLANTAE" -> { - return "Botany"; + return OdsTopicDiscipline.BOTANY; } case "BACTERIA" -> { - return "Microbiology"; + return OdsTopicDiscipline.MICROBIOLOGY; } default -> { - return UNCLASSIFIED; + return OdsTopicDiscipline.UNCLASSIFIED; } } } else { - return UNCLASSIFIED; + return OdsTopicDiscipline.UNCLASSIFIED; } } else { - return UNCLASSIFIED; + return OdsTopicDiscipline.UNCLASSIFIED; } } diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/TopicDomain.java b/src/main/java/eu/dissco/core/translator/terms/specimen/TopicDomain.java new file mode 100644 index 0000000..804ba31 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/TopicDomain.java @@ -0,0 +1,41 @@ +package eu.dissco.core.translator.terms.specimen; + +import eu.dissco.core.translator.schema.DigitalSpecimen; +import eu.dissco.core.translator.schema.DigitalSpecimen.OdsTopicDomain; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class TopicDomain extends Term { + + public static final String TERM = ODS_PREFIX + "topicDomain"; + private static final List FOSSIL_BASIS_OF_RECORD = List.of("FOSSILSPECIMEN", + "FOSSIL SPECIMEN", "FOSSIL", "PRESERVEDSPECIMEN", "PRESERVED SPECIMEN", "LIVING SPECIMEN", + "LIVINGSPECIMEN"); + private static final List EXTRATERRESTRIAL_BASIS_OF_RECORD = List.of("METEORITE", + "METEORITESPECIMEN", "METEORITE SPECIMEN"); + private static final List EARTH_SYSTEM_BASIS_OF_RECORD = List.of("ROCK", "MINERAL", + "ROCKSPECIMEN", "ROCK SPECIMEN", "MINERALSPECIMEN", "MINERAL SPECIMEN"); + + public OdsTopicDomain calculate(DigitalSpecimen ds) { + var basisOfRecord = ds.getDwcBasisOfRecord(); + if (basisOfRecord != null) { + var harBasisOfRecord = basisOfRecord.trim().toUpperCase(); + if (FOSSIL_BASIS_OF_RECORD.contains(harBasisOfRecord)) { + return OdsTopicDomain.LIFE; + } else if (EXTRATERRESTRIAL_BASIS_OF_RECORD.contains(harBasisOfRecord)) { + return OdsTopicDomain.EXTRATERRESTRIAL; + } else if (EARTH_SYSTEM_BASIS_OF_RECORD.contains(harBasisOfRecord)) { + return OdsTopicDomain.EARTH_SYSTEM; + } else { + return OdsTopicDomain.UNCLASSIFIED; + } + } else { + return OdsTopicDomain.UNCLASSIFIED; + } + } + + @Override + public String getTerm() { + return TERM; + } +} diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/TopicOrigin.java b/src/main/java/eu/dissco/core/translator/terms/specimen/TopicOrigin.java new file mode 100644 index 0000000..b4aa032 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/TopicOrigin.java @@ -0,0 +1,19 @@ +package eu.dissco.core.translator.terms.specimen; + +import eu.dissco.core.translator.schema.DigitalSpecimen; +import eu.dissco.core.translator.schema.DigitalSpecimen.OdsTopicOrigin; +import eu.dissco.core.translator.terms.Term; + +public class TopicOrigin extends Term { + + public static final String TERM = ODS_PREFIX + "topicOrigin"; + + public OdsTopicOrigin calculate(DigitalSpecimen ds) { + return OdsTopicOrigin.NATURAL; + } + + @Override + public String getTerm() { + return TERM; + } +} diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/Type.java b/src/main/java/eu/dissco/core/translator/terms/specimen/Type.java deleted file mode 100644 index 1eeca8d..0000000 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/Type.java +++ /dev/null @@ -1,13 +0,0 @@ -package eu.dissco.core.translator.terms.specimen; - -import eu.dissco.core.translator.terms.Term; - -public class Type extends Term { - - public static final String TERM = ODS_PREFIX + "type"; - - @Override - public String getTerm() { - return TERM; - } -} diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/citation/BibliographicCitation.java b/src/main/java/eu/dissco/core/translator/terms/specimen/citation/BibliographicCitation.java new file mode 100644 index 0000000..fcfcbba --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/citation/BibliographicCitation.java @@ -0,0 +1,28 @@ +package eu.dissco.core.translator.terms.specimen.citation; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class BibliographicCitation extends Term { + + public static final String TERM = "dcterms:bibliographicCitation"; + + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of("titleCitation"); + + @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/specimen/citation/CitationRemarks.java b/src/main/java/eu/dissco/core/translator/terms/specimen/citation/CitationRemarks.java new file mode 100644 index 0000000..f7712cb --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/citation/CitationRemarks.java @@ -0,0 +1,28 @@ +package eu.dissco.core.translator.terms.specimen.citation; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class CitationRemarks extends Term { + + public static final String TERM = "???:citationRemarks"; + + private final List dwcaTerms = List.of("dwc:taxonRemarks"); + private final List abcdTerms = List.of("citationDetail"); + + @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/specimen/citation/Creator.java b/src/main/java/eu/dissco/core/translator/terms/specimen/citation/Creator.java new file mode 100644 index 0000000..497fdd5 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/citation/Creator.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.citation; + +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); + + @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/citation/Date.java b/src/main/java/eu/dissco/core/translator/terms/specimen/citation/Date.java new file mode 100644 index 0000000..235f34a --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/citation/Date.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.citation; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class Date extends Term { + + public static final String TERM = "dcterms:date"; + + 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/citation/ReferenceIri.java b/src/main/java/eu/dissco/core/translator/terms/specimen/citation/ReferenceIri.java new file mode 100644 index 0000000..9d4bdf6 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/citation/ReferenceIri.java @@ -0,0 +1,24 @@ +package eu.dissco.core.translator.terms.specimen.citation; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class ReferenceIri extends Term { + + public static final String TERM = "???:referenceIri"; + + private final List abcdTerms = List.of("uri"); + + @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/specimen/citation/Title.java b/src/main/java/eu/dissco/core/translator/terms/specimen/citation/Title.java new file mode 100644 index 0000000..689b647 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/citation/Title.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.citation; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class Title extends Term { + + public static final String TERM = "dcterms:title"; + + 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/citation/Type.java b/src/main/java/eu/dissco/core/translator/terms/specimen/citation/Type.java new file mode 100644 index 0000000..47b386f --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/citation/Type.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.citation; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class Type extends Term { + + public static final String TERM = "dcterms:type"; + + 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/identification/DateIdentified.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/DateIdentified.java new file mode 100644 index 0000000..873c8ac --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/DateIdentified.java @@ -0,0 +1,29 @@ +package eu.dissco.core.translator.terms.specimen.identification; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class DateIdentified extends Term { + + public static final String TERM = DWC_PREFIX + "dateIdentified"; + + private final List dwcaTerms = List.of(TERM); + + private final List abcdTerms = List.of("date/dateText"); + + @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/specimen/identification/IdentificationId.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/IdentificationId.java new file mode 100644 index 0000000..9015b30 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/IdentificationId.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.identification; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class IdentificationId extends Term { + + public static final String TERM = DWC_PREFIX + "identificationID"; + + 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/identification/IdentificationRemarks.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/IdentificationRemarks.java new file mode 100644 index 0000000..b6637dd --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/IdentificationRemarks.java @@ -0,0 +1,29 @@ +package eu.dissco.core.translator.terms.specimen.identification; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class IdentificationRemarks extends Term { + + public static final String TERM = DWC_PREFIX + "identificationRemarks"; + + private final List dwcaTerms = List.of(TERM); + + private final List abcdTerms = List.of("notes/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/specimen/identification/IdentificationVerificationStatus.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/IdentificationVerificationStatus.java new file mode 100644 index 0000000..04a1121 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/IdentificationVerificationStatus.java @@ -0,0 +1,35 @@ +package eu.dissco.core.translator.terms.specimen.identification; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class IdentificationVerificationStatus extends Term { + + public static final String TERM = DWC_PREFIX + "identificationVerificationStatus"; + + private final List dwcaTerms = List.of(TERM); + + private final List abcdTerms = List.of("preferredFlag"); + + @Override + public String retrieveFromDWCA(JsonNode unit) { + var result = super.searchJsonForTerm(unit, dwcaTerms); + if (result.equals("1")) { + return Boolean.TRUE.toString(); + } else { + return Boolean.FALSE.toString(); + } + } + + @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/specimen/identification/IdentifiedBy.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/IdentifiedBy.java new file mode 100644 index 0000000..9c7c674 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/IdentifiedBy.java @@ -0,0 +1,29 @@ +package eu.dissco.core.translator.terms.specimen.identification; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class IdentifiedBy extends Term { + + public static final String TERM = DWC_PREFIX + "identifiedBy"; + + private final List dwcaTerms = List.of(TERM); + + private final List abcdTerms = List.of("identifiers/identifier/0/personName/fullName"); + + @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/specimen/identification/TypeStatus.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/TypeStatus.java new file mode 100644 index 0000000..52b8a01 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/TypeStatus.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.identification; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.specimen.identification.taxonomy.AbstractTaxonomy; +import java.util.List; + +public class TypeStatus extends AbstractTaxonomy { + + public static final String TERM = DWC_PREFIX + "typeStatus"; + + 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/identification/VerbatimIdentification.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/VerbatimIdentification.java new file mode 100644 index 0000000..10b12d1 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/VerbatimIdentification.java @@ -0,0 +1,23 @@ +package eu.dissco.core.translator.terms.specimen.identification; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class VerbatimIdentification extends Term { + + public static final String TERM = DWC_PREFIX + "verbatimIdentification"; + + 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/identification/taxonomy/AbstractTaxonomy.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/AbstractTaxonomy.java new file mode 100644 index 0000000..dce0312 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/AbstractTaxonomy.java @@ -0,0 +1,23 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; +import org.apache.commons.lang3.tuple.Pair; + +public abstract class AbstractTaxonomy extends Term { + + private static final Pair ABCD_TAXON_RANK = + Pair.of("result/taxonIdentified/higherTaxa/higherTaxon/", + "/higherTaxonRank"); + private static final Pair ABCD_VALUE = + Pair.of("result/taxonIdentified/higherTaxa/higherTaxon/", + "/higherTaxonName"); + + protected String searchABCDSplitTerms(JsonNode unit, List searchTerms) { + return searchABCDSplitTerms(unit, searchTerms, + Pair.of(ABCD_TAXON_RANK.getLeft(), ABCD_TAXON_RANK.getRight()), + Pair.of(ABCD_VALUE.getLeft(), ABCD_VALUE.getRight())); + } + +} diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/Class.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Class.java similarity index 62% rename from src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/Class.java rename to src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Class.java index d1f3da9..47879a6 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/Class.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Class.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; import com.fasterxml.jackson.databind.JsonNode; import java.util.List; @@ -8,15 +8,16 @@ public class Class extends AbstractTaxonomy { public static final String TERM = DWC_PREFIX + "class"; private final List dwcaTerms = List.of(TERM); + private final List abcdSplitTerms = List.of("classis", "class"); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.getTaxonFromDWCA(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDSplitTerms(unit, List.of("classis", "class")); + return super.searchABCDSplitTerms(unit, abcdSplitTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/Family.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Family.java similarity index 62% rename from src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/Family.java rename to src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Family.java index 0fc0972..1203d45 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/Family.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Family.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; import com.fasterxml.jackson.databind.JsonNode; import java.util.List; @@ -8,15 +8,16 @@ public class Family extends AbstractTaxonomy { public static final String TERM = DWC_PREFIX + "family"; private final List dwcaTerms = List.of(TERM); + private final List abcdSplitTerms = List.of("familia", "family"); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.getTaxonFromDWCA(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDSplitTerms(unit, List.of("familia", "family")); + return super.searchABCDSplitTerms(unit, abcdSplitTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/Genus.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Genus.java similarity index 58% rename from src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/Genus.java rename to src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Genus.java index e8e5aa3..5caf193 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/Genus.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Genus.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; import com.fasterxml.jackson.databind.JsonNode; import java.util.List; @@ -8,15 +8,17 @@ public class Genus extends AbstractTaxonomy { public static final String TERM = DWC_PREFIX + "genus"; private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of( + "result/taxonIdentified/scientificName/nameAtomised/botanical/genusOrMonomial"); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.getTaxonFromDWCA(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDTerms(unit, List.of("/nameAtomised/botanical/genusOrMonomial")); + return searchJsonForTerm(unit, abcdTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/InfraspecificEpithet.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/InfraspecificEpithet.java similarity index 59% rename from src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/InfraspecificEpithet.java rename to src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/InfraspecificEpithet.java index bcbff5a..531eb88 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/InfraspecificEpithet.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/InfraspecificEpithet.java @@ -1,23 +1,24 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; import com.fasterxml.jackson.databind.JsonNode; import java.util.List; public class InfraspecificEpithet extends AbstractTaxonomy { - public static final String TERM = DWC_PREFIX + "infraspecificEpithet"; private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of( + "result/taxonIdentified/scientificName/nameAtomised/botanical/infraspecificEpithet"); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.getTaxonFromDWCA(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDTerms(unit, List.of("/nameAtomised/botanical/infraspecificEpithet")); + return searchJsonForTerm(unit, abcdTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/Kingdom.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Kingdom.java similarity index 62% rename from src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/Kingdom.java rename to src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Kingdom.java index bd037d1..a691ada 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/Kingdom.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Kingdom.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; import com.fasterxml.jackson.databind.JsonNode; import java.util.List; @@ -8,15 +8,16 @@ public class Kingdom extends AbstractTaxonomy { public static final String TERM = DWC_PREFIX + "kingdom"; private final List dwcaTerms = List.of(TERM); + private final List abcdSplitTerms = List.of("regnum", "kingdom"); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.getTaxonFromDWCA(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDSplitTerms(unit, List.of("regnum", "kingdom")); + return super.searchABCDSplitTerms(unit, abcdSplitTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/NameAccordingTo.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/NameAccordingTo.java new file mode 100644 index 0000000..cd57ecd --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/NameAccordingTo.java @@ -0,0 +1,21 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import com.fasterxml.jackson.databind.JsonNode; +import java.util.List; + +public class NameAccordingTo extends AbstractTaxonomy { + + public static final String TERM = DWC_PREFIX + "nameAccordingTo"; + + 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/identification/taxonomy/NamePublishedInYear.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/NamePublishedInYear.java new file mode 100644 index 0000000..2c38540 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/NamePublishedInYear.java @@ -0,0 +1,21 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import com.fasterxml.jackson.databind.JsonNode; +import java.util.List; + +public class NamePublishedInYear extends AbstractTaxonomy { + + public static final String TERM = DWC_PREFIX + "namePublishedInYear"; + + 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/identification/taxonomy/NomenclaturalCode.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/NomenclaturalCode.java new file mode 100644 index 0000000..390dcb4 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/NomenclaturalCode.java @@ -0,0 +1,27 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import com.fasterxml.jackson.databind.JsonNode; +import java.util.List; + +public class NomenclaturalCode extends AbstractTaxonomy { + + public static final String TERM = DWC_PREFIX + "nomenclaturalCode"; + + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of("result/taxonIdentified/code"); + + @Override + public String retrieveFromDWCA(JsonNode unit) { + return super.searchJsonForTerm(unit, dwcaTerms); + } + + @Override + public String retrieveFromABCD(JsonNode unit) { + return searchJsonForTerm(unit, abcdTerms); + } + + @Override + public String getTerm() { + return TERM; + } +} diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/Order.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Order.java similarity index 62% rename from src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/Order.java rename to src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Order.java index 60034ba..f686750 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/Order.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Order.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; import com.fasterxml.jackson.databind.JsonNode; import java.util.List; @@ -8,15 +8,16 @@ public class Order extends AbstractTaxonomy { public static final String TERM = DWC_PREFIX + "order"; private final List dwcaTerms = List.of(TERM); + private final List abcdSplitTerms = List.of("ordo", "order"); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.getTaxonFromDWCA(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDSplitTerms(unit, List.of("ordo", "order")); + return super.searchABCDSplitTerms(unit, abcdSplitTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/Phylum.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Phylum.java similarity index 62% rename from src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/Phylum.java rename to src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Phylum.java index cdab771..8785b45 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/Phylum.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Phylum.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; import com.fasterxml.jackson.databind.JsonNode; import java.util.List; @@ -8,15 +8,16 @@ public class Phylum extends AbstractTaxonomy { public static final String TERM = DWC_PREFIX + "phylum"; private final List dwcaTerms = List.of(TERM); + private final List abcdSplitTerms = List.of("phylum", "divisio"); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.getTaxonFromDWCA(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDSplitTerms(unit, List.of("phylum", "divisio")); + return super.searchABCDSplitTerms(unit, abcdSplitTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/ScientificName.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/ScientificName.java new file mode 100644 index 0000000..fad9ed1 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/ScientificName.java @@ -0,0 +1,30 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import com.fasterxml.jackson.databind.JsonNode; +import java.util.List; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class ScientificName extends AbstractTaxonomy { + + public static final String TERM = DWC_PREFIX + "scientificName"; + private final List dwcaTerms = List.of("dwc:scientificName"); + private final List abcdTerms = List.of( + "result/taxonIdentified/scientificName/fullScientificNameString", + "result/mineralRockIdentified/classifiedName/fullScientificNameString"); + + @Override + public String retrieveFromDWCA(JsonNode unit) { + return super.searchJsonForTerm(unit, dwcaTerms); + } + + @Override + public String retrieveFromABCD(JsonNode unit) { + return searchJsonForTerm(unit, abcdTerms); + } + + @Override + public String getTerm() { + return TERM; + } +} diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/ScientificNameAuthorship.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/ScientificNameAuthorship.java similarity index 60% rename from src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/ScientificNameAuthorship.java rename to src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/ScientificNameAuthorship.java index edd00c5..3945260 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/ScientificNameAuthorship.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/ScientificNameAuthorship.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; import com.fasterxml.jackson.databind.JsonNode; import java.util.List; @@ -8,15 +8,17 @@ public class ScientificNameAuthorship extends AbstractTaxonomy { public static final String TERM = DWC_PREFIX + "scientificNameAuthorship"; private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of( + "result/taxonIdentified/scientificName/nameAtomised/botanical/authorTeam"); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.getTaxonFromDWCA(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDTerms(unit, List.of("/nameAtomised/botanical/authorTeam")); + return searchJsonForTerm(unit, abcdTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/SpecificEpithet.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/SpecificEpithet.java similarity index 53% rename from src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/SpecificEpithet.java rename to src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/SpecificEpithet.java index 4f29e91..73675dc 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/SpecificEpithet.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/SpecificEpithet.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; import com.fasterxml.jackson.databind.JsonNode; import java.util.List; @@ -6,17 +6,19 @@ public class SpecificEpithet extends AbstractTaxonomy { public static final String TERM = DWC_PREFIX + "specificEpithet"; - + private final List abcdTerms = List.of( + "result/taxonIdentified/scientificName/nameAtomised/botanical/firstEpithet", + "result/taxonIdentified/scientificName/nameAtomised/zoological/speciesEpithet"); private final List dwcaTerms = List.of(TERM); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.getTaxonFromDWCA(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDTerms(unit, List.of("/nameAtomised/botanical/firstEpithet")); + return searchJsonForTerm(unit, abcdTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Subfamily.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Subfamily.java new file mode 100644 index 0000000..dd10cde --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Subfamily.java @@ -0,0 +1,28 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import com.fasterxml.jackson.databind.JsonNode; +import java.util.List; + +public class Subfamily extends AbstractTaxonomy { + + public static final String TERM = DWC_PREFIX + "subfamily"; + + private final List dwcaTerms = List.of(TERM); + private final List abcdSplitTerms = List.of("subfamilia", "subfamily"); + + @Override + public String retrieveFromDWCA(JsonNode unit) { + return super.searchJsonForTerm(unit, dwcaTerms); + } + + @Override + public String retrieveFromABCD(JsonNode unit) { + return super.searchABCDSplitTerms(unit, abcdSplitTerms); + } + + @Override + public String getTerm() { + return TERM; + } + +} diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Subgenus.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Subgenus.java new file mode 100644 index 0000000..d1db855 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Subgenus.java @@ -0,0 +1,28 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import com.fasterxml.jackson.databind.JsonNode; +import java.util.List; + +public class Subgenus extends AbstractTaxonomy { + + public static final String TERM = DWC_PREFIX + "subgenus"; + + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of( + "result/taxonIdentified/scientificName/nameAtomised/zoological/subgenus"); + + @Override + public String retrieveFromDWCA(JsonNode unit) { + return super.searchJsonForTerm(unit, dwcaTerms); + } + + @Override + public String retrieveFromABCD(JsonNode unit) { + return searchJsonForTerm(unit, abcdTerms); + } + + @Override + public String getTerm() { + return TERM; + } +} diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/TaxonRank.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonId.java similarity index 52% rename from src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/TaxonRank.java rename to src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonId.java index 0fed33a..a4cf58f 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/TaxonRank.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonId.java @@ -1,17 +1,17 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; import com.fasterxml.jackson.databind.JsonNode; import java.util.List; -public class TaxonRank extends AbstractTaxonomy { +public class TaxonId extends AbstractTaxonomy { - public static final String TERM = DWC_PREFIX + "taxonRank"; + public static final String TERM = DWC_PREFIX + "taxonID"; private final List dwcaTerms = List.of(TERM); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.getTaxonFromDWCA(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonRank.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonRank.java new file mode 100644 index 0000000..c4ad6a5 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonRank.java @@ -0,0 +1,28 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import com.fasterxml.jackson.databind.JsonNode; +import java.util.List; + +public class TaxonRank extends AbstractTaxonomy { + + public static final String TERM = DWC_PREFIX + "taxonRank"; + + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of( + "result/taxonIdentified/scientificName/nameAtomised/botanical/rank"); + + @Override + public String retrieveFromDWCA(JsonNode unit) { + return super.searchJsonForTerm(unit, dwcaTerms); + } + + @Override + public String retrieveFromABCD(JsonNode unit) { + return searchJsonForTerm(unit, abcdTerms); + } + + @Override + public String getTerm() { + return TERM; + } +} diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonRemarks.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonRemarks.java new file mode 100644 index 0000000..741f3df --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonRemarks.java @@ -0,0 +1,21 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import com.fasterxml.jackson.databind.JsonNode; +import java.util.List; + +public class TaxonRemarks extends AbstractTaxonomy { + + public static final String TERM = DWC_PREFIX + "taxonRemarks"; + + 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/identification/taxonomy/TaxonomicStatus.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonomicStatus.java new file mode 100644 index 0000000..9f6a88d --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonomicStatus.java @@ -0,0 +1,21 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import com.fasterxml.jackson.databind.JsonNode; +import java.util.List; + +public class TaxonomicStatus extends AbstractTaxonomy { + + public static final String TERM = DWC_PREFIX + "taxonomicStatus"; + + 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/identification/taxonomy/VernacularName.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/VernacularName.java new file mode 100644 index 0000000..1cdd580 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/VernacularName.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import com.fasterxml.jackson.databind.JsonNode; +import java.util.List; + +public class VernacularName extends AbstractTaxonomy { + + public static final String TERM = DWC_PREFIX + "vernacularName"; + + 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/location/Continent.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/Continent.java index 1e453f5..bb46c0f 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/location/Continent.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/Continent.java @@ -9,9 +9,16 @@ public class Continent extends Term { public static final String TERM = DWC_PREFIX + "continent"; private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of("Continent"); + @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); + } + + @Override + public String retrieveFromABCD(JsonNode unit) { + return super.searchABCDSplitTerms(unit, abcdTerms, ABCD_NAMED_AREA_KEY, ABCD_NAMED_AREA_VALUE); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/location/Country.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/Country.java index 68f4bd7..a38ec0e 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/location/Country.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/Country.java @@ -15,12 +15,12 @@ public class Country 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/location/CountryCode.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/CountryCode.java index a28ec4e..3cfdec1 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/location/CountryCode.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/CountryCode.java @@ -14,12 +14,12 @@ public class CountryCode 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/location/County.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/County.java index 8fc79be..94cfd52 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/location/County.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/County.java @@ -9,9 +9,16 @@ public class County extends Term { public static final String TERM = DWC_PREFIX + "county"; private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of("County"); + @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); + } + + @Override + public String retrieveFromABCD(JsonNode unit) { + return super.searchABCDSplitTerms(unit, abcdTerms, ABCD_NAMED_AREA_KEY, ABCD_NAMED_AREA_VALUE); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/location/HigherGeography.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/HigherGeography.java new file mode 100644 index 0000000..ae3d1a1 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/HigherGeography.java @@ -0,0 +1,21 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class HigherGeography extends Term { + + public static final String TERM = DWC_PREFIX + "higherGeography"; + 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/location/Island.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/Island.java index 5f06e13..d672030 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/location/Island.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/Island.java @@ -9,9 +9,16 @@ public class Island extends Term { public static final String TERM = DWC_PREFIX + "island"; private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of("Island"); + @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); + } + + @Override + public String retrieveFromABCD(JsonNode unit) { + return super.searchABCDSplitTerms(unit, abcdTerms, ABCD_NAMED_AREA_KEY, ABCD_NAMED_AREA_VALUE); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/location/IslandGroup.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/IslandGroup.java index 9f6872e..5bf419f 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/location/IslandGroup.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/IslandGroup.java @@ -9,9 +9,16 @@ public class IslandGroup extends Term { public static final String TERM = DWC_PREFIX + "islandGroup"; private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of("Island group"); + @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); + } + + @Override + public String retrieveFromABCD(JsonNode unit) { + return super.searchABCDSplitTerms(unit, abcdTerms, ABCD_NAMED_AREA_KEY, ABCD_NAMED_AREA_VALUE); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/location/Locality.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/Locality.java index 9292ad8..6277443 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/location/Locality.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/Locality.java @@ -13,12 +13,12 @@ public class Locality 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/location/LocationAccordingTo.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/LocationAccordingTo.java new file mode 100644 index 0000000..445d456 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/LocationAccordingTo.java @@ -0,0 +1,21 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class LocationAccordingTo extends Term { + + public static final String TERM = DWC_PREFIX + "locationAccordingTo"; + 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/location/LocationRemarks.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/LocationRemarks.java new file mode 100644 index 0000000..46d12de --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/LocationRemarks.java @@ -0,0 +1,28 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class LocationRemarks extends Term { + + public static final String TERM = DWC_PREFIX + "locationRemarks"; + + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of("abcd:gathering/areaDetail/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/specimen/location/MaximumDepthInMeters.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/MaximumDepthInMeters.java new file mode 100644 index 0000000..1f17e9c --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/MaximumDepthInMeters.java @@ -0,0 +1,29 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class MaximumDepthInMeters extends Term { + + public static final String TERM = DWC_PREFIX + "maximumDepthInMeters"; + + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of( + "abcd:gathering/depth/measurementOrFactAtomised/upperValue/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/specimen/location/MaximumDistanceAboveSurfaceInMeters.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/MaximumDistanceAboveSurfaceInMeters.java new file mode 100644 index 0000000..9bc29d6 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/MaximumDistanceAboveSurfaceInMeters.java @@ -0,0 +1,29 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class MaximumDistanceAboveSurfaceInMeters extends Term { + + public static final String TERM = DWC_PREFIX + "maximumDistanceAboveSurfaceInMeters"; + + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of( + "abcd:gathering/height/measurementOrFactAtomised/upperValue/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/specimen/location/MaximumElevationInMeters.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/MaximumElevationInMeters.java new file mode 100644 index 0000000..9a912ff --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/MaximumElevationInMeters.java @@ -0,0 +1,29 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class MaximumElevationInMeters extends Term { + + public static final String TERM = DWC_PREFIX + "maximumElevationInMeters"; + + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of( + "abcd:gathering/altitude/measurementOrFactAtomised/upperValue/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/specimen/location/MinimumDepthInMeters.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/MinimumDepthInMeters.java new file mode 100644 index 0000000..186b132 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/MinimumDepthInMeters.java @@ -0,0 +1,29 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class MinimumDepthInMeters extends Term { + + public static final String TERM = DWC_PREFIX + "minimumDepthInMeters"; + + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of( + "abcd:gathering/depth/measurementOrFactAtomised/lowerValue/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/specimen/location/MinimumDistanceAboveSurfaceInMeters.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/MinimumDistanceAboveSurfaceInMeters.java new file mode 100644 index 0000000..d52b51f --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/MinimumDistanceAboveSurfaceInMeters.java @@ -0,0 +1,29 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class MinimumDistanceAboveSurfaceInMeters extends Term { + + public static final String TERM = DWC_PREFIX + "minimumDistanceAboveSurfaceInMeters"; + + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of( + "abcd:gathering/height/measurementOrFactAtomised/lowerValue/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/specimen/location/MinimumElevationInMeters.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/MinimumElevationInMeters.java new file mode 100644 index 0000000..79b2588 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/MinimumElevationInMeters.java @@ -0,0 +1,29 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class MinimumElevationInMeters extends Term { + + public static final String TERM = DWC_PREFIX + "minimumElevationInMeters"; + + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of( + "abcd:gathering/altitude/measurementOrFactAtomised/lowerValue/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/specimen/location/Municipality.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/Municipality.java index c995441..8e0a6e6 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/location/Municipality.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/Municipality.java @@ -9,9 +9,16 @@ public class Municipality extends Term { public static final String TERM = DWC_PREFIX + "municipality"; private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of("Municipality"); + @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); + } + + @Override + public String retrieveFromABCD(JsonNode unit) { + return super.searchABCDSplitTerms(unit, abcdTerms, ABCD_NAMED_AREA_KEY, ABCD_NAMED_AREA_VALUE); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/location/StateProvince.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/StateProvince.java index e5d900f..4709e7d 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/location/StateProvince.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/StateProvince.java @@ -9,9 +9,16 @@ public class StateProvince extends Term { public static final String TERM = DWC_PREFIX + "stateProvince"; private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of("State", "Province"); + @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); + } + + @Override + public String retrieveFromABCD(JsonNode unit) { + return super.searchABCDSplitTerms(unit, abcdTerms, ABCD_NAMED_AREA_KEY, ABCD_NAMED_AREA_VALUE); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/location/VerticalDatum.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/VerticalDatum.java new file mode 100644 index 0000000..036146c --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/VerticalDatum.java @@ -0,0 +1,21 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class VerticalDatum extends Term { + + public static final String TERM = DWC_PREFIX + "verticalDatum"; + 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/location/WaterBody.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/WaterBody.java index 90db959..7236e9c 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/location/WaterBody.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/WaterBody.java @@ -9,11 +9,19 @@ public class WaterBody extends Term { public static final String TERM = DWC_PREFIX + "waterBody"; private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of("Water body"); + @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } + @Override + public String retrieveFromABCD(JsonNode unit) { + return super.searchABCDSplitTerms(unit, abcdTerms, ABCD_NAMED_AREA_KEY, ABCD_NAMED_AREA_VALUE); + } + + @Override public String getTerm() { return TERM; diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/CoordinatePrecision.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/CoordinatePrecision.java new file mode 100644 index 0000000..7e554d0 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/CoordinatePrecision.java @@ -0,0 +1,29 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class CoordinatePrecision extends Term { + + public static final String TERM = DWC_PREFIX + "coordinatePrecision"; + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of( + "abcd:gathering/siteCoordinateSets/siteCoordinates/0/coordinatesLatLong/iSOAccuracy", + "abcd:gathering/siteCoordinateSets/siteCoordinates/0/coordinatesLatLong/accuracyStatement"); + + @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/specimen/location/georeference/CoordinateUncertaintyInMeters.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/CoordinateUncertaintyInMeters.java new file mode 100644 index 0000000..9f6496b --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/CoordinateUncertaintyInMeters.java @@ -0,0 +1,28 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class CoordinateUncertaintyInMeters extends Term { + + public static final String TERM = DWC_PREFIX + "coordinateUncertaintyInMeters"; + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of( + "abcd:gathering/siteCoordinateSets/siteCoordinates/0/coordinatesLatLong/coordinateErrorDistanceInMeters"); + + @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/specimen/location/DecimalLatitude.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/DecimalLatitude.java similarity index 54% rename from src/main/java/eu/dissco/core/translator/terms/specimen/location/DecimalLatitude.java rename to src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/DecimalLatitude.java index baba731..6fac7b0 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/location/DecimalLatitude.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/DecimalLatitude.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.location; +package eu.dissco.core.translator.terms.specimen.location.georeference; import com.fasterxml.jackson.databind.JsonNode; import eu.dissco.core.translator.terms.Term; @@ -7,21 +7,18 @@ public class DecimalLatitude extends Term { public static final String TERM = DWC_PREFIX + "decimalLatitude"; - private static final String ABCD_TERM = "abcd:gathering/siteCoordinateSets/siteCoordinates/0/coordinatesLatLong/latitudeDecimal"; private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of( + "abcd:gathering/siteCoordinateSets/siteCoordinates/0/coordinatesLatLong/latitudeDecimal"); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - var latitude = unit.get(ABCD_TERM); - if (latitude != null && latitude.isDouble()) { - return String.valueOf(latitude.asDouble()); - } - return null; + return super.searchJsonForTerm(unit, abcdTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/location/DecimalLongitude.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/DecimalLongitude.java similarity index 53% rename from src/main/java/eu/dissco/core/translator/terms/specimen/location/DecimalLongitude.java rename to src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/DecimalLongitude.java index 8692a1c..c9ecc05 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/location/DecimalLongitude.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/DecimalLongitude.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.location; +package eu.dissco.core.translator.terms.specimen.location.georeference; import com.fasterxml.jackson.databind.JsonNode; import eu.dissco.core.translator.terms.Term; @@ -7,21 +7,18 @@ public class DecimalLongitude extends Term { public static final String TERM = DWC_PREFIX + "decimalLongitude"; - private static final String ABCD_TERM = "abcd:gathering/siteCoordinateSets/siteCoordinates/0/coordinatesLatLong/longitudeDecimal"; private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of( + "abcd:gathering/siteCoordinateSets/siteCoordinates/0/coordinatesLatLong/longitudeDecimal"); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - var longitude = unit.get(ABCD_TERM); - if (longitude != null && longitude.isDouble()) { - return String.valueOf(longitude.asDouble()); - } - return null; + return super.searchJsonForTerm(unit, abcdTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/FootprintSpatialFit.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/FootprintSpatialFit.java new file mode 100644 index 0000000..0c8e3b1 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/FootprintSpatialFit.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class FootprintSpatialFit extends Term { + + public static final String TERM = DWC_PREFIX + "footprintSpatialFit"; + + 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/location/georeference/FootprintSrs.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/FootprintSrs.java new file mode 100644 index 0000000..8ed58a2 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/FootprintSrs.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class FootprintSrs extends Term { + + public static final String TERM = DWC_PREFIX + "footprintSrs"; + + 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/location/georeference/FootprintWkt.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/FootprintWkt.java new file mode 100644 index 0000000..06e1b46 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/FootprintWkt.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class FootprintWkt extends Term { + + public static final String TERM = DWC_PREFIX + "footprintWkt"; + + 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/location/GeodeticDatum.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeodeticDatum.java similarity index 77% rename from src/main/java/eu/dissco/core/translator/terms/specimen/location/GeodeticDatum.java rename to src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeodeticDatum.java index 56d2218..5f168de 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/location/GeodeticDatum.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeodeticDatum.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.location; +package eu.dissco.core.translator.terms.specimen.location.georeference; import com.fasterxml.jackson.databind.JsonNode; import eu.dissco.core.translator.terms.Term; @@ -14,12 +14,12 @@ public class GeodeticDatum 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/location/georeference/GeoreferenceProtocol.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferenceProtocol.java new file mode 100644 index 0000000..8924d02 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferenceProtocol.java @@ -0,0 +1,30 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class GeoreferenceProtocol extends Term { + + public static final String TERM = DWC_PREFIX + "georeferenceProtocol"; + + private final List dwcaTerms = List.of(TERM); + + private final List abcdTerms = List.of( + "abcd:gathering/siteCoordinateSets/siteCoordinates/0/coordinateMethod"); + + @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/specimen/location/georeference/GeoreferenceRemarks.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferenceRemarks.java new file mode 100644 index 0000000..0ba8e75 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferenceRemarks.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class GeoreferenceRemarks extends Term { + + public static final String TERM = DWC_PREFIX + "georeferenceRemarks"; + + 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/location/georeference/GeoreferenceSources.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferenceSources.java new file mode 100644 index 0000000..5b4fdfa --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferenceSources.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class GeoreferenceSources extends Term { + + public static final String TERM = DWC_PREFIX + "georeferenceSources"; + + 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/location/georeference/GeoreferencedBy.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferencedBy.java new file mode 100644 index 0000000..242cc10 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferencedBy.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class GeoreferencedBy extends Term { + + public static final String TERM = DWC_PREFIX + "georeferencedBy"; + + 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/location/georeference/GeoreferencedDate.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferencedDate.java new file mode 100644 index 0000000..9ee5285 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferencedDate.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class GeoreferencedDate extends Term { + + public static final String TERM = DWC_PREFIX + "georeferencedDate"; + + 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/location/georeference/PointRadiusSpatialFit.java b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/PointRadiusSpatialFit.java new file mode 100644 index 0000000..98c5ddc --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/location/georeference/PointRadiusSpatialFit.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class PointRadiusSpatialFit extends Term { + + public static final String TERM = DWC_PREFIX + "pointRadiusSpatialFit"; + + 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/occurence/Behavior.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/Behavior.java new file mode 100644 index 0000000..0e0740e --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/Behavior.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class Behavior extends Term { + + public static final String TERM = DWC_PREFIX + "behavior"; + + 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/occurence/DataGeneralizations.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/DataGeneralizations.java new file mode 100644 index 0000000..833495a --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/DataGeneralizations.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class DataGeneralizations extends Term { + + public static final String TERM = DWC_PREFIX + "dataGeneralizations"; + + 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/occurence/DegreeOfEstablishment.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/DegreeOfEstablishment.java new file mode 100644 index 0000000..9afd5ef --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/DegreeOfEstablishment.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class DegreeOfEstablishment extends Term { + + public static final String TERM = DWC_PREFIX + "degreeOfEstablishment"; + + 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/occurence/EstablishmentMeans.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/EstablishmentMeans.java new file mode 100644 index 0000000..9cf0321 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/EstablishmentMeans.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class EstablishmentMeans extends Term { + + public static final String TERM = DWC_PREFIX + "establishmentMeans"; + + 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/DateCollected.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/EventDate.java similarity index 59% rename from src/main/java/eu/dissco/core/translator/terms/specimen/DateCollected.java rename to src/main/java/eu/dissco/core/translator/terms/specimen/occurence/EventDate.java index 04bf2e0..b662030 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/DateCollected.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/EventDate.java @@ -1,25 +1,25 @@ -package eu.dissco.core.translator.terms.specimen; +package eu.dissco.core.translator.terms.specimen.occurence; import com.fasterxml.jackson.databind.JsonNode; import eu.dissco.core.translator.terms.Term; import java.util.List; -public class DateCollected extends Term { +public class EventDate extends Term { - public static final String TERM = ODS_PREFIX + "dateCollected"; + public static final String TERM = DWC_PREFIX + "eventDate"; - private final List dwcaTerms = List.of("dwc:eventDate"); + private final List dwcaTerms = List.of(TERM); private final List abcdTerms = List.of("abcd:gathering/dateTime/isodateTimeBegin", "abcd:gathering/dateTime/isodateTimeEnd", "abcd:gathering/dateTime/dateText"); @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/occurence/EventRemark.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/EventRemark.java new file mode 100644 index 0000000..f124c5e --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/EventRemark.java @@ -0,0 +1,28 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class EventRemark extends Term { + + public static final String TERM = DWC_PREFIX + "eventRemarks"; + + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of("abcd:gathering/notes/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/specimen/occurence/FieldNotes.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/FieldNotes.java new file mode 100644 index 0000000..008f98b --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/FieldNotes.java @@ -0,0 +1,28 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class FieldNotes extends Term { + + public static final String TERM = DWC_PREFIX + "fieldNotes"; + + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of("abcd:gathering/fieldNotes/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/specimen/CollectingNumber.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/FieldNumber.java similarity index 62% rename from src/main/java/eu/dissco/core/translator/terms/specimen/CollectingNumber.java rename to src/main/java/eu/dissco/core/translator/terms/specimen/occurence/FieldNumber.java index 7561a9a..92d9591 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/CollectingNumber.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/FieldNumber.java @@ -1,25 +1,25 @@ -package eu.dissco.core.translator.terms.specimen; +package eu.dissco.core.translator.terms.specimen.occurence; import com.fasterxml.jackson.databind.JsonNode; import eu.dissco.core.translator.terms.Term; import java.util.List; -public class CollectingNumber extends Term { +public class FieldNumber extends Term { - public static final String TERM = ODS_PREFIX + "collectingNumber"; + public static final String TERM = DWC_PREFIX + "fieldNumber"; - private final List dwcaTerms = List.of("dwc:recordNumber"); + private final List dwcaTerms = List.of("dwc:recordNumber", "dwc:fieldNumber"); private final List abcdTerms = List.of("abcd:collectorsFieldNumber", "abcd:gathering/code"); @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/occurence/GeoreferenceVerificationStatus.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/GeoreferenceVerificationStatus.java new file mode 100644 index 0000000..18de27e --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/GeoreferenceVerificationStatus.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class GeoreferenceVerificationStatus extends Term { + + public static final String TERM = DWC_PREFIX + "georeferenceVerificationStatus"; + + 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/occurence/Habitat.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/Habitat.java new file mode 100644 index 0000000..a9bb7cd --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/Habitat.java @@ -0,0 +1,28 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class Habitat extends Term { + + public static final String TERM = DWC_PREFIX + "habitat"; + + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of("abcd:gathering/biotope/text/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/specimen/occurence/InformationWithheld.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/InformationWithheld.java new file mode 100644 index 0000000..7dac5a9 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/InformationWithheld.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class InformationWithheld extends Term { + + public static final String TERM = DWC_PREFIX + "informationWithheld"; + + 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/occurence/LifeStage.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/LifeStage.java new file mode 100644 index 0000000..f718442 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/LifeStage.java @@ -0,0 +1,31 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class LifeStage extends Term { + + public static final String TERM = DWC_PREFIX + "lifeStage"; + + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of( + "abcd:unit/mycologicalUnit/mycologicalSexualStage", + "abcd:unit/mycologicalUnit/mycologicalLiveStages/0/mycologicalLiveStage/value", + "abcd:unit/zoologicalUnit/phasesOrStages/0/phaseOrStage/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/specimen/occurence/OccurrenceAssertions.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/OccurrenceAssertions.java new file mode 100644 index 0000000..e7094b4 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/OccurrenceAssertions.java @@ -0,0 +1,85 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.dissco.core.translator.schema.Assertions; +import eu.dissco.core.translator.terms.Term; +import java.util.ArrayList; +import java.util.List; + +public class OccurrenceAssertions extends Term { + + private static final String EXTENSIONS = "extensions"; + + public List gatherOccurrenceAssertions( + ObjectMapper mapper, JsonNode data, boolean dwc) { + if (dwc) { + return gatherOccurrenceAssertionsForDwc(data); + } else { + return gatherOccurrenceAssertionsForABCD(mapper, data); + } + } + + private List gatherOccurrenceAssertionsForABCD( + ObjectMapper mapper, JsonNode data) { + var assertions = new ArrayList(); + var iterateOverElements = true; + var count = 0; + while (iterateOverElements) { + var assertionNode = getSubJsonAbcd(mapper, data, count, + "abcd:measurementsOrFacts/measurementOrFact/"); + if (!assertionNode.isEmpty()) { + assertions.add(createOccurrenceAssertion(assertionNode)); + count++; + } else { + iterateOverElements = false; + } + } + return assertions; + } + + private eu.dissco.core.translator.schema.Assertions createOccurrenceAssertion( + JsonNode assertionNode) { + return new Assertions().withAssertionByAgentName( + super.searchJsonForTerm(assertionNode, List.of("measurementOrFactAtomised/measuredBy"))) + .withAssertionUnit(super.searchJsonForTerm(assertionNode, + List.of("measurementOrFactAtomised/unitOfMeasurement"))) + .withAssertionType( + super.searchJsonForTerm(assertionNode, + List.of("measurementOrFactAtomised/parameter/value"))) + .withAssertionRemarks( + super.searchJsonForTerm(assertionNode, List.of("measurementOrFactText/value"))) + .withAssertionValue(super.searchJsonForTerm(assertionNode, + List.of("measurementOrFactAtomised/lowerValue", + "measurementOrFactAtomised/upperValue"))) + .withAssertionMadeDate(super.searchJsonForTerm(assertionNode, + List.of("measurementOrFactAtomised/MeasurementDateTime"))); + } + + private List gatherOccurrenceAssertionsForDwc( + JsonNode data) { + var assertions = new ArrayList(); + if (data.get(EXTENSIONS) != null + && data.get(EXTENSIONS).get("dwc:MeasurementOrFact") != null) { + var measurementOrFactExtension = data.get(EXTENSIONS).get("dwc:MeasurementOrFact"); + for (var jsonNode : measurementOrFactExtension) { + var assertion = new eu.dissco.core.translator.schema.Assertions() + .withAssertionUnit( + super.searchJsonForTerm(jsonNode, List.of("dwc:measurementUnit"))) + .withAssertionType( + super.searchJsonForTerm(jsonNode, List.of("dwc:measurementType"))) + .withAssertionValue( + super.searchJsonForTerm(jsonNode, List.of("dwc:measurementValue"))) + .withAssertionRemarks( + super.searchJsonForTerm(jsonNode, List.of("dwc:measurementRemarks"))); + assertions.add(assertion); + } + } + return assertions; + } + + @Override + public String getTerm() { + return null; + } +} diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/OccurrenceRemarks.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/OccurrenceRemarks.java new file mode 100644 index 0000000..ac68da0 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/OccurrenceRemarks.java @@ -0,0 +1,28 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class OccurrenceRemarks extends Term { + + public static final String TERM = DWC_PREFIX + "occurrenceRemarks"; + private final List dwcaTerms = List.of(TERM); + private final List abcdUnitTerms = List.of("abcd:notes/value"); + + @Override + public String retrieveFromDWCA(JsonNode unit) { + return super.searchJsonForTerm(unit, dwcaTerms); + } + + @Override + public String retrieveFromABCD(JsonNode unit) { + return searchJsonForTerm(unit, abcdUnitTerms); + } + + @Override + public String getTerm() { + return TERM; + } +} + diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/OccurrenceStatus.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/OccurrenceStatus.java new file mode 100644 index 0000000..1413f0e --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/OccurrenceStatus.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class OccurrenceStatus extends Term { + + public static final String TERM = DWC_PREFIX + "occurrenceStatus"; + + 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/occurence/OrganismQuantity.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/OrganismQuantity.java new file mode 100644 index 0000000..79ab723 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/OrganismQuantity.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class OrganismQuantity extends Term { + + public static final String TERM = DWC_PREFIX + "organismQuantity"; + + private final List dwcaTerms = List.of(TERM, "dwc:individualCount"); + + @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/occurence/OrganismQuantityType.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/OrganismQuantityType.java new file mode 100644 index 0000000..7696aa8 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/OrganismQuantityType.java @@ -0,0 +1,29 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class OrganismQuantityType extends Term { + + public static final String TERM = DWC_PREFIX + "organismQuantityType"; + + private final List dwcaTerms = List.of(TERM); + + @Override + public String retrieveFromDWCA(JsonNode unit) { + var type = super.searchJsonForTerm(unit, dwcaTerms); + if (type == null) { + var individuals = super.searchJsonForTerm(unit, List.of("dwc:individualCount")); + if (individuals != null) { + return "individuals"; + } + } + return type; + } + + @Override + public String getTerm() { + return TERM; + } +} diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/Pathway.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/Pathway.java new file mode 100644 index 0000000..b4aa3e3 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/Pathway.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class Pathway extends Term { + + public static final String TERM = DWC_PREFIX + "pathway"; + + 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/occurence/ReproductiveCondition.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/ReproductiveCondition.java new file mode 100644 index 0000000..b7a24a0 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/ReproductiveCondition.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class ReproductiveCondition extends Term { + + public static final String TERM = DWC_PREFIX + "reproductiveCondition"; + + 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/occurence/SampleSizeUnit.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/SampleSizeUnit.java new file mode 100644 index 0000000..36f5f9c --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/SampleSizeUnit.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class SampleSizeUnit extends Term { + + public static final String TERM = DWC_PREFIX + "sampleSizeUnit"; + + 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/occurence/SampleSizeValue.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/SampleSizeValue.java new file mode 100644 index 0000000..44fc1d3 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/SampleSizeValue.java @@ -0,0 +1,22 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class SampleSizeValue extends Term { + + public static final String TERM = DWC_PREFIX + "sampleSizeValue"; + + 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/occurence/SamplingProtocol.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/SamplingProtocol.java new file mode 100644 index 0000000..ae52b03 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/SamplingProtocol.java @@ -0,0 +1,29 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class SamplingProtocol extends Term { + + public static final String TERM = DWC_PREFIX + "samplingProtocol"; + private final List dwcaTerms = List.of(TERM); + private final List abcdTerms = List.of("abcd:gathering/method/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/specimen/occurence/Sex.java b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/Sex.java new file mode 100644 index 0000000..115f725 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/occurence/Sex.java @@ -0,0 +1,29 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class Sex extends Term { + + public static final String TERM = DWC_PREFIX + "sex"; + + private final List dwcaTerms = List.of(TERM); + + private final List abcdTerms = List.of("abcd:sex"); + + @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/specimen/stratigraphy/biostratigraphic/HighestBiostratigraphicZone.java b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/biostratigraphic/HighestBiostratigraphicZone.java index d2bda22..671f606 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/biostratigraphic/HighestBiostratigraphicZone.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/biostratigraphic/HighestBiostratigraphicZone.java @@ -16,7 +16,7 @@ public class HighestBiostratigraphicZone extends 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/stratigraphy/biostratigraphic/LowestBiostratigraphicZone.java b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/biostratigraphic/LowestBiostratigraphicZone.java index 2b77998..258f3b3 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/biostratigraphic/LowestBiostratigraphicZone.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/biostratigraphic/LowestBiostratigraphicZone.java @@ -16,7 +16,7 @@ public class LowestBiostratigraphicZone extends 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/stratigraphy/chronostratigraphic/AbstractChronoStratigraphy.java b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/AbstractChronoStratigraphy.java index 768097d..d41f027 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/AbstractChronoStratigraphy.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/AbstractChronoStratigraphy.java @@ -3,10 +3,8 @@ import com.fasterxml.jackson.databind.JsonNode; import eu.dissco.core.translator.terms.Term; import java.util.List; -import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.tuple.Pair; -@Slf4j public abstract class AbstractChronoStratigraphy extends Term { private static final Pair ABCD_DIVISION = diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestAgeOrLowestStage.java b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestAgeOrLowestStage.java index 83012c5..cab0564 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestAgeOrLowestStage.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestAgeOrLowestStage.java @@ -7,15 +7,16 @@ public class EarliestAgeOrLowestStage extends AbstractChronoStratigraphy { public static final String TERM = DWC_PREFIX + "earliestAgeOrLowestStage"; private final List dwcaTerms = List.of(TERM); + private final List abcdSplitTerms = List.of("SubStage", "Stage"); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDSplitTerms(unit, List.of("SubStage", "Stage")); + return super.searchABCDSplitTerms(unit, abcdSplitTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestEonOrLowestEonothem.java b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestEonOrLowestEonothem.java index 9f64582..6eaec11 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestEonOrLowestEonothem.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestEonOrLowestEonothem.java @@ -8,14 +8,16 @@ public class EarliestEonOrLowestEonothem extends AbstractChronoStratigraphy { public static final String TERM = DWC_PREFIX + "earliestEonOrLowestEonothem"; private final List dwcaTerms = List.of(TERM); + private final List abcdSplitTerms = List.of("Eonothem"); + @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDSplitTerms(unit, List.of("Eonothem")); + return super.searchABCDSplitTerms(unit, abcdSplitTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestEpochOrLowestSeries.java b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestEpochOrLowestSeries.java index a94226d..f20b6f8 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestEpochOrLowestSeries.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestEpochOrLowestSeries.java @@ -8,15 +8,16 @@ public class EarliestEpochOrLowestSeries extends AbstractChronoStratigraphy { public static final String TERM = DWC_PREFIX + "earliestEpochOrLowestSeries"; private final List dwcaTerms = List.of(TERM); + private final List abcdSplitTerms = List.of("SubSeries", "SubSerie", "Series", "Serie"); + @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDSplitTerms(unit, - List.of("SubSeries", "SubSerie", "Series", "Serie")); + return super.searchABCDSplitTerms(unit, abcdSplitTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestEraOrLowestErathem.java b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestEraOrLowestErathem.java index f5152ab..f86df8d 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestEraOrLowestErathem.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestEraOrLowestErathem.java @@ -7,15 +7,16 @@ public class EarliestEraOrLowestErathem extends AbstractChronoStratigraphy { public static final String TERM = DWC_PREFIX + "earliestEraOrLowestErathem"; private final List dwcaTerms = List.of(TERM); + private final List abcdSplitTerms = List.of("Erathem"); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDSplitTerms(unit, List.of("Erathem")); + return super.searchABCDSplitTerms(unit, abcdSplitTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestPeriodOrLowestSystem.java b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestPeriodOrLowestSystem.java index 71c336d..94b8fcf 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestPeriodOrLowestSystem.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/EarliestPeriodOrLowestSystem.java @@ -8,14 +8,16 @@ public class EarliestPeriodOrLowestSystem extends AbstractChronoStratigraphy { public static final String TERM = DWC_PREFIX + "earliestPeriodOrLowestSystem"; private final List dwcaTerms = List.of(TERM); + private final List abcdSplitTerms = List.of("System"); + @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDSplitTerms(unit, List.of("System")); + return super.searchABCDSplitTerms(unit, abcdSplitTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestAgeOrHighestStage.java b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestAgeOrHighestStage.java index 94da524..bfc35cb 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestAgeOrHighestStage.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestAgeOrHighestStage.java @@ -7,15 +7,16 @@ public class LatestAgeOrHighestStage extends AbstractChronoStratigraphy { public static final String TERM = DWC_PREFIX + "latestAgeOrHighestStage"; private final List dwcaTerms = List.of(TERM); + private final List abcdSplitTerms = List.of("Stage"); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDSplitTerms(unit, List.of("Stage")); + return super.searchABCDSplitTerms(unit, abcdSplitTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestEonOrHighestEonothem.java b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestEonOrHighestEonothem.java index cae22aa..d2c836f 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestEonOrHighestEonothem.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestEonOrHighestEonothem.java @@ -7,15 +7,16 @@ public class LatestEonOrHighestEonothem extends AbstractChronoStratigraphy { public static final String TERM = DWC_PREFIX + "latestEonOrHighestEonothem"; private final List dwcaTerms = List.of(TERM); + private final List abcdSplitTerms = List.of("Eonothem"); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDSplitTerms(unit, List.of("Eonothem")); + return super.searchABCDSplitTerms(unit, abcdSplitTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestEpochOrHighestSeries.java b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestEpochOrHighestSeries.java index 2237fdf..1c267b0 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestEpochOrHighestSeries.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestEpochOrHighestSeries.java @@ -7,15 +7,16 @@ public class LatestEpochOrHighestSeries extends AbstractChronoStratigraphy { public static final String TERM = DWC_PREFIX + "latestEpochOrHighestSeries"; private final List dwcaTerms = List.of(TERM); + private final List abcdSplitTerms = List.of("Series", "Serie"); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDSplitTerms(unit, List.of("Series", "Serie")); + return super.searchABCDSplitTerms(unit, abcdSplitTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestEraOrHighestErathem.java b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestEraOrHighestErathem.java index 6d14b4f..7a3ff9b 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestEraOrHighestErathem.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestEraOrHighestErathem.java @@ -7,15 +7,16 @@ public class LatestEraOrHighestErathem extends AbstractChronoStratigraphy { public static final String TERM = DWC_PREFIX + "latestEraOrHighestErathem"; private final List dwcaTerms = List.of(TERM); + private final List abcdSplitTerms = List.of("Erathem"); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDSplitTerms(unit, List.of("Erathem")); + return super.searchABCDSplitTerms(unit, abcdSplitTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestPeriodOrHighestSystem.java b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestPeriodOrHighestSystem.java index 5eba90c..ffd784f 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestPeriodOrHighestSystem.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/chronostratigraphic/LatestPeriodOrHighestSystem.java @@ -7,15 +7,16 @@ public class LatestPeriodOrHighestSystem extends AbstractChronoStratigraphy { public static final String TERM = DWC_PREFIX + "latestPeriodOrHighestSystem"; private final List dwcaTerms = List.of(TERM); + private final List abcdSplitTerms = List.of("System"); @Override public String retrieveFromDWCA(JsonNode unit) { - return super.searchJsonForStringTerm(unit, dwcaTerms); + return super.searchJsonForTerm(unit, dwcaTerms); } @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchABCDSplitTerms(unit, List.of("System")); + return super.searchABCDSplitTerms(unit, abcdSplitTerms); } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/lithostratigraphic/Bed.java b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/lithostratigraphic/Bed.java index 12480e7..fe92c8f 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/lithostratigraphic/Bed.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/lithostratigraphic/Bed.java @@ -15,12 +15,12 @@ public class Bed 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/stratigraphy/lithostratigraphic/Formation.java b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/lithostratigraphic/Formation.java index 4848abb..df175e5 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/lithostratigraphic/Formation.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/lithostratigraphic/Formation.java @@ -15,12 +15,12 @@ public class Formation 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/stratigraphy/lithostratigraphic/Group.java b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/lithostratigraphic/Group.java index cf15229..683e5bc 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/lithostratigraphic/Group.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/lithostratigraphic/Group.java @@ -15,12 +15,12 @@ public class Group 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/stratigraphy/lithostratigraphic/LithostratigraphicTerms.java b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/lithostratigraphic/LithostratigraphicTerms.java new file mode 100644 index 0000000..033aab6 --- /dev/null +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/lithostratigraphic/LithostratigraphicTerms.java @@ -0,0 +1,30 @@ +package eu.dissco.core.translator.terms.specimen.stratigraphy.lithostratigraphic; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.dissco.core.translator.terms.Term; +import java.util.List; + +public class LithostratigraphicTerms extends Term { + + public static final String TERM = DWC_PREFIX + "lithostratigraphicTerms"; + + private final List dwcaTerms = List.of(TERM); + // Take the first lithostratigraphicAttribution we can find + private final List abcdTerms = List.of( + "abcd:gathering/stratigraphy/lithostratigraphicTerms/lithostratigraphicTerm/0/term"); + + @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/specimen/stratigraphy/lithostratigraphic/Member.java b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/lithostratigraphic/Member.java index 8531f29..10f7ef9 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/lithostratigraphic/Member.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/stratigraphy/lithostratigraphic/Member.java @@ -15,12 +15,12 @@ public class Member 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/taxonomy/AbstractTaxonomy.java b/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/AbstractTaxonomy.java deleted file mode 100644 index 636d843..0000000 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/AbstractTaxonomy.java +++ /dev/null @@ -1,136 +0,0 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import eu.dissco.core.translator.terms.Term; -import java.util.List; -import java.util.Optional; -import org.apache.commons.lang3.tuple.Pair; -import org.apache.commons.lang3.tuple.Triple; - -public abstract class AbstractTaxonomy extends Term { - - protected static final String IDENTIFICATION = "abcd:identifications/identification/"; - protected static final String EXTENSIONS = "extensions"; - protected static final String IDENTIFICATION_EXTENSION = "dwc:Identification"; - protected static final String IDENTIFICATION_VERIFICATION_STATUS = "dwc:identificationVerificationStatus"; - private static final String IDENTIFICATION_INDEX = "ods:taxonIdentificationIndex"; - private static final Triple ABCD_TAXON_RANK = - Triple.of( - IDENTIFICATION, - "/result/taxonIdentified/higherTaxa/higherTaxon/", - "/higherTaxonRank"); - private static final Triple ABCD_VALUE = - Triple.of( - IDENTIFICATION, - "/result/taxonIdentified/higherTaxa/higherTaxon/", - "/higherTaxonName"); - private static final Pair abcdPreferredFlag = Pair.of(IDENTIFICATION, - "/preferredFlag"); - - protected String getTaxonFromDWCA(JsonNode unit, List dwcaTerms) { - var result = super.searchJsonForStringTerm(unit, dwcaTerms); - if (result != null) { - return result; - } else if (unit.get(EXTENSIONS) != null - && unit.get(EXTENSIONS).get(IDENTIFICATION_EXTENSION) != null) { - var identificationIndex = getIdentificationIndexDWCA(unit); - if (identificationIndex != null) { - return searchJsonForStringTerm( - unit.get(EXTENSIONS).get(IDENTIFICATION_EXTENSION) - .get(Integer.parseInt(identificationIndex)), dwcaTerms); - } - } - return null; - } - - private Optional determineIdentificationIndexDWCA(JsonNode unit) { - if (unit.get(EXTENSIONS) != null - && unit.get(EXTENSIONS).get(IDENTIFICATION_EXTENSION) != null) { - var identifications = unit.get(EXTENSIONS).get(IDENTIFICATION_EXTENSION); - for (int i = 0; i < identifications.size(); i++) { - var identification = identifications.get(i); - if (identification.get(IDENTIFICATION_VERIFICATION_STATUS) == null) { - return Optional.of(String.valueOf(i)); - } else { - var verificationStatus = identification.get(IDENTIFICATION_VERIFICATION_STATUS) - .asText(); - if (verificationStatus.equals("1")) { - return Optional.of(String.valueOf(i)); - } - } - } - } - return Optional.empty(); - } - - protected String getIdentificationIndexDWCA(JsonNode unit) { - if (unit.get(IDENTIFICATION_INDEX) != null) { - return unit.get(IDENTIFICATION_INDEX).asText(); - } else { - var optionalIndex = determineIdentificationIndexDWCA(unit); - if (optionalIndex.isPresent()) { - ((ObjectNode) unit).put(IDENTIFICATION_INDEX, optionalIndex.get()); - return optionalIndex.get(); - } else { - return null; - } - } - } - - protected String getIdentificationIndexABCD(JsonNode unit) { - if (unit.get(IDENTIFICATION_INDEX) != null) { - return unit.get(IDENTIFICATION_INDEX).asText(); - } else { - var identificationIndex = determineIdentificationIndexABCD(unit); - ((ObjectNode) unit).put(IDENTIFICATION_INDEX, identificationIndex); - return identificationIndex; - } - } - - private String determineIdentificationIndexABCD(JsonNode unit) { - var numberFound = 0; - while (true) { - if (unit.get(getStringAtIndex(abcdPreferredFlag, numberFound)) != null) { - var optionalResult = checkPreferredFlag(unit, numberFound); - if (optionalResult.isPresent()) { - return optionalResult.get(); - } else { - numberFound++; - } - } else { - return "0"; - } - } - } - - protected String searchABCDSplitTerms(JsonNode unit, List searchTerms) { - var identificationIndex = getIdentificationIndexABCD(unit); - return searchABCDSplitTerms(unit, searchTerms, - Pair.of(ABCD_TAXON_RANK.getLeft() + identificationIndex + ABCD_TAXON_RANK.getMiddle(), - ABCD_TAXON_RANK.getRight()), - Pair.of(ABCD_VALUE.getLeft() + identificationIndex + ABCD_VALUE.getMiddle(), - ABCD_VALUE.getRight())); - } - - protected String searchABCDTerms(JsonNode unit, List searchTerms) { - var identificationIndex = getIdentificationIndexABCD(unit); - var terms = searchTerms.stream().map( - term -> IDENTIFICATION + identificationIndex + "/result/taxonIdentified" + term).toList(); - return searchJsonForStringTerm(unit, terms); - } - - protected String getStringAtIndex(Pair string, int numberFound) { - return string.getLeft() + numberFound + string.getRight(); - } - - private Optional checkPreferredFlag(JsonNode unit, int numberFound) { - var preferred = unit.get(getStringAtIndex(abcdPreferredFlag, numberFound)).asBoolean(); - if (preferred) { - return Optional.of(String.valueOf(numberFound)); - } - return Optional.empty(); - } - - -} diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/SpecimenName.java b/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/SpecimenName.java deleted file mode 100644 index 94478fd..0000000 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/SpecimenName.java +++ /dev/null @@ -1,41 +0,0 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; - -import com.fasterxml.jackson.databind.JsonNode; -import java.util.List; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.tuple.Pair; - -@Slf4j -public class SpecimenName extends AbstractTaxonomy { - - public static final String TERM = ODS_PREFIX + "specimenName"; - private final List dwcaTerms = List.of("dwc:scientificName"); - private final List> abcdTerms = List.of( - Pair.of(IDENTIFICATION, "/result/taxonIdentified/scientificName/fullScientificNameString"), - Pair.of("abcd-efg:identifications/identification/", - "/result/mineralRockIdentified/classifiedName/fullScientificNameString"), - Pair.of(IDENTIFICATION, "result/taxonIdentified/informalNameString"), - Pair.of(IDENTIFICATION, - "result/taxonIdentified/scientificName/nameAtomised/zoological/namedIndividual") - ); - - @Override - public String retrieveFromDWCA(JsonNode unit) { - return super.getTaxonFromDWCA(unit, dwcaTerms); - } - - - @Override - public String retrieveFromABCD(JsonNode unit) { - var identificationIndex = getIdentificationIndexABCD(unit); - var terms = abcdTerms.stream() - .map(abcdTerm -> getStringAtIndex(abcdTerm, Integer.parseInt(identificationIndex))) - .toList(); - return searchJsonForStringTerm(unit, terms); - } - - @Override - public String getTerm() { - return TERM; - } -} diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/TypeStatus.java b/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/TypeStatus.java deleted file mode 100644 index 2553cd6..0000000 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/taxonomy/TypeStatus.java +++ /dev/null @@ -1,34 +0,0 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; - -import com.fasterxml.jackson.databind.JsonNode; -import java.util.List; - -public class TypeStatus extends AbstractTaxonomy { - - public static final String TERM = DWC_PREFIX + "typeStatus"; - - private final List dwcaTerms = List.of(TERM); - - // Pick the first TypeStatus from ABCD - private final List abcdTerms = - List.of( - "abcd:specimenUnit/nomenclaturalTypeDesignations/nomenclaturalTypeDesignation/0/typeStatus", - "abcd:specimenUnit/nomenclaturalTypeDesignations/nomenclaturalTypeDesignation/0/typifiedName/fullScientificNameString", - "abcd:specimenUnit/nomenclaturalTypeDesignations/nomenclaturalTypeDesignation/0/nomenclaturalReference/titleCitation" - ); - - @Override - public String retrieveFromDWCA(JsonNode unit) { - return super.getTaxonFromDWCA(unit, dwcaTerms); - } - - @Override - public String retrieveFromABCD(JsonNode unit) { - return super.combineABCDTerms(unit, abcdTerms); - } - - @Override - public String getTerm() { - return TERM; - } -} diff --git a/src/main/resources/json-schema/agent.json b/src/main/resources/json-schema/agent.json new file mode 100644 index 0000000..7ab402f --- /dev/null +++ b/src/main/resources/json-schema/agent.json @@ -0,0 +1,50 @@ +{ + "$id": "agent", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "$comment": "", + "properties": { + "agentRole": { + "type": "string", + "examples": [ + "collector" + ] + }, + "agentType": { + "type": "string", + "examples": [ + "machine", + "human", + "organisation" + ] + }, + "agentName": { + "type": "string", + "examples": [ + "John Smith" + ] + }, + "agentRoleBegan": { + "type": "string", + "format": "date-time" + }, + "agentRoleEnded": { + "type": "string", + "format": "date-time" + }, + "agentRoleOrder": { + "type": "integer", + "minimum": 0 + }, + "identifiers": { + "type": "array", + "items": { + "$ref": "identifications.json" + } + } + }, + "required": [ + "agentType", + "agentName" + ] +} \ No newline at end of file diff --git a/src/main/resources/json-schema/assertions.json b/src/main/resources/json-schema/assertions.json new file mode 100644 index 0000000..c0370f3 --- /dev/null +++ b/src/main/resources/json-schema/assertions.json @@ -0,0 +1,44 @@ +{ + "$id": "assertion", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "$comment": "Looks like Measurement or Fact but terminology is different, no ontology yet?", + "properties": { + "???:assertionType": { + "type": "string" + }, + "???:assertionMadeDate": { + "type": "string" + }, + "???:assertionEffectiveDate": { + "type": "string" + }, + "???:assertionValue": { + "type": "string" + }, + "???:assertionValueNumeric": { + "type": "integer" + }, + "???:assertionUnit": { + "type": "string" + }, + "???:assertionByAgentName": { + "type": "string" + }, + "???:assertionByAgentId": { + "type": "string" + }, + "???:assertionProtocol": { + "type": "string" + }, + "???:assertionProtocolId": { + "type": "string" + }, + "???:assertionRemarks": { + "type": "string" + } + }, + "required": [ + "assertionType" + ] +} \ No newline at end of file diff --git a/src/main/resources/json-schema/chronometric_age.json b/src/main/resources/json-schema/chronometric_age.json new file mode 100644 index 0000000..5947b2c --- /dev/null +++ b/src/main/resources/json-schema/chronometric_age.json @@ -0,0 +1,124 @@ +{ + "$id": "chronometric_age", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "chrono:verbatimChronometricAge": { + "type": "string", + "description": "https://rs.tdwg.org/chrono/terms/verbatimChronometricAge", + "examples": [ + "27 BC to 14 AD" + ] + }, + "???:verbatimChronometricAgeProtocol": { + "type": "string", + "$comment": "Unknown term" + }, + "chrono:uncalibratedChronometricAge": { + "type": "string", + "description": "https://rs.tdwg.org/chrono/terms/uncalibratedChronometricAge", + "examples": [ + "1510 +/- 25 14C yr BP" + ] + }, + "chrono:chronometricAgeConversionProtocol": { + "type": "string", + "description": "https://rs.tdwg.org/chrono/terms/chronometricAgeConversionProtocol", + "examples": [ + "INTCAL13" + ] + }, + "chrono:earliestChronometricAge": { + "type": "integer", + "description": "https://rs.tdwg.org/chrono/terms/earliestChronometricAge", + "examples": [ + 100 + ] + }, + "chrono:earliestChronometricAgeReferenceSystem": { + "type": "string", + "description": "https://rs.tdwg.org/chrono/terms/earliestChronometricAgeReferenceSystem", + "examples": [ + "BP" + ] + }, + "chrono:latestChronometricAge": { + "type": "integer", + "description": "https://rs.tdwg.org/chrono/terms/latestChronometricAge", + "examples": [ + 12 + ] + }, + "chrono:latestChronometricAgeReferenceSystem": { + "type": "string", + "description": "https://rs.tdwg.org/chrono/terms/latestChronometricAgeReferenceSystem", + "examples": [ + "BCE" + ] + }, + "chrono:chronometricAgeUncertaintyInYears": { + "type": "integer", + "description": "https://rs.tdwg.org/chrono/terms/chronometricAgeUncertaintyInYears", + "examples": [ + 100 + ] + }, + "chrono:chronometricAgeUncertaintyMethod": { + "type": "string", + "description": "https://rs.tdwg.org/chrono/terms/chronometricAgeUncertaintyMethod", + "examples": [ + "Half of 95% confidence interval" + ] + }, + "chrono:materialDated": { + "type": "string", + "description": "https://rs.tdwg.org/chrono/terms/materialDated", + "examples": [ + "charred wood" + ] + }, + "chrono:materialDatedId": { + "type": "string", + "description": "https://rs.tdwg.org/chrono/terms/materialDatedID", + "examples": [ + "https://doi.org/10.22/XXX-XXX-XXX" + ] + }, + "chrono:materialDatedRelationship": { + "type": "string", + "description": "https://rs.tdwg.org/chrono/terms/materialDatedRelationship", + "examples": [ + "sameAs" + ] + }, + "chrono:chronometricAgeDeterminedBy": { + "type": "string", + "description": "https://rs.tdwg.org/chrono/terms/chronometricAgeDeterminedBy", + "examples": [ + "Michelle LeFebvre" + ] + }, + "chrono:chronometricAgeDeterminedDate": { + "type": "string", + "description": "https://rs.tdwg.org/chrono/terms/chronometricAgeDeterminedDate", + "examples": [ + "2018-11-13T20:20:39+00:00" + ] + }, + "chrono:chronometricAgeReferences": { + "type": "string", + "description": "https://rs.tdwg.org/chrono/terms/chronometricAgeReferences", + "examples": [ + "https://doi.org/10.1007/s10814-019-09140-x" + ], + "$comment": "Or include citation object?" + }, + "chrono:chronometricAgeRemarks": { + "type": "string", + "description": "https://rs.tdwg.org/chrono/terms/chronometricAgeRemarks", + "examples": [ + "Beta Analytic number: 323913" + ] + } + } +} \ No newline at end of file diff --git a/src/main/resources/json-schema/citations.json b/src/main/resources/json-schema/citations.json new file mode 100644 index 0000000..9f1fb99 --- /dev/null +++ b/src/main/resources/json-schema/citations.json @@ -0,0 +1,65 @@ +{ + "$id": "root", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "dcterms:type": { + "type": "string", + "description": "Unclear yet", + "$comment": "Unknown what this field should be" + }, + "dcterms:date": { + "type": "string", + "description": "Unclear yet", + "$comment": "Unknown what this field should be" + }, + "dcterms:title": { + "type": "string", + "description": "Unclear yet", + "$comment": "Unknown what this field should be" + }, + "dcterms:creator": { + "type": "string", + "description": "Unclear yet", + "$comment": "Unknown what this field should be" + }, + "???:citationPageNumber": { + "type": "string", + "description": "Unclear yet", + "$comment": "Unknown what this field should be" + }, + "???:citationRemarks": { + "type": "string", + "description": "Unclear yet", + "$comment": "Unknown what this field should be" + }, + "???:referenceType": { + "type": "string", + "description": "Unclear yet", + "$comment": "Unknown what this field should be" + }, + "dcterms:bibliographicCitation": { + "type": "string", + "description": "https://dublincore.org/usage/terms/history/#bibliographicCitation-002", + "example": [ + "https://www.gbif.org/species/2439608 Source: GBIF Taxonomic Backbone" + ] + }, + "???:referenceYear": { + "type": "string", + "description": "Unclear yet", + "$comment": "Unknown what this field should be" + }, + "???:referenceIri": { + "type": "string", + "format": "iri", + "description": "Unclear yet", + "$comment": "Unknown what this field should be" + }, + "???:isPeerReviewed": { + "type": "boolean", + "description": "Unclear yet", + "$comment": "Unknown what this field should be" + } + } +} \ No newline at end of file diff --git a/src/main/resources/json-schema/digital_entity.json b/src/main/resources/json-schema/digital_entity.json new file mode 100644 index 0000000..19b50c6 --- /dev/null +++ b/src/main/resources/json-schema/digital_entity.json @@ -0,0 +1,163 @@ +{ + "$id": "digitalEntity", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "ods:id": { + "type": "string", + "description": "The unique digital identifier of the object", + "pattern": "https:\/\/doi.org\/10.22\/(.){3}-(.){3}-(.){3}", + "examples": [ + "https://doi.org/10.22/XXX-XXX-XXX" + ], + "$comment": "Does an image get a DOI or a handle?" + }, + "ods:version": { + "type": "integer", + "description": "The version of the object, each change generates a new version", + "minimum": 0, + "examples": [ + 1 + ] + }, + "ods:created": { + "type": "string", + "description": "The timestamp that the object version was created in DiSSCo", + "format": "date-time", + "examples": [ + ] + }, + "dcterms:type": { + "type": "string", + "description": "https://purl.org/dc/terms/type", + "enum": [ + "Collection", + "Dataset", + "Event", + "Image", + "InteractiveResource", + "MovingImage", + "PhysicalObject", + "Service", + "Software", + "Sound", + "StillImage", + "Text" + ] + }, + "ac:accessUri": { + "type": "string", + "description": "https://rs.tdwg.org/ac/terms/accessURI", + "examples": [ + ] + }, + "dwc:institutionId": { + "type": "string", + "description": "ROR or Wikidata identifier, based on https://rs.tdwg.org/dwc/terms/institutionID", + "examples": [ + "https://ror.org/015hz7p22" + ], + "$comment": "Add format for ROR or Wikidata ID" + }, + "dwc:institutionName": { + "type": "string", + "description": "Full museum name according to ROR or Wikidata", + "examples": [ + "National Museum of Natural History" + ], + "$comment": "Not part of DWC or the GBIF UM" + }, + "xmpRights:webStatement": { + "type": "string", + "description": "https://ns.adobe.com/xap/1.0/rights/WebStatement", + "$comment": "What is the difference with dcterms:license?" + }, + "dcterms:format": { + "type": "string", + "description": "https://purl.org/dc/terms/format", + "$comment": "Create a enum for this?" + }, + "dcterms:license": { + "type": "string", + "description": "https://purl.org/dc/terms/license", + "$comment": "Create a enum for this?" + }, + "dcterms:description": { + "type": "string", + "description": "https://purl.org/dc/terms/description" + }, + "dcterms:rights": { + "type": "string", + "description": "https://purl.org/dc/terms/rights", + "$comment": "What is the difference with dcterms:license?" + }, + "???:rightsUri": { + "type": "string", + "format": "uri", + "$comment": "What is the difference with dcterms:license? or dcterms:rights?. dcterms:rights is already recommended to be a URI" + }, + "dcterms:accessRights": { + "type": "string", + "description": "https://purl.org/dc/terms/accessRights", + "$comment": "What is the difference with dcterms:license?" + }, + "dcterms:rightsHolder": { + "type": "string", + "description": "https://purl.org/dc/terms/rightsHolder", + "examples": [ + ] + }, + "dcterms:source": { + "type": "string", + "description": "https://purl.org/dc/terms/source" + }, + "???:sourceUri": { + "type": "string", + "format": "uri", + "$comment": "It is already recommended to use URI in the dcterms:source" + }, + "dcterms:creator": { + "type": "string", + "description": "https://purl.org/dc/elements/1.1/creator" + }, + "dcterms:created": { + "type": "string", + "description": "https://purl.org/dc/terms/created" + }, + "dcterms:modified": { + "type": "string", + "description": "https://purl.org/dc/terms/modified" + }, + "assertions": { + "type": "array", + "items": { + "$ref": "assertions.json" + } + }, + "citations": { + "type": "array", + "items": { + "$ref": "citations.json" + } + }, + "identifiers": { + "type": "array", + "items": { + "$ref": "identifiers.json" + } + }, + "entityRelationships": { + "type": "array", + "items": { + "$ref": "entity_relationships.json" + } + } + }, + "required": [ + "ods:id", + "ods:version", + "ods:created", + "ac:accessUri", + "dcterms:license" + ] +} \ No newline at end of file diff --git a/src/main/resources/json-schema/digital_specimen.json b/src/main/resources/json-schema/digital_specimen.json new file mode 100644 index 0000000..ac3327b --- /dev/null +++ b/src/main/resources/json-schema/digital_specimen.json @@ -0,0 +1,313 @@ +{ + "$id": "root", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "ods:id": { + "type": "string", + "description": "The unique digital identifier of the object", + "pattern": "https:\/\/doi.org\/10.22\/(.){3}-(.){3}-(.){3}", + "examples": [ + "https://doi.org/10.22/XXX-XXX-XXX" + ] + }, + "ods:version": { + "type": "integer", + "description": "The version of the object, each change generates a new version", + "minimum": 1, + "examples": [ + 1 + ] + }, + "ods:created": { + "type": "string", + "description": "The timestamp that the object version was created in DiSSCo", + "format": "date-time", + "examples": [ + ] + }, + "ods:type": { + "type": "string", + "description": "The FDO type of the object", + "$comment": "Unclear what value goes here" + }, + "ods:midsLevel": { + "type": "integer", + "description": "The MIDS level of the object, see https://www.tdwg.org/community/cd/mids/", + "minimum": 0, + "maximum": 3 + }, + "ods:normalisedPhysicalSpecimenId": { + "type": "string", + "description": "The physical specimen identifier of the object. When locally unique this is a combination between source-system-id and the local identifier" + }, + "ods:physicalSpecimenId": { + "type": "string", + "description": "The physical specimen identifier of the object. Taken over as-is" + }, + "ods:physicalSpecimenIdType": { + "type": "string", + "description": "To indicate if the physical identifier is globally unique or locally unique", + "enum": [ + "RESOLVABLE", + "GLOBAL", + "LOCAL" + ], + "$comment": "Do we need to further distinguish the identifier, for example add 'RESOLVABLE'" + }, + "ods:topicOrigin": { + "type": "string", + "description": "The topic origin of the specimen", + "enum": [ + "Natural", + "Human-made", + "Mixed origin", + "Unclassified" + ], + "example": [ + "Natural" + ], + "$comment": "Do we need to add 'UNKNOWN'?" + }, + "ods:topicDomain": { + "type": "string", + "description": "The topic domain of the specimen", + "enum": [ + "Life", + "Environment", + "Earth System", + "Extraterrestrial", + "Cultural Artefacts", + "Archive Material", + "Unclassified" + ], + "example": [ + "Life" + ], + "$comment": "Do we need to add 'UNKNOWN'?" + }, + "ods:topicDiscipline": { + "type": "string", + "description": "The topic discipline of the specimen", + "enum": [ + "Anthropology", + "Botany", + "Astrogeology", + "Geology", + "Microbiology", + "Palaeontology", + "Zoology", + "Ecology", + "Other Biodiversity", + "Other Geodiversity", + "Unclassified" + ], + "example": [ + "Botany" + ], + "$comment": "Do we need to add 'UNKNOWN'?" + }, + "ods:markedAsType": { + "type": "boolean", + "description": "The specimen is marked as a type specimen" + }, + "ods:hasMedia": { + "type": "boolean", + "description": "Indicates if there are any media objects attached to this specimen" + }, + "ods:specimenName": { + "type": "string", + "description": "The accepted specimen name of the digital specimen", + "example": [ + "Roptrocerus typographi (Györfi, 1952)" + ] + }, + "ods:sourceSystem": { + "type": "string", + "description": "The handle to the source system object which retrieved the data from the CMS", + "pattern": "https:\/\/hdl.handle.net\/20.5000.1025\/(.){3}-(.){3}-(.){3}" + }, + "ods:livingOrPreserved": { + "type": "string", + "description": "Whether the specimen is living or preserved", + "enum": [ + "Living", + "Preserved" + ] + }, + "dcterms:license": { + "type": "string", + "description": "License for the metadata of the physical specimen", + "$comment": "Determine available licenses" + }, + "dcterms:modified": { + "type": "string", + "description": "Modification date for specimen information" + }, + "dwc:basisOfRecord": { + "type": "string", + "description": "The basis for the record", + "$comment": "Switch to enumeration as this is a limited list" + }, + "dwc:preparations": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/preparations", + "example": [ + "fossil" + ] + }, + "dwc:disposition": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/disposition", + "examples": [ + "in collection" + ] + }, + "dwc:institutionCode": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/institutionCode", + "examples": [ + "MNF" + ] + }, + "dwc:institutionId": { + "type": "string", + "description": "ROR or Wikidata identifier, based on https://rs.tdwg.org/dwc/terms/institutionID", + "examples": [ + "https://ror.org/015hz7p22" + ], + "$comment": "Add format for ROR or Wikidata ID" + }, + "dwc:institutionName": { + "type": "string", + "description": "Full museum name according to ROR or Wikidata", + "examples": [ + "National Museum of Natural History" + ], + "$comment": "Not part of DWC or the GBIF UM" + }, + "dwc:collectionCode": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/collectionCode", + "examples": [ + "EBIRD" + ], + "$comment": "Cetaf collection code?" + }, + "dwc:collectionId": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/collectionID", + "examples": [ + "https://www.gbif.org/grscicoll/collection/fbd3ed74-5a21-4e01-b86a-33d36f032d9c" + ], + "$comment": "Are we going to use GRSciColl or Cetaf collection identifiers?" + }, + "dwc:ownerInstitutionId": { + "type": "string", + "description": "ROR or Wikidata identifier for the owning institution", + "$comment": "DWC only has ownerInstitutionCode, however code is not an (resolvable identifier)", + "examples": [ + "https://ror.org/03wkt5x30" + ] + }, + "dwc:recordedBy": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/recordedBy", + "examples": [ + "José E. Crespo" + ] + }, + "???:recordedByAgent": { + "$ref": "agent.json", + "$comment": "Is this an option for the agent instead of adding a list?" + }, + "dwc:recordedById": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/recordedByID", + "examples": [ + "https://orcid.org/0000-0002-1825-0097" + ] + }, + "dwc:datasetName": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/datasetName", + "examples": [ + "Hummingbirds" + ] + }, + "dcterms:accessRights": { + "type": "string", + "description": "https://purl.org/dc/terms/accessRights", + "examples": [ + "not-for-profit use only" + ] + }, + "dcterms:rightsHolder": { + "type": "string", + "description": "https://purl.org/dc/terms/rightsHolder", + "examples": [ + "Museu de História Natural e da Ciência da Universidade do Porto" + ] + }, + "materialEntity": { + "type": "array", + "items": { + "$ref": "material_entity.json" + } + }, + "dwc:identification": { + "type": "array", + "items": { + "$ref": "identifications.json" + } + }, + "assertions": { + "type": "array", + "items": { + "$ref": "assertions.json" + } + }, + "occurrences": { + "type": "array", + "items": { + "$ref": "occurrences.json" + } + }, + "entityRelationships": { + "type": "array", + "items": { + "$ref": "entity_relationships.json" + } + }, + "citations": { + "type": "array", + "items": { + "$ref": "citations.json" + } + }, + "identifiers": { + "type": "array", + "items": { + "$ref": "identifiers.json" + } + }, + "chronometricAge": { + "type": "array", + "items": { + "$ref": "chronometric_age.json" + } + } + }, + "required": [ + "ods:id", + "ods:version", + "ods:type", + "ods:created", + "ods:midsLevel", + "ods:physicalSpecimenId", + "ods:physicalSpecimenIdType", + "ods:sourceSystem", + "dcterms:license", + "???:institutionId" + ] +} diff --git a/src/main/resources/json-schema/entity_relationships.json b/src/main/resources/json-schema/entity_relationships.json new file mode 100644 index 0000000..d2f0817 --- /dev/null +++ b/src/main/resources/json-schema/entity_relationships.json @@ -0,0 +1,40 @@ +{ + "$id": "entityRelationship", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "entityRelationshipType": { + "type": "string" + }, + "objectEntityIri": { + "type": "string", + "format": "iri", + "description": "The link to the referenced resource. This could be an internal object linked through the PID or an external object" + }, + "entityRelationshipDate": { + "type": "string", + "format": "date-time", + "description": "The data time on which the relationship was established" + }, + "entityRelationshipOrder": { + "type": "integer", + "description": "When multiple relationships are added an order can be defined" + }, + "entityRelationshipCreatorName": { + "type": "string", + "description": "The name of the relationship creator", + "$comment": "Not available in GBIF UM" + }, + "entityRelationshipCreatorId": { + "type": "string", + "description": "The PID of the creator, this could be a Orcid(user), PID(machine) or ROR(organisation)", + "$comment": "Not available in GBIF UM" + } + }, + "required": [ + "entityRelationshipType", + "objectEntityIri", + "entityRelationshipDate", + "entityRelationshipCreatorId" + ] +} \ No newline at end of file diff --git a/src/main/resources/json-schema/events.json b/src/main/resources/json-schema/events.json new file mode 100644 index 0000000..df8a60b --- /dev/null +++ b/src/main/resources/json-schema/events.json @@ -0,0 +1,101 @@ +{ + "$id": "events", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "???:eventName": { + "type": "string", + "comment": "Not sure what this field means" + }, + "dwc:fieldNumber": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/fieldNumber", + "examples": [ + "RV Sol 87-03-08" + ] + }, + "dwc:eventDate": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/eventDate", + "examples": [ + "1963-03-08T14:07-0600" + ] + }, + "dwc:year": { + "type": "integer", + "description": "https://rs.tdwg.org/dwc/terms/year", + "examples": [ + 2008 + ] + }, + "dwc:month": { + "type": "integer", + "description": "https://rs.tdwg.org/dwc/terms/month", + "examples": [ + 12 + ] + }, + "dwc:day": { + "type": "integer", + "description": "https://rs.tdwg.org/dwc/terms/day", + "examples": [ + 29 + ] + }, + "dwc:habitat": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/habitat", + "examples": [ + "savanna" + ], + "$comment": "Is this necessary for specimens" + }, + "???:protocolDescription": { + "type": "string", + "comment": "Not sure what this field means" + }, + "dwc:sampleSizeValue": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/sampleSizeValue", + "examples": [ + "5" + ] + }, + "dwc:sampleSizeUnit": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/sampleSizeUnit", + "examples": [ + "meters" + ] + }, + "???:eventEffort": { + "type": "string", + "comment": "Not sure what this field means" + }, + "dwc:fieldNotes": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/fieldNotes", + "examples": [ + "Notes available in the Grinnell-Miller Library" + ] + }, + "dwc:eventRemarks": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/eventRemarks", + "examples": [ + "After the recent rains the river is nearly at flood stage" + ] + }, + "???:collectorName": { + "type": "string", + "$comment": "Not part of DWC or the UM?" + }, + "???:collectorId": { + "type": "string", + "$comment": "Not part of DWC or the UM?" + }, + "location": { + "$ref": "./location.json" + } + } +} \ No newline at end of file diff --git a/src/main/resources/json-schema/identifications.json b/src/main/resources/json-schema/identifications.json new file mode 100644 index 0000000..eb8b0d2 --- /dev/null +++ b/src/main/resources/json-schema/identifications.json @@ -0,0 +1,252 @@ +{ + "$id": "identifications", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "dwc:identificationID": { + "type": "string", + "description": "Check DWC terms" + }, + "???:identificationType": { + "type": "string", + "description": "Unclear yet", + "$comment": "Unknown what this field should be" + }, + "???:taxonFormula": { + "type": "string", + "description": "Unclear yet", + "$comment": "Unknown what this field should be" + }, + "dwc:verbatimIdentification": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/verbatimIdentification", + "examples": [ + "Peromyscus sp." + ] + }, + "dwc:typeStatus": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/typeStatus", + "example": [ + "holotype" + ], + "$comment": "Unclear if we can make this an enumeration, which values?" + }, + "dwc:identifiedBy": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/identifiedBy", + "example": [ + "James L. Patton" + ] + }, + "dwc:identifiedById": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/identifiedByID", + "example": [ + "https://orcid.org/0000-0002-1825-0097" + ] + }, + "dwc:dateIdentified": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/dateIdentified", + "example": [ + "2009-02-20T08:40Z" + ] + }, + "dwc:identificationReferences": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/identificationReferences", + "example": [ + "Aves del Noroeste Patagonico. Christie et al. 2004." + ], + "$comment": "Is this still needed or can we add the citation object here?" + }, + "dwc:identificationVerificationStatus": { + "type": "boolean", + "description": "If this is the accepted identification, based on https://rs.tdwg.org/dwc/terms/identificationVerificationStatus", + "example": [ + true + ] + }, + "dwc:identificationRemarks": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/identificationRemarks", + "examples": [ + "Distinguished between Anthus correndera and Anthus hellmayri based on the comparative lengths of the uñas." + ] + }, + "???:typeDesignationType": { + "type": "string", + "description": "Unclear yet", + "$comment": "Unknown what this field should be" + }, + "???:typeDesignatedBy": { + "type": "string", + "description": "Unclear yet", + "$comment": "Unknown what this field should be" + }, + "citations": { + "type": "array", + "items": { + "$ref": "citations.json" + } + }, + "taxonIdentifications": { + "type": "array", + "items": { + "type": "object", + "properties": { + "dwc:taxonID": { + "type": "string", + "description": "See DWC Terms" + }, + "dwc:scientificName": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/scientificName", + "examples": [ + "Roptrocerus typographi (Györfi, 1952)" + ] + }, + "dwc:scientificNameAuthorship": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/scientificNameAuthorship", + "examples": [ + "(Torr.) J.T. Howell" + ] + }, + "dwc:nameAccordingTo": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/nameAccordingTo", + "examples": [ + "Plants of the World Online" + ] + }, + "dwc:namePublishedInYear":{ + "type": "string", + "description": "", + "examples": [ + "" + ] + }, + "dwc:taxonRank": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/taxonRank", + "examples": [ + "species" + ] + }, + "???:taxonSource": { + "type": "string", + "description": "Unclear yet", + "$comment": "Unknown what this field should be" + }, + "dwc:taxonRemarks": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/taxonRemarks", + "examples": [ + "this name is a misspelling in common use" + ] + }, + "dwc:kingdom": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/kingdom", + "examples": [ + "animalia" + ], + "$comment": "Could be an enum?" + }, + "dwc:phylum": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/phylum", + "examples": [ + "Chordata" + ] + }, + "dwc:class": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/class", + "examples": [ + "Hepaticopsida" + ] + }, + "dwc:order": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/order", + "examples": [ + "Carnivora" + ] + }, + "dwc:family": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/family", + "examples": [ + "Felidae" + ] + }, + "dwc:subfamily": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/subfamily", + "examples": [ + "Orchidoideae" + ] + }, + "dwc:genus": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/genus", + "examples": [ + "Puma" + ] + }, + "dwc:specificEpithet": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/specificEpithet", + "examples": [ + "concolor" + ] + }, + "dwc:taxonomicStatus": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/taxonomicStatus", + "$comment": "Might become an enum", + "examples": [ + "accepted" + ] + }, + "dwc:nomenclaturalCode": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/nomenclaturalCode", + "$comment": "Might become an enum", + "examples": [ + "ICBN" + ] + }, + "dwc:vernacularName": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/vernacularName", + "examples": [ + "Meerval | Wels | Catfish | Silure glane | Wels | Waller | Siluro | Malle" + ] + }, + "dwc:subgenus": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/subgenus", + "examples": [ + "Strobus" + ] + }, + "???:acceptedScientificName": { + "type": "string", + "description": "Unclear yet", + "$comment": "Is this field necessary if we indicated accepted on the identification level" + } + }, + "required": [ + "dwc:scientificName" + ] + } + } + }, + "required": [ + "dwc:identificationVerificationStatus" + ] +} \ No newline at end of file diff --git a/src/main/resources/json-schema/identifiers.json b/src/main/resources/json-schema/identifiers.json new file mode 100644 index 0000000..3144ea6 --- /dev/null +++ b/src/main/resources/json-schema/identifiers.json @@ -0,0 +1,40 @@ +{ + "$id": "identifiers", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "???:identifierType": { + "type": "string", + "description": "The type of the identifier", + "examples": [ + "dwc:catalogueNumber", + "dwca:id" + ], + "$comments": "Should become new term in DWC or borrow from somewhere else?" + }, + "???:identifierValue":{ + "type": "string", + "description": "The value for the identifier", + "examples": [ + "BMNH(E)1902475", + "RGM.800315" + ], + "$comments": "Should become new term in DWC or borrow from somewhere else?" + }, + "???:partOfLabel": { + "type": "boolean", + "description": "Is the identifier part of the physical label" + }, + "???:barcodeOrNfc": { + "type": "string", + "description": "Part of barcode or nfc chip" + }, + "isIdPersistent": { + "type": "boolean", + "description": "" + } + }, + "required": [ + "???:identifierValue" + ] +} \ No newline at end of file diff --git a/src/main/resources/json-schema/location.json b/src/main/resources/json-schema/location.json new file mode 100644 index 0000000..d463fb4 --- /dev/null +++ b/src/main/resources/json-schema/location.json @@ -0,0 +1,396 @@ +{ + "$id": "location", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "dwc:continent": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/continent", + "examples": [ + "Africa" + ] + }, + "dwc:waterBody": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/waterBody", + "examples": [ + "Baltic Sea" + ] + }, + "dwc:islandGroup": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/islandGroup", + "examples": [ + "Seychelles" + ] + }, + "dwc:island": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/island", + "examples": [ + "Vancouver" + ] + }, + "dwc:country": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/country", + "examples": [ + "Colombia" + ] + }, + "dwc:countryCode": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/countryCode", + "examples": [ + "SV" + ] + }, + "dwc:stateProvince": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/stateProvince", + "examples": [ + "Montana" + ] + }, + "dwc:county": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/county", + "examples": [ + "Los Lagos" + ] + }, + "dwc:municipality": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/municipality", + "examples": [ + "Holzminden" + ] + }, + "dwc:locality": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/locality", + "examples": [ + "Zeeuws-Vlaanderen, Hulst, Braakman" + ] + }, + "dwc:minimumElevationInMeters": { + "type": "number", + "description": "https://rs.tdwg.org/dwc/terms/minimumElevationInMeters", + "examples": [ + -100 + ] + }, + "dwc:higherGeography": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/higherGeography", + "examples": [ + "Britain and Ireland" + ] + }, + "dwc:maximumElevationInMeters": { + "type": "number", + "description": "https://rs.tdwg.org/dwc/terms/maximumElevationInMeters", + "examples": [ + 205 + ] + }, + "dwc:minimumDistanceAboveSurfaceInMeters": { + "type": "number", + "description": "https://rs.tdwg.org/dwc/terms/minimumDistanceAboveSurfaceInMeters", + "examples": [ + -1, + 5 + ] + }, + "dwc:maximumDistanceAboveSurfaceInMeters": { + "type": "number", + "description": "https://rs.tdwg.org/dwc/terms/maximumDistanceAboveSurfaceInMeters", + "examples": [ + 4.2 + ] + }, + "dwc:minimumDepthInMeters": { + "type": "number", + "description": "https://rs.tdwg.org/dwc/terms/minimumDepthInMeters", + "examples": [ + 50 + ] + }, + "dwc:maximumDepthInMeters": { + "type": "number", + "description": "https://rs.tdwg.org/dwc/terms/maximumDepthInMeters", + "examples": [ + 340 + ] + }, + "dwc:verticalDatum": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/verticalDatum", + "examples": [ + "EGM84" + ] + }, + "dwc:locationAccordingTo": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/locationAccordingTo", + "examples": [ + "GADM" + ] + }, + "dwc:locationRemarks": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/locationRemarks", + "examples": [ + "under water since 2005" + ] + }, + "georeference": { + "type": "object", + "properties": { + "dwc:decimalLatitude": { + "type": "number", + "description": "https://rs.tdwg.org/dwc/terms/decimalLatitude", + "examples": [ + -41.0983423 + ], + "minimum": -180, + "maximum": 180 + }, + "dwc:decimalLongitude": { + "type": "number", + "description": "https://rs.tdwg.org/dwc/terms/decimalLongitude", + "examples": [ + -121.1761111 + ], + "minimum": -180, + "maximum": 180 + }, + "dwc:geodeticDatum": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/geodeticDatum", + "examples": [ + "WGS84" + ] + }, + "dwc:coordinateUncertaintyInMeters": { + "type": "number", + "description": "https://rs.tdwg.org/dwc/terms/coordinateUncertaintyInMeters", + "examples": [ + 100 + ], + "minimum": 0 + }, + "dwc:coordinatePrecision": { + "type": "number", + "description": "https://rs.tdwg.org/dwc/terms/coordinatePrecision", + "examples": [ + 0.01667 + ] + }, + "dwc:pointRadiusSpatialFit": { + "type": "number", + "description": "https://rs.tdwg.org/dwc/terms/pointRadiusSpatialFit", + "examples": [ + 1.5708 + ] + }, + "dwc:footprintWkt": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/footprintWKT", + "examples": [ + "POLYGON ((10 20, 11 20, 11 21, 10 21, 10 20))" + ] + }, + "dwc:footprintSrs": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/footprintSRS", + "examples": [ + "epsg:4326" + ] + }, + "dwc:footprintSpatialFit": { + "type": "integer", + "description": "https://rs.tdwg.org/dwc/terms/footprintSpatialFit", + "examples": [ + 1.5708 + ] + }, + "dwc:georeferencedBy": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/georeferencedBy", + "examples": [ + "Janet Fang" + ] + }, + "dwc:georeferencedDate": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/georeferencedDate", + "examples": [ + "1963-03-08T14:07-0600" + ] + }, + "dwc:georeferenceProtocol": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/georeferenceProtocol", + "examples": [ + "https://doi.org/10.35035/e09p-h128" + ] + }, + "dwc:georeferenceSources": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/georeferenceSources", + "examples": [ + "https://www.geonames.org/" + ] + }, + "dwc:georeferenceRemarks": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/georeferenceRemarks", + "examples": [ + "Assumed distance by road (Hwy. 101)" + ] + }, + "???:preferredSpatialRepresentation": { + "type": "string", + "$comment": "Not part of DWC" + } + } + }, + "geologicalContext": { + "type": "object", + "properties": { + "dwc:earliestEonOrLowestEonothem": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/earliestEonOrLowestEonothem", + "examples": [ + "Phanerozoic" + ], + "$comment": "Strange field, mixes geologic and stratigraphic unit. The earliest/latest is not in line with the rest" + }, + "dwc:latestEonOrHighestEonothem": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/latestEonOrHighestEonothem", + "examples": [ + "Proterozoic" + ], + "$comment": "Strange field, mixes geologic and stratigraphic unit. The earliest/latest is not in line with the rest" + }, + "dwc:earliestEraOrLowestErathem": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/earliestEraOrLowestErathem", + "examples": [ + "Cenozoic" + ], + "$comment": "Strange field, mixes geologic and stratigraphic unit. The earliest/latest is not in line with the rest" + }, + "dwc:latestEraOrHighestErathem": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/latestEraOrHighestErathem", + "examples": [ + "Mesozoic" + ], + "$comment": "Strange field, mixes geologic and stratigraphic unit. The earliest/latest is not in line with the rest" + }, + "dwc:earliestPeriodOrLowestSystem": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/earliestPeriodOrLowestSystem", + "examples": [ + "Tertiary" + ], + "$comment": "Strange field, mixes geologic and stratigraphic unit. The earliest/latest is not in line with the rest" + }, + "dwc:latestPeriodOrHighestSystem": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/latestPeriodOrHighestSystem", + "examples": [ + "Quaternary" + ], + "$comment": "Strange field, mixes geologic and stratigraphic unit. The earliest/latest is not in line with the rest" + }, + "dwc:earliestEpochOrLowestSeries": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/earliestEpochOrLowestSeries", + "examples": [ + "Holocene" + ], + "$comment": "Strange field, mixes geologic and stratigraphic unit. The earliest/latest is not in line with the rest" + }, + "dwc:latestEpochOrHighestSeries": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/latestEpochOrHighestSeries", + "examples": [ + "Pleistocene" + ], + "$comment": "Strange field, mixes geologic and stratigraphic unit. The earliest/latest is not in line with the rest" + }, + "dwc:earliestAgeOrLowestStage": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/earliestAgeOrLowestStage", + "examples": [ + "Atlantic" + ], + "$comment": "Strange field, mixes geologic and stratigraphic unit. The earliest/latest is not in line with the rest" + }, + "dwc:latestAgeOrHighestStage": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/latestAgeOrHighestStage", + "examples": [ + "Boreal" + ], + "$comment": "Strange field, mixes geologic and stratigraphic unit. The earliest/latest is not in line with the rest" + }, + "dwc:lowestBiostratigraphicZone": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/lowestBiostratigraphicZone", + "examples": [ + "Maastrichtian" + ], + "$comment": "Strange field, lowest and highest" + }, + "dwc:highestBiostratigraphicZone": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/highestBiostratigraphicZone", + "examples": [ + "Blancan" + ], + "$comment": "Strange field, lowest and highest" + }, + "dwc:lithostratigraphicTerms": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/lithostratigraphicTerms", + "examples": [ + "Pleistocene-Weichselien" + ] + }, + "dwc:group": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/group", + "examples": [ + "Bathurst" + ] + }, + "dwc:formation": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/formation", + "examples": [ + "House Limestone" + ] + }, + "dwc:member": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/member", + "examples": [ + "Lava Dam Member" + ] + }, + "dwc:bed": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/bed", + "examples": [ + "Harlem coal" + ] + } + } + } + } +} diff --git a/src/main/resources/json-schema/material_entity.json b/src/main/resources/json-schema/material_entity.json new file mode 100644 index 0000000..42c8733 --- /dev/null +++ b/src/main/resources/json-schema/material_entity.json @@ -0,0 +1,120 @@ +{ + "$id": "materialEntity", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "$comment": "Only if the part did not get a separate catalogue number, otherwise it will be a separate digital specimen itself", + "properties": { + "materialEntityId": { + "type": "string" + }, + "dwc:preparations": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/preparations", + "example": [ + "fossil" + ] + }, + "dwc:disposition": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/disposition", + "examples": [ + "in collection" + ] + }, + "dwc:institutionCode": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/institutionCode", + "examples": [ + "MNF" + ] + }, + "???:institutionId": { + "type": "string", + "description": "ROR or Wikidata identifier, based on https://rs.tdwg.org/dwc/terms/institutionID", + "examples": [ + "https://ror.org/015hz7p22" + ] + }, + "dwc:institutionName": { + "type": "string", + "description": "Full museum name according to ROR or Wikidata", + "examples": [ + "National Museum of Natural History" + ], + "$comment": "Not part of DWC or the GBIF UM" + }, + "dwc:collectionCode": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/collectionCode", + "examples": [ + "EBIRD" + ] + }, + "dwc:collectionId": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/collectionID", + "examples": [ + "https://www.gbif.org/grscicoll/collection/fbd3ed74-5a21-4e01-b86a-33d36f032d9c" + ], + "$comment": "Are we going to use GRSciColl or Cetaf collection identifiers?" + }, + "dwc:ownerInstitutionId": { + "type": "string", + "description": "ROR or Wikidata identifier for the owning institution", + "$comment": "DWC only has ownerInstitutionCode, however code is not an (resolvable identifier)", + "examples": [ + "https://ror.org/03wkt5x30" + ] + }, + "dwc:recordedBy": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/recordedBy", + "examples": [ + "José E. Crespo" + ] + }, + "dwc:recordedById": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/recordedByID", + "examples": [ + "https://orcid.org/0000-0002-1825-0097" + ] + }, + "identifications": { + "type": "array", + "items": { + "$ref": "identifications.json" + } + }, + "assertions": { + "type": "array", + "items": { + "$ref": "assertions.json" + } + }, + "entityRelationships": { + "type": "array", + "items": { + "$ref": "entity_relationships.json" + } + }, + "citations": { + "type": "array", + "items": { + "$ref": "citations.json" + } + }, + "identifiers": { + "type": "array", + "items": { + "$ref": "identifications.json" + } + }, + "events": { + "type": "array", + "items": { + "$ref": "events.json" + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/json-schema/occurrences.json b/src/main/resources/json-schema/occurrences.json new file mode 100644 index 0000000..036a27b --- /dev/null +++ b/src/main/resources/json-schema/occurrences.json @@ -0,0 +1,245 @@ +{ + "$id": "occurrence", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "dwc:organismQuantity": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/organismQuantity", + "examples": [ + "27" + ] + }, + "dwc:organismQuantityType": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/organismQuantityType", + "examples": [ + "individuals" + ], + "$comment": "Could this become a enum?" + }, + "dwc:sex": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/sex", + "examples": [ + "female" + ], + "$comment": "Could this become a enum?" + }, + "dwc:lifeStage": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/lifeStage", + "examples": [ + "adult" + ], + "$comment": "Could this become a enum?" + }, + "dwc:reproductiveCondition": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/reproductiveCondition", + "examples": [ + "pregnant" + ], + "$comment": "Could this become a enum?" + }, + "dwc:behavior": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/behavior", + "examples": [ + "running" + ], + "$comment": "Is this needed for specimen data?" + }, + "dwc:establishmentMeans": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/establishmentMeans", + "examples": [ + "introduced" + ], + "$comment": "Could be an enumeration based on https://rs.tdwg.org/dwc/doc/em/" + }, + "dwc:occurrenceStatus": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/occurrenceStatus", + "examples": [ + "present" + ], + "enum": [ + "present", + "absent" + ] + }, + "dwc:pathway": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/pathway", + "examples": [ + "releasedForUse" + ], + "$comment": "Could be an enumeration based on https://rs.tdwg.org/dwc/doc/pw/" + }, + "dwc:degreeOfEstablishment": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/degreeOfEstablishment", + "examples": [ + "captive" + ], + "$comment": "Could be an enumeration based on https://rs.tdwg.org/dwc/doc/doe/" + }, + "dwc:georeferenceVerificationStatus": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/georeferenceVerificationStatus", + "examples": [ + "verified by data custodian" + ], + "$comment": "Could be an enumeration based on https://rs.tdwg.org/dwc/doc/em/" + }, + "dwc:occurrenceRemarks": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/occurrenceRemarks", + "examples": [ + "found dead on road" + ] + }, + "dwc:informationWithheld": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/informationWithheld", + "examples": [ + "location information not given for endangered species" + ], + "$comment": "Feels like this field should be true or false and another field should contain the explanation" + }, + "dwc:dataGeneralizations": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/dataGeneralizations", + "examples": [ + "Coordinates generalized from original GPS coordinates to the nearest half degree grid cell." + ] + }, + "dwc:recordedBy": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/recordedBy", + "examples": [ + "José E. Crespo" + ] + }, + "dwc:recordedById": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/recordedByID", + "examples": [ + "https://orcid.org/0000-0002-1825-0097" + ] + }, + "???:eventName": { + "type": "string", + "comment": "Not sure what this field means" + }, + "dwc:fieldNumber": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/fieldNumber", + "examples": [ + "RV Sol 87-03-08" + ] + }, + "dwc:eventDate": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/eventDate", + "examples": [ + "1963-03-08T14:07-0600" + ] + }, + "dwc:year": { + "type": "integer", + "description": "https://rs.tdwg.org/dwc/terms/year", + "maximum": 9999, + "examples": [ + 2008 + ] + }, + "dwc:month": { + "type": "integer", + "description": "https://rs.tdwg.org/dwc/terms/month", + "maximum": 12, + "minimum": 1, + "examples": [ + 12 + ] + }, + "dwc:day": { + "type": "integer", + "description": "https://rs.tdwg.org/dwc/terms/day", + "maximum": 31, + "minimum": 1, + "examples": [ + 29 + ] + }, + "dwc:habitat": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/habitat", + "examples": [ + "savanna" + ], + "$comment": "Is this necessary for specimens" + }, + "???:protocolDescription": { + "type": "string", + "comment": "Not sure what this field means" + }, + "dwc:sampleSizeValue": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/sampleSizeValue", + "examples": [ + "5" + ] + }, + "dwc:sampleSizeUnit": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/sampleSizeUnit", + "examples": [ + "meters" + ] + }, + "dwc:samplingProtocol": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/samplingProtocol", + "examples": [ + "collected directly from the wild" + ] + }, + "???:eventEffort": { + "type": "string", + "comment": "Not sure what this field means" + }, + "dwc:fieldNotes": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/fieldNotes", + "examples": [ + "Notes available in the Grinnell-Miller Library" + ] + }, + "dwc:eventRemarks": { + "type": "string", + "description": "https://rs.tdwg.org/dwc/terms/eventRemarks", + "examples": [ + "After the recent rains the river is nearly at flood stage" + ] + }, + "???:collectorName": { + "type": "string", + "$comment": "Not part of DWC or the UM?" + }, + "???:collectorId": { + "type": "string", + "$comment": "Not part of DWC or the UM?" + }, + "assertions": { + "type": "array", + "items": { + "$ref": "assertions.json" + } + }, + "location": { + "$ref": "./location.json" + } + } +} \ No newline at end of file diff --git a/src/test/java/eu/dissco/core/translator/TestUtils.java b/src/test/java/eu/dissco/core/translator/TestUtils.java index ffffd43..7091fa7 100644 --- a/src/test/java/eu/dissco/core/translator/TestUtils.java +++ b/src/test/java/eu/dissco/core/translator/TestUtils.java @@ -1,6 +1,7 @@ package eu.dissco.core.translator; import com.fasterxml.jackson.databind.ObjectMapper; +import eu.dissco.core.translator.schema.DigitalSpecimen; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Map; @@ -9,22 +10,10 @@ public class TestUtils { public static ObjectMapper MAPPER = new ObjectMapper().findAndRegisterModules(); - - public static final Map ABCD_DEFAULTS = Map.of( - "ods:organisationId", "https://ror.org/0443cwa12", - "ods:type", "ZoologyVertebrateSpecimen", - "ods:physicalSpecimenIdType", "cetaf"); - public static final Map DWC_DEFAULTS = Map.of( - "ods:organisationId", "https://ror.org/02y22ws83", - "ods:type", "ZoologyVertebrateSpecimen", - "ods:physicalSpecimenIdType", "cetaf"); - public static final Map DWC_KEW_DEFAULTS = Map.of( - "ods:organisationId", "https://ror.org/00ynnr806", - "ods:type", "ZoologyVertebrateSpecimen", - "ods:physicalSpecimenIdType", "cetaf"); - public static String SOURCE_SYSTEM_ID = "20.5000.1025/GW0-TYL-YRU"; public static String ENDPOINT = "https://data.rbge.org.uk/service/dwca/data/darwin_core_living.zip"; + + public static String MOCK_DATE = "29-09-2023"; public static Map DEFAULT_MAPPING = Map.of( "ods:physicalSpecimenIdType", "cetaf", "ods:type", "ZoologyVertebrateSpecimen", @@ -70,4 +59,8 @@ public static String loadResourceFile(String fileName) throws IOException { .readAllBytes(), StandardCharsets.UTF_8); } + public static DigitalSpecimen givenDigitalSpecimen() { + return new DigitalSpecimen() + .withOdsNormalisedPhysicalSpecimenId("http://coldb.mnhn.fr/catalognumber/mnhn/ec/ec10867"); + } } diff --git a/src/test/java/eu/dissco/core/translator/component/MappingComponentTest.java b/src/test/java/eu/dissco/core/translator/component/MappingComponentTest.java index 324d4d1..ada6250 100644 --- a/src/test/java/eu/dissco/core/translator/component/MappingComponentTest.java +++ b/src/test/java/eu/dissco/core/translator/component/MappingComponentTest.java @@ -42,7 +42,7 @@ void testSetup() throws Exception { // Then assertThat(mappingComponent.getFieldMappings()).isEqualTo(TERM_MAPPING); - assertThat(mappingComponent.getDefaultMappings()).isEqualTo(DEFAULT_MAPPING); + assertThat(mappingComponent.getDefaults()).isEqualTo(DEFAULT_MAPPING); } } diff --git a/src/test/java/eu/dissco/core/translator/component/RorComponentTest.java b/src/test/java/eu/dissco/core/translator/component/RorComponentTest.java index 0288539..0dcc362 100644 --- a/src/test/java/eu/dissco/core/translator/component/RorComponentTest.java +++ b/src/test/java/eu/dissco/core/translator/component/RorComponentTest.java @@ -57,7 +57,7 @@ void testGetRorId() throws ExecutionException, InterruptedException, IOException mapper.readTree(loadResourceFile("ror/example-ror.json"))); // When - var result = rorComponent.getRoRId(ROR); + var result = rorComponent.getRorName(ROR); // Then assertThat(result).isEqualTo(ORGANISATION_NAME); @@ -71,7 +71,7 @@ void testResponseInvalid() throws ExecutionException, InterruptedException, IOEx mapper.readTree(loadResourceFile("ror/response-invalid.json"))); // When - var result = rorComponent.getRoRId(ROR); + var result = rorComponent.getRorName(ROR); // Then assertThat(result).isNull(); @@ -84,7 +84,7 @@ void testEmptyMono() throws ExecutionException, InterruptedException { given(jsonFuture.get()).willReturn(null); // When - var result = rorComponent.getRoRId(ROR); + var result = rorComponent.getRorName(ROR); // Then assertThat(result).isNull(); diff --git a/src/test/java/eu/dissco/core/translator/repository/BaseRepositoryIT.java b/src/test/java/eu/dissco/core/translator/repository/BaseRepositoryIT.java index 6543b71..92ba0f0 100644 --- a/src/test/java/eu/dissco/core/translator/repository/BaseRepositoryIT.java +++ b/src/test/java/eu/dissco/core/translator/repository/BaseRepositoryIT.java @@ -18,7 +18,7 @@ public class BaseRepositoryIT { private static final DockerImageName POSTGIS = - DockerImageName.parse("postgres:13.7").asCompatibleSubstituteFor(IMAGE); + DockerImageName.parse("postgres:15.2").asCompatibleSubstituteFor(IMAGE); @Container private static final PostgreSQLContainer CONTAINER = new PostgreSQLContainer<>(POSTGIS); diff --git a/src/test/java/eu/dissco/core/translator/repository/MappingRepositoryIT.java b/src/test/java/eu/dissco/core/translator/repository/MappingRepositoryIT.java index bb68ed9..7e234bf 100644 --- a/src/test/java/eu/dissco/core/translator/repository/MappingRepositoryIT.java +++ b/src/test/java/eu/dissco/core/translator/repository/MappingRepositoryIT.java @@ -57,7 +57,6 @@ private void givenInsertRecords(String mapping) { .set(MAPPING.MAPPING_, JSONB.valueOf(mapping)) .set(MAPPING.CREATED, Instant.parse("2022-09-16T08:25:01.00Z")) .set(MAPPING.CREATOR, "e2befba6-9324-4bb4-9f41-d7dfae4a44b0") - .set(MAPPING.SOURCEDATASTANDARD, "dwc") .execute(); context.insertInto(SOURCE_SYSTEM) diff --git a/src/test/java/eu/dissco/core/translator/service/BioCaseServiceTest.java b/src/test/java/eu/dissco/core/translator/service/BioCaseServiceTest.java index 399110f..b5efe5f 100644 --- a/src/test/java/eu/dissco/core/translator/service/BioCaseServiceTest.java +++ b/src/test/java/eu/dissco/core/translator/service/BioCaseServiceTest.java @@ -2,6 +2,7 @@ import static eu.dissco.core.translator.TestUtils.loadResourceFile; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; @@ -10,13 +11,13 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import eu.dissco.core.translator.component.RorComponent; +import eu.dissco.core.translator.TestUtils; 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.DigitalObjectDirector; import eu.dissco.core.translator.terms.TermMapper; -import eu.dissco.core.translator.terms.specimen.OrganisationId; -import eu.dissco.core.translator.terms.specimen.PhysicalSpecimenIdType; import freemarker.cache.FileTemplateLoader; import freemarker.template.Configuration; import java.io.IOException; @@ -57,7 +58,9 @@ class BioCaseServiceTest { @Mock private EnrichmentProperties enrichmentProperties; @Mock - private RorComponent rorComponent; + private DigitalObjectDirector digitalSpecimenDirector; + @Mock + private FdoProperties fdoProperties; private BioCaseService service; @BeforeEach @@ -66,19 +69,15 @@ void setup() throws IOException { configuration.setTemplateLoader( new FileTemplateLoader(new ClassPathResource("templates").getFile())); service = new BioCaseService(mapper, properties, webClient, repository, configuration, factory, - termMapper, kafkaService, enrichmentProperties, rorComponent); + kafkaService, enrichmentProperties, digitalSpecimenDirector, fdoProperties); // Given givenJsonWebclient(); - given(termMapper.retrieveFromABCD(any(), any(JsonNode.class))).willReturn("someValue"); - given(termMapper.retrieveFromABCD(any(PhysicalSpecimenIdType.class), any(JsonNode.class))) - .willReturn("cetaf"); - given(termMapper.retrieveFromABCD(any(OrganisationId.class), any(JsonNode.class))).willReturn( - "https://ror.org/03srysw20"); + given(fdoProperties.getDigitalSpecimenType()).willReturn("Doi of the digital specimen"); } @Test - void testRetrieveData206() throws IOException { + void testRetrieveData206() throws Exception { // Given given(properties.getSourceSystemId()).willReturn("ABC-DDD-ASD"); given(repository.getEndpoint(anyString())).willReturn("https://endpoint.com"); @@ -86,7 +85,8 @@ void testRetrieveData206() throws IOException { Mono.just(loadResourceFile("biocase/geocase-record-dropped.xml"))) .willReturn(Mono.just(loadResourceFile("biocase/biocase-206-response.xml"))); given(properties.getItemsPerRequest()).willReturn(100); - given(rorComponent.getRoRId(anyString())).willReturn("organisationName"); + given(digitalSpecimenDirector.assembleDigitalSpecimenTerm(any(JsonNode.class), anyBoolean())) + .willReturn(TestUtils.givenDigitalSpecimen()); // When service.retrieveData(); @@ -97,14 +97,16 @@ void testRetrieveData206() throws IOException { } @Test - void testRetrieveDataWithMedia206() throws IOException { + void testRetrieveDataWithMedia206() throws Exception { // Given given(properties.getSourceSystemId()).willReturn("ABC-DDD-ASD"); given(repository.getEndpoint(anyString())).willReturn("https://endpoint.com"); given(responseSpec.bodyToMono(any(Class.class))).willReturn( Mono.just(loadResourceFile("biocase/biocase-206-with-media.xml"))); given(properties.getItemsPerRequest()).willReturn(101); - given(rorComponent.getRoRId(anyString())).willReturn("organisationName"); + given(digitalSpecimenDirector.assembleDigitalSpecimenTerm(any(JsonNode.class), anyBoolean())) + .willReturn(TestUtils.givenDigitalSpecimen()); + given(fdoProperties.getDigitalMediaObjectType()).willReturn("Doi of the digital media object"); // When service.retrieveData(); @@ -112,7 +114,6 @@ void testRetrieveDataWithMedia206() throws IOException { // Then then(webClient).should(times(1)).get(); then(kafkaService).should(times(100)).sendMessage(eq("digital-specimen"), anyString()); - then(kafkaService).should(times(299)).sendMessage(eq("digital-media-object"), anyString()); } private void givenJsonWebclient() { diff --git a/src/test/java/eu/dissco/core/translator/service/DwcaServiceTest.java b/src/test/java/eu/dissco/core/translator/service/DwcaServiceTest.java index fb7860d..e99954f 100644 --- a/src/test/java/eu/dissco/core/translator/service/DwcaServiceTest.java +++ b/src/test/java/eu/dissco/core/translator/service/DwcaServiceTest.java @@ -2,6 +2,7 @@ import static eu.dissco.core.translator.TestUtils.MAPPER; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyList; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -9,16 +10,17 @@ import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.times; +import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import eu.dissco.core.translator.component.RorComponent; +import eu.dissco.core.translator.TestUtils; 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.DigitalObjectDirector; import eu.dissco.core.translator.terms.TermMapper; -import eu.dissco.core.translator.terms.specimen.OrganisationId; -import eu.dissco.core.translator.terms.specimen.PhysicalSpecimenIdType; import java.io.File; import java.io.IOException; import java.net.URI; @@ -68,7 +70,9 @@ class DwcaServiceTest { @Mock private DwcaRepository dwcaRepository; @Mock - private RorComponent rorComponent; + private DigitalObjectDirector digitalSpecimenDirector; + @Mock + private FdoProperties fdoProperties; private DwcaService service; @@ -81,26 +85,21 @@ private static void cleanup(String first) throws IOException { @BeforeEach void setup() { this.service = new DwcaService(MAPPER, webClientProperties, webClient, dwcaProperties, - kafkaService, termMapper, enrichmentProperties, repository, dwcaRepository, rorComponent); + kafkaService, enrichmentProperties, repository, dwcaRepository, + digitalSpecimenDirector, fdoProperties); // Given givenEndpoint(); } - private void setupTermMapper() { - given(termMapper.retrieveFromDWCA(any(), any())).willReturn("someValue"); - given(termMapper.retrieveFromDWCA(any(OrganisationId.class), any())).willReturn("https://ror.org/03srysw20"); - given(termMapper.retrieveFromDWCA(any(PhysicalSpecimenIdType.class), any())).willReturn( - "cetaf"); - } - @Test - void testRetrieveData() throws IOException { + void testRetrieveData() throws Exception { // Given - setupTermMapper(); givenDWCA("/dwca-rbins.zip"); given(dwcaRepository.getCoreRecords(anyList(), anyString())).willReturn(givenSpecimenMap(9)); - given(rorComponent.getRoRId(anyString())).willReturn("organisationName"); + given(digitalSpecimenDirector.assembleDigitalSpecimenTerm(any(JsonNode.class), anyBoolean())) + .willReturn(TestUtils.givenDigitalSpecimen()); + given(fdoProperties.getDigitalSpecimenType()).willReturn("Doi of the digital specimen"); // When service.retrieveData(); @@ -109,7 +108,6 @@ void testRetrieveData() throws IOException { then(dwcaRepository).should(times(2)).createTable(anyString()); then(dwcaRepository).should(times(21)).postRecords(anyString(), anyList()); then(kafkaService).should(times(9)).sendMessage(eq("digital-specimen"), anyString()); - then(kafkaService).should(times(0)).sendMessage(eq("digital-media-object"), anyString()); cleanup("src/test/resources/dwca/test/dwca-rbins.zip"); } @@ -126,15 +124,18 @@ private Map givenSpecimenMap(int amount) { } @Test - void testRetrieveDataWithGbifMedia() throws IOException { + void testRetrieveDataWithGbifMedia() throws Exception { // Given givenDWCA("/dwca-kew-gbif-media.zip"); - setupTermMapper(); given(dwcaRepository.getCoreRecords(anyList(), anyString())).willReturn(givenSpecimenMap(19)); given(dwcaRepository.getRecords(anyList(), eq("ABC-DDD-ASD_dwc:Identification"))).willReturn( Map.of()); - given(dwcaRepository.getRecords(anyList(), eq("ABC-DDD-ASD_gbif:Multimedia"))).willReturn(givenImageMap(19)); - given(rorComponent.getRoRId(anyString())).willReturn("organisationName"); + given(dwcaRepository.getRecords(anyList(), eq("ABC-DDD-ASD_gbif:Multimedia"))).willReturn( + givenImageMap(19)); + given(digitalSpecimenDirector.assembleDigitalSpecimenTerm(any(JsonNode.class), anyBoolean())) + .willReturn(TestUtils.givenDigitalSpecimen()); + given(fdoProperties.getDigitalMediaObjectType()).willReturn("Doi of the digital media object"); + given(fdoProperties.getDigitalSpecimenType()).willReturn("Doi of the digital specimen"); // When service.retrieveData(); @@ -143,7 +144,6 @@ void testRetrieveDataWithGbifMedia() throws IOException { then(dwcaRepository).should(times(3)).createTable(anyString()); then(dwcaRepository).should(times(19)).postRecords(anyString(), anyList()); then(kafkaService).should(times(19)).sendMessage(eq("digital-specimen"), anyString()); - then(kafkaService).should(times(19)).sendMessage(eq("digital-media-object"), anyString()); cleanup("src/test/resources/dwca/test/dwca-kew-gbif-media.zip"); } @@ -159,13 +159,16 @@ private Map> givenImageMap(int amount) { } @Test - void testRetrieveDataWithAcMedia() throws IOException { + void testRetrieveDataWithAcMedia() throws Exception { // Given givenDWCA("/dwca-naturalis-ac-media.zip"); - setupTermMapper(); given(dwcaRepository.getCoreRecords(anyList(), anyString())).willReturn(givenSpecimenMap(14)); - given(dwcaRepository.getRecords(anyList(), eq("ABC-DDD-ASD_http://rs.tdwg.org/ac/terms/Multimedia"))).willReturn(givenImageMap(14)); - given(rorComponent.getRoRId(anyString())).willReturn("organisationName"); + given(dwcaRepository.getRecords(anyList(), + eq("ABC-DDD-ASD_http://rs.tdwg.org/ac/terms/Multimedia"))).willReturn(givenImageMap(14)); + given(digitalSpecimenDirector.assembleDigitalSpecimenTerm(any(JsonNode.class), anyBoolean())) + .willReturn(TestUtils.givenDigitalSpecimen()); + given(fdoProperties.getDigitalMediaObjectType()).willReturn("Doi of the digital media object"); + given(fdoProperties.getDigitalSpecimenType()).willReturn("Doi of the digital specimen"); // When service.retrieveData(); @@ -174,17 +177,19 @@ void testRetrieveDataWithAcMedia() throws IOException { then(dwcaRepository).should(times(2)).createTable(anyString()); then(dwcaRepository).should(times(2)).postRecords(anyString(), anyList()); then(kafkaService).should(times(14)).sendMessage(eq("digital-specimen"), anyString()); - then(kafkaService).should(times(14)).sendMessage(eq("digital-media-object"), anyString()); cleanup("src/test/resources/dwca/test/dwca-naturalis-ac-media.zip"); } @Test - void testRetrieveDataWithAssociatedMedia() throws IOException { + void testRetrieveDataWithAssociatedMedia() throws Exception { // Given givenDWCA("/dwca-lux-associated-media.zip"); - setupTermMapper(); - given(dwcaRepository.getCoreRecords(anyList(), anyString())).willReturn(givenSpecimenMapWithMedia(20)); - given(rorComponent.getRoRId(anyString())).willReturn("organisationName"); + given(dwcaRepository.getCoreRecords(anyList(), anyString())).willReturn( + givenSpecimenMapWithMedia(20)); + given(digitalSpecimenDirector.assembleDigitalSpecimenTerm(any(JsonNode.class), anyBoolean())) + .willReturn(TestUtils.givenDigitalSpecimen()); + given(fdoProperties.getDigitalMediaObjectType()).willReturn("Doi of the digital media object"); + given(fdoProperties.getDigitalSpecimenType()).willReturn("Doi of the digital specimen"); // When service.retrieveData(); @@ -193,7 +198,6 @@ void testRetrieveDataWithAssociatedMedia() throws IOException { then(dwcaRepository).should(times(1)).createTable(anyString()); then(dwcaRepository).should(times(1)).postRecords(anyString(), anyList()); then(kafkaService).should(times(20)).sendMessage(eq("digital-specimen"), anyString()); - then(kafkaService).should(times(40)).sendMessage(eq("digital-media-object"), anyString()); cleanup("src/test/resources/dwca/test/dwca-lux-associated-media.zip"); } diff --git a/src/test/java/eu/dissco/core/translator/service/IngestionUtlityTest.java b/src/test/java/eu/dissco/core/translator/service/IngestionUtlityTest.java deleted file mode 100644 index bb6f86e..0000000 --- a/src/test/java/eu/dissco/core/translator/service/IngestionUtlityTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package eu.dissco.core.translator.service; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrowsExactly; - -import eu.dissco.core.translator.exception.DiSSCoDataException; -import eu.dissco.core.translator.exception.OrganisationNotRorId; -import eu.dissco.core.translator.exception.UnknownPhysicalSpecimenIdType; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class IngestionUtlityTest { - - @Test - void testCombined() throws DiSSCoDataException { - // Given - var type = "combined"; - var organisationId = "https://ror.org/0566bfb96"; - var id = "12345"; - - // When - var result = IngestionUtility.getPhysicalSpecimenId(type, organisationId, id); - - // Then - assertThat(result).isEqualTo(id + ":0566bfb96"); - } - - @Test - void testCetaf() throws DiSSCoDataException { - // Given - var type = "cetaf"; - var organisationId = "https://ror.org/0566bfb96"; - var id = "https://globally.unique.com/12345"; - - // When - var result = IngestionUtility.getPhysicalSpecimenId(type, organisationId, id); - - // Then - assertThat(result).isEqualTo(id); - } - - @Test - void testInvalidIdType() { - // Given - var type = "unknown"; - var organisationId = "https://ror.org/0566bfb96"; - var id = "https://globally.unique.com/12345"; - - // When - var exception = assertThrowsExactly(UnknownPhysicalSpecimenIdType.class, - () -> IngestionUtility.getPhysicalSpecimenId(type, organisationId, id)); - - // Then - assertThat(exception).isInstanceOf(UnknownPhysicalSpecimenIdType.class); - } - - @Test - void testInvalidRoR() { - // Given - var type = "combined"; - var organisationId = "0566bfb96"; - var id = "https://globally.unique.com/12345"; - - // When - var exception = assertThrowsExactly(OrganisationNotRorId.class, - () -> IngestionUtility.getPhysicalSpecimenId(type, organisationId, id)); - - // Then - assertThat(exception).isInstanceOf(OrganisationNotRorId.class); - } - -} diff --git a/src/test/java/eu/dissco/core/translator/terms/DigitalObjectDirectorTest.java b/src/test/java/eu/dissco/core/translator/terms/DigitalObjectDirectorTest.java new file mode 100644 index 0000000..7e03df7 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/DigitalObjectDirectorTest.java @@ -0,0 +1,319 @@ +package eu.dissco.core.translator.terms; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrowsExactly; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.given; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +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.DigitalSpecimen.OdsPhysicalSpecimenIdType; +import eu.dissco.core.translator.terms.specimen.OrganisationId; +import eu.dissco.core.translator.terms.specimen.PhysicalSpecimenIdType; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.NullSource; +import org.junit.jupiter.params.provider.ValueSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class DigitalObjectDirectorTest { + + @Mock + private TermMapper termMapper; + @Mock + private RorComponent rorComponent; + @Mock + private WebClientProperties webClientProperties; + @Mock + private FdoProperties fdoProperties; + + private DigitalObjectDirector director; + + @BeforeEach + void setup() { + director = new DigitalObjectDirector(MAPPER, termMapper, rorComponent, webClientProperties, + fdoProperties); + } + + @Test + void testConstructAbcdDigitalSpecimen() throws Exception { + // Given + var specimenJson = givenAbcdSpecimenJson(); + given(rorComponent.getRorName(anyString())).willReturn("Tallinn University of Technology"); + given(termMapper.retrieveTerm(any(Term.class), eq(specimenJson), eq(false))).willReturn( + "a mapped term"); + given(termMapper.retrieveTerm(any(OrganisationId.class), eq(specimenJson), eq(false))) + .willReturn("https://ror.org/0443cwa12"); + given(termMapper.retrieveTerm(any(PhysicalSpecimenIdType.class), eq(specimenJson), eq(false))) + .willReturn(OdsPhysicalSpecimenIdType.RESOLVABLE.value()); + + // When + var result = director.assembleDigitalSpecimenTerm(specimenJson, false); + + // Then + assertThat(result).isNotNull(); + assertThat(result.getEntityRelationships()).asList().hasSize(4); + assertThat(result.getIdentifiers()).asList().hasSize(4); + assertThat(result.getCitations()).asList().hasSize(1); + assertThat(result.getDwcIdentification()).asList().hasSize(1); + } + + @ParameterizedTest + @ValueSource(strings = {"An Unknown PhysicalSpecimenIdType"}) + @NullSource + void testConstructAbcdDigitalSpecimenUnknownIdType(String value) throws Exception { + // Given + var specimenJson = givenAbcdSpecimenJson(); + given(termMapper.retrieveTerm(any(PhysicalSpecimenIdType.class), eq(specimenJson), eq(false))) + .willReturn(value); + + // When / Then + assertThrowsExactly(UnknownPhysicalSpecimenIdType.class, + () -> director.assembleDigitalSpecimenTerm(specimenJson, false)); + } + + @Test + void testConstructDwcaDigitalSpecimen() throws Exception { + // Given + var specimenJson = givenDwcaSpecimenJson(); + given(rorComponent.getRorName(anyString())).willReturn("National Museum of Natural History"); + given(termMapper.retrieveTerm(any(Term.class), eq(specimenJson), eq(true))).willReturn( + "a mapped term"); + given(termMapper.retrieveTerm(any(OrganisationId.class), eq(specimenJson), eq(true))) + .willReturn("https://ror.org/0443cwa12"); + given(termMapper.retrieveTerm(any(PhysicalSpecimenIdType.class), eq(specimenJson), eq(true))) + .willReturn(OdsPhysicalSpecimenIdType.LOCAL.value()); + + // When + var result = director.assembleDigitalSpecimenTerm(specimenJson, true); + + // Then + assertThat(result).isNotNull(); + assertThat(result.getEntityRelationships()).asList().hasSize(3); + assertThat(result.getIdentifiers()).asList().hasSize(3); + assertThat(result.getCitations()).asList().hasSize(2); + assertThat(result.getDwcIdentification()).asList().hasSize(2); + } + + @Test + void testConstructDwcaDigitalMediaObject() throws JsonProcessingException, OrganisationNotRorId { + // Given + var specimenJson = givenDwcaMediaObject(); + given(rorComponent.getRorName(anyString())).willReturn("National Museum of Natural History"); + given(termMapper.retrieveTerm(any(Term.class), eq(specimenJson), eq(true))).willReturn( + "a mapped term"); + + // When + var result = director.assembleDigitalMediaObjects(true, specimenJson, + "https://ror.org/0443cwa12"); + + // Then + assertThat(result).isNotNull(); + assertThat(result.getEntityRelationships()).asList().hasSize(3); + assertThat(result.getIdentifiers()).asList().hasSize(2); + } + + private JsonNode givenDwcaMediaObject() throws JsonProcessingException { + return MAPPER.readTree(""" + { + "dwca:ID": "http://coldb.mnhn.fr/catalognumber/mnhn/ec/ec12801", + "dcterms:type": "StillImage", + "dcterms:format": "image/jpeg", + "dcterms:creator": "Antoine Mantilleri", + "dcterms:license": "cc-by-nc-nd", + "dcterms:identifier": "https://mediaphoto.mnhn.fr/media/1622116345730PeXvxZIhEfm1vcVV" + } + """); + } + + private JsonNode givenDwcaSpecimenJson() throws JsonProcessingException { + return MAPPER.readTree(""" + { + "dwc:sex": "M", + "dwca:ID": "http://coldb.mnhn.fr/catalognumber/mnhn/ec/ec10867", + "dwc:genus": "Pogonostoma", + "dwc:order": "Coleoptera", + "dwc:county": "Boeny", + "dwc:family": "Cicindelidae", + "extensions": { + "dwc:Identification": [ + { + "dwca:ID": "http://coldb.mnhn.fr/catalognumber/mnhn/ec/ec10867", + "dwc:genus": "Pogonostoma", + "dwc:order": "Coleoptera", + "dwc:family": "Cicindelidae", + "dwc:taxonID": "ARTHROTER|145865", + "dwc:subgenus": "Pogonostoma", + "dwc:typeStatus": "paratype(s)", + "dwc:identifiedBy": "Moravec, J.", + "dwc:dateIdentified": "2007", + "dwc:scientificName": "Pogonostoma (Pogonostoma) subtiligrossum pacholatkoi Moravec, 2003", + "dwc:specificEpithet": "subtiligrossum", + "dwc:identificationID": "ARTHROTER|218826", + "dwc:namePublishedInYear": "2003", + "dwc:higherClassification": "Pogonostoma subtiligrossum;Pogonostoma;Cicindelidae;Coleoptera", + "dwc:infraspecificEpithet": "pacholatkoi", + "dwc:scientificNameAuthorship": "Moravec, 2003", + "dwc:identificationVerificationStatus": "1" + }, + { + "dwca:ID": "http://coldb.mnhn.fr/catalognumber/mnhn/ec/ec10867", + "dwc:genus": "Pogonostoma", + "dwc:order": "Coleoptera", + "dwc:family": "Cicindelidae", + "dwc:taxonID": "ARTHROTER|145865", + "dwc:subgenus": "Pogonostoma", + "dwc:typeStatus": "paratype(s)", + "dwc:identifiedBy": "Moravec, J.", + "dwc:dateIdentified": "2003", + "dwc:scientificName": "Pogonostoma (Pogonostoma) subtiligrossum pacholatkoi Moravec, 2003", + "dwc:specificEpithet": "subtiligrossum", + "dwc:identificationID": "ARTHROTER|218827", + "dwc:namePublishedInYear": "2003", + "dwc:higherClassification": "Pogonostoma subtiligrossum;Pogonostoma;Cicindelidae;Coleoptera", + "dwc:infraspecificEpithet": "pacholatkoi", + "dwc:scientificNameAuthorship": "Moravec, 2003", + "dwc:identificationVerificationStatus": "0" + } + ], + "gbif:Reference": [ + { + "dwca:ID": "http://coldb.mnhn.fr/catalognumber/mnhn/ec/ec10867", + "dcterms:date": "2003", + "dcterms:type": "publication", + "dcterms:title": "New or rare Madagascar tiger beetles-8.Some taxonomic results in the genus Pogonostoma (Coleoptera: Cicindelidae). Folia Heyrovskyana 11: 5-34.", + "dcterms:creator": "Moravec, J.", + "dwc:taxonRemarks": "Pogonostoma (Pogonostoma) subtiligrossum pacholatkoi Moravec, 2003", + "dcterms:bibliographicCitation": "Moravec, J., 2003 - New or rare Madagascar tiger beetles-8.Some taxonomic results in the genus Pogonostoma (Coleoptera: Cicindelidae). Folia Heyrovskyana 11: 5-34." + }, + { + "dwca:ID": "http://coldb.mnhn.fr/catalognumber/mnhn/ec/ec10867", + "dcterms:date": "2007", + "dcterms:type": "publication", + "dcterms:title": "A Monograph of the Genus Pogonostoma (Coleoptera: Cicindelidae). Tiger Beetles of Madagascar volume 1. Zlin: Kabourek ed., 499 pp.", + "dcterms:creator": "Moravec, J.", + "dwc:taxonRemarks": "Pogonostoma (Pogonostoma) subtiligrossum pacholatkoi Moravec, 2003", + "dcterms:bibliographicCitation": "Moravec, J., 2007 - A Monograph of the Genus Pogonostoma (Coleoptera: Cicindelidae). Tiger Beetles of Madagascar volume 1. Zlin: Kabourek ed., 499 pp." + } + ] + }, + "dwc:country": "Madagascar", + "dwc:locality": "Katsepy", + "dwc:continent": "Afrique", + "dwc:eventDate": "1997-12-24/1997-12-31", + "dwc:recordedBy": "Moravec J. & Pacholátko P.", + "dwc:typeStatus": "paratype(s)", + "dcterms:modified": "2021-01-22 09:42:52.0", + "dwc:identifiedBy": "Moravec, J.", + "dwc:occurrenceID": "http://coldb.mnhn.fr/catalognumber/mnhn/ec/ec10867", + "dwc:basisOfRecord": "PreservedSpecimen", + "dwc:catalogNumber": "EC10867", + "dwc:stateProvince": "Mahajanga", + "dwc:collectionCode": "EC", + "dwc:scientificName": "Pogonostoma (Pogonostoma) subtiligrossum pacholatkoi Moravec, 2003", + "dwc:decimalLatitude": "-15.766667", + "dwc:individualCount": "1", + "dwc:institutionCode": "MNHN", + "dwc:decimalLongitude": "46.233333", + "dwc:verbatimLatitude": "-15.766667", + "dwc:occurrenceRemarks": "Madagascar, Katsepy (Majunga), 24-31.XII. 1997 leg., Moravec et Pacholatko/ Paratype, Pogonostoma (s.str.), subtiligrossum, pacholatkoi ssp.n., det. J. Moravec 2002/ MNHN, EC10867", + "dwc:verbatimLongitude": "46.233333", + "dwc:scientificNameAuthorship": "Moravec, 2003" + } + """); + } + + private JsonNode givenAbcdSpecimenJson() throws JsonProcessingException { + return MAPPER.readTree( + """ + { + "abcd:unitGUID": "https://geocollections.info/specimen/287", + "abcd:sourceInstitutionID": "Department of Geology, TalTech", + "abcd:sourceID": "GIT", + "abcd:unitID": "155-287", + "abcd:unitIDNumeric": 287, + "abcd:dateLastEdited": 1649859975000, + "abcd:unitReferences/unitReference/0/titleCitation": "Ernst, 2022", + "abcd:unitReferences/unitReference/0/citationDetail": "Bryozoan fauna from the Kunda Stage (Darriwilian, Middle Ordovician) of Estonia and NW Russia", + "abcd:unitReferences/unitReference/0/uri": "10.3140/bull.geosci.1843", + "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonName": "Bryozoa", + "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonRank": "Phylum", + "abcd:identifications/identification/0/result/taxonIdentified/scientificName/fullScientificNameString": "Hemiphragma rotundatum", + "abcd:identifications/identification/0/result/taxonIdentified/scientificName/nameAtomised/zoological/speciesEpithet": "rotundatum", + "abcd:identifications/identification/0/preferredFlag": true, + "abcd:identifications/identification/0/identifiers/identifier/0/personName/fullName": "Ernst", + "abcd:identifications/identification/0/identifiers/identifier/0/personName/atomisedName/inheritedName": "Ernst", + "abcd:identifications/identification/0/identifiers/identifier/0/personName/atomisedName/givenNames": "Andrej", + "abcd:recordBasis": "FossilSpecimen", + "abcd:kindOfUnit/0/value": "specimen in parts", + "abcd:kindOfUnit/0/language": "en", + "abcd:gathering/dateTime/dateText": "1957", + "abcd:gathering/agents/gatheringAgent/0/agentText": "Rubel, Madis", + "abcd:gathering/agents/gatheringAgent/0/person/fullName": "Rubel, Madis", + "abcd:gathering/agents/gatheringAgent/0/person/atomisedName/inheritedName": "Rubel", + "abcd:gathering/agents/gatheringAgent/0/person/atomisedName/givenNames": "Madis", + "abcd:gathering/localityText/value": "Väike-Pakri cliff", + "abcd:gathering/localityText/language": "en", + "abcd:gathering/country/name/value": "Estonia", + "abcd:gathering/country/iso3166Code": "EE", + "abcd:gathering/siteCoordinateSets/siteCoordinates/0/coordinateMethod": "Est Land Board map server", + "abcd:gathering/siteCoordinateSets/siteCoordinates/0/coordinatesLatLong/longitudeDecimal": 23.978771, + "abcd:gathering/siteCoordinateSets/siteCoordinates/0/coordinatesLatLong/latitudeDecimal": 59.357624, + "abcd:gathering/siteCoordinateSets/siteCoordinates/0/coordinatesLatLong/spatialDatum": "WGS84", + "abcd:gathering/stratigraphy/chronostratigraphicTerms/chronostratigraphicTerm/0/term": "Kunda Stage", + "abcd:gathering/stratigraphy/chronostratigraphicTerms/chronostratigraphicTerm/0/language": "en", + "abcd:gathering/stratigraphy/chronostratigraphicTerms/chronostratigraphicTerm/1/term": "Darriwilian", + "abcd:gathering/stratigraphy/chronostratigraphicTerms/chronostratigraphicTerm/1/language": "en", + "abcd:gathering/stratigraphy/lithostratigraphicTerms/lithostratigraphicTerm/0/term": "Pakri Formation", + "abcd:gathering/stratigraphy/lithostratigraphicTerms/lithostratigraphicTerm/0/language": "en", + "abcd:gathering/stratigraphy/stratigraphyText/value": "b", + "abcd:recordURI": "https://geocollections.info/specimen/287", + "abcd-efg:earthScienceSpecimen/unitStratigraphicDetermination/chronostratigraphicAttributions/chronostratigraphicAttribution/0/chronoStratigraphicDivision": "Stage", + "abcd-efg:earthScienceSpecimen/unitStratigraphicDetermination/chronostratigraphicAttributions/chronostratigraphicAttribution/0/chronostratigraphicName": "Kunda Stage", + "abcd-efg:earthScienceSpecimen/unitStratigraphicDetermination/lithostratigraphicAttributions/lithostratigraphicAttribution/0/formation": "Pakri Formation", + "abcd:description/representation/0/title": "TalTech geological collections", + "abcd:description/representation/0/details": "Geological and paleontological collections housed at the Institute of Geology at Tallinn University of Technology (formerly an institute of the Estonian Academy of Sciences) are the largest of their kind in Estonia. The particular strength of the collection lies in Ordovician and Silurian invertebrates and Devonian fish fossils of the Baltica paleocontinent. Most of the ca 300000 specimens are collected since the mid 20th century, few collections date back to 1850s.", + "abcd:description/representation/0/coverage": "Invertebrate and early vertebrate fossils, and sedimentary rocks primarily from the Paleozoic strata of Baltic Region and former Soviet Union; Quaternary sediments and fossils from Estonia; minerals and meteorites of worldwide coverage.", + "abcd:description/representation/0/uri": "https://geocollections.info", + "abcd:description/representation/0/language": "en", + "abcd:revisionData/dateModified": 1604528959000, + "abcd:owners/owner/0/organisation/name/representation/0/text": "Department of Geology, TalTech", + "abcd:owners/owner/0/organisation/name/representation/0/abbreviation": "GIT", + "abcd:owners/owner/0/organisation/name/representation/0/language": "en", + "abcd:owners/owner/0/person/fullName": "Ursula Toom", + "abcd:owners/owner/0/roles/role/0/value": "Chief Curator", + "abcd:owners/owner/0/addresses/address/0/value": "Ehitajate 5, 19086 Tallinn, Estonia", + "abcd:owners/owner/0/emailAddresses/emailAddress/0/value": "ursula.toom@taltech.ee", + "abcd:owners/owner/0/logoURI": "https://files.geocollections.info/img/geocase/taltech1.png", + "abcd:iprstatements/copyrights/copyright/0/text": "© Department of Geology, TalTech", + "abcd:iprstatements/copyrights/copyright/0/language": "en", + "abcd:iprstatements/licenses/license/0/text": "(CC) BY-NC", + "abcd:iprstatements/licenses/license/0/details": "Creative Commons Attribution-NonCommercial 4.0 Unported License", + "abcd:iprstatements/licenses/license/0/uri": "http://creativecommons.org/licenses/by-nc/4.0/", + "abcd:iprstatements/licenses/license/0/language": "en", + "abcd:iprstatements/termsOfUseStatements/termsOfUse/0/text": "Free for non-commercial usage, provided that Department of Geology at TalTech and https://geocollections.info are acknowledged.", + "abcd:iprstatements/termsOfUseStatements/termsOfUse/0/language": "en", + "abcd:iprstatements/disclaimers/disclaimer/0/text": "We make efforts to ensure that the data we serve are accurate. However, quality and completeness of every data record cannot be guaranteed. Use the data at your own responsibility.", + "abcd:iprstatements/disclaimers/disclaimer/0/language": "en", + "abcd:iprstatements/acknowledgements/acknowledgement/0/text": "National geological collection of Estonia; Department of Geology, TalTech", + "abcd:iprstatements/acknowledgements/acknowledgement/0/language": "en", + "abcd:iprstatements/citations/citation/text": "National geological collection of Estonia; Department of Geology, TalTech", + "abcd:iprstatements/citations/citation/language": "en" + } + """ + ); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/LicenseTest.java b/src/test/java/eu/dissco/core/translator/terms/LicenseTest.java index f478f7d..0e5337b 100644 --- a/src/test/java/eu/dissco/core/translator/terms/LicenseTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/LicenseTest.java @@ -3,11 +3,6 @@ import static eu.dissco.core.translator.TestUtils.MAPPER; import static org.assertj.core.api.Assertions.assertThat; -import efg.ContentMetadata; -import efg.DataSets.DataSet; -import efg.IPRStatements; -import efg.IPRStatements.Licenses; -import efg.Statement; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; @@ -35,13 +30,12 @@ void testRetrieveFromDWCA() { @Test void testRetrieveFromABCD() { // Given - var dataset = MAPPER.createObjectNode(); - dataset.put("abcd:metadata/iprstatements/licenses/license/0/uri", "Another License"); var unit = MAPPER.createObjectNode(); unit.put("abcd:iprstatements/licenses/license/0/uri", LICENSE_STRING); + unit.put("abcd:metadata/iprstatements/licenses/license/0/uri", "Another License"); // When - var result = license.retrieveFromABCD(dataset, unit); + var result = license.retrieveFromABCD(unit); // Then assertThat(result).isEqualTo(LICENSE_STRING); @@ -50,12 +44,11 @@ void testRetrieveFromABCD() { @Test void testRetrieveFromABCDMetadata() { // Given - var dataset = MAPPER.createObjectNode(); - dataset.put("abcd:metadata/iprstatements/licenses/license/0/text", "Another License"); var unit = MAPPER.createObjectNode(); + unit.put("abcd:iprstatements/licenses/license/0/text", "Another License"); // When - var result = license.retrieveFromABCD(dataset, unit); + var result = license.retrieveFromABCD(unit); // Then assertThat(result).isEqualTo("Another License"); diff --git a/src/test/java/eu/dissco/core/translator/terms/TermMapperTest.java b/src/test/java/eu/dissco/core/translator/terms/TermMapperTest.java index 20a143f..9fcbb49 100644 --- a/src/test/java/eu/dissco/core/translator/terms/TermMapperTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/TermMapperTest.java @@ -7,10 +7,9 @@ import static org.mockito.Mockito.mock; import com.fasterxml.jackson.databind.JsonNode; -import efg.DataSets.DataSet; import eu.dissco.core.translator.component.MappingComponent; +import eu.dissco.core.translator.terms.specimen.CollectionId; import eu.dissco.core.translator.terms.specimen.OrganisationId; -import eu.dissco.core.translator.terms.specimen.PhysicalSpecimenCollection; import eu.dissco.core.translator.terms.specimen.PhysicalSpecimenId; import java.util.Map; import org.junit.jupiter.api.BeforeEach; @@ -35,12 +34,11 @@ void setup() { @Test void testRetrieveFromDWCADefault() { // Given - var organisationId = new OrganisationId(); - given(mappingComponent.getDefaultMappings()).willReturn( + given(mappingComponent.getDefaults()).willReturn( Map.of(OrganisationId.TERM, "https://ror.org/02y22ws83")); // When - var result = termMapper.retrieveFromDWCA(organisationId, mock(JsonNode.class)); + var result = termMapper.retrieveTerm(new OrganisationId(), mock(JsonNode.class), true); // Then assertThat(result).isEqualTo("https://ror.org/02y22ws83"); @@ -49,15 +47,15 @@ void testRetrieveFromDWCADefault() { @Test void testRetrieveFromDWCAFieldMapping() { // Given - var physicalSpecimenCollection = new PhysicalSpecimenCollection(); + var physicalSpecimenCollection = new CollectionId(); var dwcaTerm = "dwc:collectionID"; given(mappingComponent.getFieldMappings()).willReturn( - Map.of(PhysicalSpecimenCollection.TERM, dwcaTerm)); + Map.of(CollectionId.TERM, dwcaTerm)); var unit = MAPPER.createObjectNode(); unit.put("dwc:collectionID", "TestCollection"); // When - var result = termMapper.retrieveFromDWCA(physicalSpecimenCollection, unit); + var result = termMapper.retrieveTerm(physicalSpecimenCollection, unit, true); // Then assertThat(result).isEqualTo("TestCollection"); @@ -66,26 +64,26 @@ void testRetrieveFromDWCAFieldMapping() { @Test void testRetrieveFromDWCANoMapping() { // Given - var physicalSpecimenCollection = mock(PhysicalSpecimenCollection.class); - given(physicalSpecimenCollection.getTerm()).willReturn(PhysicalSpecimenCollection.TERM); + var collectionId = mock(CollectionId.class); + given(collectionId.getTerm()).willReturn(CollectionId.TERM); var attributes = mock(JsonNode.class); // When - termMapper.retrieveFromDWCA(physicalSpecimenCollection, attributes); + termMapper.retrieveTerm(collectionId, attributes, true); // Then - then(physicalSpecimenCollection).should().retrieveFromDWCA(attributes); + then(collectionId).should().retrieveFromDWCA(attributes); } @Test void testRetrieveFromABCDDefault() { // Given var organisationId = new OrganisationId(); - given(mappingComponent.getDefaultMappings()).willReturn( + given(mappingComponent.getDefaults()).willReturn( Map.of(OrganisationId.TERM, "https://ror.org/02y22ws83")); // When - var result = termMapper.retrieveFromABCD(organisationId, mock(JsonNode.class)); + var result = termMapper.retrieveTerm(organisationId, mock(JsonNode.class), false); // Then assertThat(result).isEqualTo("https://ror.org/02y22ws83"); @@ -101,7 +99,7 @@ void testRetrieveFromABCDFieldMapping() { Map.of(PhysicalSpecimenId.TERM, abcdTerm)); // When - var result = termMapper.retrieveFromABCD(new PhysicalSpecimenId(), attributes); + var result = termMapper.retrieveTerm(new PhysicalSpecimenId(), attributes, false); // Then assertThat(result).isEqualTo("123456"); @@ -110,12 +108,12 @@ void testRetrieveFromABCDFieldMapping() { @Test void testRetrieveFromABCDNoMapping() { // Given - var physicalSpecimenCollection = mock(PhysicalSpecimenCollection.class); - given(physicalSpecimenCollection.getTerm()).willReturn(PhysicalSpecimenCollection.TERM); + var physicalSpecimenCollection = mock(CollectionId.class); + given(physicalSpecimenCollection.getTerm()).willReturn(CollectionId.TERM); var attributes = mock(JsonNode.class); // When - termMapper.retrieveFromABCD(physicalSpecimenCollection, attributes); + termMapper.retrieveTerm(physicalSpecimenCollection, attributes, false); // Then then(physicalSpecimenCollection).should().retrieveFromABCD(attributes); diff --git a/src/test/java/eu/dissco/core/translator/terms/media/AccessRightsTest.java b/src/test/java/eu/dissco/core/translator/terms/media/AccessRightsTest.java new file mode 100644 index 0000000..051b828 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/media/AccessRightsTest.java @@ -0,0 +1,38 @@ +package eu.dissco.core.translator.terms.media; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class AccessRightsTest { + + private final AccessRights accessRights = new AccessRights(); + + @Test + void testRetrieveFromDWCA() { + // Given + var accessRightsString = "Description of accessRights"; + var unit = MAPPER.createObjectNode(); + unit.put("dcterms:accessRights", accessRightsString); + + // When + var result = accessRights.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(accessRightsString); + } + + @Test + void testGetTerm() { + // When + var result = accessRights.getTerm(); + + // Then + assertThat(result).isEqualTo(AccessRights.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/media/CreatedTest.java b/src/test/java/eu/dissco/core/translator/terms/media/CreatedTest.java new file mode 100644 index 0000000..286243e --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/media/CreatedTest.java @@ -0,0 +1,52 @@ +package eu.dissco.core.translator.terms.media; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static eu.dissco.core.translator.TestUtils.MOCK_DATE; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class CreatedTest { + + private final Created created = new Created(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dcterms:created", MOCK_DATE); + + // When + var result = created.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(MOCK_DATE); + } + + @Test + void testRetrieveFromAbcd() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:createdDate", MOCK_DATE); + + // When + var result = created.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(MOCK_DATE); + } + + + @Test + void testGetTerm() { + // When + var result = created.getTerm(); + + // Then + assertThat(result).isEqualTo(Created.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/media/CreatorTest.java b/src/test/java/eu/dissco/core/translator/terms/media/CreatorTest.java new file mode 100644 index 0000000..0e276ba --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/media/CreatorTest.java @@ -0,0 +1,53 @@ +package eu.dissco.core.translator.terms.media; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class CreatorTest { + + private final Creator creator = new Creator(); + + @Test + void testRetrieveFromDWCA() { + // Given + var creatorString = "Sam Leeflang"; + var unit = MAPPER.createObjectNode(); + unit.put("dcterms:creator", creatorString); + + // When + var result = creator.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(creatorString); + } + + @Test + void testRetrieveFromAbcd() { + // Given + var createdString = "Sam Leeflang"; + var unit = MAPPER.createObjectNode(); + unit.put("abcd:creator", createdString); + + // When + var result = creator.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(createdString); + } + + + @Test + void testGetTerm() { + // When + var result = creator.getTerm(); + + // Then + assertThat(result).isEqualTo(Creator.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/media/DescriptionTest.java b/src/test/java/eu/dissco/core/translator/terms/media/DescriptionTest.java new file mode 100644 index 0000000..8fa8fdb --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/media/DescriptionTest.java @@ -0,0 +1,53 @@ +package eu.dissco.core.translator.terms.media; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class DescriptionTest { + + private final Description description = new Description(); + + @Test + void testRetrieveFromDWCA() { + // Given + var descriptionString = "An image of a plant"; + var unit = MAPPER.createObjectNode(); + unit.put("dcterms:description", descriptionString); + + // When + var result = description.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(descriptionString); + } + + @Test + void testRetrieveFromAbcd() { + // Given + var descriptionString = "An image of a plant"; + var unit = MAPPER.createObjectNode(); + unit.put("abcd:context/value", descriptionString); + + // When + var result = description.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(descriptionString); + } + + + @Test + void testGetTerm() { + // When + var result = description.getTerm(); + + // Then + assertThat(result).isEqualTo(Description.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/media/FileSizeTest.java b/src/test/java/eu/dissco/core/translator/terms/media/FileSizeTest.java new file mode 100644 index 0000000..1cae2c4 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/media/FileSizeTest.java @@ -0,0 +1,53 @@ +package eu.dissco.core.translator.terms.media; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class FileSizeTest { + + private final FileSize fileSize = new FileSize(); + + @Test + void testRetrieveFromDWCA() { + // Given + var fileSizeString = "38"; + var unit = MAPPER.createObjectNode(); + unit.put("dcterms:extent", fileSizeString); + + // When + var result = fileSize.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(fileSizeString); + } + + @Test + void testRetrieveFromAbcd() { + // Given + var fileSizeString = "38"; + var unit = MAPPER.createObjectNode(); + unit.put("abcd:fileSize", fileSizeString); + + // When + var result = fileSize.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(fileSizeString); + } + + + @Test + void testGetTerm() { + // When + var result = fileSize.getTerm(); + + // Then + assertThat(result).isEqualTo(FileSize.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/media/MediaAssertionsTest.java b/src/test/java/eu/dissco/core/translator/terms/media/MediaAssertionsTest.java new file mode 100644 index 0000000..3a68809 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/media/MediaAssertionsTest.java @@ -0,0 +1,42 @@ +package eu.dissco.core.translator.terms.media; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class MediaAssertionsTest { + + private final MediaAssertions assertions = new MediaAssertions(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + + // When + var result = assertions.gatherAssertions(unit, true); + + // Then + assertThat(result).isEmpty(); + } + + @Test + void testRetrieveFromABCD() { + // Given + var formatString = "SpecimenName"; + var unit = MAPPER.createObjectNode(); + unit.put("abcd:fileSize", "38"); + unit.put("abcd:imageSize/width", "500"); + unit.put("abcd:imageSize/height", 1500); + + // When + var result = assertions.gatherAssertions(unit, false); + + // Then + assertThat(result).hasSize(3); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/media/MediaTypeTest.java b/src/test/java/eu/dissco/core/translator/terms/media/MediaTypeTest.java index 06b6593..29553c3 100644 --- a/src/test/java/eu/dissco/core/translator/terms/media/MediaTypeTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/media/MediaTypeTest.java @@ -18,26 +18,28 @@ class MediaTypeTest { private static Stream provideACTypes() { return Stream.of( - Arguments.of("StillImage", "2DImageObject"), - Arguments.of("Image", "2DImageObject"), - Arguments.of("Sound", "AudioObject"), - Arguments.of("MovingImage", "VideoObject"), - Arguments.of("RandomString", null) + Arguments.of("StillImage", "StillImage"), + Arguments.of("Image", "StillImage"), + Arguments.of("Sound", "Sound"), + Arguments.of("MovingImage", "MovingImage"), + Arguments.of("RandomString", null), + Arguments.of(null, null) ); } private static Stream provideFormatTypes() { return Stream.of( - Arguments.of("image/jpeg", "2DImageObject"), - Arguments.of("audio/example", "AudioObject"), - Arguments.of("video/example", "VideoObject"), - Arguments.of("RandomString", null) + Arguments.of("image/jpeg", "StillImage"), + Arguments.of("audio/example", "Sound"), + Arguments.of("video/example", "MovingImage"), + Arguments.of("RandomString", null), + Arguments.of(null, null) ); } private static Stream provideABCDFormats() { return Stream.of( - Arguments.of("image/jpeg", "2DImageObject"), + Arguments.of("image/jpeg", "StillImage"), Arguments.of("unknown/format", null), Arguments.of(null, null) ); diff --git a/src/test/java/eu/dissco/core/translator/terms/media/ModifiedTest.java b/src/test/java/eu/dissco/core/translator/terms/media/ModifiedTest.java new file mode 100644 index 0000000..e277836 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/media/ModifiedTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.media; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class ModifiedTest { + + private final Modified modified = new Modified(); + + @Test + void testRetrieveFromDWCA() { + // Given + var modifiedString = "18-09-2023"; + var unit = MAPPER.createObjectNode(); + unit.put("dcterms:modified", modifiedString); + + // When + var result = modified.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(modifiedString); + } + + + @Test + void testGetTerm() { + // When + var result = modified.getTerm(); + + // Then + assertThat(result).isEqualTo(Modified.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/media/PixelXDimensionTest.java b/src/test/java/eu/dissco/core/translator/terms/media/PixelXDimensionTest.java new file mode 100644 index 0000000..2dd6052 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/media/PixelXDimensionTest.java @@ -0,0 +1,53 @@ +package eu.dissco.core.translator.terms.media; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class PixelXDimensionTest { + + private final PixelXDimension pixelXDimension = new PixelXDimension(); + + @Test + void testRetrieveFromDWCA() { + // Given + var pixelXDimensionString = "500"; + var unit = MAPPER.createObjectNode(); + unit.put("exif:PixelXDimension", pixelXDimensionString); + + // When + var result = pixelXDimension.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(pixelXDimensionString); + } + + @Test + void testRetrieveFromAbcd() { + // Given + var pixelXDimensionString = "500"; + var unit = MAPPER.createObjectNode(); + unit.put("abcd:imageSize/width", pixelXDimensionString); + + // When + var result = pixelXDimension.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(pixelXDimensionString); + } + + + @Test + void testGetTerm() { + // When + var result = pixelXDimension.getTerm(); + + // Then + assertThat(result).isEqualTo(PixelXDimension.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/media/PixelYDimensionTest.java b/src/test/java/eu/dissco/core/translator/terms/media/PixelYDimensionTest.java new file mode 100644 index 0000000..425a6ea --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/media/PixelYDimensionTest.java @@ -0,0 +1,53 @@ +package eu.dissco.core.translator.terms.media; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class PixelYDimensionTest { + + private final PixelYDimension pixelYDimension = new PixelYDimension(); + + @Test + void testRetrieveFromDWCA() { + // Given + var pixelyDimensionString = "1500"; + var unit = MAPPER.createObjectNode(); + unit.put("exif:PixelYDimension", pixelyDimensionString); + + // When + var result = pixelYDimension.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(pixelyDimensionString); + } + + @Test + void testRetrieveFromAbcd() { + // Given + var pixelyDimensionString = "1500"; + var unit = MAPPER.createObjectNode(); + unit.put("abcd:imageSize/height", pixelyDimensionString); + + // When + var result = pixelYDimension.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(pixelyDimensionString); + } + + + @Test + void testGetTerm() { + // When + var result = pixelYDimension.getTerm(); + + // Then + assertThat(result).isEqualTo(PixelYDimension.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/media/RightsHolderTest.java b/src/test/java/eu/dissco/core/translator/terms/media/RightsHolderTest.java new file mode 100644 index 0000000..585fca7 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/media/RightsHolderTest.java @@ -0,0 +1,38 @@ +package eu.dissco.core.translator.terms.media; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class RightsHolderTest { + + private final RightsHolder rightsHolder = new RightsHolder(); + + @Test + void testRetrieveFromDWCA() { + // Given + var rightsHolderString = "The rightsHolder"; + var unit = MAPPER.createObjectNode(); + unit.put("dcterms:rightsHolder", rightsHolderString); + + // When + var result = rightsHolder.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(rightsHolderString); + } + + @Test + void testGetTerm() { + // When + var result = rightsHolder.getTerm(); + + // Then + assertThat(result).isEqualTo(RightsHolder.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/media/RightsTest.java b/src/test/java/eu/dissco/core/translator/terms/media/RightsTest.java new file mode 100644 index 0000000..2a12a6f --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/media/RightsTest.java @@ -0,0 +1,38 @@ +package eu.dissco.core.translator.terms.media; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class RightsTest { + + private final Rights rights = new Rights(); + + @Test + void testRetrieveFromDWCA() { + // Given + var rightsString = "Some rights"; + var unit = MAPPER.createObjectNode(); + unit.put("dc:rights", rightsString); + + // When + var result = rights.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(rightsString); + } + + @Test + void testGetTerm() { + // When + var result = rights.getTerm(); + + // Then + assertThat(result).isEqualTo(Rights.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/media/SourceTest.java b/src/test/java/eu/dissco/core/translator/terms/media/SourceTest.java new file mode 100644 index 0000000..9640925 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/media/SourceTest.java @@ -0,0 +1,53 @@ +package eu.dissco.core.translator.terms.media; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class SourceTest { + + private final Source source = new Source(); + + @Test + void testRetrieveFromDWCA() { + // Given + var sourceString = "https://geocollections.info/file/168145"; + var unit = MAPPER.createObjectNode(); + unit.put("dcterms:source", sourceString); + + // When + var result = source.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(sourceString); + } + + @Test + void testRetrieveFromAbcd() { + // Given + var sourceString = "https://geocollections.info/file/168145"; + var unit = MAPPER.createObjectNode(); + unit.put("abcd:productURI", sourceString); + + // When + var result = source.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(sourceString); + } + + + @Test + void testGetTerm() { + // When + var result = source.getTerm(); + + // Then + assertThat(result).isEqualTo(Source.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/media/WebStatementTest.java b/src/test/java/eu/dissco/core/translator/terms/media/WebStatementTest.java new file mode 100644 index 0000000..abab472 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/media/WebStatementTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.media; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class WebStatementTest { + + private final WebStatement webStatement = new WebStatement(); + + @Test + void testRetrieveFromDWCA() { + // Given + var webStatementString = "Some statement"; + var unit = MAPPER.createObjectNode(); + unit.put("xmpRights:webStatement", webStatementString); + + // When + var result = webStatement.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(webStatementString); + } + + + @Test + void testGetTerm() { + // When + var result = webStatement.getTerm(); + + // Then + assertThat(result).isEqualTo(WebStatement.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/AccessRightsTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/AccessRightsTest.java new file mode 100644 index 0000000..d08bd6c --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/AccessRightsTest.java @@ -0,0 +1,37 @@ +package eu.dissco.core.translator.terms.specimen; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class AccessRightsTest { + + private static final String ACCESS_RIGHTS_STRING = "S. Leeflang"; + private final AccessRights accessRights = new AccessRights(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dcterms:accessRights", ACCESS_RIGHTS_STRING); + + // When + var result = accessRights.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(ACCESS_RIGHTS_STRING); + } + + @Test + void testGetTerm() { + // When + var result = accessRights.getTerm(); + + // Then + assertThat(result).isEqualTo(AccessRights.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/DatasetNameTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/DatasetNameTest.java new file mode 100644 index 0000000..f650896 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/DatasetNameTest.java @@ -0,0 +1,37 @@ +package eu.dissco.core.translator.terms.specimen; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class DatasetNameTest { + + private static final String DATASET_NAME_STRING = "Grinnell Resurvey Mammals"; + private final DatasetName datasetName = new DatasetName(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:datasetName", DATASET_NAME_STRING); + + // When + var result = datasetName.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(DATASET_NAME_STRING); + } + + @Test + void testGetTerm() { + // When + var result = datasetName.getTerm(); + + // Then + assertThat(result).isEqualTo(DatasetName.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/DataSetIdTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/DispositionTest.java similarity index 57% rename from src/test/java/eu/dissco/core/translator/terms/specimen/DataSetIdTest.java rename to src/test/java/eu/dissco/core/translator/terms/specimen/DispositionTest.java index 7a55783..26d53d7 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/DataSetIdTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/DispositionTest.java @@ -8,30 +8,30 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class DataSetIdTest { +class DispositionTest { - private final DatasetId datasetId = new DatasetId(); + private static final String DISPOSITION_STRING = "missing"; + private final Disposition disposition = new Disposition(); @Test void testRetrieveFromDWCA() { // Given - var datasetIdString = "datasetId-123456"; var unit = MAPPER.createObjectNode(); - unit.put("dwc:datasetID", datasetIdString); + unit.put("dwc:disposition", DISPOSITION_STRING); // When - var result = datasetId.retrieveFromDWCA(unit); + var result = disposition.retrieveFromDWCA(unit); // Then - assertThat(result).isEqualTo(datasetIdString); + assertThat(result).isEqualTo(DISPOSITION_STRING); } @Test void testGetTerm() { // When - var result = datasetId.getTerm(); + var result = disposition.getTerm(); // Then - assertThat(result).isEqualTo(DatasetId.TERM); + assertThat(result).isEqualTo(Disposition.TERM); } } diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/MarkedAsTypeTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/MarkedAsTypeTest.java new file mode 100644 index 0000000..f8763ea --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/MarkedAsTypeTest.java @@ -0,0 +1,83 @@ +package eu.dissco.core.translator.terms.specimen; + +import static org.assertj.core.api.Assertions.assertThat; + +import eu.dissco.core.translator.schema.DigitalSpecimen; +import eu.dissco.core.translator.schema.Identifications; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class MarkedAsTypeTest { + + private final MarkedAsType markedAsType = new MarkedAsType(); + + @ParameterizedTest + @ValueSource(strings = {"holotype", "haplotype", "some other type"}) + void testRetrieve(String typeStatus) { + // Given + var ds = new DigitalSpecimen().withDwcIdentification(List.of( + new Identifications() + .withDwcIdentificationVerificationStatus(Boolean.FALSE), + new Identifications() + .withDwcIdentificationVerificationStatus(Boolean.TRUE) + .withDwcTypeStatus(typeStatus) + )); + + // When + var result = markedAsType.calculate(ds); + + // Then + assertThat(result).isTrue(); + } + + @ParameterizedTest + @ValueSource(strings = {"", " ", "specimen", "false"}) + void testRetrieveFalse(String typeStatus) { + // Given + var ds = new DigitalSpecimen().withDwcIdentification(List.of( + new Identifications() + .withDwcIdentificationVerificationStatus(Boolean.FALSE), + new Identifications() + .withDwcIdentificationVerificationStatus(Boolean.TRUE) + .withDwcTypeStatus(typeStatus) + )); + + // When + var result = markedAsType.calculate(ds); + + // Then + assertThat(result).isFalse(); + } + + @Test + void testRetrieveNull() { + // Given + var ds = new DigitalSpecimen().withDwcIdentification(List.of( + new Identifications() + .withDwcIdentificationVerificationStatus(Boolean.FALSE) + .withDwcTypeStatus("holotype"), + new Identifications() + .withDwcIdentificationVerificationStatus(Boolean.TRUE) + )); + + // When + var result = markedAsType.calculate(ds); + + // Then + assertThat(result).isNull(); + } + + @Test + void testGetTerm() { + // When + var result = markedAsType.getTerm(); + + // Then + assertThat(result).isEqualTo(MarkedAsType.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/ModifiedTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/ModifiedTest.java index e6d4bb3..fef0ada 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/ModifiedTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/ModifiedTest.java @@ -1,6 +1,7 @@ package eu.dissco.core.translator.terms.specimen; import static eu.dissco.core.translator.TestUtils.MAPPER; +import static eu.dissco.core.translator.TestUtils.MOCK_DATE; import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Test; @@ -15,7 +16,7 @@ class ModifiedTest { @Test void testRetrieveFromDWCA() { // Given - var licenseString = "23-03-1989"; + var licenseString = MOCK_DATE; var unit = MAPPER.createObjectNode(); unit.put("dcterms:modified", licenseString); @@ -30,13 +31,12 @@ void testRetrieveFromDWCA() { void testRetrieveFromABCD() { // Given String modifiedString = "1674553668909"; - var dataset = MAPPER.createObjectNode(); - dataset.put("abcd:metadata/revisionData/dateModified", "1604521759000"); var unit = MAPPER.createObjectNode(); unit.put("abcd:dateLastEdited", modifiedString); + unit.put("abcd:metadata/revisionData/dateModified", "1604521759000"); // When - var result = modified.retrieveFromABCD(dataset, unit); + var result = modified.retrieveFromABCD(unit); // Then assertThat(result).isEqualTo(modifiedString); @@ -45,12 +45,11 @@ void testRetrieveFromABCD() { @Test void testRetrieveFromABCDFromMeta() { // Given - var dataset = MAPPER.createObjectNode(); - dataset.put("abcd:metadata/revisionData/dateModified", "1604521759000"); var unit = MAPPER.createObjectNode(); + unit.put("abcd:revisionData/dateModified", "1604521759000"); // When - var result = modified.retrieveFromABCD(dataset, unit); + var result = modified.retrieveFromABCD(unit); // Then assertThat(result).isEqualTo("1604521759000"); @@ -59,12 +58,11 @@ void testRetrieveFromABCDFromMeta() { @Test void testRetrieveFromABCDFromMetaLong() { // Given - var dataset = MAPPER.createObjectNode(); - dataset.put("abcd:metadata/revisionData/dateModified", 1604521759000L); var unit = MAPPER.createObjectNode(); + unit.put("abcd:revisionData/dateModified", 1604521759000L); // When - var result = modified.retrieveFromABCD(dataset, unit); + var result = modified.retrieveFromABCD(unit); // Then assertThat(result).isEqualTo("1604521759000"); diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/PhysicalSpecimenCollectionTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/PhysicalSpecimenCollectionTest.java index ea9f390..faf8e76 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/PhysicalSpecimenCollectionTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/PhysicalSpecimenCollectionTest.java @@ -10,15 +10,14 @@ @ExtendWith(MockitoExtension.class) class PhysicalSpecimenCollectionTest { - private final PhysicalSpecimenCollection physicalSpecimenCollection = new PhysicalSpecimenCollection(); + private final CollectionId physicalSpecimenCollection = new CollectionId(); @Test void testRetrieveFromDWCA() { // Given var collectionString = "collection-123456"; var unit = MAPPER.createObjectNode(); - unit.putNull("dwc:collectionID"); - unit.put("dwc:collectionCode", collectionString); + unit.put("dwc:collectionID", collectionString); // When var result = physicalSpecimenCollection.retrieveFromDWCA(unit); @@ -33,6 +32,6 @@ void testGetTerm() { var result = physicalSpecimenCollection.getTerm(); // Then - assertThat(result).isEqualTo(PhysicalSpecimenCollection.TERM); + assertThat(result).isEqualTo(CollectionId.TERM); } } diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/ObjectTypeTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/PreparationsTest.java similarity index 76% rename from src/test/java/eu/dissco/core/translator/terms/specimen/ObjectTypeTest.java rename to src/test/java/eu/dissco/core/translator/terms/specimen/PreparationsTest.java index 346d5da..5ca678b 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/ObjectTypeTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/PreparationsTest.java @@ -8,9 +8,9 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class ObjectTypeTest { +class PreparationsTest { - private final ObjectType objectType = new ObjectType(); + private final Preparations preparations = new Preparations(); @Test void testRetrieveFromDWCA() { @@ -20,7 +20,7 @@ void testRetrieveFromDWCA() { unit.put("dwc:preparations", objectTypeString); // When - var result = objectType.retrieveFromDWCA(unit); + var result = preparations.retrieveFromDWCA(unit); // Then assertThat(result).isEqualTo(objectTypeString); @@ -34,7 +34,7 @@ void testRetrieveFromABCD() { unit.put("abcd:kindOfUnit/0/value", objectTypeString); // When - var result = objectType.retrieveFromABCD(unit); + var result = preparations.retrieveFromABCD(unit); // Then assertThat(result).isEqualTo(objectTypeString); @@ -43,10 +43,10 @@ void testRetrieveFromABCD() { @Test void testGetTerm() { // When - var result = objectType.getTerm(); + var result = preparations.getTerm(); // Then - assertThat(result).isEqualTo(ObjectType.TERM); + assertThat(result).isEqualTo(Preparations.TERM); } } diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/CollectorTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/RecordedByTest.java similarity index 62% rename from src/test/java/eu/dissco/core/translator/terms/specimen/CollectorTest.java rename to src/test/java/eu/dissco/core/translator/terms/specimen/RecordedByTest.java index cbdc6bf..0ee4bfb 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/CollectorTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/RecordedByTest.java @@ -8,22 +8,22 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class CollectorTest { +class RecordedByTest { - private static final String COLLECTOR_NAME = "Fricke, Ronald"; - private final Collector collector = new Collector(); + private static final String RECORDED_BY_STRING = "Fricke, Ronald"; + private final RecordedBy recordedBy = new RecordedBy(); @Test void testRetrieveFromDWCA() { // Given var unit = MAPPER.createObjectNode(); - unit.put("dwc:recordedBy", COLLECTOR_NAME); + unit.put("dwc:recordedBy", RECORDED_BY_STRING); // When - var result = collector.retrieveFromDWCA(unit); + var result = recordedBy.retrieveFromDWCA(unit); // Then - assertThat(result).isEqualTo(COLLECTOR_NAME); + assertThat(result).isEqualTo(RECORDED_BY_STRING); } @Test @@ -31,29 +31,29 @@ void testRetrieveFromABCDMultipleAgents() { // Given var collectorName2 = "Troschel, Hans-Julius"; var unit = MAPPER.createObjectNode(); - unit.put("abcd:gathering/agents/gatheringAgent/0/person/fullName", COLLECTOR_NAME); + unit.put("abcd:gathering/agents/gatheringAgent/0/person/fullName", RECORDED_BY_STRING); unit.put("abcd:gathering/agents/gatheringAgent/0/person/agentText", "Tom"); unit.put("abcd:gathering/agents/gatheringAgent/1/person/agentText", collectorName2); unit.put("abcd:gathering/agents/gatheringAgentsText", "Sam Leeflang"); // When - var result = collector.retrieveFromABCD(unit); + var result = recordedBy.retrieveFromABCD(unit); // Then - assertThat(result).isEqualTo(COLLECTOR_NAME + " | " + collectorName2); + assertThat(result).isEqualTo(RECORDED_BY_STRING + " | " + collectorName2); } @Test void testRetrieveFromABCDGatheringAgentsText() { // Given var unit = MAPPER.createObjectNode(); - unit.put("abcd:gathering/agents/gatheringAgentsText", COLLECTOR_NAME); + unit.put("abcd:gathering/agents/gatheringAgentsText/value", RECORDED_BY_STRING); // When - var result = collector.retrieveFromABCD(unit); + var result = recordedBy.retrieveFromABCD(unit); // Then - assertThat(result).isEqualTo(COLLECTOR_NAME); + assertThat(result).isEqualTo(RECORDED_BY_STRING); } @Test @@ -62,7 +62,7 @@ void testRetrieveFromABCDEmpty() { var unit = MAPPER.createObjectNode(); // When - var result = collector.retrieveFromABCD(unit); + var result = recordedBy.retrieveFromABCD(unit); // Then assertThat(result).isNull(); @@ -71,10 +71,10 @@ void testRetrieveFromABCDEmpty() { @Test void testGetTerm() { // When - var result = collector.getTerm(); + var result = recordedBy.getTerm(); // Then - assertThat(result).isEqualTo(Collector.TERM); + assertThat(result).isEqualTo(RecordedBy.TERM); } } diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/RightsHolderTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/RightsHolderTest.java new file mode 100644 index 0000000..289cd8c --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/RightsHolderTest.java @@ -0,0 +1,37 @@ +package eu.dissco.core.translator.terms.specimen; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class RightsHolderTest { + + private static final String RIGHTS_HOLDER_STRING = "S. Leeflang"; + private final RightsHolder rightsHolder = new RightsHolder(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dcterms:rightsHolder", RIGHTS_HOLDER_STRING); + + // When + var result = rightsHolder.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(RIGHTS_HOLDER_STRING); + } + + @Test + void testGetTerm() { + // When + var result = rightsHolder.getTerm(); + + // Then + assertThat(result).isEqualTo(RightsHolder.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/SpecimenNameTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/SpecimenNameTest.java new file mode 100644 index 0000000..d7d3876 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/SpecimenNameTest.java @@ -0,0 +1,47 @@ +package eu.dissco.core.translator.terms.specimen; + +import static org.assertj.core.api.Assertions.assertThat; + +import eu.dissco.core.translator.schema.TaxonIdentification; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class SpecimenNameTest { + + private static final String SPECIMEN_NAME = "\"Bignonia chica Humb. & Bonpl.\""; + private final SpecimenName specimenName = new SpecimenName(); + + @Test + void testRetrieve() { + // Given + var ds = new eu.dissco.core.translator.schema.DigitalSpecimen() + .withDwcIdentification(List.of( + new eu.dissco.core.translator.schema.Identifications() + .withDwcIdentificationVerificationStatus(Boolean.FALSE) + .withTaxonIdentifications(List.of( + new TaxonIdentification().withDwcScientificName("A very scientific name"))), + new eu.dissco.core.translator.schema.Identifications() + .withDwcIdentificationVerificationStatus(Boolean.TRUE) + .withTaxonIdentifications( + List.of(new TaxonIdentification().withDwcScientificName(SPECIMEN_NAME))) + )); + + // When + var result = specimenName.calculate(ds); + + // Then + assertThat(result).isEqualTo(SPECIMEN_NAME); + } + + @Test + void testGetTerm() { + // When + var result = specimenName.getTerm(); + + // Then + assertThat(result).isEqualTo(SpecimenName.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/TopicDisciplineTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/TopicDisciplineTest.java index ef46347..68cc547 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/TopicDisciplineTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/TopicDisciplineTest.java @@ -1,8 +1,11 @@ package eu.dissco.core.translator.terms.specimen; -import static eu.dissco.core.translator.TestUtils.MAPPER; import static org.assertj.core.api.Assertions.assertThat; +import eu.dissco.core.translator.schema.DigitalSpecimen; +import eu.dissco.core.translator.schema.DigitalSpecimen.OdsTopicDiscipline; +import eu.dissco.core.translator.schema.TaxonIdentification; +import java.util.List; import java.util.stream.Stream; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -13,51 +16,52 @@ @ExtendWith(MockitoExtension.class) class TopicDisciplineTest { - private final TopicDiscipline topicDiscipline = new TopicDiscipline(); - - @ParameterizedTest - @MethodSource("arguments") - void testRetrieveFromDWCA(String basisOfRecord, String kingdom, String expected) { - // Given - var unit = MAPPER.createObjectNode(); - unit.put("dwc:basisOfRecord", basisOfRecord); - unit.put("dwc:kingdom", kingdom); - - // When - var result = topicDiscipline.retrieveFromDWCA(unit); - // Then - assertThat(result).isEqualTo(expected); - } + private final TopicDiscipline topicDiscipline = new TopicDiscipline(); private static Stream arguments() { return Stream.of( - Arguments.of("FossilSpecimen", null, "Palaeontology"), - Arguments.of("MeteoriteSpecimen", null, "Astrogeology"), - Arguments.of("RockSpecimen", null, "Geology"), - Arguments.of("PreservedSpecimen", "Animalia", "Zoology"), - Arguments.of("PreservedSpecimen", "Plantae", "Botany"), - Arguments.of("PreservedSpecimen", "Bacteria", "Microbiology"), - Arguments.of("PreservedSpecimen", "incertae sedis", "Unclassified"), - Arguments.of("Other", null, "Unclassified") + Arguments.of(givenDigitalSpecimen("FossilSpecimen", null), + OdsTopicDiscipline.PALAEONTOLOGY), + Arguments.of(givenDigitalSpecimen("MeteoriteSpecimen", null), + OdsTopicDiscipline.ASTROGEOLOGY), + Arguments.of(givenDigitalSpecimen("RockSpecimen", null), + OdsTopicDiscipline.GEOLOGY), + Arguments.of(givenDigitalSpecimen("PreservedSpecimen", "Animalia"), + OdsTopicDiscipline.ZOOLOGY), + Arguments.of(givenDigitalSpecimen("PreservedSpecimen", "Plantae"), + OdsTopicDiscipline.BOTANY), + Arguments.of(givenDigitalSpecimen("PreservedSpecimen", "Bacteria"), + OdsTopicDiscipline.MICROBIOLOGY), + Arguments.of(givenDigitalSpecimen("PreservedSpecimen", "incertae sedis"), + OdsTopicDiscipline.UNCLASSIFIED), + Arguments.of(givenDigitalSpecimen("Other", null), OdsTopicDiscipline.UNCLASSIFIED) ); } + private static Object givenDigitalSpecimen(String basisOfRecord, String kingdom) { + return new DigitalSpecimen() + .withDwcBasisOfRecord(basisOfRecord) + .withDwcIdentification(List.of( + new eu.dissco.core.translator.schema.Identifications() + .withDwcIdentificationVerificationStatus(false) + .withTaxonIdentifications( + List.of(new TaxonIdentification().withDwcKingdom("Unicorn Kingdom"))), + new eu.dissco.core.translator.schema.Identifications() + .withDwcIdentificationVerificationStatus(true) + .withTaxonIdentifications( + List.of(new TaxonIdentification().withDwcKingdom(kingdom))) + ) + ); + } + @ParameterizedTest @MethodSource("arguments") - void testRetrieveFromABCD(String basisOfRecord, String kingdom, String expected) { - // Given - var unit = MAPPER.createObjectNode(); - unit.put("abcd:recordBasis", basisOfRecord); - unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonRank", - "regnum"); - unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonName", - kingdom); + void testRetrieveFromDWCA(eu.dissco.core.translator.schema.DigitalSpecimen ds, + OdsTopicDiscipline expected) { // When - var result = topicDiscipline.retrieveFromABCD(unit); + var result = topicDiscipline.calculate(ds); // Then assertThat(result).isEqualTo(expected); diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/TopicDomainTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/TopicDomainTest.java new file mode 100644 index 0000000..4ec2675 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/TopicDomainTest.java @@ -0,0 +1,54 @@ +package eu.dissco.core.translator.terms.specimen; + +import static org.assertj.core.api.Assertions.assertThat; + +import eu.dissco.core.translator.schema.DigitalSpecimen.OdsTopicDomain; +import java.util.stream.Stream; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class TopicDomainTest { + + private final TopicDomain topicDomain = new TopicDomain(); + + private static Stream arguments() { + return Stream.of( + Arguments.of(givenDigitalSpecimen("FossilSpecimen"), OdsTopicDomain.LIFE), + Arguments.of(givenDigitalSpecimen("MeteoriteSpecimen"), OdsTopicDomain.EXTRATERRESTRIAL), + Arguments.of(givenDigitalSpecimen("RockSpecimen"), OdsTopicDomain.EARTH_SYSTEM), + Arguments.of(givenDigitalSpecimen("PreservedSpecimen"), OdsTopicDomain.LIFE), + Arguments.of(givenDigitalSpecimen("Other"), OdsTopicDomain.UNCLASSIFIED) + ); + } + + private static Object givenDigitalSpecimen(String basisOfRecord) { + return new eu.dissco.core.translator.schema.DigitalSpecimen() + .withDwcBasisOfRecord(basisOfRecord); + } + + @ParameterizedTest + @MethodSource("arguments") + void testRetrieveFromDWCA(eu.dissco.core.translator.schema.DigitalSpecimen ds, + OdsTopicDomain expected) { + + // When + var result = topicDomain.calculate(ds); + + // Then + assertThat(result).isEqualTo(expected); + } + + @Test + void testGetTerm() { + // When + var result = topicDomain.getTerm(); + + // Then + assertThat(result).isEqualTo(TopicDomain.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/TopicOriginTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/TopicOriginTest.java new file mode 100644 index 0000000..3220cb3 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/TopicOriginTest.java @@ -0,0 +1,36 @@ +package eu.dissco.core.translator.terms.specimen; + +import static org.assertj.core.api.Assertions.assertThat; + +import eu.dissco.core.translator.schema.DigitalSpecimen.OdsTopicOrigin; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class TopicOriginTest { + + private static final OdsTopicOrigin TOPIC_ORIGIN_STRING = OdsTopicOrigin.NATURAL; + private final TopicOrigin topicOrigin = new TopicOrigin(); + + @Test + void testRetrieveFromDWCA() { + // Given + var ds = new eu.dissco.core.translator.schema.DigitalSpecimen(); + + // When + var result = topicOrigin.calculate(ds); + + // Then + assertThat(result).isEqualTo(TOPIC_ORIGIN_STRING); + } + + @Test + void testGetTerm() { + // When + var result = topicOrigin.getTerm(); + + // Then + assertThat(result).isEqualTo(TopicOrigin.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/citation/BilbiographicCitationTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/citation/BilbiographicCitationTest.java new file mode 100644 index 0000000..36f3e8c --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/citation/BilbiographicCitationTest.java @@ -0,0 +1,52 @@ +package eu.dissco.core.translator.terms.specimen.citation; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class BilbiographicCitationTest { + + private final BibliographicCitation bibliographicCitation = new BibliographicCitation(); + + @Test + void testRetrieveFromDWCA() { + // Given + var bibliographicCitationString = "A new bibliographic citation"; + var unit = MAPPER.createObjectNode(); + unit.put("dcterms:bibliographicCitation", bibliographicCitationString); + + // When + var result = bibliographicCitation.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(bibliographicCitationString); + } + + @Test + void testRetrieveFromABCD() { + // Given + var bibliographicCitationString = "A new bibliographic citation"; + var unit = MAPPER.createObjectNode(); + unit.put("titleCitation", bibliographicCitationString); + + // When + var result = bibliographicCitation.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(bibliographicCitationString); + } + + @Test + void testGetTerm() { + // When + var result = bibliographicCitation.getTerm(); + + // Then + assertThat(result).isEqualTo(BibliographicCitation.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/citation/CitationRemarksTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/citation/CitationRemarksTest.java new file mode 100644 index 0000000..d77bf86 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/citation/CitationRemarksTest.java @@ -0,0 +1,52 @@ +package eu.dissco.core.translator.terms.specimen.citation; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class CitationRemarksTest { + + private final CitationRemarks citationRemarks = new CitationRemarks(); + + @Test + void testRetrieveFromDWCA() { + // Given + var citationRemarksString = "A new citation remark"; + var unit = MAPPER.createObjectNode(); + unit.put("dwc:taxonRemarks", citationRemarksString); + + // When + var result = citationRemarks.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(citationRemarksString); + } + + @Test + void testRetrieveFromABCD() { + // Given + var citationRemarksString = "A new citation remark"; + var unit = MAPPER.createObjectNode(); + unit.put("citationDetail", citationRemarksString); + + // When + var result = citationRemarks.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(citationRemarksString); + } + + @Test + void testGetTerm() { + // When + var result = citationRemarks.getTerm(); + + // Then + assertThat(result).isEqualTo(CitationRemarks.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/citation/CreatorTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/citation/CreatorTest.java new file mode 100644 index 0000000..9bb7a63 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/citation/CreatorTest.java @@ -0,0 +1,38 @@ +package eu.dissco.core.translator.terms.specimen.citation; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class CreatorTest { + + private final Creator creator = new Creator(); + + @Test + void testRetrieveFromDWCA() { + // Given + var creatorString = "S. Leeflang"; + var unit = MAPPER.createObjectNode(); + unit.put("dcterms:creator", creatorString); + + // When + var result = creator.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(creatorString); + } + + @Test + void testGetTerm() { + // When + var result = creator.getTerm(); + + // Then + assertThat(result).isEqualTo(Creator.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/citation/DateTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/citation/DateTest.java new file mode 100644 index 0000000..58b0db5 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/citation/DateTest.java @@ -0,0 +1,38 @@ +package eu.dissco.core.translator.terms.specimen.citation; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static eu.dissco.core.translator.TestUtils.MOCK_DATE; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class DateTest { + + private final Date date = new Date(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dcterms:date", MOCK_DATE); + + // When + var result = date.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(MOCK_DATE); + } + + @Test + void testGetTerm() { + // When + var result = date.getTerm(); + + // Then + assertThat(result).isEqualTo(Date.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/citation/ReferenceIriTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/citation/ReferenceIriTest.java new file mode 100644 index 0000000..9c16ee0 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/citation/ReferenceIriTest.java @@ -0,0 +1,38 @@ +package eu.dissco.core.translator.terms.specimen.citation; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class ReferenceIriTest { + + private final ReferenceIri referenceIri = new ReferenceIri(); + + @Test + void testRetrieveFromABCD() { + // Given + var referenceIriString = "https://iri-to-reference.com"; + var unit = MAPPER.createObjectNode(); + unit.put("uri", referenceIriString); + + // When + var result = referenceIri.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(referenceIriString); + } + + @Test + void testGetTerm() { + // When + var result = referenceIri.getTerm(); + + // Then + assertThat(result).isEqualTo(ReferenceIri.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/citation/TitleTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/citation/TitleTest.java new file mode 100644 index 0000000..fdd0e3b --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/citation/TitleTest.java @@ -0,0 +1,38 @@ +package eu.dissco.core.translator.terms.specimen.citation; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class TitleTest { + + private final Title title = new Title(); + + @Test + void testRetrieveFromDWCA() { + // Given + var titleString = "A good title"; + var unit = MAPPER.createObjectNode(); + unit.put("dcterms:title", titleString); + + // When + var result = title.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(titleString); + } + + @Test + void testGetTerm() { + // When + var result = title.getTerm(); + + // Then + assertThat(result).isEqualTo(Title.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/TypeTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/citation/TypeTest.java similarity index 51% rename from src/test/java/eu/dissco/core/translator/terms/specimen/TypeTest.java rename to src/test/java/eu/dissco/core/translator/terms/specimen/citation/TypeTest.java index fe27a6f..b7a11c1 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/TypeTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/citation/TypeTest.java @@ -1,5 +1,6 @@ -package eu.dissco.core.translator.terms.specimen; +package eu.dissco.core.translator.terms.specimen.citation; +import static eu.dissco.core.translator.TestUtils.MAPPER; import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Test; @@ -11,6 +12,20 @@ class TypeTest { private final Type type = new Type(); + @Test + void testRetrieveFromDWCA() { + // Given + var typeString = "Publication"; + var unit = MAPPER.createObjectNode(); + unit.put("dcterms:type", typeString); + + // When + var result = type.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(typeString); + } + @Test void testGetTerm() { // When @@ -18,6 +33,6 @@ void testGetTerm() { // Then assertThat(result).isEqualTo(Type.TERM); - } + } diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/identification/DateIdentifiedTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/DateIdentifiedTest.java new file mode 100644 index 0000000..052a1b7 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/DateIdentifiedTest.java @@ -0,0 +1,51 @@ +package eu.dissco.core.translator.terms.specimen.identification; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static eu.dissco.core.translator.TestUtils.MOCK_DATE; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class DateIdentifiedTest { + + private final DateIdentified dateIdentified = new DateIdentified(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:dateIdentified", MOCK_DATE); + + // When + var result = dateIdentified.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(MOCK_DATE); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("date/dateText", MOCK_DATE); + + // When + var result = dateIdentified.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(MOCK_DATE); + } + + @Test + void testGetTerm() { + // When + var result = dateIdentified.getTerm(); + + // Then + assertThat(result).isEqualTo(DateIdentified.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/identification/IdentificationIdTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/IdentificationIdTest.java new file mode 100644 index 0000000..3a1f0f4 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/IdentificationIdTest.java @@ -0,0 +1,38 @@ +package eu.dissco.core.translator.terms.specimen.identification; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class IdentificationIdTest { + + private final IdentificationId identificationId = new IdentificationId(); + + @Test + void testRetrieveFromDWCA() { + // Given + var identificationIdString = "NBC-31249"; + var unit = MAPPER.createObjectNode(); + unit.put("dwc:identificationID", identificationIdString); + + // When + var result = identificationId.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(identificationIdString); + } + + @Test + void testGetTerm() { + // When + var result = identificationId.getTerm(); + + // Then + assertThat(result).isEqualTo(IdentificationId.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/identification/IdentificationRemarksTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/IdentificationRemarksTest.java new file mode 100644 index 0000000..bd4921c --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/IdentificationRemarksTest.java @@ -0,0 +1,52 @@ +package eu.dissco.core.translator.terms.specimen.identification; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class IdentificationRemarksTest { + + private final IdentificationRemarks identificationRemarks = new IdentificationRemarks(); + + @Test + void testRetrieveFromDWCA() { + // Given + var identificationRemarkString = "A remark about the identification"; + var unit = MAPPER.createObjectNode(); + unit.put("dwc:identificationRemarks", identificationRemarkString); + + // When + var result = identificationRemarks.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(identificationRemarkString); + } + + @Test + void testRetrieveFromABCD() { + // Given + var identificationRemarkString = "A remark about the identification"; + var unit = MAPPER.createObjectNode(); + unit.put("notes/value", identificationRemarkString); + + // When + var result = identificationRemarks.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(identificationRemarkString); + } + + @Test + void testGetTerm() { + // When + var result = identificationRemarks.getTerm(); + + // Then + assertThat(result).isEqualTo(IdentificationRemarks.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/identification/IdentificationVerificationStatusTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/IdentificationVerificationStatusTest.java new file mode 100644 index 0000000..efa6494 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/IdentificationVerificationStatusTest.java @@ -0,0 +1,68 @@ +package eu.dissco.core.translator.terms.specimen.identification; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class IdentificationVerificationStatusTest { + + private final IdentificationVerificationStatus identificationVerificationStatus = new IdentificationVerificationStatus(); + + @Test + void testRetrieveFromDWCA() { + // Given + var identificationVerificationStatusString = "1"; + var unit = MAPPER.createObjectNode(); + unit.put("dwc:identificationVerificationStatus", identificationVerificationStatusString); + + // When + var result = identificationVerificationStatus.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo("true"); + } + + @ParameterizedTest + @ValueSource(strings = {"0", "some other value"}) + void testRetrieveFromDWCAFalse(String identificationVerificationStatusString) { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:identificationVerificationStatus", identificationVerificationStatusString); + + // When + var result = identificationVerificationStatus.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo("false"); + } + + @Test + void testRetrieveFromABCD() { + // Given + var identificationVerificationStatusString = "true"; + var unit = MAPPER.createObjectNode(); + unit.put("preferredFlag", identificationVerificationStatusString); + + // When + var result = identificationVerificationStatus.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(identificationVerificationStatusString); + } + + @Test + void testGetTerm() { + // When + var result = identificationVerificationStatus.getTerm(); + + // Then + assertThat(result).isEqualTo(IdentificationVerificationStatus.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/identification/IdentifiedByTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/IdentifiedByTest.java new file mode 100644 index 0000000..563ac20 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/IdentifiedByTest.java @@ -0,0 +1,52 @@ +package eu.dissco.core.translator.terms.specimen.identification; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class IdentifiedByTest { + + private final IdentifiedBy identifiedBy = new IdentifiedBy(); + + @Test + void testRetrieveFromDWCA() { + // Given + var identifiedByString = "Sam Leeflang"; + var unit = MAPPER.createObjectNode(); + unit.put("dwc:identifiedBy", identifiedByString); + + // When + var result = identifiedBy.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(identifiedByString); + } + + @Test + void testRetrieveFromABCD() { + // Given + var identifiedByString = "Sam Leeflang"; + var unit = MAPPER.createObjectNode(); + unit.put("identifiers/identifier/0/personName/fullName", identifiedByString); + + // When + var result = identifiedBy.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(identifiedByString); + } + + @Test + void testGetTerm() { + // When + var result = identifiedBy.getTerm(); + + // Then + assertThat(result).isEqualTo(IdentifiedBy.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/identification/TypeStatusTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/TypeStatusTest.java new file mode 100644 index 0000000..5498923 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/TypeStatusTest.java @@ -0,0 +1,38 @@ +package eu.dissco.core.translator.terms.specimen.identification; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class TypeStatusTest { + + private final TypeStatus typeStatus = new TypeStatus(); + + @Test + void testRetrieveFromDWCA() { + // Given + var typeStatusString = "holotype"; + var unit = MAPPER.createObjectNode(); + unit.put("dwc:typeStatus", typeStatusString); + + // When + var result = typeStatus.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(typeStatusString); + } + + @Test + void testGetTerm() { + // When + var result = typeStatus.getTerm(); + + // Then + assertThat(result).isEqualTo(TypeStatus.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/identification/VerbatimIdentificationTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/VerbatimIdentificationTest.java new file mode 100644 index 0000000..97525b3 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/VerbatimIdentificationTest.java @@ -0,0 +1,38 @@ +package eu.dissco.core.translator.terms.specimen.identification; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class VerbatimIdentificationTest { + + private final VerbatimIdentification verbatimIdentification = new VerbatimIdentification(); + + @Test + void testRetrieveFromDWCA() { + // Given + var verbatimIdentificationString = "A verbatim identification"; + var unit = MAPPER.createObjectNode(); + unit.put("dwc:verbatimIdentification", verbatimIdentificationString); + + // When + var result = verbatimIdentification.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(verbatimIdentificationString); + } + + @Test + void testGetTerm() { + // When + var result = verbatimIdentification.getTerm(); + + // Then + assertThat(result).isEqualTo(VerbatimIdentification.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/ClassTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/ClassTest.java new file mode 100644 index 0000000..707768f --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/ClassTest.java @@ -0,0 +1,53 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class ClassTest { + + private final Class classTax = new Class(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:class", "Mammalia"); + + // When + var result = classTax.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo("Mammalia"); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + + unit.put( + "result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonRank", "classis"); + unit.put( + "result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonName", "Mammalia"); + + // When + var result = classTax.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo("Mammalia"); + } + + @Test + void testGetTerm() { + // When + var result = classTax.getTerm(); + + // Then + assertThat(result).isEqualTo(Class.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/FamilyTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/FamilyTest.java similarity index 68% rename from src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/FamilyTest.java rename to src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/FamilyTest.java index d36da44..0f0335d 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/FamilyTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/FamilyTest.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; import static eu.dissco.core.translator.TestUtils.MAPPER; import static org.assertj.core.api.Assertions.assertThat; @@ -28,17 +28,11 @@ void testRetrieveFromDWCA() { @Test void testRetrieveFromDWCAExtensionNoVerified() { // Given - var unit = MAPPER.createObjectNode(); - var extension = MAPPER.createObjectNode(); var identification = MAPPER.createObjectNode(); identification.put("dwc:family", "Soricidae"); - var identifications = MAPPER.createArrayNode(); - identifications.add(identification); - extension.set("dwc:Identification", identifications); - unit.set("extensions", extension); // When - var result = family.retrieveFromDWCA(unit); + var result = family.retrieveFromDWCA(identification); // Then assertThat(result).isEqualTo("Soricidae"); @@ -49,10 +43,10 @@ void testRetrieveFromABCD() { // Given var unit = MAPPER.createObjectNode(); unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonRank", + "result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonRank", "familia"); unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonName", + "result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonName", "BIGNONIACEAE"); // When diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/GenusTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/GenusTest.java new file mode 100644 index 0000000..bba82c8 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/GenusTest.java @@ -0,0 +1,64 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class GenusTest { + + private final Genus genus = new Genus(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:genus", "Rhinopoma"); + + // When + var result = genus.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo("Rhinopoma"); + } + + @Test + void testRetrieveFromDWCAExtensionNoVerified() { + // Given + var identificationVerified = MAPPER.createObjectNode(); + identificationVerified.put("dwc:genus", "Rhinopoma"); + + // When + var result = genus.retrieveFromDWCA(identificationVerified); + + // Then + assertThat(result).isEqualTo("Rhinopoma"); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put( + "result/taxonIdentified/scientificName/nameAtomised/botanical/genusOrMonomial", + "Arrabidaea"); + + // When + var result = genus.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo("Arrabidaea"); + } + + @Test + void testGetTerm() { + // When + var result = genus.getTerm(); + + // Then + assertThat(result).isEqualTo(Genus.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/InfraSpecificEpithetTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/InfraSpecificEpithetTest.java similarity index 70% rename from src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/InfraSpecificEpithetTest.java rename to src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/InfraSpecificEpithetTest.java index e2ce97c..b8544a6 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/InfraSpecificEpithetTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/InfraSpecificEpithetTest.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; import static eu.dissco.core.translator.TestUtils.MAPPER; import static org.assertj.core.api.Assertions.assertThat; @@ -30,13 +30,8 @@ void testRetrieveFromABCD() { // Given var unit = MAPPER.createObjectNode(); unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/nameAtomised/botanical/genusOrMonomial", - "Fridericia Mart."); - unit.put("abcd:identifications/identification/0/preferredFlag", false); - unit.put( - "abcd:identifications/identification/1/result/taxonIdentified/nameAtomised/botanical/infraspecificEpithet", + "result/taxonIdentified/scientificName/nameAtomised/botanical/infraspecificEpithet", "thyrsoidea"); - unit.put("abcd:identifications/identification/1/preferredFlag", true); // When var result = infraSpecificEpithet.retrieveFromABCD(unit); diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/KingdomTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/KingdomTest.java similarity index 75% rename from src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/KingdomTest.java rename to src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/KingdomTest.java index 4fcbca0..a5bc5b2 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/KingdomTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/KingdomTest.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; import static eu.dissco.core.translator.TestUtils.MAPPER; import static org.assertj.core.api.Assertions.assertThat; @@ -30,11 +30,9 @@ void testRetrieveFromABCD() { // Given var unit = MAPPER.createObjectNode(); unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonRank", - "regnum"); + "result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonRank", "regnum"); unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonName", - "Plantae"); + "result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonName", "Plantae"); // When var result = kingdom.retrieveFromABCD(unit); diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/NameAccordingToTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/NameAccordingToTest.java new file mode 100644 index 0000000..6afaa2c --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/NameAccordingToTest.java @@ -0,0 +1,36 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class NameAccordingToTest { + + private final NameAccordingTo nameAccordingTo = new NameAccordingTo(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:nameAccordingTo", "COL"); + + // When + var result = nameAccordingTo.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo("COL"); + } + + @Test + void testGetTerm() { + // When + var result = nameAccordingTo.getTerm(); + + // Then + assertThat(result).isEqualTo(NameAccordingTo.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/NamePublishedInYearTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/NamePublishedInYearTest.java new file mode 100644 index 0000000..a09f592 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/NamePublishedInYearTest.java @@ -0,0 +1,37 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class NamePublishedInYearTest { + + private final NamePublishedInYear namePublishedInYear = new NamePublishedInYear(); + + @Test + void testRetrieveFromDWCA() { + // Given + var namePublishedInYearString = "2023"; + var unit = MAPPER.createObjectNode(); + unit.put("dwc:namePublishedInYear", namePublishedInYearString); + + // When + var result = namePublishedInYear.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(namePublishedInYearString); + } + + @Test + void testGetTerm() { + // When + var result = namePublishedInYear.getTerm(); + + // Then + assertThat(result).isEqualTo(NamePublishedInYear.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/NomenclaturalCodeTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/NomenclaturalCodeTest.java new file mode 100644 index 0000000..83a393f --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/NomenclaturalCodeTest.java @@ -0,0 +1,51 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class NomenclaturalCodeTest { + + private final NomenclaturalCode nomenclaturalCode = new NomenclaturalCode(); + + @Test + void testRetrieveFromDWCA() { + // Given + var nomenclaturalCodeString = "A nomenclatural code"; + var unit = MAPPER.createObjectNode(); + unit.put("dwc:nomenclaturalCode", nomenclaturalCodeString); + + // When + var result = nomenclaturalCode.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(nomenclaturalCodeString); + } + + @Test + void testRetrieveFromABCD() { + // Given + var nomenclaturalCodeString = "A nomenclatural code"; + var unit = MAPPER.createObjectNode(); + unit.put("result/taxonIdentified/code", nomenclaturalCodeString); + + // When + var result = nomenclaturalCode.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(nomenclaturalCodeString); + } + + @Test + void testGetTerm() { + // When + var result = nomenclaturalCode.getTerm(); + + // Then + assertThat(result).isEqualTo(NomenclaturalCode.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/OrderTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/OrderTest.java similarity index 78% rename from src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/OrderTest.java rename to src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/OrderTest.java index e98961d..33181f3 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/OrderTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/OrderTest.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; import static eu.dissco.core.translator.TestUtils.MAPPER; import static org.assertj.core.api.Assertions.assertThat; @@ -30,10 +30,10 @@ void testRetrieveFromABCD() { // Given var unit = MAPPER.createObjectNode(); unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonRank", + "result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonRank", "ordo"); unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonName", + "result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonName", "Soricomorpha"); // When diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/PhylumTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/PhylumTest.java similarity index 78% rename from src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/PhylumTest.java rename to src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/PhylumTest.java index 7e275f5..9c80b12 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/PhylumTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/PhylumTest.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; import static eu.dissco.core.translator.TestUtils.MAPPER; import static org.assertj.core.api.Assertions.assertThat; @@ -30,10 +30,10 @@ void testRetrieveFromABCD() { // Given var unit = MAPPER.createObjectNode(); unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonRank", + "result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonRank", "phylum"); unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonName", + "result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonName", "Chordata"); // When diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/ScientificNameAuthorshipTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/ScientificNameAuthorshipTest.java similarity index 68% rename from src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/ScientificNameAuthorshipTest.java rename to src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/ScientificNameAuthorshipTest.java index aa75cc2..3b1415e 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/ScientificNameAuthorshipTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/ScientificNameAuthorshipTest.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; import static eu.dissco.core.translator.TestUtils.MAPPER; import static org.assertj.core.api.Assertions.assertThat; @@ -30,15 +30,8 @@ void testRetrieveFromABCD() { // Given var unit = MAPPER.createObjectNode(); unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonRank", - "classis"); - unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonName", - "Eurotatoria"); - unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/nameAtomised/botanical/authorTeam", + "result/taxonIdentified/scientificName/nameAtomised/botanical/authorTeam", "Cham. & Schltdl."); - unit.put("abcd:identifications/identification/0/preferredFlag", true); // When var result = authorship.retrieveFromABCD(unit); diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/ScientificNameTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/ScientificNameTest.java new file mode 100644 index 0000000..34b94c8 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/ScientificNameTest.java @@ -0,0 +1,98 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class ScientificNameTest { + + private final ScientificName scientificname = new ScientificName(); + + @Test + void testRetrieveFromDWCA() { + // Given + var scientificNameString = "SpecimenName"; + var unit = MAPPER.createObjectNode(); + unit.put("dwc:scientificName", scientificNameString); + + // When + var result = scientificname.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(scientificNameString); + } + + @Test + void testRetrieveFromDWCAExtension() { + // Given + var identificationVerified = MAPPER.createObjectNode(); + identificationVerified.put("dwc:scientificName", "SpecimenNameVerified"); + + // When + var result = scientificname.retrieveFromDWCA(identificationVerified); + + // Then + assertThat(result).isEqualTo("SpecimenNameVerified"); + } + + @Test + void testRetrieveFromABCDEFG() { + // Given + var scientificNameString = "SpecimenName"; + var unit = MAPPER.createObjectNode(); + unit.put( + "result/mineralRockIdentified/classifiedName/fullScientificNameString", + scientificNameString); + + // When + var result = scientificname.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(scientificNameString); + } + + @Test + void testRetrieveFromABCDWithPreferred() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put( + "result/taxonIdentified/scientificName/fullScientificNameString", + "Bignonia chica Humb. & Bonpl."); + unit.put( + "result/mineralRockIdentified/classifiedName/fullScientificNameString", + "Another specimen name"); + + // When + var result = scientificname.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo("Bignonia chica Humb. & Bonpl."); + } + + @Test + void testRetrieveFromABCDNotPresent() { + // Given + var unit = MAPPER.createObjectNode(); + + // When + var result = scientificname.retrieveFromABCD(unit); + + // Then + assertThat(result).isNull(); + } + + + @Test + void testGetTerm() { + // When + var result = scientificname.getTerm(); + + // Then + assertThat(result).isEqualTo(ScientificName.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/SpecificEpithetTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/SpecificEpithetTest.java similarity index 65% rename from src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/SpecificEpithetTest.java rename to src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/SpecificEpithetTest.java index 7e41e51..5896f43 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/SpecificEpithetTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/SpecificEpithetTest.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; import static eu.dissco.core.translator.TestUtils.MAPPER; import static org.assertj.core.api.Assertions.assertThat; @@ -30,15 +30,7 @@ void testRetrieveFromABCD() { // Given var unit = MAPPER.createObjectNode(); unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonRank", - "classis"); - unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonName", - "Eurotatoria"); - unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/nameAtomised/botanical/firstEpithet", - "bogotensis"); - unit.put("abcd:identifications/identification/0/preferredFlag", true); + "result/taxonIdentified/scientificName/nameAtomised/botanical/firstEpithet", "bogotensis"); // When var result = specificEpithet.retrieveFromABCD(unit); diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/SubgenusTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/SubgenusTest.java new file mode 100644 index 0000000..6283ebd --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/SubgenusTest.java @@ -0,0 +1,52 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class SubgenusTest { + + private final Subgenus subgenus = new Subgenus(); + + @Test + void testRetrieveFromDWCA() { + // Given + var subgenusString = "A new subgenus"; + var unit = MAPPER.createObjectNode(); + unit.put("dwc:subgenus", subgenusString); + + // When + var result = subgenus.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(subgenusString); + } + + @Test + void testRetrieveFromABCD() { + // Given + var subgenusString = "A new subgenus"; + var unit = MAPPER.createObjectNode(); + unit.put("result/taxonIdentified/scientificName/nameAtomised/zoological/subgenus", + subgenusString); + + // When + var result = subgenus.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(subgenusString); + } + + @Test + void testGetTerm() { + // When + var result = subgenus.getTerm(); + + // Then + assertThat(result).isEqualTo(Subgenus.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonIdTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonIdTest.java new file mode 100644 index 0000000..21b5ece --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonIdTest.java @@ -0,0 +1,37 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class TaxonIdTest { + + private final TaxonId taxonId = new TaxonId(); + + @Test + void testRetrieveFromDWCA() { + // Given + var taxonIdString = "UDS:283845"; + var unit = MAPPER.createObjectNode(); + unit.put("dwc:taxonID", taxonIdString); + + // When + var result = taxonId.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(taxonIdString); + } + + @Test + void testGetTerm() { + // When + var result = taxonId.getTerm(); + + // Then + assertThat(result).isEqualTo(TaxonId.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/TaxonRankTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonRankTest.java similarity index 93% rename from src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/TaxonRankTest.java rename to src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonRankTest.java index 70f99d5..7b9b2ae 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/TaxonRankTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonRankTest.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; import static eu.dissco.core.translator.TestUtils.MAPPER; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonomicRemarkTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonomicRemarkTest.java new file mode 100644 index 0000000..77100a9 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonomicRemarkTest.java @@ -0,0 +1,37 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class TaxonomicRemarkTest { + + private final TaxonRemarks taxonRemarks = new TaxonRemarks(); + + @Test + void testRetrieveFromDWCA() { + // Given + var taxonRemarksString = "An interesting remark about a taxon"; + var unit = MAPPER.createObjectNode(); + unit.put("dwc:taxonRemarks", taxonRemarksString); + + // When + var result = taxonRemarks.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(taxonRemarksString); + } + + @Test + void testGetTerm() { + // When + var result = taxonRemarks.getTerm(); + + // Then + assertThat(result).isEqualTo(TaxonRemarks.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonomicStatusTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonomicStatusTest.java new file mode 100644 index 0000000..c4f3138 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/TaxonomicStatusTest.java @@ -0,0 +1,37 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class TaxonomicStatusTest { + + private final TaxonomicStatus taxonomicStatus = new TaxonomicStatus(); + + @Test + void testRetrieveFromDWCA() { + // Given + var taxonomicStatusString = "accepted"; + var unit = MAPPER.createObjectNode(); + unit.put("dwc:taxonomicStatus", taxonomicStatusString); + + // When + var result = taxonomicStatus.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(taxonomicStatusString); + } + + @Test + void testGetTerm() { + // When + var result = taxonomicStatus.getTerm(); + + // Then + assertThat(result).isEqualTo(TaxonomicStatus.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/VernacularNameTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/VernacularNameTest.java new file mode 100644 index 0000000..4ea20c7 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/VernacularNameTest.java @@ -0,0 +1,37 @@ +package eu.dissco.core.translator.terms.specimen.identification.taxonomy; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class VernacularNameTest { + + private final VernacularName vernacularName = new VernacularName(); + + @Test + void testRetrieveFromDWCA() { + // Given + var vernacularNameString = "A vernacular name"; + var unit = MAPPER.createObjectNode(); + unit.put("dwc:vernacularName", vernacularNameString); + + // When + var result = vernacularName.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(vernacularNameString); + } + + @Test + void testGetTerm() { + // When + var result = vernacularName.getTerm(); + + // Then + assertThat(result).isEqualTo(VernacularName.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/ContinentTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/ContinentTest.java index e973300..725a4ca 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/location/ContinentTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/ContinentTest.java @@ -10,20 +10,35 @@ @ExtendWith(MockitoExtension.class) class ContinentTest { + private static final String CONTINENT_STRING = "Europe"; + private final Continent continent = new Continent(); @Test void testRetrieveFromDWCA() { // Given - var continentString = "Europe"; var unit = MAPPER.createObjectNode(); - unit.put("dwc:continent", continentString); + unit.put("dwc:continent", CONTINENT_STRING); // When var result = continent.retrieveFromDWCA(unit); // Then - assertThat(result).isEqualTo(continentString); + assertThat(result).isEqualTo(CONTINENT_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:gathering/namedAreas/namedArea/0/areaClass/value", "Continent"); + unit.put("abcd:gathering/namedAreas/namedArea/0/areaName/value", CONTINENT_STRING); + + // When + var result = continent.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(CONTINENT_STRING); } @Test diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/CountyTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/CountyTest.java index 6e745e2..56f78fb 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/location/CountyTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/CountyTest.java @@ -10,20 +10,34 @@ @ExtendWith(MockitoExtension.class) class CountyTest { + private static final String COUNTY_STRING = "Northumberland"; private final County county = new County(); @Test void testRetrieveFromDWCA() { // Given - var countyString = "Northumberland"; var unit = MAPPER.createObjectNode(); - unit.put("dwc:county", countyString); + unit.put("dwc:county", COUNTY_STRING); // When var result = county.retrieveFromDWCA(unit); // Then - assertThat(result).isEqualTo(countyString); + assertThat(result).isEqualTo(COUNTY_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:gathering/namedAreas/namedArea/0/areaClass/value", "County"); + unit.put("abcd:gathering/namedAreas/namedArea/0/areaName/value", COUNTY_STRING); + + // When + var result = county.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(COUNTY_STRING); } @Test diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/IslandGroupTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/IslandGroupTest.java index f61ce26..a6d6e78 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/location/IslandGroupTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/IslandGroupTest.java @@ -10,20 +10,34 @@ @ExtendWith(MockitoExtension.class) class IslandGroupTest { + private static final String ISLAND_GROUP_STRING = "Harrison Islands"; private final IslandGroup islandGroup = new IslandGroup(); @Test void testRetrieveFromDWCA() { // Given - var islandGroupString = "Harrison Islands"; var unit = MAPPER.createObjectNode(); - unit.put("dwc:islandGroup", islandGroupString); + unit.put("dwc:islandGroup", ISLAND_GROUP_STRING); // When var result = islandGroup.retrieveFromDWCA(unit); // Then - assertThat(result).isEqualTo(islandGroupString); + assertThat(result).isEqualTo(ISLAND_GROUP_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:gathering/namedAreas/namedArea/0/areaClass/value", "Island group"); + unit.put("abcd:gathering/namedAreas/namedArea/0/areaName/value", ISLAND_GROUP_STRING); + + // When + var result = islandGroup.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(ISLAND_GROUP_STRING); } @Test diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/IslandTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/IslandTest.java index 3b51085..b1327a8 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/location/IslandTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/IslandTest.java @@ -10,20 +10,34 @@ @ExtendWith(MockitoExtension.class) class IslandTest { + private static final String ISLAND_STRING = "Texel"; private final Island island = new Island(); @Test void testRetrieveFromDWCA() { // Given - var islandString = "Texel"; var unit = MAPPER.createObjectNode(); - unit.put("dwc:island", islandString); + unit.put("dwc:island", ISLAND_STRING); // When var result = island.retrieveFromDWCA(unit); // Then - assertThat(result).isEqualTo(islandString); + assertThat(result).isEqualTo(ISLAND_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:gathering/namedAreas/namedArea/0/areaClass/value", "Island"); + unit.put("abcd:gathering/namedAreas/namedArea/0/areaName/value", ISLAND_STRING); + + // When + var result = island.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(ISLAND_STRING); } @Test diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/LocationAccordingToTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/LocationAccordingToTest.java new file mode 100644 index 0000000..fa8a205 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/LocationAccordingToTest.java @@ -0,0 +1,38 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class LocationAccordingToTest { + + private static final String LOCATION_ACCORDING_TO_STRING = "Sam Leeflang"; + private final LocationAccordingTo locationAccordingTo = new LocationAccordingTo(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:locationAccordingTo", LOCATION_ACCORDING_TO_STRING); + + // When + var result = locationAccordingTo.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(LOCATION_ACCORDING_TO_STRING); + } + + + @Test + void testGetTerm() { + // When + var result = locationAccordingTo.getTerm(); + + // Then + assertThat(result).isEqualTo(LocationAccordingTo.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/LocationRemarksTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/LocationRemarksTest.java new file mode 100644 index 0000000..16e16c8 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/LocationRemarksTest.java @@ -0,0 +1,51 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class LocationRemarksTest { + + private static final String LOCATION_REMARKS_STRING = "Remarks about the location"; + private final LocationRemarks locationRemarks = new LocationRemarks(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:locationRemarks", LOCATION_REMARKS_STRING); + + // When + var result = locationRemarks.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(LOCATION_REMARKS_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:gathering/areaDetail/value", + LOCATION_REMARKS_STRING); + + // When + var result = locationRemarks.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(LOCATION_REMARKS_STRING); + } + + @Test + void testGetTerm() { + // When + var result = locationRemarks.getTerm(); + + // Then + assertThat(result).isEqualTo(LocationRemarks.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/MaximumDepthInMetersTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/MaximumDepthInMetersTest.java new file mode 100644 index 0000000..8e46381 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/MaximumDepthInMetersTest.java @@ -0,0 +1,51 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class MaximumDepthInMetersTest { + + private static final String MAXIMUM_DEPTH_IN_METERS_STRING = "-350"; + private final MaximumDepthInMeters maximumDepthInMeters = new MaximumDepthInMeters(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:maximumDepthInMeters", MAXIMUM_DEPTH_IN_METERS_STRING); + + // When + var result = maximumDepthInMeters.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(MAXIMUM_DEPTH_IN_METERS_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:gathering/depth/measurementOrFactAtomised/upperValue/value", + MAXIMUM_DEPTH_IN_METERS_STRING); + + // When + var result = maximumDepthInMeters.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(MAXIMUM_DEPTH_IN_METERS_STRING); + } + + @Test + void testGetTerm() { + // When + var result = maximumDepthInMeters.getTerm(); + + // Then + assertThat(result).isEqualTo(MaximumDepthInMeters.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/MaximumDistanceAboveSurfaceInMetersTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/MaximumDistanceAboveSurfaceInMetersTest.java new file mode 100644 index 0000000..1ba68df --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/MaximumDistanceAboveSurfaceInMetersTest.java @@ -0,0 +1,52 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class MaximumDistanceAboveSurfaceInMetersTest { + + private static final String MAXIMUM_DISTANCE_ABOVE_SURFACE_IN_METERS_STRING = "350"; + private final MaximumDistanceAboveSurfaceInMeters maximumDistanceAboveSurfaceInMeters = new MaximumDistanceAboveSurfaceInMeters(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:maximumDistanceAboveSurfaceInMeters", + MAXIMUM_DISTANCE_ABOVE_SURFACE_IN_METERS_STRING); + + // When + var result = maximumDistanceAboveSurfaceInMeters.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(MAXIMUM_DISTANCE_ABOVE_SURFACE_IN_METERS_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:gathering/height/measurementOrFactAtomised/upperValue/value", + MAXIMUM_DISTANCE_ABOVE_SURFACE_IN_METERS_STRING); + + // When + var result = maximumDistanceAboveSurfaceInMeters.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(MAXIMUM_DISTANCE_ABOVE_SURFACE_IN_METERS_STRING); + } + + @Test + void testGetTerm() { + // When + var result = maximumDistanceAboveSurfaceInMeters.getTerm(); + + // Then + assertThat(result).isEqualTo(MaximumDistanceAboveSurfaceInMeters.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/MaximumElevationInMetersTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/MaximumElevationInMetersTest.java new file mode 100644 index 0000000..4b0781a --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/MaximumElevationInMetersTest.java @@ -0,0 +1,51 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class MaximumElevationInMetersTest { + + private static final String MAXIMUM_ELEVATION_IN_METERS_STRING = "350"; + private final MaximumElevationInMeters maximumElevationInMeters = new MaximumElevationInMeters(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:maximumElevationInMeters", MAXIMUM_ELEVATION_IN_METERS_STRING); + + // When + var result = maximumElevationInMeters.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(MAXIMUM_ELEVATION_IN_METERS_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:gathering/altitude/measurementOrFactAtomised/upperValue/value", + MAXIMUM_ELEVATION_IN_METERS_STRING); + + // When + var result = maximumElevationInMeters.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(MAXIMUM_ELEVATION_IN_METERS_STRING); + } + + @Test + void testGetTerm() { + // When + var result = maximumElevationInMeters.getTerm(); + + // Then + assertThat(result).isEqualTo(MaximumElevationInMeters.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/MinimumDepthInMetersTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/MinimumDepthInMetersTest.java new file mode 100644 index 0000000..9e664c0 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/MinimumDepthInMetersTest.java @@ -0,0 +1,51 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class MinimumDepthInMetersTest { + + private static final String MINIMUM_DEPTH_IN_METERS_STRING = "-50"; + private final MinimumDepthInMeters minimumDepthInMeters = new MinimumDepthInMeters(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:minimumDepthInMeters", MINIMUM_DEPTH_IN_METERS_STRING); + + // When + var result = minimumDepthInMeters.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(MINIMUM_DEPTH_IN_METERS_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:gathering/depth/measurementOrFactAtomised/lowerValue/value", + MINIMUM_DEPTH_IN_METERS_STRING); + + // When + var result = minimumDepthInMeters.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(MINIMUM_DEPTH_IN_METERS_STRING); + } + + @Test + void testGetTerm() { + // When + var result = minimumDepthInMeters.getTerm(); + + // Then + assertThat(result).isEqualTo(MinimumDepthInMeters.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/MinimumDistanceAboveSurfaceInMetersTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/MinimumDistanceAboveSurfaceInMetersTest.java new file mode 100644 index 0000000..d4353e9 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/MinimumDistanceAboveSurfaceInMetersTest.java @@ -0,0 +1,52 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class MinimumDistanceAboveSurfaceInMetersTest { + + private static final String MINIMUM_DISTANCE_ABOVE_SURFACE_IN_METERS_STRING = "250"; + private final MinimumDistanceAboveSurfaceInMeters minimumDistanceAboveSurfaceInMeters = new MinimumDistanceAboveSurfaceInMeters(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:minimumDistanceAboveSurfaceInMeters", + MINIMUM_DISTANCE_ABOVE_SURFACE_IN_METERS_STRING); + + // When + var result = minimumDistanceAboveSurfaceInMeters.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(MINIMUM_DISTANCE_ABOVE_SURFACE_IN_METERS_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:gathering/height/measurementOrFactAtomised/lowerValue/value", + MINIMUM_DISTANCE_ABOVE_SURFACE_IN_METERS_STRING); + + // When + var result = minimumDistanceAboveSurfaceInMeters.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(MINIMUM_DISTANCE_ABOVE_SURFACE_IN_METERS_STRING); + } + + @Test + void testGetTerm() { + // When + var result = minimumDistanceAboveSurfaceInMeters.getTerm(); + + // Then + assertThat(result).isEqualTo(MinimumDistanceAboveSurfaceInMeters.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/MinimumElevationInMetersTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/MinimumElevationInMetersTest.java new file mode 100644 index 0000000..e587ff2 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/MinimumElevationInMetersTest.java @@ -0,0 +1,51 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class MinimumElevationInMetersTest { + + private static final String MINIMUM_ELEVATION_IN_METERS_STRING = "250"; + private final MinimumElevationInMeters minimumElevationInMeters = new MinimumElevationInMeters(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:minimumElevationInMeters", MINIMUM_ELEVATION_IN_METERS_STRING); + + // When + var result = minimumElevationInMeters.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(MINIMUM_ELEVATION_IN_METERS_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:gathering/altitude/measurementOrFactAtomised/lowerValue/value", + MINIMUM_ELEVATION_IN_METERS_STRING); + + // When + var result = minimumElevationInMeters.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(MINIMUM_ELEVATION_IN_METERS_STRING); + } + + @Test + void testGetTerm() { + // When + var result = minimumElevationInMeters.getTerm(); + + // Then + assertThat(result).isEqualTo(MinimumElevationInMeters.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/MunicipalityTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/MunicipalityTest.java index 47eab51..1390b84 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/location/MunicipalityTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/MunicipalityTest.java @@ -10,20 +10,34 @@ @ExtendWith(MockitoExtension.class) class MunicipalityTest { + private static final String MUNICIPALITY_STRING = "Gouda"; private final Municipality municipality = new Municipality(); @Test void testRetrieveFromDWCA() { // Given - var municipalityString = "Gouda"; var unit = MAPPER.createObjectNode(); - unit.put("dwc:municipality", municipalityString); + unit.put("dwc:municipality", MUNICIPALITY_STRING); // When var result = municipality.retrieveFromDWCA(unit); // Then - assertThat(result).isEqualTo(municipalityString); + assertThat(result).isEqualTo(MUNICIPALITY_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:gathering/namedAreas/namedArea/0/areaClass/value", "Municipality"); + unit.put("abcd:gathering/namedAreas/namedArea/0/areaName/value", MUNICIPALITY_STRING); + + // When + var result = municipality.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(MUNICIPALITY_STRING); } @Test diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/StateProvinceTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/StateProvinceTest.java index f92eaba..0a78fa8 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/location/StateProvinceTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/StateProvinceTest.java @@ -10,20 +10,34 @@ @ExtendWith(MockitoExtension.class) class StateProvinceTest { + private static final String STATE_PROVINCE_STRING = "Brittany"; private final StateProvince stateProvince = new StateProvince(); @Test void testRetrieveFromDWCA() { // Given - var stateProvinceString = "Brittany"; var unit = MAPPER.createObjectNode(); - unit.put("dwc:stateProvince", stateProvinceString); + unit.put("dwc:stateProvince", STATE_PROVINCE_STRING); // When var result = stateProvince.retrieveFromDWCA(unit); // Then - assertThat(result).isEqualTo(stateProvinceString); + assertThat(result).isEqualTo(STATE_PROVINCE_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:gathering/namedAreas/namedArea/0/areaClass/value", "Province"); + unit.put("abcd:gathering/namedAreas/namedArea/0/areaName/value", STATE_PROVINCE_STRING); + + // When + var result = stateProvince.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(STATE_PROVINCE_STRING); } @Test diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/VericalDatumTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/VericalDatumTest.java new file mode 100644 index 0000000..e97f490 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/VericalDatumTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.location; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class VericalDatumTest { + + private static final String VERTICAL_DATUM_STRING = "EGM84"; + + private final VerticalDatum verticalDatum = new VerticalDatum(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:verticalDatum", VERTICAL_DATUM_STRING); + + // When + var result = verticalDatum.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(VERTICAL_DATUM_STRING); + } + + @Test + void testGetTerm() { + // When + var result = verticalDatum.getTerm(); + + // Then + assertThat(result).isEqualTo(VerticalDatum.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/WaterBodyTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/WaterBodyTest.java index bec32be..4a1c553 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/location/WaterBodyTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/WaterBodyTest.java @@ -10,20 +10,35 @@ @ExtendWith(MockitoExtension.class) class WaterBodyTest { + private static final String WATER_BODY_STRING = "The Aegean Sea"; + private final WaterBody waterBody = new WaterBody(); @Test void testRetrieveFromDWCA() { // Given - var waterBodyString = "The Aegean Sea"; var unit = MAPPER.createObjectNode(); - unit.put("dwc:waterBody", waterBodyString); + unit.put("dwc:waterBody", WATER_BODY_STRING); // When var result = waterBody.retrieveFromDWCA(unit); // Then - assertThat(result).isEqualTo(waterBodyString); + assertThat(result).isEqualTo(WATER_BODY_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:gathering/namedAreas/namedArea/0/areaClass/value", "Water body"); + unit.put("abcd:gathering/namedAreas/namedArea/0/areaName/value", WATER_BODY_STRING); + + // When + var result = waterBody.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(WATER_BODY_STRING); } @Test diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/CoordinatePrecisionTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/CoordinatePrecisionTest.java new file mode 100644 index 0000000..59a20d9 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/CoordinatePrecisionTest.java @@ -0,0 +1,53 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class CoordinatePrecisionTest { + + private static final String COORDINATE_PRECISION_STRING = "0.10"; + + private final CoordinatePrecision coordinatePrecision = new CoordinatePrecision(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:coordinatePrecision", COORDINATE_PRECISION_STRING); + + // When + var result = coordinatePrecision.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(COORDINATE_PRECISION_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put( + "abcd:gathering/siteCoordinateSets/siteCoordinates/0/coordinatesLatLong/iSOAccuracy", + COORDINATE_PRECISION_STRING); + + // When + var result = coordinatePrecision.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(COORDINATE_PRECISION_STRING); + } + + @Test + void testGetTerm() { + // When + var result = coordinatePrecision.getTerm(); + + // Then + assertThat(result).isEqualTo(CoordinatePrecision.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/CoordinateUncertaintyInMetersTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/CoordinateUncertaintyInMetersTest.java new file mode 100644 index 0000000..ab9645d --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/CoordinateUncertaintyInMetersTest.java @@ -0,0 +1,53 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class CoordinateUncertaintyInMetersTest { + + private static final String COORDINATE_UNCERTAINTY_IN_METERS = "4.6050"; + + private final CoordinateUncertaintyInMeters coordinateUncertaintyInMeters = new CoordinateUncertaintyInMeters(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:coordinateUncertaintyInMeters", COORDINATE_UNCERTAINTY_IN_METERS); + + // When + var result = coordinateUncertaintyInMeters.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(COORDINATE_UNCERTAINTY_IN_METERS); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put( + "abcd:gathering/siteCoordinateSets/siteCoordinates/0/coordinatesLatLong/coordinateErrorDistanceInMeters", + COORDINATE_UNCERTAINTY_IN_METERS); + + // When + var result = coordinateUncertaintyInMeters.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(COORDINATE_UNCERTAINTY_IN_METERS); + } + + @Test + void testGetTerm() { + // When + var result = coordinateUncertaintyInMeters.getTerm(); + + // Then + assertThat(result).isEqualTo(CoordinateUncertaintyInMeters.TERM); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/DecimalLatitudeTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/DecimalLatitudeTest.java similarity index 94% rename from src/test/java/eu/dissco/core/translator/terms/specimen/location/DecimalLatitudeTest.java rename to src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/DecimalLatitudeTest.java index c77114e..bad7e95 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/location/DecimalLatitudeTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/DecimalLatitudeTest.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.location; +package eu.dissco.core.translator.terms.specimen.location.georeference; import static eu.dissco.core.translator.TestUtils.MAPPER; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/DecimalLongitudeTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/DecimalLongitudeTest.java similarity index 94% rename from src/test/java/eu/dissco/core/translator/terms/specimen/location/DecimalLongitudeTest.java rename to src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/DecimalLongitudeTest.java index 72150f5..914fe60 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/location/DecimalLongitudeTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/DecimalLongitudeTest.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.location; +package eu.dissco.core.translator.terms.specimen.location.georeference; import static eu.dissco.core.translator.TestUtils.MAPPER; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/FootprintSpatialFitTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/FootprintSpatialFitTest.java new file mode 100644 index 0000000..4e69c56 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/FootprintSpatialFitTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class FootprintSpatialFitTest { + + private static final String FOOTPRINT_SPATIAL_FIT_STRING = "1"; + + private final FootprintSpatialFit footprintSpatialFit = new FootprintSpatialFit(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:footprintSpatialFit", FOOTPRINT_SPATIAL_FIT_STRING); + + // When + var result = footprintSpatialFit.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(FOOTPRINT_SPATIAL_FIT_STRING); + } + + @Test + void testGetTerm() { + // When + var result = footprintSpatialFit.getTerm(); + + // Then + assertThat(result).isEqualTo(FootprintSpatialFit.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/FootprintSrsTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/FootprintSrsTest.java new file mode 100644 index 0000000..d377313 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/FootprintSrsTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class FootprintSrsTest { + + private static final String FOOTPRINT_SRS_STRING = "epsg:4326"; + + private final FootprintSrs footprintSrs = new FootprintSrs(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:footprintSrs", FOOTPRINT_SRS_STRING); + + // When + var result = footprintSrs.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(FOOTPRINT_SRS_STRING); + } + + @Test + void testGetTerm() { + // When + var result = footprintSrs.getTerm(); + + // Then + assertThat(result).isEqualTo(FootprintSrs.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/FootprintWKTTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/FootprintWKTTest.java new file mode 100644 index 0000000..47afc12 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/FootprintWKTTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class FootprintWKTTest { + + private static final String FOOTPRINT_WKT_STRING = "POLYGON ((10 20, 11 20, 11 21, 10 21, 10 20))"; + + private final FootprintWkt footprintWkt = new FootprintWkt(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:footprintWkt", FOOTPRINT_WKT_STRING); + + // When + var result = footprintWkt.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(FOOTPRINT_WKT_STRING); + } + + @Test + void testGetTerm() { + // When + var result = footprintWkt.getTerm(); + + // Then + assertThat(result).isEqualTo(FootprintWkt.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoReferenceSourcesTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoReferenceSourcesTest.java new file mode 100644 index 0000000..5ab5ebd --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoReferenceSourcesTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class GeoReferenceSourcesTest { + + private static final String GEOREFERENCE_SOURCES = "https://www.geonames.org/"; + + private final GeoreferenceSources georeferenceSources = new GeoreferenceSources(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:georeferenceSources", GEOREFERENCE_SOURCES); + + // When + var result = georeferenceSources.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(GEOREFERENCE_SOURCES); + } + + @Test + void testGetTerm() { + // When + var result = georeferenceSources.getTerm(); + + // Then + assertThat(result).isEqualTo(GeoreferenceSources.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/GeodeticDatumTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeodeticDatumTest.java similarity index 94% rename from src/test/java/eu/dissco/core/translator/terms/specimen/location/GeodeticDatumTest.java rename to src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeodeticDatumTest.java index 5ca223a..29d6b39 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/location/GeodeticDatumTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeodeticDatumTest.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen.location; +package eu.dissco.core.translator.terms.specimen.location.georeference; import static eu.dissco.core.translator.TestUtils.MAPPER; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferenceProtocolTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferenceProtocolTest.java new file mode 100644 index 0000000..7540946 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferenceProtocolTest.java @@ -0,0 +1,54 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class GeoreferenceProtocolTest { + + private static final String GEOREFERENCE_PROTOCOL = "Georeferencing Quick Reference Guide (Zermoglio et al. 2020, https://doi.org/10.35035/e09p-h128)"; + + private final GeoreferenceProtocol georeferenceProtocol = new GeoreferenceProtocol(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:georeferenceProtocol", GEOREFERENCE_PROTOCOL); + + // When + var result = georeferenceProtocol.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(GEOREFERENCE_PROTOCOL); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put( + "abcd:gathering/siteCoordinateSets/siteCoordinates/0/coordinateMethod", + GEOREFERENCE_PROTOCOL); + + // When + var result = georeferenceProtocol.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(GEOREFERENCE_PROTOCOL); + } + + @Test + void testGetTerm() { + // When + var result = georeferenceProtocol.getTerm(); + + // Then + assertThat(result).isEqualTo(GeoreferenceProtocol.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferenceRemarksTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferenceRemarksTest.java new file mode 100644 index 0000000..3221d70 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferenceRemarksTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class GeoreferenceRemarksTest { + + private static final String GEOREFERENCE_REMARKS = "Assumed distance by road (Hwy. 101)"; + + private final GeoreferenceRemarks georeferenceRemarks = new GeoreferenceRemarks(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:georeferenceRemarks", GEOREFERENCE_REMARKS); + + // When + var result = georeferenceRemarks.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(GEOREFERENCE_REMARKS); + } + + @Test + void testGetTerm() { + // When + var result = georeferenceRemarks.getTerm(); + + // Then + assertThat(result).isEqualTo(GeoreferenceRemarks.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferencedByTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferencedByTest.java new file mode 100644 index 0000000..3e57c88 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferencedByTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class GeoreferencedByTest { + + private static final String GEOREFERENCED_BY = "S. Leeflang"; + + private final GeoreferencedBy georeferencedBy = new GeoreferencedBy(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:georeferencedBy", GEOREFERENCED_BY); + + // When + var result = georeferencedBy.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(GEOREFERENCED_BY); + } + + @Test + void testGetTerm() { + // When + var result = georeferencedBy.getTerm(); + + // Then + assertThat(result).isEqualTo(GeoreferencedBy.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferencedDateTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferencedDateTest.java new file mode 100644 index 0000000..50fc505 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/GeoreferencedDateTest.java @@ -0,0 +1,38 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static eu.dissco.core.translator.TestUtils.MOCK_DATE; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class GeoreferencedDateTest { + + private final GeoreferencedDate georeferencedDate = new GeoreferencedDate(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:georeferencedDate", MOCK_DATE); + + // When + var result = georeferencedDate.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(MOCK_DATE); + } + + @Test + void testGetTerm() { + // When + var result = georeferencedDate.getTerm(); + + // Then + assertThat(result).isEqualTo(GeoreferencedDate.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/PointRadiusSpatialFitTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/PointRadiusSpatialFitTest.java new file mode 100644 index 0000000..243de59 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/location/georeference/PointRadiusSpatialFitTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.location.georeference; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class PointRadiusSpatialFitTest { + + private static final String POINT_RADIUS_SPATIAL_FIT_STRING = "1.5708"; + + private final PointRadiusSpatialFit pointRadiusSpatialFit = new PointRadiusSpatialFit(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:pointRadiusSpatialFit", POINT_RADIUS_SPATIAL_FIT_STRING); + + // When + var result = pointRadiusSpatialFit.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(POINT_RADIUS_SPATIAL_FIT_STRING); + } + + @Test + void testGetTerm() { + // When + var result = pointRadiusSpatialFit.getTerm(); + + // Then + assertThat(result).isEqualTo(PointRadiusSpatialFit.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/BehaviorTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/BehaviorTest.java new file mode 100644 index 0000000..c867b35 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/BehaviorTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class BehaviorTest { + + private static final String BEHAVIOR_STRING = "foraging"; + + private final Behavior behavior = new Behavior(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:behavior", BEHAVIOR_STRING); + + // When + var result = behavior.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(BEHAVIOR_STRING); + } + + @Test + void testGetTerm() { + // When + var result = behavior.getTerm(); + + // Then + assertThat(result).isEqualTo(Behavior.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/DataGeneralizationsTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/DataGeneralizationsTest.java new file mode 100644 index 0000000..c717dea --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/DataGeneralizationsTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class DataGeneralizationsTest { + + private static final String DATA_GENERALIZATIONS_STRING = "The data was generalised"; + + private final DataGeneralizations dataGeneralizations = new DataGeneralizations(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:dataGeneralizations", DATA_GENERALIZATIONS_STRING); + + // When + var result = dataGeneralizations.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(DATA_GENERALIZATIONS_STRING); + } + + @Test + void testGetTerm() { + // When + var result = dataGeneralizations.getTerm(); + + // Then + assertThat(result).isEqualTo(DataGeneralizations.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/DegreeOfEstablishmentTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/DegreeOfEstablishmentTest.java new file mode 100644 index 0000000..642cebd --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/DegreeOfEstablishmentTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class DegreeOfEstablishmentTest { + + private static final String DEGREE_OF_ESTABLISHMENT_STRING = "http://rs.tdwg.org/dwcdoe/values/d003"; + + private final DegreeOfEstablishment degreeOfEstablishment = new DegreeOfEstablishment(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:degreeOfEstablishment", DEGREE_OF_ESTABLISHMENT_STRING); + + // When + var result = degreeOfEstablishment.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(DEGREE_OF_ESTABLISHMENT_STRING); + } + + @Test + void testGetTerm() { + // When + var result = degreeOfEstablishment.getTerm(); + + // Then + assertThat(result).isEqualTo(DegreeOfEstablishment.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/EstablishmentMeansTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/EstablishmentMeansTest.java new file mode 100644 index 0000000..c59b567 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/EstablishmentMeansTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class EstablishmentMeansTest { + + private static final String ESTABLISHMENT_MEANS_STRING = "http://rs.tdwg.org/dwcem/values/e001"; + + private final EstablishmentMeans establishmentMeans = new EstablishmentMeans(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:establishmentMeans", ESTABLISHMENT_MEANS_STRING); + + // When + var result = establishmentMeans.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(ESTABLISHMENT_MEANS_STRING); + } + + @Test + void testGetTerm() { + // When + var result = establishmentMeans.getTerm(); + + // Then + assertThat(result).isEqualTo(EstablishmentMeans.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/EventDateTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/EventDateTest.java new file mode 100644 index 0000000..3ec7fd1 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/EventDateTest.java @@ -0,0 +1,51 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static eu.dissco.core.translator.TestUtils.MOCK_DATE; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class EventDateTest { + + private final EventDate eventData = new EventDate(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:eventDate", MOCK_DATE); + + // When + var result = eventData.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(MOCK_DATE); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:gathering/dateTime/isodateTimeBegin", MOCK_DATE); + + // When + var result = eventData.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(MOCK_DATE); + } + + @Test + void testGetTerm() { + // When + var result = eventData.getTerm(); + + // Then + assertThat(result).isEqualTo(EventDate.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/EventRemarkTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/EventRemarkTest.java new file mode 100644 index 0000000..415dd91 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/EventRemarkTest.java @@ -0,0 +1,52 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class EventRemarkTest { + + private static final String EVENT_REMARKS_STRING = "A remark about the event"; + + private final EventRemark eventRemark = new EventRemark(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:eventRemarks", EVENT_REMARKS_STRING); + + // When + var result = eventRemark.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(EVENT_REMARKS_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:gathering/notes/value", EVENT_REMARKS_STRING); + + // When + var result = eventRemark.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(EVENT_REMARKS_STRING); + } + + @Test + void testGetTerm() { + // When + var result = eventRemark.getTerm(); + + // Then + assertThat(result).isEqualTo(EventRemark.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/FieldNotesTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/FieldNotesTest.java new file mode 100644 index 0000000..2292fa9 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/FieldNotesTest.java @@ -0,0 +1,52 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class FieldNotesTest { + + private static final String FIELD_NOTES_STRING = "Collected while raining"; + + private final FieldNotes fieldNotes = new FieldNotes(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:fieldNotes", FIELD_NOTES_STRING); + + // When + var result = fieldNotes.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(FIELD_NOTES_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:gathering/fieldNotes/value", FIELD_NOTES_STRING); + + // When + var result = fieldNotes.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(FIELD_NOTES_STRING); + } + + @Test + void testGetTerm() { + // When + var result = fieldNotes.getTerm(); + + // Then + assertThat(result).isEqualTo(FieldNotes.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/CollectingNumberTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/FieldNumberTest.java similarity index 69% rename from src/test/java/eu/dissco/core/translator/terms/specimen/CollectingNumberTest.java rename to src/test/java/eu/dissco/core/translator/terms/specimen/occurence/FieldNumberTest.java index f043919..7b0082c 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/CollectingNumberTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/FieldNumberTest.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen; +package eu.dissco.core.translator.terms.specimen.occurence; import static eu.dissco.core.translator.TestUtils.MAPPER; import static org.assertj.core.api.Assertions.assertThat; @@ -8,11 +8,11 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class CollectingNumberTest { +class FieldNumberTest { private static final String NUMBER = "245"; - private final CollectingNumber collectingNumber = new CollectingNumber(); + private final FieldNumber fieldNumber = new FieldNumber(); @Test void testRetrieveFromDWCA() { @@ -21,7 +21,7 @@ void testRetrieveFromDWCA() { unit.put("dwc:recordNumber", NUMBER); // When - var result = collectingNumber.retrieveFromDWCA(unit); + var result = fieldNumber.retrieveFromDWCA(unit); // Then assertThat(result).isEqualTo(NUMBER); @@ -34,7 +34,7 @@ void testRetrieveFromABCD() { unit.put("abcd:collectorsFieldNumber", NUMBER); // When - var result = collectingNumber.retrieveFromABCD(unit); + var result = fieldNumber.retrieveFromABCD(unit); // Then assertThat(result).isEqualTo(NUMBER); @@ -43,10 +43,10 @@ void testRetrieveFromABCD() { @Test void testGetTerm() { // When - var result = collectingNumber.getTerm(); + var result = fieldNumber.getTerm(); // Then - assertThat(result).isEqualTo(CollectingNumber.TERM); + assertThat(result).isEqualTo(FieldNumber.TERM); } } diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/GeoreferenceVerificationStatusTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/GeoreferenceVerificationStatusTest.java new file mode 100644 index 0000000..a4bf89c --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/GeoreferenceVerificationStatusTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class GeoreferenceVerificationStatusTest { + + private static final String GEOREFERENCE_VERIFICATION_STATUS_STRING = "confirmed"; + + private final GeoreferenceVerificationStatus georeferenceVerificationStatus = new GeoreferenceVerificationStatus(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:georeferenceVerificationStatus", GEOREFERENCE_VERIFICATION_STATUS_STRING); + + // When + var result = georeferenceVerificationStatus.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(GEOREFERENCE_VERIFICATION_STATUS_STRING); + } + + @Test + void testGetTerm() { + // When + var result = georeferenceVerificationStatus.getTerm(); + + // Then + assertThat(result).isEqualTo(GeoreferenceVerificationStatus.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/DateCollectedTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/HabitatTest.java similarity index 51% rename from src/test/java/eu/dissco/core/translator/terms/specimen/DateCollectedTest.java rename to src/test/java/eu/dissco/core/translator/terms/specimen/occurence/HabitatTest.java index b630bf9..f313779 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/DateCollectedTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/HabitatTest.java @@ -1,4 +1,4 @@ -package eu.dissco.core.translator.terms.specimen; +package eu.dissco.core.translator.terms.specimen.occurence; import static eu.dissco.core.translator.TestUtils.MAPPER; import static org.assertj.core.api.Assertions.assertThat; @@ -8,45 +8,45 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class DateCollectedTest { +class HabitatTest { - private static final String DATE = "1924-11-20"; + private static final String HABITAT_STRING = "Forest"; - private final DateCollected dateCollected = new DateCollected(); + private final Habitat habitat = new Habitat(); @Test void testRetrieveFromDWCA() { // Given var unit = MAPPER.createObjectNode(); - unit.put("dwc:eventDate", DATE); + unit.put("dwc:habitat", HABITAT_STRING); // When - var result = dateCollected.retrieveFromDWCA(unit); + var result = habitat.retrieveFromDWCA(unit); // Then - assertThat(result).isEqualTo(DATE); + assertThat(result).isEqualTo(HABITAT_STRING); } @Test void testRetrieveFromABCD() { // Given var unit = MAPPER.createObjectNode(); - unit.put("abcd:gathering/dateTime/isodateTimeBegin", DATE); + unit.put("abcd:gathering/biotope/text/value", HABITAT_STRING); // When - var result = dateCollected.retrieveFromABCD(unit); + var result = habitat.retrieveFromABCD(unit); // Then - assertThat(result).isEqualTo(DATE); + assertThat(result).isEqualTo(HABITAT_STRING); } @Test void testGetTerm() { // When - var result = dateCollected.getTerm(); + var result = habitat.getTerm(); // Then - assertThat(result).isEqualTo(DateCollected.TERM); + assertThat(result).isEqualTo(Habitat.TERM); } } diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/InformationWithheldTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/InformationWithheldTest.java new file mode 100644 index 0000000..94f6e30 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/InformationWithheldTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class InformationWithheldTest { + + private static final String INFORMATION_WITHHELD_STRING = "Yes"; + + private final InformationWithheld informationWithheld = new InformationWithheld(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:informationWithheld", INFORMATION_WITHHELD_STRING); + + // When + var result = informationWithheld.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(INFORMATION_WITHHELD_STRING); + } + + @Test + void testGetTerm() { + // When + var result = informationWithheld.getTerm(); + + // Then + assertThat(result).isEqualTo(InformationWithheld.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/LifeStageTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/LifeStageTest.java new file mode 100644 index 0000000..acaa467 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/LifeStageTest.java @@ -0,0 +1,53 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class LifeStageTest { + + private static final String LIFE_STAGE_STRING = "Adult"; + + private final LifeStage lifeStage = new LifeStage(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:lifeStage", LIFE_STAGE_STRING); + + // When + var result = lifeStage.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(LIFE_STAGE_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:unit/mycologicalUnit/mycologicalLiveStages/0/mycologicalLiveStage/value", + LIFE_STAGE_STRING); + + // When + var result = lifeStage.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(LIFE_STAGE_STRING); + } + + @Test + void testGetTerm() { + // When + var result = lifeStage.getTerm(); + + // Then + assertThat(result).isEqualTo(LifeStage.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/OccurrenceAssertionsTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/OccurrenceAssertionsTest.java new file mode 100644 index 0000000..607a58d --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/OccurrenceAssertionsTest.java @@ -0,0 +1,77 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static eu.dissco.core.translator.TestUtils.MOCK_DATE; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class OccurrenceAssertionsTest { + + private static final String MEASURED_BY = "S. Leeflang"; + private static final String UNIT = "meters"; + private static final String TYPE = "full length"; + private static final String VALUE = "2.5"; + private static final String REMARK = "Measurement of the full length10"; + private final OccurrenceAssertions occurrenceAssertions = new OccurrenceAssertions(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + var extensions = MAPPER.createObjectNode(); + var measurementOrFacts = MAPPER.createArrayNode(); + var measurementOrFact = MAPPER.createObjectNode(); + measurementOrFact.put("dwc:measurementUnit", UNIT); + measurementOrFact.put("dwc:measurementType", TYPE); + measurementOrFact.put("dwc:measurementValue", VALUE); + measurementOrFact.put("dwc:measurementRemarks", REMARK); + measurementOrFacts.add(measurementOrFact); + extensions.set("dwc:MeasurementOrFact", measurementOrFacts); + unit.set("extensions", extensions); + + var expected = new eu.dissco.core.translator.schema.Assertions() + .withAssertionUnit(UNIT).withAssertionType(TYPE).withAssertionValue(VALUE) + .withAssertionRemarks(REMARK); + // When + var result = occurrenceAssertions.gatherOccurrenceAssertions(MAPPER, unit, true); + + // Then + assertThat(result).hasSize(1); + assertThat(result.get(0)).isEqualTo(expected); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:measurementsOrFacts/measurementOrFact/0/measurementOrFactAtomised/measuredBy", + MEASURED_BY); + unit.put( + "abcd:measurementsOrFacts/measurementOrFact/0/measurementOrFactAtomised/unitOfMeasurement", + UNIT); + unit.put( + "abcd:measurementsOrFacts/measurementOrFact/0/measurementOrFactAtomised/parameter/value", + TYPE); + unit.put("abcd:measurementsOrFacts/measurementOrFact/0/measurementOrFactText/value", REMARK); + unit.put("abcd:measurementsOrFacts/measurementOrFact/0/measurementOrFactAtomised/lowerValue", + VALUE); + unit.put( + "abcd:measurementsOrFacts/measurementOrFact/0/measurementOrFactAtomised/MeasurementDateTime", + MOCK_DATE); + + var expected = new eu.dissco.core.translator.schema.Assertions() + .withAssertionUnit(UNIT).withAssertionType(TYPE).withAssertionValue(VALUE) + .withAssertionByAgentName( + MEASURED_BY).withAssertionMadeDate(MOCK_DATE).withAssertionRemarks(REMARK); + // When + var result = occurrenceAssertions.gatherOccurrenceAssertions(MAPPER, unit, false); + + // Then + assertThat(result).hasSize(1); + assertThat(result.get(0)).isEqualTo(expected); + } +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/OccurrenceRemarksTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/OccurrenceRemarksTest.java new file mode 100644 index 0000000..edd1205 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/OccurrenceRemarksTest.java @@ -0,0 +1,52 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class OccurrenceRemarksTest { + + private static final String OCCURRENCE_REMARKS_STRING = "Remarks about the event"; + + private final OccurrenceRemarks occurrenceRemarks = new OccurrenceRemarks(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:occurrenceRemarks", OCCURRENCE_REMARKS_STRING); + + // When + var result = occurrenceRemarks.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(OCCURRENCE_REMARKS_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:notes/value", OCCURRENCE_REMARKS_STRING); + + // When + var result = occurrenceRemarks.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(OCCURRENCE_REMARKS_STRING); + } + + @Test + void testGetTerm() { + // When + var result = occurrenceRemarks.getTerm(); + + // Then + assertThat(result).isEqualTo(OccurrenceRemarks.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/OccurrenceStatusTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/OccurrenceStatusTest.java new file mode 100644 index 0000000..f7aeeab --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/OccurrenceStatusTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class OccurrenceStatusTest { + + private static final String OCCURRENCE_STATUS_STRING = "Present"; + + private final OccurrenceStatus occurrenceStatus = new OccurrenceStatus(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:occurrenceStatus", OCCURRENCE_STATUS_STRING); + + // When + var result = occurrenceStatus.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(OCCURRENCE_STATUS_STRING); + } + + @Test + void testGetTerm() { + // When + var result = occurrenceStatus.getTerm(); + + // Then + assertThat(result).isEqualTo(OccurrenceStatus.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/OrganismQuantityTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/OrganismQuantityTest.java new file mode 100644 index 0000000..6a16308 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/OrganismQuantityTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class OrganismQuantityTest { + + private static final String ORGANISM_QUANTITY_STRING = "3"; + + private final OrganismQuantity organismQuantity = new OrganismQuantity(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:individualCount", ORGANISM_QUANTITY_STRING); + + // When + var result = organismQuantity.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(ORGANISM_QUANTITY_STRING); + } + + @Test + void testGetTerm() { + // When + var result = organismQuantity.getTerm(); + + // Then + assertThat(result).isEqualTo(OrganismQuantity.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/OrganismQuantityTypeTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/OrganismQuantityTypeTest.java new file mode 100644 index 0000000..ee7820f --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/OrganismQuantityTypeTest.java @@ -0,0 +1,51 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class OrganismQuantityTypeTest { + + private final OrganismQuantityType organismQuantityType = new OrganismQuantityType(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:individualCount", "5"); + + // When + var result = organismQuantityType.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo("individuals"); + } + + @Test + void testRetrieveFromDWCAIsEmpty() { + // Given + var organismQuantityTypeString = "Some nice quantitative type"; + var unit = MAPPER.createObjectNode(); + unit.put("dwc:organismQuantityType", organismQuantityTypeString); + + // When + var result = organismQuantityType.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(organismQuantityTypeString); + } + + @Test + void testGetTerm() { + // When + var result = organismQuantityType.getTerm(); + + // Then + assertThat(result).isEqualTo(OrganismQuantityType.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/PathwayTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/PathwayTest.java new file mode 100644 index 0000000..4d39450 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/PathwayTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class PathwayTest { + + private static final String PATHWAY_STRING = "transportStowaway"; + + private final Pathway pathway = new Pathway(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:pathway", PATHWAY_STRING); + + // When + var result = pathway.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(PATHWAY_STRING); + } + + @Test + void testGetTerm() { + // When + var result = pathway.getTerm(); + + // Then + assertThat(result).isEqualTo(Pathway.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/ReproductiveConditionTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/ReproductiveConditionTest.java new file mode 100644 index 0000000..336b38f --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/ReproductiveConditionTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class ReproductiveConditionTest { + + private static final String REPRODUCTIVE_CONDITION_STRING = "in bloom"; + + private final ReproductiveCondition reproductiveCondition = new ReproductiveCondition(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:reproductiveCondition", REPRODUCTIVE_CONDITION_STRING); + + // When + var result = reproductiveCondition.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(REPRODUCTIVE_CONDITION_STRING); + } + + @Test + void testGetTerm() { + // When + var result = reproductiveCondition.getTerm(); + + // Then + assertThat(result).isEqualTo(ReproductiveCondition.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/SampleSizeUnitTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/SampleSizeUnitTest.java new file mode 100644 index 0000000..b6a52fc --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/SampleSizeUnitTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class SampleSizeUnitTest { + + private static final String SAMPLE_SIZE_UNIT_STRING = "individuals"; + + private final SampleSizeUnit sampleSizeUnit = new SampleSizeUnit(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:sampleSizeUnit", SAMPLE_SIZE_UNIT_STRING); + + // When + var result = sampleSizeUnit.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(SAMPLE_SIZE_UNIT_STRING); + } + + @Test + void testGetTerm() { + // When + var result = sampleSizeUnit.getTerm(); + + // Then + assertThat(result).isEqualTo(SampleSizeUnit.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/SampleSizeValueTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/SampleSizeValueTest.java new file mode 100644 index 0000000..f640325 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/SampleSizeValueTest.java @@ -0,0 +1,39 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class SampleSizeValueTest { + + private static final String SAMPLE_SIZE_STRING = "3"; + + private final SampleSizeValue sampleSizeValue = new SampleSizeValue(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:sampleSizeValue", SAMPLE_SIZE_STRING); + + // When + var result = sampleSizeValue.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(SAMPLE_SIZE_STRING); + } + + @Test + void testGetTerm() { + // When + var result = sampleSizeValue.getTerm(); + + // Then + assertThat(result).isEqualTo(SampleSizeValue.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/SamplingProtocolTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/SamplingProtocolTest.java new file mode 100644 index 0000000..37bc369 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/SamplingProtocolTest.java @@ -0,0 +1,52 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class SamplingProtocolTest { + + private static final String SAMPLING_PROTOCOL_STRING = "bottom trawl"; + + private final SamplingProtocol samplingProtocol = new SamplingProtocol(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:samplingProtocol", SAMPLING_PROTOCOL_STRING); + + // When + var result = samplingProtocol.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(SAMPLING_PROTOCOL_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:gathering/method/value", SAMPLING_PROTOCOL_STRING); + + // When + var result = samplingProtocol.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(SAMPLING_PROTOCOL_STRING); + } + + @Test + void testGetTerm() { + // When + var result = samplingProtocol.getTerm(); + + // Then + assertThat(result).isEqualTo(SamplingProtocol.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/SexTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/SexTest.java new file mode 100644 index 0000000..f9f7539 --- /dev/null +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/occurence/SexTest.java @@ -0,0 +1,52 @@ +package eu.dissco.core.translator.terms.specimen.occurence; + +import static eu.dissco.core.translator.TestUtils.MAPPER; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class SexTest { + + private static final String SEX_STRING = "Female"; + + private final Sex sex = new Sex(); + + @Test + void testRetrieveFromDWCA() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("dwc:sex", SEX_STRING); + + // When + var result = sex.retrieveFromDWCA(unit); + + // Then + assertThat(result).isEqualTo(SEX_STRING); + } + + @Test + void testRetrieveFromABCD() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:sex", SEX_STRING); + + // When + var result = sex.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo(SEX_STRING); + } + + @Test + void testGetTerm() { + // When + var result = sex.getTerm(); + + // Then + assertThat(result).isEqualTo(Sex.TERM); + } + +} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/ClassTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/ClassTest.java deleted file mode 100644 index abef51d..0000000 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/ClassTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; - -import static eu.dissco.core.translator.TestUtils.MAPPER; -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class ClassTest { - - private final Class classTax = new Class(); - - @Test - void testRetrieveFromDWCA() { - // Given - var unit = MAPPER.createObjectNode(); - unit.put("dwc:class", "Mammalia"); - - // When - var result = classTax.retrieveFromDWCA(unit); - - // Then - assertThat(result).isEqualTo("Mammalia"); - } - - @Test - void testRetrieveFromABCD() { - // Given - var unit = MAPPER.createObjectNode(); - unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonRank", - "classis"); - unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonName", - "Eurotatoria"); - unit.put("abcd:identifications/identification/0/preferredFlag", false); - unit.put( - "abcd:identifications/identification/1/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonRank", - "classis"); - unit.put( - "abcd:identifications/identification/1/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonName", - "Mammalia"); - unit.put( - "abcd:identifications/identification/1/result/taxonIdentified/higherTaxa/higherTaxon/1/higherTaxonRank", - "regnum"); - unit.put( - "abcd:identifications/identification/1/result/taxonIdentified/higherTaxa/higherTaxon/1/higherTaxonName", - "Animalia"); - unit.put("abcd:identifications/identification/1/preferredFlag", true); - - // When - var result = classTax.retrieveFromABCD(unit); - - // Then - assertThat(result).isEqualTo("Mammalia"); - } - - @Test - void testGetTerm() { - // When - var result = classTax.getTerm(); - - // Then - assertThat(result).isEqualTo(Class.TERM); - } -} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/GenusTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/GenusTest.java deleted file mode 100644 index f502f27..0000000 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/GenusTest.java +++ /dev/null @@ -1,100 +0,0 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; - -import static eu.dissco.core.translator.TestUtils.MAPPER; -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class GenusTest { - - private final Genus genus = new Genus(); - - @Test - void testRetrieveFromDWCA() { - // Given - var unit = MAPPER.createObjectNode(); - unit.put("dwc:genus", "Rhinopoma"); - - // When - var result = genus.retrieveFromDWCA(unit); - - // Then - assertThat(result).isEqualTo("Rhinopoma"); - } - - @Test - void testRetrieveFromDWCAExtensionNoVerified() { - // Given - var unit = MAPPER.createObjectNode(); - var extension = MAPPER.createObjectNode(); - var identificationUnverified = MAPPER.createObjectNode(); - identificationUnverified.put("dwc:genus", "Rhinopoma"); - identificationUnverified.put("dwc:identificationVerificationStatus", "0"); - var identificationVerified = MAPPER.createObjectNode(); - identificationVerified.put("dwc:genus", "Rhinopoma"); - identificationVerified.put("dwc:identificationVerificationStatus", "1"); - var identifications = MAPPER.createArrayNode(); - identifications.add(identificationUnverified); - identifications.add(identificationVerified); - extension.set("dwc:Identification", identifications); - unit.set("extensions", extension); - unit.put("ods:taxonIdentificationIndex", "1"); - - // When - var result = genus.retrieveFromDWCA(unit); - - // Then - assertThat(result).isEqualTo("Rhinopoma"); - } - - @Test - void testRetrieveFromABCD() { - // Given - var unit = MAPPER.createObjectNode(); - unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonRank", - "classis"); - unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonName", - "Eurotatoria"); - unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/nameAtomised/botanical/genusOrMonomial", - "Fridericia Mart."); - unit.put("abcd:identifications/identification/0/preferredFlag", false); - unit.put( - "abcd:identifications/identification/1/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonRank", - "classis"); - unit.put( - "abcd:identifications/identification/1/result/taxonIdentified/higherTaxa/higherTaxon/0/higherTaxonName", - "Mammalia"); - unit.put( - "abcd:identifications/identification/1/result/taxonIdentified/higherTaxa/higherTaxon/1/higherTaxonRank", - "regnum"); - unit.put( - "abcd:identifications/identification/1/result/taxonIdentified/higherTaxa/higherTaxon/1/higherTaxonName", - "Animalia"); - unit.put( - "abcd:identifications/identification/1/result/taxonIdentified/nameAtomised/botanical/genusOrMonomial", - "Arrabidaea"); - - unit.put("abcd:identifications/identification/1/preferredFlag", true); - - // When - var result = genus.retrieveFromABCD(unit); - - // Then - assertThat(result).isEqualTo("Arrabidaea"); - } - - @Test - void testGetTerm() { - // When - var result = genus.getTerm(); - - // Then - assertThat(result).isEqualTo(Genus.TERM); - } -} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/SpecimenNameTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/SpecimenNameTest.java deleted file mode 100644 index da7b257..0000000 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/SpecimenNameTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; - -import static eu.dissco.core.translator.TestUtils.MAPPER; -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class SpecimenNameTest { - - private final SpecimenName specimenName = new SpecimenName(); - - @Test - void testRetrieveFromDWCA() { - // Given - var specimenNameString = "SpecimenName"; - var unit = MAPPER.createObjectNode(); - unit.put("dwc:scientificName", specimenNameString); - - // When - var result = specimenName.retrieveFromDWCA(unit); - - // Then - assertThat(result).isEqualTo(specimenNameString); - } - - @Test - void testRetrieveFromDWCAExtension() { - // Given - var unit = MAPPER.createObjectNode(); - var extension = MAPPER.createObjectNode(); - var identificationUnverified = MAPPER.createObjectNode(); - identificationUnverified.put("dwc:scientificName", "SpecimenNameUnVerified"); - identificationUnverified.put("dwc:identificationVerificationStatus", "0"); - var identificationVerified = MAPPER.createObjectNode(); - identificationVerified.put("dwc:scientificName", "SpecimenNameVerified"); - identificationVerified.put("dwc:identificationVerificationStatus", "1"); - var identifications = MAPPER.createArrayNode(); - identifications.add(identificationVerified); - identifications.add(identificationUnverified); - extension.set("dwc:Identification", identifications); - unit.set("extensions", extension); - - // When - var result = specimenName.retrieveFromDWCA(unit); - - // Then - assertThat(result).isEqualTo("SpecimenNameVerified"); - } - - @Test - void testRetrieveFromDWCAExtensionNoVerified() { - // Given - var unit = MAPPER.createObjectNode(); - var extension = MAPPER.createObjectNode(); - var identificationUnverified = MAPPER.createObjectNode(); - identificationUnverified.put("dwc:scientificName", "SpecimenNameUnVerified"); - identificationUnverified.put("dwc:identificationVerificationStatus", "0"); - var identifications = MAPPER.createArrayNode(); - identifications.add(identificationUnverified); - extension.set("dwc:Identification", identifications); - unit.set("extensions", extension); - - // When - var result = specimenName.retrieveFromDWCA(unit); - - // Then - assertThat(result).isNull(); - } - - @Test - void testRetrieveFromABCDEFG() { - // Given - var specimenNameString = "SpecimenName"; - var unit = MAPPER.createObjectNode(); - unit.put( - "abcd-efg:identifications/identification/0/result/mineralRockIdentified/classifiedName/fullScientificNameString", - specimenNameString); - - // When - var result = specimenName.retrieveFromABCD(unit); - - // Then - assertThat(result).isEqualTo(specimenNameString); - } - - @Test - void testRetrieveFromABCDWithPreferred() { - // Given - var unit = MAPPER.createObjectNode(); - unit.put( - "abcd:identifications/identification/0/preferredFlag", false); - unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/scientificName/fullScientificNameString", - "Arrabidaea chica (Humb. & Bonpl.) B.Verl."); - unit.put( - "abcd:identifications/identification/1/preferredFlag", true); - unit.put( - "abcd:identifications/identification/1/result/taxonIdentified/scientificName/fullScientificNameString", - "Bignonia chica Humb. & Bonpl."); - unit.put( - "abcd:identifications/identification/2/preferredFlag", false); - unit.put( - "abcd:identifications/identification/2/result/taxonIdentified/scientificName/fullScientificNameString", - "Arrabidaea chica var. thyrsoidea Bureau"); - - // When - var result = specimenName.retrieveFromABCD(unit); - - // Then - assertThat(result).isEqualTo("Bignonia chica Humb. & Bonpl."); - } - - @Test - void testRetrieveFromABCD() { - // Given - var specimenNameString = "SpecimenName"; - var unit = MAPPER.createObjectNode(); - unit.put( - "abcd:identifications/identification/0/result/taxonIdentified/scientificName/fullScientificNameString", - specimenNameString); - - // When - var result = specimenName.retrieveFromABCD(unit); - - // Then - assertThat(result).isEqualTo(specimenNameString); - } - - @Test - void testRetrieveFromABCDNotPresent() { - // Given - var unit = MAPPER.createObjectNode(); - - // When - var result = specimenName.retrieveFromABCD(unit); - - // Then - assertThat(result).isNull(); - } - - - @Test - void testGetTerm() { - // When - var result = specimenName.getTerm(); - - // Then - assertThat(result).isEqualTo(SpecimenName.TERM); - } - -} diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/TypeStatusTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/TypeStatusTest.java deleted file mode 100644 index 4d40038..0000000 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/taxonomy/TypeStatusTest.java +++ /dev/null @@ -1,95 +0,0 @@ -package eu.dissco.core.translator.terms.specimen.taxonomy; - -import static eu.dissco.core.translator.TestUtils.MAPPER; -import static org.assertj.core.api.Assertions.assertThat; - -import eu.dissco.core.translator.terms.specimen.taxonomy.TypeStatus; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class TypeStatusTest { - - private static final String STATUS = "holotype | FULL_NAME | CITATION"; - - private final TypeStatus typeStatus = new TypeStatus(); - - @Test - void testRetrieveFromDWCA() { - // Given - var unit = MAPPER.createObjectNode(); - unit.put("dwc:typeStatus", STATUS); - - // When - var result = typeStatus.retrieveFromDWCA(unit); - - // Then - assertThat(result).isEqualTo(STATUS); - } - - @Test - void testRetrieveFromDWCAInExtension() { - // Given - var unit = MAPPER.createObjectNode(); - var array = MAPPER.createArrayNode(); - var extension = MAPPER.createObjectNode(); - extension.put("dwc:typeStatus", STATUS); - array.add(extension); - var extensions = MAPPER.createObjectNode(); - extensions.set("dwc:Identification", array); - unit.set("extensions", extensions); - - // When - var result = typeStatus.retrieveFromDWCA(unit); - - // Then - assertThat(result).isEqualTo(STATUS); - } - - @Test - void testRetrieveFromABCD() { - // Given - var unit = MAPPER.createObjectNode(); - unit.put( - "abcd:specimenUnit/nomenclaturalTypeDesignations/nomenclaturalTypeDesignation/0/typeStatus", - "holotype"); - unit.put( - "abcd:specimenUnit/nomenclaturalTypeDesignations/nomenclaturalTypeDesignation/0/typifiedName/fullScientificNameString", - "FULL_NAME"); - unit.put( - "abcd:specimenUnit/nomenclaturalTypeDesignations/nomenclaturalTypeDesignation/0/nomenclaturalReference/titleCitation", - "CITATION"); - unit.put( - "abcd:specimenUnit/nomenclaturalTypeDesignations/nomenclaturalTypeDesignation/1/typeStatus", - "Another_Status"); - - // When - var result = typeStatus.retrieveFromABCD(unit); - - // Then - assertThat(result).isEqualTo(STATUS); - } - - @Test - void testRetrieveFromABCDNoTypeStatus() { - // Given - var unit = MAPPER.createObjectNode(); - - // When - var result = typeStatus.retrieveFromABCD(unit); - - // Then - assertThat(result).isNull(); - } - - @Test - void testGetTerm() { - // When - var result = typeStatus.getTerm(); - - // Then - assertThat(result).isEqualTo(TypeStatus.TERM); - } - -} diff --git a/src/test/resources/db/migration/V1__init_db.sql b/src/test/resources/db/migration/V1__init_db.sql index 7f6f7e8..a08079c 100644 --- a/src/test/resources/db/migration/V1__init_db.sql +++ b/src/test/resources/db/migration/V1__init_db.sql @@ -1,29 +1,23 @@ -create table mapping -( - id text not null, - version integer not null, - name text not null, - description text, - mapping jsonb not null, - created timestamp with time zone not null, - creator text not null, - deleted timestamp with time zone, - sourcedatastandard varchar not null, - constraint new_mapping_pk - primary key (id, version) +CREATE TABLE public.mapping ( + id text NOT NULL, + "version" int4 NOT NULL, + "name" text NOT NULL, + description text NULL, + "mapping" jsonb NOT NULL, + created timestamptz NOT NULL, + creator text NOT NULL, + deleted timestamptz NULL, + CONSTRAINT new_mapping_pk PRIMARY KEY (id, version) ); -create table source_system -( - id text not null - constraint new_source_system_pkey - primary key, - name text not null, - endpoint text not null, - description text, - created timestamp with time zone not null, - deleted timestamp with time zone, - mapping_id text not null, - version integer default 1 not null, - creator text default '0000-0002-5669-2769'::text not null +CREATE TABLE public.source_system ( + id text NOT NULL, + "name" text NOT NULL, + endpoint text NOT NULL, + description text NULL, + created timestamptz NOT NULL, + deleted timestamptz NULL, + mapping_id text NOT NULL, + CONSTRAINT new_source_system_endpoint_key UNIQUE (endpoint), + CONSTRAINT new_source_system_pkey PRIMARY KEY (id) ); \ No newline at end of file