From be005cd59e0a63c91ac12ec52f20efdf77d3116a Mon Sep 17 00:00:00 2001 From: Sam Leeflang Date: Tue, 17 Oct 2023 15:53:42 +0200 Subject: [PATCH 1/3] Add additional mapping ABCD --- .../core/translator/service/BioCaseService.java | 4 ++-- .../terms/BaseDigitalObjectDirector.java | 2 +- .../terms/BiocaseDigitalObjectDirector.java | 3 +++ .../translator/terms/specimen/BasisOfRecord.java | 7 ++++++- .../translator/terms/specimen/Preparations.java | 2 +- .../specimen/identification/IdentifiedBy.java | 2 +- .../specimen/identification/taxonomy/Genus.java | 3 ++- .../identification/taxonomy/ScientificName.java | 4 +++- .../terms/specimen/BasisOfRecordTest.java | 13 +++++++++++++ .../identification/taxonomy/GenusTest.java | 15 +++++++++++++++ 10 files changed, 47 insertions(+), 8 deletions(-) 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 8d9e781..d036ee5 100644 --- a/src/main/java/eu/dissco/core/translator/service/BioCaseService.java +++ b/src/main/java/eu/dissco/core/translator/service/BioCaseService.java @@ -69,7 +69,7 @@ public class BioCaseService implements WebClientService { private static final List allowedBasisOfRecord = List.of("PRESERVEDSPECIMEN", "FOSSIL", "OTHER", "ROCK", "MINERAL", "METEORITE", "FOSSILSPECIMEN", "LIVINGSPECIMEN", "MATERIALSAMPLE", "FOSSIL SPECIMEN", "ROCKSPECIMEN", "ROCK SPECIMEN", "MINERALSPECIMEN", "MINERAL SPECIMEN", - "METEORITESPECIMEN", "METEORITE SPECIMEN"); + "METEORITESPECIMEN", "METEORITE SPECIMEN", "HERBARIUM SHEET", "HERBARIUMSHEET"); private final ObjectMapper mapper; private final WebClientProperties webClientProperties; @@ -203,7 +203,7 @@ private void processUnit(DataSet dataset, Unit unit) } } else { log.info("Record with record basis: {} and id: {} is ignored ", unit.getRecordBasis(), - unit.getUnitGUID()); + unit.getUnitID()); } } diff --git a/src/main/java/eu/dissco/core/translator/terms/BaseDigitalObjectDirector.java b/src/main/java/eu/dissco/core/translator/terms/BaseDigitalObjectDirector.java index 116ee82..3001114 100644 --- a/src/main/java/eu/dissco/core/translator/terms/BaseDigitalObjectDirector.java +++ b/src/main/java/eu/dissco/core/translator/terms/BaseDigitalObjectDirector.java @@ -553,7 +553,7 @@ private String getNormalisedPhysicalSpecimenId(OdsPhysicalSpecimenIdType physica || physicalSpecimenIdType.equals(OdsPhysicalSpecimenIdType.RESOLVABLE)) { return physicalSpecimenId; } else { - var minifiedSourceSystemId = sourceSystemId.substring(sourceSystemId.indexOf('/') + 1); + var minifiedSourceSystemId = sourceSystemId.substring(sourceSystemId.lastIndexOf('/') + 1); return physicalSpecimenId + ":" + minifiedSourceSystemId; } } diff --git a/src/main/java/eu/dissco/core/translator/terms/BiocaseDigitalObjectDirector.java b/src/main/java/eu/dissco/core/translator/terms/BiocaseDigitalObjectDirector.java index e2fdb89..ff2101c 100644 --- a/src/main/java/eu/dissco/core/translator/terms/BiocaseDigitalObjectDirector.java +++ b/src/main/java/eu/dissco/core/translator/terms/BiocaseDigitalObjectDirector.java @@ -34,6 +34,9 @@ private static List identifierTerms() { list.add("abcd:unitIDNumeric"); list.add("abcd:unitGUID"); list.add("abcd:recordURI"); + // For now just look at the two first accession numbers as a shortcut + list.add("abcd:specimenUnit/accessions/accessionDateAndAccessionCatalogueAndAccessionNumber/0/value"); + list.add("abcd:specimenUnit/accessions/accessionDateAndAccessionCatalogueAndAccessionNumber/1/value"); return list; } 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 27e5dfd..fceed18 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 @@ -10,6 +10,7 @@ public class BasisOfRecord extends Term { private final List dwcaTerms = List.of(TERM); private final List abcdTerms = List.of("abcd:recordBasis"); + private static final List PRESERVED_SPECIMEN_ALTERNATIVES = List.of("HERBARIUM SHEET", "HERBARIUMSHEET"); @Override public String retrieveFromDWCA(JsonNode unit) { @@ -18,7 +19,11 @@ public String retrieveFromDWCA(JsonNode unit) { @Override public String retrieveFromABCD(JsonNode unit) { - return super.searchJsonForTerm(unit, abcdTerms); + var result = super.searchJsonForTerm(unit, abcdTerms); + if (result != null && PRESERVED_SPECIMEN_ALTERNATIVES.contains(result.toUpperCase())) { + return "Preserved specimen"; + } + return result; } @Override diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/Preparations.java b/src/main/java/eu/dissco/core/translator/terms/specimen/Preparations.java index 90438a0..8277f2f 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/Preparations.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/Preparations.java @@ -8,7 +8,7 @@ public class Preparations extends Term { 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"); + private final List abcdTerms = List.of("abcd:kindOfUnit/0/value", "abcd:specimenUnit/preparations/preparation/0/preparationType/value"); @Override public String retrieveFromDWCA(JsonNode unit) { 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 index 9c7c674..539d3b2 100644 --- 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 @@ -8,7 +8,7 @@ public class IdentifiedBy extends Term { public static final String TERM = DWC_PREFIX + "identifiedBy"; - private final List dwcaTerms = List.of(TERM); + private final List dwcaTerms = List.of(TERM, "dwc:identifiedByID"); private final List abcdTerms = List.of("identifiers/identifier/0/personName/fullName"); diff --git a/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Genus.java b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Genus.java index 5caf193..2405405 100644 --- a/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Genus.java +++ b/src/main/java/eu/dissco/core/translator/terms/specimen/identification/taxonomy/Genus.java @@ -9,7 +9,8 @@ public class Genus extends AbstractTaxonomy { private final List dwcaTerms = List.of(TERM); private final List abcdTerms = List.of( - "result/taxonIdentified/scientificName/nameAtomised/botanical/genusOrMonomial"); + "result/taxonIdentified/scientificName/nameAtomised/botanical/genusOrMonomial", + "result/taxonIdentified/scientificName/nameAtomised/zoological/genusOrMonomial"); @Override public String retrieveFromDWCA(JsonNode unit) { 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 index fad9ed1..251314c 100644 --- 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 @@ -11,7 +11,9 @@ public class ScientificName extends AbstractTaxonomy { private final List dwcaTerms = List.of("dwc:scientificName"); private final List abcdTerms = List.of( "result/taxonIdentified/scientificName/fullScientificNameString", - "result/mineralRockIdentified/classifiedName/fullScientificNameString"); + "result/mineralRockIdentified/classifiedName/fullScientificNameString", + "result/taxonIdentified/informalNameString/value", + "result/taxonIdentified/scientificName/nameAtomised/zoological/namedIndividual"); @Override public String retrieveFromDWCA(JsonNode unit) { diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/BasisOfRecordTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/BasisOfRecordTest.java index c175a70..505fba9 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/BasisOfRecordTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/BasisOfRecordTest.java @@ -51,6 +51,19 @@ void testRetrieveFromABCD() { assertThat(result).isEqualTo("RockSpecimen"); } + @Test + void testRetrieveFromABCDNotFromControlledVocab() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put("abcd:recordBasis", "Herbarium Sheet"); + + // When + var result = basisOfRecord.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo("Preserved specimen"); + } + @Test void testGetTerm() { // 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 index bba82c8..bf931ce 100644 --- 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 @@ -53,6 +53,21 @@ void testRetrieveFromABCD() { assertThat(result).isEqualTo("Arrabidaea"); } + @Test + void testRetrieveFromABCDZoology() { + // Given + var unit = MAPPER.createObjectNode(); + unit.put( + "result/taxonIdentified/scientificName/nameAtomised/zoological/genusOrMonomial", + "Alchemilla"); + + // When + var result = genus.retrieveFromABCD(unit); + + // Then + assertThat(result).isEqualTo("Alchemilla"); + } + @Test void testGetTerm() { // When From 184cd9500ebf428055560f08b2a65a1b0b98359c Mon Sep 17 00:00:00 2001 From: Sam Leeflang Date: Tue, 17 Oct 2023 16:10:26 +0200 Subject: [PATCH 2/3] Add additional test case --- .../terms/specimen/BasisOfRecordTest.java | 47 +++++++------------ 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/BasisOfRecordTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/BasisOfRecordTest.java index 505fba9..c372af0 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/BasisOfRecordTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/BasisOfRecordTest.java @@ -3,8 +3,12 @@ import static eu.dissco.core.translator.TestUtils.MAPPER; import static org.assertj.core.api.Assertions.assertThat; +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) @@ -12,6 +16,15 @@ class BasisOfRecordTest { private final BasisOfRecord basisOfRecord = new BasisOfRecord(); + public static Stream prepareABCDRecordBasis() { + return Stream.of( + Arguments.of("PreservedSpecimen", "PreservedSpecimen"), + Arguments.of("RockSpecimen", "RockSpecimen"), + Arguments.of("HerbariumSheet", "Preserved specimen"), + Arguments.of(null, null) + ); + } + @Test void testRetrieveFromDWCA() { // Given @@ -25,44 +38,20 @@ void testRetrieveFromDWCA() { assertThat(result).isEqualTo("LivingSpecimen"); } - @Test - void testRetrieveFromDWCANotLiving() { - // Given - var unit = MAPPER.createObjectNode(); - unit.put("dwc:basisOfRecord", "PreservedSpecimen"); - - // When - var result = basisOfRecord.retrieveFromDWCA(unit); - - // Then - assertThat(result).isEqualTo("PreservedSpecimen"); - } - - @Test - void testRetrieveFromABCD() { + @ParameterizedTest + @MethodSource("prepareABCDRecordBasis") + void testRetrieveFromABCD(String recordBasis, String expected) { // Given var unit = MAPPER.createObjectNode(); - unit.put("abcd:recordBasis", "RockSpecimen"); + unit.put("abcd:recordBasis", recordBasis); // When var result = basisOfRecord.retrieveFromABCD(unit); // Then - assertThat(result).isEqualTo("RockSpecimen"); + assertThat(result).isEqualTo(expected); } - @Test - void testRetrieveFromABCDNotFromControlledVocab() { - // Given - var unit = MAPPER.createObjectNode(); - unit.put("abcd:recordBasis", "Herbarium Sheet"); - - // When - var result = basisOfRecord.retrieveFromABCD(unit); - - // Then - assertThat(result).isEqualTo("Preserved specimen"); - } @Test void testGetTerm() { From 4081818a65e47d9eb2a662579bc2c20e142e35b7 Mon Sep 17 00:00:00 2001 From: Sam Leeflang Date: Wed, 18 Oct 2023 11:10:07 +0200 Subject: [PATCH 3/3] Add DRIED as accepted recordBasis --- .../eu/dissco/core/translator/service/BioCaseService.java | 2 +- .../dissco/core/translator/terms/specimen/BasisOfRecord.java | 4 ++-- .../core/translator/terms/specimen/BasisOfRecordTest.java | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) 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 d036ee5..304d3bd 100644 --- a/src/main/java/eu/dissco/core/translator/service/BioCaseService.java +++ b/src/main/java/eu/dissco/core/translator/service/BioCaseService.java @@ -69,7 +69,7 @@ public class BioCaseService implements WebClientService { private static final List allowedBasisOfRecord = List.of("PRESERVEDSPECIMEN", "FOSSIL", "OTHER", "ROCK", "MINERAL", "METEORITE", "FOSSILSPECIMEN", "LIVINGSPECIMEN", "MATERIALSAMPLE", "FOSSIL SPECIMEN", "ROCKSPECIMEN", "ROCK SPECIMEN", "MINERALSPECIMEN", "MINERAL SPECIMEN", - "METEORITESPECIMEN", "METEORITE SPECIMEN", "HERBARIUM SHEET", "HERBARIUMSHEET"); + "METEORITESPECIMEN", "METEORITE SPECIMEN", "HERBARIUM SHEET", "HERBARIUMSHEET", "DRIED"); private final ObjectMapper mapper; private final WebClientProperties webClientProperties; 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 fceed18..3c4caf5 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 @@ -7,10 +7,10 @@ public class BasisOfRecord extends Term { public static final String TERM = DWC_PREFIX + "basisOfRecord"; - + private static final List PRESERVED_SPECIMEN_ALTERNATIVES = List.of("HERBARIUM SHEET", + "HERBARIUMSHEET", "DRIED"); private final List dwcaTerms = List.of(TERM); private final List abcdTerms = List.of("abcd:recordBasis"); - private static final List PRESERVED_SPECIMEN_ALTERNATIVES = List.of("HERBARIUM SHEET", "HERBARIUMSHEET"); @Override public String retrieveFromDWCA(JsonNode unit) { diff --git a/src/test/java/eu/dissco/core/translator/terms/specimen/BasisOfRecordTest.java b/src/test/java/eu/dissco/core/translator/terms/specimen/BasisOfRecordTest.java index c372af0..36c33c8 100644 --- a/src/test/java/eu/dissco/core/translator/terms/specimen/BasisOfRecordTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/specimen/BasisOfRecordTest.java @@ -21,6 +21,7 @@ public static Stream prepareABCDRecordBasis() { Arguments.of("PreservedSpecimen", "PreservedSpecimen"), Arguments.of("RockSpecimen", "RockSpecimen"), Arguments.of("HerbariumSheet", "Preserved specimen"), + Arguments.of("Dried", "Preserved specimen"), Arguments.of(null, null) ); }