Skip to content

Commit

Permalink
Merge pull request #73 from DiSSCo/feature/add-chronometric-age
Browse files Browse the repository at this point in the history
Add mapping for chronometricAge
  • Loading branch information
samleeflang authored Nov 20, 2024
2 parents 40e8f17 + fb97254 commit 71264ad
Show file tree
Hide file tree
Showing 43 changed files with 1,368 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public enum AgentRoleType {
CREATOR("creator"),
IDENTIFIER("identifier"),
GEOREFERENCER("georeferencer"),
RIGHTS_OWNER("rights-owner");
RIGHTS_OWNER("rights-owner"),
CHRONOMETRIC_AGE_DETERMINER("chronometric-age-determiner"),;

private final String name;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package eu.dissco.core.translator.terms;

import static eu.dissco.core.translator.domain.AgentRoleType.CHRONOMETRIC_AGE_DETERMINER;
import static eu.dissco.core.translator.domain.AgentRoleType.COLLECTOR;
import static eu.dissco.core.translator.domain.AgentRoleType.CREATOR;
import static eu.dissco.core.translator.domain.AgentRoleType.GEOREFERENCER;
Expand All @@ -25,6 +26,7 @@
import eu.dissco.core.translator.exception.OrganisationException;
import eu.dissco.core.translator.exception.UnknownPhysicalSpecimenIdType;
import eu.dissco.core.translator.properties.FdoProperties;
import eu.dissco.core.translator.schema.ChronometricAge;
import eu.dissco.core.translator.schema.Citation;
import eu.dissco.core.translator.schema.DigitalMedia;
import eu.dissco.core.translator.schema.DigitalMedia.DctermsType;
Expand Down Expand Up @@ -102,6 +104,24 @@
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.chronometric.ChronometricAgeConversionProtocol;
import eu.dissco.core.translator.terms.specimen.chronometric.ChronometricAgeDeterminedBy;
import eu.dissco.core.translator.terms.specimen.chronometric.ChronometricAgeDeterminedDate;
import eu.dissco.core.translator.terms.specimen.chronometric.ChronometricAgeID;
import eu.dissco.core.translator.terms.specimen.chronometric.ChronometricAgeProtocol;
import eu.dissco.core.translator.terms.specimen.chronometric.ChronometricAgeReferences;
import eu.dissco.core.translator.terms.specimen.chronometric.ChronometricAgeRemarks;
import eu.dissco.core.translator.terms.specimen.chronometric.ChronometricAgeUncertaintyInYears;
import eu.dissco.core.translator.terms.specimen.chronometric.ChronometricAgeUncertaintyMethod;
import eu.dissco.core.translator.terms.specimen.chronometric.EarliestChronometricAge;
import eu.dissco.core.translator.terms.specimen.chronometric.EarliestChronometricAgeReferenceSystem;
import eu.dissco.core.translator.terms.specimen.chronometric.LatestChronometricAge;
import eu.dissco.core.translator.terms.specimen.chronometric.LatestChronometricAgeReferenceSystem;
import eu.dissco.core.translator.terms.specimen.chronometric.MaterialDated;
import eu.dissco.core.translator.terms.specimen.chronometric.MaterialDatedID;
import eu.dissco.core.translator.terms.specimen.chronometric.MaterialDatedRelationship;
import eu.dissco.core.translator.terms.specimen.chronometric.UncalibratedChronometricAge;
import eu.dissco.core.translator.terms.specimen.chronometric.VerbatimChronometricAge;
import eu.dissco.core.translator.terms.specimen.citation.BibliographicCitation;
import eu.dissco.core.translator.terms.specimen.citation.CitationDescription;
import eu.dissco.core.translator.terms.specimen.citation.Date;
Expand Down Expand Up @@ -260,6 +280,7 @@ public DigitalSpecimen assembleDigitalSpecimenTerm(JsonNode data, boolean dwc)
ds.withOdsHasIdentifiers(assembleIdentifiers(data));
ds.withOdsHasCitations(assembleSpecimenCitations(data, dwc));
ds.withOdsHasEntityRelationships(assembleDigitalSpecimenEntityRelationships(ds));
ds.withOdsHasChronometricAges(assembleChronometricAges(data, dwc));
setCalculatedFields(ds, data);
return ds;
}
Expand All @@ -281,6 +302,8 @@ private void setCalculatedFields(DigitalSpecimen ds, JsonNode data) {

protected abstract List<Identification> assembleIdentifications(JsonNode data, boolean dwc);

protected abstract List<ChronometricAge> assembleChronometricAges(JsonNode data, boolean dwc);

protected Citation createCitation(JsonNode data, boolean dwc) {
var citation = new Citation()
.withId(termMapper.retrieveTerm(new ReferenceIRI(), data, dwc))
Expand Down Expand Up @@ -397,6 +420,45 @@ private List<eu.dissco.core.translator.schema.Identifier> assembleIdentifiers(Js
return identifiers;
}

protected ChronometricAge createChronometricAge(JsonNode data, boolean dwc) {
var chronometricAge = new ChronometricAge()
.withChronoChronometricAgeConversionProtocol(
termMapper.retrieveTerm(new ChronometricAgeConversionProtocol(), data, dwc))
.withChronoChronometricAgeDeterminedDate(
termMapper.retrieveTerm(new ChronometricAgeDeterminedDate(), data, dwc))
.withChronoChronometricAgeID(termMapper.retrieveTerm(new ChronometricAgeID(), data, dwc))
.withChronoChronometricAgeReferences(
termMapper.retrieveTerm(new ChronometricAgeReferences(), data, dwc))
.withChronoChronometricAgeRemarks(
termMapper.retrieveTerm(new ChronometricAgeRemarks(), data, dwc))
.withChronoChronometricAgeUncertaintyInYears(
parseToInteger(new ChronometricAgeUncertaintyInYears(), data, dwc))
.withChronoChronometricAgeUncertaintyMethod(
termMapper.retrieveTerm(new ChronometricAgeUncertaintyMethod(), data, dwc))
.withChronoEarliestChronometricAge(parseToInteger(new EarliestChronometricAge(), data, dwc))
.withChronoEarliestChronometricAgeReferenceSystem(
termMapper.retrieveTerm(new EarliestChronometricAgeReferenceSystem(), data, dwc))
.withChronoLatestChronometricAge(parseToInteger(new LatestChronometricAge(), data, dwc))
.withChronoLatestChronometricAgeReferenceSystem(
termMapper.retrieveTerm(new LatestChronometricAgeReferenceSystem(), data, dwc))
.withChronoMaterialDated(termMapper.retrieveTerm(new MaterialDated(), data, dwc))
.withChronoMaterialDatedID(termMapper.retrieveTerm(new MaterialDatedID(), data, dwc))
.withChronoMaterialDatedRelationship(
termMapper.retrieveTerm(new MaterialDatedRelationship(), data, dwc))
.withChronoUncalibratedChronometricAge(
termMapper.retrieveTerm(new UncalibratedChronometricAge(), data, dwc))
.withChronoVerbatimChronometricAge(
termMapper.retrieveTerm(new VerbatimChronometricAge(), data, dwc))
.withChronoChronometricAgeProtocol(
termMapper.retrieveTerm(new ChronometricAgeProtocol(), data, dwc))
.withChronoVerbatimChronometricAge(
termMapper.retrieveTerm(new VerbatimChronometricAge(), data, dwc));
chronometricAge.setOdsHasAgents(addAgent(chronometricAge.getOdsHasAgents(),
termMapper.retrieveTerm(new ChronometricAgeDeterminedBy(), data, dwc), null,
CHRONOMETRIC_AGE_DETERMINER, SCHEMA_PERSON));
return chronometricAge;
}

protected Identification createIdentification(JsonNode data, boolean dwc) {
var taxonId = termMapper.retrieveTerm(new TaxonID(), data, dwc);
var mappedTaxonIdentification = new TaxonIdentification()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import eu.dissco.core.translator.component.OrganisationNameComponent;
import eu.dissco.core.translator.component.SourceSystemComponent;
import eu.dissco.core.translator.properties.FdoProperties;
import eu.dissco.core.translator.schema.ChronometricAge;
import eu.dissco.core.translator.schema.Citation;
import eu.dissco.core.translator.schema.DigitalSpecimen;
import eu.dissco.core.translator.schema.Identification;
Expand Down Expand Up @@ -82,6 +83,24 @@ protected List<Identification> assembleIdentifications(JsonNode data, boolean dw
return identifications;
}

@Override
protected List<ChronometricAge> assembleChronometricAges(JsonNode data, boolean dwc) {
var chronometricAges = new ArrayList<ChronometricAge>();
var iterateOverElements = true;
var count = 0;
while (iterateOverElements) {
var chronometricAgeNode = getSubJsonAbcd(data, count,
List.of("abcd-efg:earthScienceSpecimen:unitStratigraphicDetermination/radiometricDates/radiometricDate"));
if (!chronometricAgeNode.isEmpty()) {
chronometricAges.add(createChronometricAge(chronometricAgeNode, dwc));
count++;
} else {
iterateOverElements = false;
}
}
return chronometricAges;
}

private ArrayList<Citation> getCitations(JsonNode data, boolean dwc, String subPath) {
var citations = new ArrayList<Citation>();
var iterateOverElements = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import eu.dissco.core.translator.component.OrganisationNameComponent;
import eu.dissco.core.translator.component.SourceSystemComponent;
import eu.dissco.core.translator.properties.FdoProperties;
import eu.dissco.core.translator.schema.ChronometricAge;
import eu.dissco.core.translator.schema.Citation;
import eu.dissco.core.translator.schema.DigitalSpecimen;
import eu.dissco.core.translator.schema.Identification;
Expand Down Expand Up @@ -91,6 +92,20 @@ protected List<Identification> assembleIdentifications(JsonNode data, boolean dw
}
return mappedIdentifications;
}

@Override
protected List<ChronometricAge> assembleChronometricAges(JsonNode data, boolean dwc) {
var mappedChrono = new ArrayList<ChronometricAge>();
if (data.get(EXTENSION) != null
&& data.get(EXTENSION).get("http://rs.tdwg.org/chrono/terms/ChronometricAge") != null) {
var chronometricAges = data.get(EXTENSION).get("http://rs.tdwg.org/chrono/terms/ChronometricAge");
for (int i = 0; i < chronometricAges.size(); i++) {
var chronometricAge = chronometricAges.get(i);
mappedChrono.add(createChronometricAge(chronometricAge, dwc));
}
}
return mappedChrono;
}
}


1 change: 1 addition & 0 deletions src/main/java/eu/dissco/core/translator/terms/Term.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ 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 CHRONO_PREFIX = "chrono:";
protected static final Pair<String, String> ABCD_NAMED_AREA_KEY =
Pair.of(
"abcd:gathering/namedAreas/namedArea/",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package eu.dissco.core.translator.terms.specimen.chronometric;

import com.fasterxml.jackson.databind.JsonNode;
import eu.dissco.core.translator.terms.Term;
import java.util.List;

public class ChronometricAgeConversionProtocol extends Term {

public static final String TERM = CHRONO_PREFIX + "chronometricAgeConversionProtocol";

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
@@ -0,0 +1,22 @@
package eu.dissco.core.translator.terms.specimen.chronometric;

import com.fasterxml.jackson.databind.JsonNode;
import eu.dissco.core.translator.terms.Term;
import java.util.List;

public class ChronometricAgeDeterminedBy extends Term {

public static final String TERM = CHRONO_PREFIX + "chronometricAgeDeterminedBy";

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
@@ -0,0 +1,28 @@
package eu.dissco.core.translator.terms.specimen.chronometric;

import com.fasterxml.jackson.databind.JsonNode;
import eu.dissco.core.translator.terms.Term;
import java.util.List;

public class ChronometricAgeDeterminedDate extends Term {

public static final String TERM = CHRONO_PREFIX + "chronometricAgeDeterminedDate";
private final List<String> abcdTerms = List.of("analysisDateTime/exactDate/dateText",
"analysisDateTime/dateText");
private final List<String> dwcaTerms = List.of(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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package eu.dissco.core.translator.terms.specimen.chronometric;

import com.fasterxml.jackson.databind.JsonNode;
import eu.dissco.core.translator.terms.Term;
import java.util.List;

public class ChronometricAgeID extends Term {

public static final String TERM = CHRONO_PREFIX + "chronometricAgeID";

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
@@ -0,0 +1,28 @@
package eu.dissco.core.translator.terms.specimen.chronometric;

import com.fasterxml.jackson.databind.JsonNode;
import eu.dissco.core.translator.terms.Term;
import java.util.List;

public class ChronometricAgeProtocol extends Term {

public static final String TERM = CHRONO_PREFIX + "chronometricAgeProtocol";

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

@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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package eu.dissco.core.translator.terms.specimen.chronometric;

import com.fasterxml.jackson.databind.JsonNode;
import eu.dissco.core.translator.terms.Term;
import java.util.List;

public class ChronometricAgeReferences extends Term {

public static final String TERM = CHRONO_PREFIX + "chronometricAgeReferences";

private final List<String> dwcaTerms = List.of(TERM);
private final List<String> abcdTerms = List.of("analysisReferences/uri",
"analysisReferences/titleCitation", "analysisReferences/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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package eu.dissco.core.translator.terms.specimen.chronometric;

import com.fasterxml.jackson.databind.JsonNode;
import eu.dissco.core.translator.terms.Term;
import java.util.List;

public class ChronometricAgeRemarks extends Term {

public static final String TERM = CHRONO_PREFIX + "chronometricAgeRemarks";

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

@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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package eu.dissco.core.translator.terms.specimen.chronometric;

import com.fasterxml.jackson.databind.JsonNode;
import eu.dissco.core.translator.terms.Term;
import java.util.List;

public class ChronometricAgeUncertaintyInYears extends Term {

public static final String TERM = CHRONO_PREFIX + "chronometricAgeUncertaintyInYears";

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;
}
}
Loading

0 comments on commit 71264ad

Please sign in to comment.