Skip to content

Commit

Permalink
Merge pull request #373 from gaiaresources/BDRSPS-1131
Browse files Browse the repository at this point in the history
BDRSPS-1131 Make datatype attributions named nodes in metadata mapping
  • Loading branch information
serge-gaia authored Dec 18, 2024
2 parents dc3ce67 + 8ba2a14 commit 456d013
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 26 deletions.
34 changes: 16 additions & 18 deletions abis_mapping/templates/survey_metadata_v3/examples/minimal.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,11 @@

<https://linked.data.gov.au/dataset/bdr/datatypes/surveyID/CSIRO> a rdfs:Datatype ;
skos:prefLabel "surveyID source" ;
prov:qualifiedAttribution [ a prov:Attribution ;
prov:agent <https://linked.data.gov.au/dataset/bdr/orgs/CSIRO> ;
prov:hadRole <https://linked.data.gov.au/def/data-roles/principalInvestigator> ],
[ a prov:Attribution ;
prov:agent <https://linked.data.gov.au/dataset/bdr/orgs/CSIRO> ;
prov:hadRole <https://linked.data.gov.au/def/data-roles/principalInvestigator> ] .
prov:qualifiedAttribution <https://linked.data.gov.au/dataset/bdr/00000000-0000-0000-0000-000000000000/attribution/CSIRO/principalInvestigator> .

<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 <https://linked.data.gov.au/dataset/bdr/orgs/NSW-Department-of-Planning-Industry-and-Environment> ;
prov:hadRole <https://linked.data.gov.au/def/data-roles/principalInvestigator> ],
[ a prov:Attribution ;
prov:agent <https://linked.data.gov.au/dataset/bdr/orgs/NSW-Department-of-Planning-Industry-and-Environment> ;
prov:hadRole <https://linked.data.gov.au/def/data-roles/principalInvestigator> ] .
prov:qualifiedAttribution <https://linked.data.gov.au/dataset/bdr/00000000-0000-0000-0000-000000000000/attribution/NSW-Department-of-Planning-Industry-and-Environment/principalInvestigator> .

<https://linked.data.gov.au/dataset/bdr/00000000-0000-0000-0000-000000000000/attribute/surveyType/Wet-pitfall-trapping> a tern:Attribute ;
schema:isPartOf <https://linked.data.gov.au/dataset/bdr/00000000-0000-0000-0000-000000000000> ;
Expand All @@ -92,6 +82,14 @@
tern:hasSimpleValue "Insecta" ;
tern:hasValue <https://linked.data.gov.au/dataset/bdr/00000000-0000-0000-0000-000000000000/value/targetTaxonomicScope/Insecta> .

<https://linked.data.gov.au/dataset/bdr/00000000-0000-0000-0000-000000000000/attribution/CSIRO/principalInvestigator> a prov:Attribution ;
prov:agent <https://linked.data.gov.au/dataset/bdr/orgs/CSIRO> ;
prov:hadRole <https://linked.data.gov.au/def/data-roles/principalInvestigator> .

<https://linked.data.gov.au/dataset/bdr/00000000-0000-0000-0000-000000000000/attribution/NSW-Department-of-Planning-Industry-and-Environment/principalInvestigator> a prov:Attribution ;
prov:agent <https://linked.data.gov.au/dataset/bdr/orgs/NSW-Department-of-Planning-Industry-and-Environment> ;
prov:hadRole <https://linked.data.gov.au/def/data-roles/principalInvestigator> .

<https://linked.data.gov.au/dataset/bdr/00000000-0000-0000-0000-000000000000/bdr-cv/attribute/targetTaxonomicScope/Coleoptera> a skos:Concept ;
skos:broader <https://linked.data.gov.au/def/nrm/7ea12fed-6b87-4c20-9ab4-600b32ce15ec> ;
skos:definition "A type of targetTaxonomicScope" ;
Expand Down Expand Up @@ -126,6 +124,12 @@
rdfs:label "Insecta" ;
rdf:value <https://linked.data.gov.au/dataset/bdr/00000000-0000-0000-0000-000000000000/bdr-cv/attribute/targetTaxonomicScope/Insecta> .

<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" .

<https://linked.data.gov.au/dataset/bdr/00000000-0000-0000-0000-000000000000/Survey/COL1> a tern:Survey ;
bdr:purpose "Summer sampling for peak insect diversity." ;
bdr:target "Coleoptera",
Expand Down Expand Up @@ -172,12 +176,6 @@
"woodland" ;
schema:name "Disentangling the effects of farmland use, habitat edges, and vegetation structure on ground beetle morphological traits - Winter" .

<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" .

<https://linked.data.gov.au/dataset/bdr/00000000-0000-0000-0000-000000000000/survey/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." ;
Expand Down
32 changes: 25 additions & 7 deletions abis_mapping/templates/survey_metadata_v3/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class SurveyIDDatatype:

name: str
datatype: rdflib.URIRef
attribution: rdflib.URIRef
agent: rdflib.URIRef


Expand Down Expand Up @@ -222,6 +223,7 @@ def apply_mapping_row(
SurveyIDDatatype(
name=raw_org,
datatype=utils.iri_patterns.datatype_iri("surveyID", raw_org),
attribution=utils.iri_patterns.attribution_iri(base_iri, "principalInvestigator", raw_org),
agent=utils.iri_patterns.agent_iri(raw_org),
)
)
Expand Down Expand Up @@ -262,7 +264,15 @@ def apply_mapping_row(
# Add survey ID source datatype nodes
self.add_survey_id_source_datatypes(
uri=so_obj.datatype,
attribution=so_obj.attribution,
graph=graph,
)

# Add attribution
self.add_attribution(
uri=so_obj.attribution,
agent=so_obj.agent,
role=PRINCIPAL_INVESTIGATOR,
graph=graph,
)

Expand Down Expand Up @@ -541,29 +551,37 @@ def add_temporal_coverage(
def add_survey_id_source_datatypes(
self,
uri: rdflib.URIRef,
agent: rdflib.URIRef,
attribution: rdflib.URIRef,
graph: rdflib.Graph,
) -> None:
"""Adds the source datatype nodes to graph.
Args:
uri (rdflib.URIRef): The reference uri.
agent (rdflib.URIRef): Agent uri.
attribution (rdflib.URIRef): Attribution uri.
graph (rdflib.Graph): Graph to be modified.
"""
# Add type
graph.add((uri, a, rdflib.RDFS.Datatype))

# Add label
graph.add((uri, rdflib.SKOS.prefLabel, rdflib.Literal("surveyID source")))

# Add attribution
attribution = rdflib.BNode()
graph.add((attribution, a, rdflib.PROV.Attribution))
graph.add((attribution, rdflib.PROV.agent, agent))
graph.add((attribution, rdflib.PROV.hadRole, PRINCIPAL_INVESTIGATOR))
graph.add((uri, rdflib.PROV.qualifiedAttribution, attribution))

def add_attribution(
self,
uri: rdflib.URIRef,
agent: rdflib.URIRef,
role: rdflib.URIRef,
graph: rdflib.Graph,
) -> None:
"""Add the prov:Attribution nodes to the graph."""
# Add attribution
graph.add((uri, a, rdflib.PROV.Attribution))
graph.add((uri, rdflib.PROV.agent, agent))
graph.add((uri, rdflib.PROV.hadRole, role))

def add_agent(
self,
uri: rdflib.URIRef,
Expand Down
2 changes: 1 addition & 1 deletion abis_mapping/utils/iri_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def plan_iri(

def attribution_iri(
base_iri: rdflib.Namespace,
role: Literal["resourceProvider", "owner", "rightsHolder", "creator"],
role: Literal["resourceProvider", "owner", "rightsHolder", "creator", "principalInvestigator"],
source: str,
) -> rdflib.URIRef:
"""Get the IRI to use for a prov:Attribution node.
Expand Down

0 comments on commit 456d013

Please sign in to comment.