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

BDRSPS-966: Part1: Update IRIs appearing in survey metadata v2 RDF #304

Merged
merged 8 commits into from
Nov 8, 2024
116 changes: 58 additions & 58 deletions abis_mapping/templates/survey_metadata_v2/examples/minimal.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -10,58 +10,76 @@
@prefix void: <http://rdfs.org/ns/void#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/SurveyCollection/surveyType/Wet-pitfall-trapping> a schema:Collection ;
<http://createme.org/SurveyCollection/surveyType/Wet-pitfall-trapping> a schema:Collection ;
void:inDataset <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset> ;
schema:identifier "Survey Collection - Survey Type - Wet pitfall trapping" ;
schema:member <http://createme.org/survey/SSD-survey/1/plan> ;
tern:hasAttribute <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/attribute/surveyType/Wet-pitfall-trapping> .
schema:member <http://createme.org/Plan/COL1> ;
tern:hasAttribute <http://createme.org/attribute/surveyType/Wet-pitfall-trapping> .

<http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/SurveyCollection/targetHabitatScope/Woodland> a schema:Collection ;
<http://createme.org/SurveyCollection/targetHabitatScope/Woodland> a schema:Collection ;
void:inDataset <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset> ;
schema:identifier "Survey Collection - Target Habitat Scope - Woodland" ;
schema:member <http://createme.org/survey/SSD-survey/1/plan> ;
tern:hasAttribute <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/attribute/targetHabitatScope/Woodland> .
schema:member <http://createme.org/Plan/COL1> ;
tern:hasAttribute <http://createme.org/attribute/targetHabitatScope/Woodland> .

<http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/SurveyCollection/targetTaxonomicScope/Coleoptera> a schema:Collection ;
<http://createme.org/SurveyCollection/targetTaxonomicScope/Coleoptera> a schema:Collection ;
void:inDataset <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset> ;
schema:identifier "Survey Collection - Target Taxonomic Scope - Coleoptera" ;
schema:member <http://createme.org/survey/SSD-survey/1/plan> ;
tern:hasAttribute <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/attribute/targetTaxonomicScope/Coleoptera> .
schema:member <http://createme.org/Plan/COL1> ;
tern:hasAttribute <http://createme.org/attribute/targetTaxonomicScope/Coleoptera> .

<http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/SurveyCollection/targetTaxonomicScope/Insecta> a schema:Collection ;
<http://createme.org/SurveyCollection/targetTaxonomicScope/Insecta> a schema:Collection ;
void:inDataset <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset> ;
schema:identifier "Survey Collection - Target Taxonomic Scope - Insecta" ;
schema:member <http://createme.org/survey/SSD-survey/1/plan> ;
tern:hasAttribute <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/attribute/targetTaxonomicScope/Insecta> .
schema:member <http://createme.org/Plan/COL1> ;
tern:hasAttribute <http://createme.org/attribute/targetTaxonomicScope/Insecta> .

<http://createme.org/datatype/datasetID/Gaia-Resources> a rdfs:Datatype ;
skos:definition "An identifier for the dataset" ;
skos:prefLabel "Gaia Resources datasetID" ;
prov:wasAttributedTo <http://createme.org/provider/Gaia-Resources> .

<http://createme.org/datatype/surveyID/CSIRO> a rdfs:Datatype ;
<http://createme.org/project/SSD-Survey-Project/1> a bdr:Project ;
void:inDataset <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset> ;
schema:hasPart <http://createme.org/Survey/COL1> ;
schema:identifier "COL1" ;
schema:name "Disentangling the effects of farmland use, habitat edges, and vegetation structure on ground beetle morphological traits - Summer" .

<https://linked.data.gov.au/dataset/bdr/datatypes/surveyID/CSIRO> a rdfs:Datatype ;
skos:prefLabel "surveyID source" ;
prov:qualifiedAttribution [ a prov:Attribution ;
prov:agent <http://createme.org/agent/CSIRO> ;
prov:agent <https://linked.data.gov.au/dataset/bdr/orgs/CSIRO> ;
prov:hadRole <http://def.isotc211.org/iso19115/-1/2018/CitationAndResponsiblePartyInformation/code/CI_RoleCode/principalInvestigator> ] .

<http://createme.org/datatype/surveyID/NSW-Department-of-Planning-Industry-and-Environment> a rdfs:Datatype ;
<https://linked.data.gov.au/dataset/bdr/datatypes/surveyID/NSW-Department-of-Planning-Industry-and-Environment> a rdfs:Datatype ;
skos:prefLabel "surveyID source" ;
prov:qualifiedAttribution [ a prov:Attribution ;
prov:agent <http://createme.org/agent/NSW-Department-of-Planning-Industry-and-Environment> ;
prov:agent <https://linked.data.gov.au/dataset/bdr/orgs/NSW-Department-of-Planning-Industry-and-Environment> ;
prov:hadRole <http://def.isotc211.org/iso19115/-1/2018/CitationAndResponsiblePartyInformation/code/CI_RoleCode/principalInvestigator> ] .

<http://createme.org/project/SSD-Survey-Project/1> a bdr:Project ;
<http://createme.org/attribute/surveyType/Wet-pitfall-trapping> a tern:Attribute ;
void:inDataset <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset> ;
schema:hasPart <http://createme.org/survey/COL1> ;
schema:identifier "COL1" ;
schema:name "Disentangling the effects of farmland use, habitat edges, and vegetation structure on ground beetle morphological traits - Summer" .
tern:attribute <http://example.com/concept/surveyType> ;
tern:hasSimpleValue "Wet pitfall trapping" ;
tern:hasValue <http://createme.org/value/surveyType/Wet-pitfall-trapping> .

<http://createme.org/agent/CSIRO> a prov:Agent ;
schema:name "CSIRO" .
<http://createme.org/attribute/targetHabitatScope/Woodland> a tern:Attribute ;
void:inDataset <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset> ;
tern:attribute <https://linked.data.gov.au/def/nrm/ae2c88be-63d5-44d3-95ac-54b14c4a4b28> ;
tern:hasSimpleValue "Woodland" ;
tern:hasValue <http://createme.org/value/targetHabitatScope/Woodland> .

<http://createme.org/agent/NSW-Department-of-Planning-Industry-and-Environment> a prov:Agent ;
schema:name "NSW Department of Planning, Industry and Environment" .
<http://createme.org/attribute/targetTaxonomicScope/Coleoptera> a tern:Attribute ;
void:inDataset <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset> ;
tern:attribute <https://linked.data.gov.au/def/nrm/7ea12fed-6b87-4c20-9ab4-600b32ce15ec> ;
tern:hasSimpleValue "Coleoptera" ;
tern:hasValue <http://createme.org/value/targetTaxonomicScope/Coleoptera> .

<http://createme.org/attribute/targetTaxonomicScope/Insecta> a tern:Attribute ;
void:inDataset <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset> ;
tern:attribute <https://linked.data.gov.au/def/nrm/7ea12fed-6b87-4c20-9ab4-600b32ce15ec> ;
tern:hasSimpleValue "Insecta" ;
tern:hasValue <http://createme.org/value/targetTaxonomicScope/Insecta> .

<http://createme.org/bdr-cv/attribute/targetTaxonomicScope/Coleoptera> a skos:Concept ;
skos:broader <https://linked.data.gov.au/def/nrm/7ea12fed-6b87-4c20-9ab4-600b32ce15ec> ;
Expand All @@ -77,51 +95,33 @@
skos:prefLabel "Insecta" ;
schema:citation "http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset"^^xsd:anyURI .

<http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/attribute/surveyType/Wet-pitfall-trapping> a tern:Attribute ;
void:inDataset <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset> ;
tern:attribute <http://example.com/concept/surveyType> ;
tern:hasSimpleValue "Wet pitfall trapping" ;
tern:hasValue <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/value/surveyType/Wet-pitfall-trapping> .

<http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/attribute/targetHabitatScope/Woodland> a tern:Attribute ;
void:inDataset <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset> ;
tern:attribute <https://linked.data.gov.au/def/nrm/ae2c88be-63d5-44d3-95ac-54b14c4a4b28> ;
tern:hasSimpleValue "Woodland" ;
tern:hasValue <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/value/targetHabitatScope/Woodland> .

<http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/attribute/targetTaxonomicScope/Coleoptera> a tern:Attribute ;
void:inDataset <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset> ;
tern:attribute <https://linked.data.gov.au/def/nrm/7ea12fed-6b87-4c20-9ab4-600b32ce15ec> ;
tern:hasSimpleValue "Coleoptera" ;
tern:hasValue <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/value/targetTaxonomicScope/Coleoptera> .

<http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/attribute/targetTaxonomicScope/Insecta> a tern:Attribute ;
void:inDataset <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset> ;
tern:attribute <https://linked.data.gov.au/def/nrm/7ea12fed-6b87-4c20-9ab4-600b32ce15ec> ;
tern:hasSimpleValue "Insecta" ;
tern:hasValue <http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/value/targetTaxonomicScope/Insecta> .

<http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/value/surveyType/Wet-pitfall-trapping> a tern:IRI,
<http://createme.org/value/surveyType/Wet-pitfall-trapping> a tern:IRI,
tern:Value ;
rdfs:label "Wet pitfall trapping" ;
rdf:value <https://linked.data.gov.au/def/nrm/054145e7-137d-50c5-a750-d85a47e81fad> .

<http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/value/targetHabitatScope/Woodland> a tern:IRI,
<http://createme.org/value/targetHabitatScope/Woodland> a tern:IRI,
tern:Value ;
rdfs:label "Woodland" ;
rdf:value <https://linked.data.gov.au/def/nrm/e2193542-9203-532b-99d3-853a4640114d> .

<http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/value/targetTaxonomicScope/Coleoptera> a tern:IRI,
<http://createme.org/value/targetTaxonomicScope/Coleoptera> a tern:IRI,
tern:Value ;
rdfs:label "Coleoptera" ;
rdf:value <http://createme.org/bdr-cv/attribute/targetTaxonomicScope/Coleoptera> .

<http://createme.org/dataset/Example-Systematic-Survey-Metadata-Dataset/value/targetTaxonomicScope/Insecta> a tern:IRI,
<http://createme.org/value/targetTaxonomicScope/Insecta> a tern:IRI,
tern:Value ;
rdfs:label "Insecta" ;
rdf:value <http://createme.org/bdr-cv/attribute/targetTaxonomicScope/Insecta> .

<http://createme.org/survey/COL1> a tern:Survey ;
<https://linked.data.gov.au/dataset/bdr/orgs/CSIRO> a prov:Agent ;
schema:name "CSIRO" .

<https://linked.data.gov.au/dataset/bdr/orgs/NSW-Department-of-Planning-Industry-and-Environment> a prov:Agent ;
schema:name "NSW Department of Planning, Industry and Environment" .

<http://createme.org/Survey/COL1> a tern:Survey ;
bdr:purpose "Summer sampling for peak insect diversity." ;
bdr:target "Coleoptera",
"Insecta" ;
Expand All @@ -131,9 +131,9 @@
time:inXSDDate "2015-01-21"^^xsd:date ] ;
time:hasEnd [ a time:Instant ;
time:inXSDDate "2015-02-03"^^xsd:date ] ] ;
prov:hadPlan <http://createme.org/survey/SSD-survey/1/plan> ;
schema:identifier "COL1"^^<http://createme.org/datatype/surveyID/CSIRO>,
"COL1"^^<http://createme.org/datatype/surveyID/NSW-Department-of-Planning-Industry-and-Environment> ;
prov:hadPlan <http://createme.org/Plan/COL1> ;
schema:identifier "COL1"^^<https://linked.data.gov.au/dataset/bdr/datatypes/surveyID/CSIRO>,
"COL1"^^<https://linked.data.gov.au/dataset/bdr/datatypes/surveyID/NSW-Department-of-Planning-Industry-and-Environment> ;
schema:keywords "farmland",
"ground beetle",
"habitat",
Expand All @@ -144,7 +144,7 @@
"woodland" ;
schema:name "Disentangling the effects of farmland use, habitat edges, and vegetation structure on ground beetle morphological traits - Summer" .

<http://createme.org/survey/SSD-survey/1/plan> a prov:Plan ;
<http://createme.org/Plan/COL1> a prov:Plan ;
schema:citation "Ng, K., Barton, P.S., Blanchard, W. et al. Disentangling the effects of farmland use, habitat edges, and vegetation structure on ground beetle morphological traits. Oecologia 188, 645–657 (2018). https://doi.org/10.1007/s00442-018-4180-9\"" ;
schema:description "Our experimental design consisted of four 400 m transects running from inside each woodland patch out into four adjoining farmland uses (crop, rested, woody debris application, revegetation plantings). To quantify potential edge efects on beetle species traits, we sampled beetles at five locations along each transect: 200 and 20 m inside woodlands, 200 and 20 m inside farmlands, and at the woodland–farmland edge (0 m). Each sampling location comprised a pair of wet invertebrate pitfall traps. separated by a drift fence (60 cm long x 10 cm high) to help direct arthropods into traps. We opened a total of 220 pairs of traps for 14 days during spring (Oct–Nov 2014), and repeated sampling during summer (January–February 2015). Beetle samples from each pitfall trap pair, and across the two time periods, were pooled to provide one sample per sampling location." ;
schema:url "https://biocollect.ala.org.au/document/download/2022-01/202201%20CBR%20Flora%20and%20Vegetation%20report_draftv1.pdf"^^xsd:anyURI,
Expand All @@ -161,7 +161,7 @@
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/7844> POLYGON ((-33.826 146.363, -33.826 148.499, -34.411 148.499, -33.826 146.363))"^^geo:wktLiteral ] ;
rdf:object _:N52d3d4f338b894a95032d27200000000 ;
rdf:predicate geo:hasGeometry ;
rdf:subject <http://createme.org/survey/COL1> ;
rdf:subject <http://createme.org/Survey/COL1> ;
rdfs:comment "supplied as" .

_:N52d3d4f338b894a95032d27200000000 a geo:Geometry ;
Expand Down
41 changes: 23 additions & 18 deletions abis_mapping/templates/survey_metadata_v2/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

# Standard
import dataclasses
import urllib.parse
Lincoln-GR marked this conversation as resolved.
Show resolved Hide resolved

# Third-party
import frictionless
Expand Down Expand Up @@ -193,19 +192,25 @@ def apply_mapping_row(
# Create BDR project IRI
project = utils.rdf.uri(f"project/SSD-Survey-Project/{row_num}", base_iri)

# Create TERN survey IRI - Note this needs to match the iri construction of the
# survey occurrence and site vist template mapping, ensuring they will resolve properly.
survey = utils.rdf.uri("survey/", base_iri) + urllib.parse.quote(row["surveyID"], safe="")
# Create TERN survey IRI from surveyID field
survey_id: str | None = row["surveyID"]
survey = utils.iri_patterns.survey_iri(base_iri, survey_id)

# Create survey plan IRI
survey_plan = utils.rdf.uri(f"survey/SSD-survey/{row_num}/plan")
survey_plan = utils.rdf.uri_quoted(
base_iri,
"Plan/{survey_id}",
survey_id=(survey_id or str(row_num)), # fallback to row number when surveyID not available.
)

# Conditionally create survey type attribute, value and collection IRIs
row_survey_type: str | None = row["surveyType"]
if row_survey_type:
survey_type_attribute = utils.rdf.extend_uri(dataset, "attribute", "surveyType", row_survey_type)
survey_type_value = utils.rdf.extend_uri(dataset, "value", "surveyType", row_survey_type)
survey_type_collection = utils.rdf.extend_uri(dataset, "SurveyCollection", "surveyType", row_survey_type)
survey_type_attribute = utils.iri_patterns.attribute_iri(base_iri, "surveyType", row_survey_type)
survey_type_value = utils.iri_patterns.attribute_value_iri(base_iri, "surveyType", row_survey_type)
survey_type_collection = utils.iri_patterns.attribute_collection_iri(
base_iri, "Survey", "surveyType", row_survey_type
)
else:
survey_type_attribute = None
survey_type_value = None
Expand All @@ -218,10 +223,10 @@ def apply_mapping_row(
target_habitat_objects.append(
AttributeValue(
raw=target_habitat,
attribute=utils.rdf.extend_uri(dataset, "attribute", "targetHabitatScope", target_habitat),
value=utils.rdf.extend_uri(dataset, "value", "targetHabitatScope", target_habitat),
collection=utils.rdf.extend_uri(
dataset, "SurveyCollection", "targetHabitatScope", target_habitat
attribute=utils.iri_patterns.attribute_iri(base_iri, "targetHabitatScope", target_habitat),
value=utils.iri_patterns.attribute_value_iri(base_iri, "targetHabitatScope", target_habitat),
collection=utils.iri_patterns.attribute_collection_iri(
base_iri, "Survey", "targetHabitatScope", target_habitat
),
),
)
Expand All @@ -233,10 +238,10 @@ def apply_mapping_row(
target_taxonomic_objects.append(
AttributeValue(
raw=target_taxon,
attribute=utils.rdf.extend_uri(dataset, "attribute", "targetTaxonomicScope", target_taxon),
value=utils.rdf.extend_uri(dataset, "value", "targetTaxonomicScope", target_taxon),
collection=utils.rdf.extend_uri(
dataset, "SurveyCollection", "targetTaxonomicScope", target_taxon
attribute=utils.iri_patterns.attribute_iri(base_iri, "targetTaxonomicScope", target_taxon),
value=utils.iri_patterns.attribute_value_iri(base_iri, "targetTaxonomicScope", target_taxon),
collection=utils.iri_patterns.attribute_collection_iri(
base_iri, "Survey", "targetTaxonomicScope", target_taxon
),
)
)
Expand All @@ -248,8 +253,8 @@ def apply_mapping_row(
survey_org_objects.append(
SurveyIDDatatype(
name=raw_org,
datatype=utils.rdf.uri(f"datatype/surveyID/{raw_org}", base_iri),
agent=utils.rdf.uri(f"agent/{raw_org}"),
datatype=utils.iri_patterns.datatype_iri("surveyID", raw_org),
agent=utils.iri_patterns.agent_iri(raw_org),
)
)

Expand Down
Loading