Skip to content

Commit

Permalink
Merge pull request #59 from DiSSCo/feature/add-additional-terms
Browse files Browse the repository at this point in the history
Feature/add additional terms
  • Loading branch information
samleeflang authored May 22, 2024
2 parents c3810a2 + 78ceee8 commit 0356a2f
Show file tree
Hide file tree
Showing 86 changed files with 1,673 additions and 143 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.4</version>
<version>3.2.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>eu.dissco.core</groupId>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ protected List<Identifications> assembleIdentifications(JsonNode data, boolean d
iterateOverElements = false;
}
}
if (identifications.size() == 1 && identifications.get(0).getDwcIdentificationVerificationStatus() == null){
if (identifications.size() == 1
&& identifications.get(0).getDwcIdentificationVerificationStatus() == null) {
//If there is only one identification, and it doesn't have a verification status, set it to true
identifications.get(0).setDwcIdentificationVerificationStatus(Boolean.TRUE);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/eu/dissco/core/translator/terms/License.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class License extends Term {

public static final String TERM = DCTERMS_PREFIX + "license";

// Fall back to dc terms rights if no license is present
// Fall back to dc terms rights if no license is present
private final List<String> dwcaTerms = List.of(TERM, "dc:license", "eml:license",
"dcterms:rights", "dc:rights");
private final List<String> abcdUnitTerms = List.of(
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/eu/dissco/core/translator/terms/Term.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package eu.dissco.core.translator.terms;


import eu.dissco.core.translator.schema.Identifications;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.dissco.core.translator.schema.Identifications;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Pair;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public class PhysicalSpecimenId extends Term {

public static final String TERM = ODS_PREFIX + "physicalSpecimenId";

private final List<String> dwcaTerms = List.of("dwc:occurrenceID", "dwc:catalogNumber");
private final List<String> dwcaTerms = List.of("dwc:occurrenceID", "dwc:catalogNumber",
"dwc:materialSampleID", "dwc:materialEntityID");
private final List<String> abcdTerms = List.of("abcd:unitGUID", "abcd:unitID");

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public class Preparations extends Term {

public static final String TERM = DWC_PREFIX + "preparations";
private final List<String> dwcaTerms = List.of("dwc:preparations");
private final List<String> abcdTerms = List.of("abcd:kindOfUnit/0/value", "abcd:specimenUnit/preparations/preparation/0/preparationType/value");
private final List<String> abcdTerms = List.of("abcd:kindOfUnit/0/value",
"abcd:specimenUnit/preparations/preparation/0/preparationType/value");

@Override
public String retrieveFromDWCA(JsonNode unit) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 RecordedById extends Term {

public static final String TERM = DWC_PREFIX + "recordedByID";

private final List<String> dwcaTerms = List.of("dwc:recordedByID");

@Override
public String retrieveFromDWCA(JsonNode unit) {
return super.searchJsonForTerm(unit, dwcaTerms);
}

@Override
public String getTerm() {
return TERM;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ public String calculate(DigitalSpecimen ds) {
var acceptedIdentification = retrieveAcceptedIdentification(ds);
if (acceptedIdentification != null && acceptedIdentification.getTaxonIdentifications() != null
&& !acceptedIdentification.getTaxonIdentifications().isEmpty()) {
return acceptedIdentification.getTaxonIdentifications().get(0).getDwcScientificName();
if (acceptedIdentification.getTaxonIdentifications().get(0)
.getDwcScientificName() != null) {
return acceptedIdentification.getTaxonIdentifications().get(0)
.getDwcScientificName();
}
if (acceptedIdentification.getTaxonIdentifications().get(0)
.getDwcVernacularName() != null) {
return acceptedIdentification.getTaxonIdentifications().get(0)
.getDwcVernacularName();
}
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 VerbatimLabel extends Term {

public static final String TERM = DWC_PREFIX + "verbatimLabel";
private final List<String> dwcaTerms = List.of(TERM);
private final List<String> abcdUnitTerms = List.of(
"abcd:specimenUnit/marks/mark/0/markText/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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ private boolean isNameMatch(Identifications identification, JsonNode node) {
}
}

private void setAdditionalIdentificationInfo(Identifications identification, JsonNode typeDesignationNodes) {
identification.setTypeDesignatedBy(new TypeDesignatedBy().retrieveFromABCD(typeDesignationNodes));
private void setAdditionalIdentificationInfo(Identifications identification,
JsonNode typeDesignationNodes) {
identification.setTypeDesignatedBy(
new TypeDesignatedBy().retrieveFromABCD(typeDesignationNodes));
identification.setDwcTypeStatus(new TypeStatus().retrieveFromABCD(typeDesignationNodes));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class IdentificationVerificationStatus extends Term {
@Override
public String retrieveFromDWCA(JsonNode unit) {
var result = super.searchJsonForTerm(unit, dwcaTerms);
if (result != null){
if (result != null) {
if (result.equals("1")) {
return Boolean.TRUE.toString();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class IdentifiedBy extends Term {

public static final String TERM = DWC_PREFIX + "identifiedBy";

private final List<String> dwcaTerms = List.of(TERM, "dwc:identifiedByID");
private final List<String> dwcaTerms = List.of(TERM);

private final List<String> abcdTerms = List.of("identifiers/identifier/0/personName/fullName");

Expand Down
Original file line number Diff line number Diff line change
@@ -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 IdentifiedById extends Term {

public static final String TERM = DWC_PREFIX + "identifiedById";

private final List<String> dwcaTerms = List.of(TERM);

@Override
public String retrieveFromDWCA(JsonNode unit) {
return super.searchJsonForTerm(unit, dwcaTerms);
}

@Override
public String getTerm() {
return TERM;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;

public class TypeDesignatedBy extends Term {

public static final String TERM = "typeDesignatedBy";

private final List<String> abcdTerms = List.of("verifier/fullName/value");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;

public class AcceptedNameUsage extends Term {

public static final String TERM = DWC_PREFIX + "acceptedNameUsage";

private final List<String> dwcaTerms = List.of(TERM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;

public class AcceptedNameUsageId extends Term {

public static final String TERM = DWC_PREFIX + "acceptedNameUsageId";

private final List<String> dwcaTerms = List.of(TERM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;

public class CultivarEpithet extends Term {

public static final String TERM = DWC_PREFIX + "cultivarEpithet";

private final List<String> dwcaTerms = List.of(TERM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;

public class GenericName extends Term {

public static final String TERM = DWC_PREFIX + "genericName";

private final List<String> dwcaTerms = List.of(TERM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;

public class OriginalNameUsage extends Term {

public static final String TERM = DWC_PREFIX + "originalNameUsage";

private final List<String> dwcaTerms = List.of(TERM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class ScientificName extends AbstractTaxonomy {

public static final String TERM = DWC_PREFIX + "scientificName";
private final List<String> dwcaTerms = List.of("dwc:scientificName");
private final List<String> dwcaTerms = List.of(TERM);
private final List<String> abcdTerms = List.of(
"result/taxonIdentified/scientificName/fullScientificNameString",
"result/mineralRockIdentified/classifiedName/fullScientificNameString",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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;

public class ScientificNameId extends Term {

public static final String TERM = DWC_PREFIX + "scientificNameID";
private final List<String> dwcaTerms = List.of(TERM);

@Override
public String retrieveFromDWCA(JsonNode unit) {
return super.searchJsonForTerm(unit, dwcaTerms);
}

@Override
public String getTerm() {
return TERM;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public String retrieveFromDWCA(JsonNode unit) {
public String retrieveFromABCD(JsonNode unit) {
return super.searchABCDSplitTerms(unit, abcdSplitTerms);
}

@Override
public String getTerm() {
return TERM;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public String retrieveFromDWCA(JsonNode unit) {
public String retrieveFromABCD(JsonNode unit) {
return super.searchABCDSplitTerms(unit, abcdSplitTerms);
}

@Override
public String getTerm() {
return TERM;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class TaxonRank extends AbstractTaxonomy {

public static final String TERM = DWC_PREFIX + "taxonRank";

private final List<String> dwcaTerms = List.of(TERM);
private final List<String> dwcaTerms = List.of(TERM, VerbatimTaxonRank.TERM);
private final List<String> abcdTerms = List.of(
"result/taxonIdentified/scientificName/nameAtomised/botanical/rank");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public String retrieveFromDWCA(JsonNode unit) {
public String retrieveFromABCD(JsonNode unit) {
return super.searchABCDSplitTerms(unit, abcdSplitTerms);
}

@Override
public String getTerm() {
return TERM;
Expand Down
Original file line number Diff line number Diff line change
@@ -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 VerbatimTaxonRank extends AbstractTaxonomy {

public static final String TERM = DWC_PREFIX + "verbatimTaxonRank";

private final List<String> dwcaTerms = List.of(TERM);
private final List<String> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class Locality extends Term {

public static final String TERM = DWC_PREFIX + "locality";

private final List<String> dwcaTerms = List.of(TERM, "dwc:verbatimLocality");
private final List<String> dwcaTerms = List.of(TERM, VerbatimLocality.TERM);
private final List<String> abcdTerms = List.of("abcd:gathering/localityText/value");

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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 LocationId extends Term {

public static final String TERM = DWC_PREFIX + "locationID";

private final List<String> dwcaTerms = List.of(TERM);

@Override
public String retrieveFromDWCA(JsonNode unit) {
return super.searchJsonForTerm(unit, dwcaTerms);
}

@Override
public String getTerm() {
return TERM;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ public class MaximumDepthInMeters extends Term {

public static final String TERM = DWC_PREFIX + "maximumDepthInMeters";

private final List<String> dwcaTerms = List.of(TERM);
private final List<String> dwcaTerms = List.of(TERM, VerbatimDepth.TERM);
private final List<String> abcdTerms = List.of(
"abcd:gathering/depth/measurementOrFactAtomised/upperValue/value");
"abcd:gathering/depth/measurementOrFactAtomised/upperValue/value",
"abcd:gathering/depth/measurementOrFactText/value");

@Override
public String retrieveFromDWCA(JsonNode unit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ public class MaximumElevationInMeters extends Term {

public static final String TERM = DWC_PREFIX + "maximumElevationInMeters";

private final List<String> dwcaTerms = List.of(TERM);
private final List<String> dwcaTerms = List.of(TERM, VerbatimElevation.TERM);
private final List<String> abcdTerms = List.of(
"abcd:gathering/altitude/measurementOrFactAtomised/upperValue/value", "abcd:gathering/altitude/measurementOrFactText/value");
"abcd:gathering/altitude/measurementOrFactAtomised/upperValue/value",
"abcd:gathering/altitude/measurementOrFactText/value");

@Override
public String retrieveFromDWCA(JsonNode unit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ public class MinimumDepthInMeters extends Term {

public static final String TERM = DWC_PREFIX + "minimumDepthInMeters";

private final List<String> dwcaTerms = List.of(TERM);
private final List<String> dwcaTerms = List.of(TERM, VerbatimDepth.TERM);
private final List<String> abcdTerms = List.of(
"abcd:gathering/depth/measurementOrFactAtomised/lowerValue/value");
"abcd:gathering/depth/measurementOrFactAtomised/lowerValue/value",
"abcd:gathering/depth/measurementOrFactText/value");

@Override
public String retrieveFromDWCA(JsonNode unit) {
Expand Down
Loading

0 comments on commit 0356a2f

Please sign in to comment.