Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add additional terms #59

Merged
merged 8 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@
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.RecordedById;
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.VerbatimLabel;
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;
Expand Down Expand Up @@ -83,6 +85,7 @@
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.ScientificNameId;
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;
Expand All @@ -93,6 +96,7 @@
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.Tribe;
import eu.dissco.core.translator.terms.specimen.identification.taxonomy.VerbatimTaxonRank;
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;
Expand All @@ -103,6 +107,7 @@
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.LocationId;
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;
Expand All @@ -112,6 +117,9 @@
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.VerbatimDepth;
import eu.dissco.core.translator.terms.specimen.location.VerbatimElevation;
import eu.dissco.core.translator.terms.specimen.location.VerbatimLocality;
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;
Expand All @@ -128,8 +136,14 @@
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.location.georeference.VerbatimCoordinateSystem;
import eu.dissco.core.translator.terms.specimen.location.georeference.VerbatimCoordinates;
import eu.dissco.core.translator.terms.specimen.location.georeference.VerbatimLatitude;
import eu.dissco.core.translator.terms.specimen.location.georeference.VerbatimLongitude;
import eu.dissco.core.translator.terms.specimen.location.georeference.VerbatimSRS;
import eu.dissco.core.translator.terms.specimen.occurence.Behavior;
import eu.dissco.core.translator.terms.specimen.occurence.Caste;
import eu.dissco.core.translator.terms.specimen.occurence.Day;
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;
Expand All @@ -139,18 +153,22 @@
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.LifeStage;
import eu.dissco.core.translator.terms.specimen.occurence.Month;
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.RecordNumber;
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.occurence.VerbatimEventDate;
import eu.dissco.core.translator.terms.specimen.occurence.Vitality;
import eu.dissco.core.translator.terms.specimen.occurence.Year;
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;
Expand Down Expand Up @@ -256,12 +274,14 @@ private DigitalSpecimen assembleDigitalSpecimenTerms(JsonNode data, boolean dwc)
.withDwcInstitutionName(
getInstitutionName(organisationId))
.withDwcRecordedBy(termMapper.retrieveTerm(new RecordedBy(), data, dwc))
.withDwcRecordedById(termMapper.retrieveTerm(new RecordedById(), 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))
.withDwcInformationWithheld(termMapper.retrieveTerm(new InformationWithheld(), data, dwc))
.withDwcVerbatimLabel(termMapper.retrieveTerm(new VerbatimLabel(), data, dwc))
.withDwcDataGeneralizations(termMapper.retrieveTerm(new DataGeneralizations(), data, dwc));
}

Expand All @@ -273,7 +293,8 @@ private String getInstitutionName(String organisationId) throws OrganisationExce
var wikidataId = organisationId.replace("https://www.wikidata.org/wiki/", "");
return institutionNameComponent.getWikiDataName(wikidataId);
} else {
throw new OrganisationException(organisationId + " is not a valid ror or wikidata identifier");
throw new OrganisationException(
organisationId + " is not a valid ror or wikidata identifier");
}
}

Expand Down Expand Up @@ -324,12 +345,14 @@ protected Identifications createIdentification(JsonNode data, boolean dwc) {
.withDwcTaxonID(termMapper.retrieveTerm(new TaxonId(), data, dwc))
.withDwcKingdom(termMapper.retrieveTerm(new Kingdom(), data, dwc))
.withDwcTaxonRank(termMapper.retrieveTerm(new TaxonRank(), data, dwc))
.withDwcVerbatimTaxonRank(termMapper.retrieveTerm(new VerbatimTaxonRank(), 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))
.withDwcScientificNameId(termMapper.retrieveTerm(new ScientificNameId(), data, dwc))
.withDwcNamePublishedInYear(termMapper.retrieveTerm(new NamePublishedInYear(), data, dwc))
.withDwcClass(termMapper.retrieveTerm(new Class(), data, dwc))
.withDwcFamily(termMapper.retrieveTerm(new Family(), data, dwc))
Expand Down Expand Up @@ -373,8 +396,14 @@ private List<Occurrences> assembleOccurrenceTerms(JsonNode data,
var georeference = new Georeference()
.withDwcDecimalLatitude(
parseToDouble(new DecimalLatitude(), data, dwc))
.withDwcVerbatimLatitude(termMapper.retrieveTerm(new VerbatimLatitude(), data, dwc))
.withDwcDecimalLongitude(parseToDouble(new DecimalLongitude(), data, dwc))
.withDwcVerbatimLongitude(termMapper.retrieveTerm(new VerbatimLongitude(), data, dwc))
.withDwcGeodeticDatum(termMapper.retrieveTerm(new GeodeticDatum(), data, dwc))
.withDwcVerbatimCoordinates(termMapper.retrieveTerm(new VerbatimCoordinates(), data, dwc))
.withDwcVerbatimCoordinateSystem(
termMapper.retrieveTerm(new VerbatimCoordinateSystem(), data, dwc))
.withDwcVerbatimSRS(termMapper.retrieveTerm(new VerbatimSRS(), data, dwc))
.withDwcGeoreferenceProtocol(termMapper.retrieveTerm(new GeoreferenceProtocol(), data, dwc))
.withDwcCoordinatePrecision(parseToDouble(new CoordinatePrecision(), data, dwc))
.withDwcCoordinateUncertaintyInMeters(
Expand Down Expand Up @@ -419,6 +448,7 @@ private List<Occurrences> assembleOccurrenceTerms(JsonNode data,
.withDwcGroup(termMapper.retrieveTerm(new Group(), data, dwc))
.withDwcMember(termMapper.retrieveTerm(new Member(), data, dwc));
var location = new eu.dissco.core.translator.schema.Location()
.withDwcLocationID(termMapper.retrieveTerm(new LocationId(), data, dwc))
.withDwcContinent(termMapper.retrieveTerm(new Continent(), data, dwc))
.withDwcCountry(termMapper.retrieveTerm(new Country(), data, dwc))
.withDwcCountryCode(termMapper.retrieveTerm(new CountryCode(), data, dwc))
Expand All @@ -427,6 +457,7 @@ private List<Occurrences> assembleOccurrenceTerms(JsonNode data,
.withDwcIslandGroup(termMapper.retrieveTerm(new IslandGroup(), data, dwc))
.withDwcMunicipality(termMapper.retrieveTerm(new Municipality(), data, dwc))
.withDwcLocality(termMapper.retrieveTerm(new Locality(), data, dwc))
.withDwcVerbatimLocality(termMapper.retrieveTerm(new VerbatimLocality(), data, dwc))
.withDwcStateProvince(termMapper.retrieveTerm(new StateProvince(), data, dwc))
.withDwcWaterBody(termMapper.retrieveTerm(new WaterBody(), data, dwc))
.withDwcHigherGeography(termMapper.retrieveTerm(new HigherGeography(), data, dwc))
Expand All @@ -438,6 +469,8 @@ private List<Occurrences> assembleOccurrenceTerms(JsonNode data,
.withDwcMinimumDistanceAboveSurfaceInMeters(
parseToDouble(new MinimumDistanceAboveSurfaceInMeters(), data, dwc))
.withDwcMinimumElevationInMeters(parseToDouble(new MinimumElevationInMeters(), data, dwc))
.withDwcVerbatimDepth(termMapper.retrieveTerm(new VerbatimDepth(), data, dwc))
.withDwcVerbatimElevation(termMapper.retrieveTerm(new VerbatimElevation(), data, dwc))
.withDwcVerticalDatum(termMapper.retrieveTerm(new VerticalDatum(), data, dwc))
.withDwcLocationAccordingTo(termMapper.retrieveTerm(new LocationAccordingTo(), data, dwc))
.withDwcLocationRemarks(termMapper.retrieveTerm(new LocationRemarks(), data, dwc))
Expand All @@ -447,13 +480,18 @@ private List<Occurrences> assembleOccurrenceTerms(JsonNode data,
var occurrence = new eu.dissco.core.translator.schema.Occurrences()
.withDwcFieldNumber(termMapper.retrieveTerm(new FieldNumber(), data, dwc))
.withDwcEventDate(termMapper.retrieveTerm(new EventDate(), data, dwc))
.withDwcVerbatimEventDate(termMapper.retrieveTerm(new VerbatimEventDate(), data, dwc))
.withDwcYear(parseToInteger(new Year(), data, dwc))
.withDwcMonth(parseToInteger(new Month(), data, dwc))
.withDwcDay(parseToInteger(new Day(), 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))
.withDwcRecordNumber(termMapper.retrieveTerm(new RecordNumber(), data, dwc))
.withDwcFieldNotes(termMapper.retrieveTerm(new FieldNotes(), data, dwc))
.withDwcHabitat(termMapper.retrieveTerm(new Habitat(), data, dwc))
.withDwcReproductiveCondition(
Expand Down
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
Loading
Loading