diff --git a/abis_mapping/templates/survey_metadata_v3/examples/minimal.ttl b/abis_mapping/templates/survey_metadata_v3/examples/minimal.ttl index d72779ec..50595256 100644 --- a/abis_mapping/templates/survey_metadata_v3/examples/minimal.ttl +++ b/abis_mapping/templates/survey_metadata_v3/examples/minimal.ttl @@ -52,21 +52,11 @@ a rdfs:Datatype ; skos:prefLabel "surveyID source" ; - prov:qualifiedAttribution [ a prov:Attribution ; - prov:agent ; - prov:hadRole ], - [ a prov:Attribution ; - prov:agent ; - prov:hadRole ] . + prov:qualifiedAttribution . a rdfs:Datatype ; skos:prefLabel "surveyID source" ; - prov:qualifiedAttribution [ a prov:Attribution ; - prov:agent ; - prov:hadRole ], - [ a prov:Attribution ; - prov:agent ; - prov:hadRole ] . + prov:qualifiedAttribution . a tern:Attribute ; schema:isPartOf ; @@ -92,6 +82,14 @@ tern:hasSimpleValue "Insecta" ; tern:hasValue . + a prov:Attribution ; + prov:agent ; + prov:hadRole . + + a prov:Attribution ; + prov:agent ; + prov:hadRole . + a skos:Concept ; skos:broader ; skos:definition "A type of targetTaxonomicScope" ; @@ -126,6 +124,12 @@ rdfs:label "Insecta" ; rdf:value . + a prov:Agent ; + schema:name "CSIRO" . + + a prov:Agent ; + schema:name "NSW Department of Planning, Industry and Environment" . + a tern:Survey ; bdr:purpose "Summer sampling for peak insect diversity." ; bdr:target "Coleoptera", @@ -172,12 +176,6 @@ "woodland" ; schema:name "Disentangling the effects of farmland use, habitat edges, and vegetation structure on ground beetle morphological traits - Winter" . - a prov:Agent ; - schema:name "CSIRO" . - - a prov:Agent ; - schema:name "NSW Department of Planning, Industry and Environment" . - 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." ; diff --git a/abis_mapping/templates/survey_metadata_v3/mapping.py b/abis_mapping/templates/survey_metadata_v3/mapping.py index f17ee45b..fb34902a 100644 --- a/abis_mapping/templates/survey_metadata_v3/mapping.py +++ b/abis_mapping/templates/survey_metadata_v3/mapping.py @@ -35,6 +35,7 @@ class SurveyIDDatatype: name: str datatype: rdflib.URIRef + attribution: rdflib.URIRef agent: rdflib.URIRef @@ -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), ) ) @@ -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, ) @@ -541,14 +551,14 @@ 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 @@ -556,14 +566,22 @@ def add_survey_id_source_datatypes( # 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, diff --git a/abis_mapping/utils/iri_patterns.py b/abis_mapping/utils/iri_patterns.py index 9ce5e719..0c093547 100644 --- a/abis_mapping/utils/iri_patterns.py +++ b/abis_mapping/utils/iri_patterns.py @@ -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.