Skip to content

Commit

Permalink
Merge pull request #208 from gaiaresources/BDRSPS-813-rename-in-ttl
Browse files Browse the repository at this point in the history
BDRSPS-813 Incidental V3: Rename conservationJurisdiction to conservationAuthority in RDF output
  • Loading branch information
chungvl authored Sep 17, 2024
2 parents d501993 + fd271a7 commit 0df5d59
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@
rdfs:comment "Date unknown, template dateIdentified used as proxy" ;
time:inXSDDateTimeStamp "2019-09-27T12:34:00+08:00"^^xsd:dateTimeStamp ] ;
prov:wasAssociatedWith <http://createme.org/provider/WA-BIO> ;
prov:wasInfluencedBy <http://createme.org/attribute/conservationJurisdiction/15> ;
prov:wasInfluencedBy <http://createme.org/attribute/conservationAuthority/15> ;
sosa:hasFeatureOfInterest <http://createme.org/value/acceptedNameUsage/15> ;
sosa:hasResult <http://createme.org/value/threatStatus/15> ;
sosa:hasSimpleResult "VU" ;
Expand All @@ -528,7 +528,7 @@
time:hasTime [ a time:Instant ;
rdfs:comment "Date unknown, template dateIdentified used as proxy" ;
time:inXSDDateTimeStamp "2019-09-27T12:34:00+08:00"^^xsd:dateTimeStamp ] ;
prov:wasInfluencedBy <http://createme.org/attribute/conservationJurisdiction/16> ;
prov:wasInfluencedBy <http://createme.org/attribute/conservationAuthority/16> ;
sosa:hasFeatureOfInterest <http://createme.org/value/acceptedNameUsage/16> ;
sosa:hasResult <http://createme.org/value/threatStatus/16> ;
sosa:hasSimpleResult "new threat status" ;
Expand Down Expand Up @@ -739,17 +739,17 @@
tern:hasSimpleValue "new basis of record" ;
tern:hasValue <http://createme.org/value/basisOfRecord/16> .

<http://createme.org/attribute/conservationJurisdiction/15> a tern:Attribute ;
<http://createme.org/attribute/conservationAuthority/15> a tern:Attribute ;
void:inDataset <http://createme.org/dataset/Example-Incidental-Occurrence-Dataset> ;
tern:attribute <http://linked.data.gov.au/def/tern-cv/755b1456-b76f-4d54-8690-10e41e25c5a7> ;
tern:hasSimpleValue "WA" ;
tern:hasValue <http://createme.org/value/conservationJurisdiction/15> .
tern:hasValue <http://createme.org/value/conservationAuthority/15> .

<http://createme.org/attribute/conservationJurisdiction/16> a tern:Attribute ;
<http://createme.org/attribute/conservationAuthority/16> a tern:Attribute ;
void:inDataset <http://createme.org/dataset/Example-Incidental-Occurrence-Dataset> ;
tern:attribute <http://linked.data.gov.au/def/tern-cv/755b1456-b76f-4d54-8690-10e41e25c5a7> ;
tern:hasSimpleValue "WA" ;
tern:hasValue <http://createme.org/value/conservationJurisdiction/16> .
tern:hasValue <http://createme.org/value/conservationAuthority/16> .

<http://createme.org/attribute/habitat/15> a tern:Attribute ;
void:inDataset <http://createme.org/dataset/Example-Incidental-Occurrence-Dataset> ;
Expand Down Expand Up @@ -1127,14 +1127,14 @@
rdfs:label "basisOfRecord" ;
rdf:value <http://createme.org/bdr-cv/attribute/basisOfRecord/new-basis-of-record> .

<http://createme.org/value/conservationJurisdiction/15> a tern:IRI,
<http://createme.org/value/conservationAuthority/15> a tern:IRI,
tern:Value ;
rdfs:label "Conservation Jurisdiction = WA" ;
rdfs:label "Conservation Authority = WA" ;
rdf:value <https://sws.geonames.org/2058645/> .

<http://createme.org/value/conservationJurisdiction/16> a tern:IRI,
<http://createme.org/value/conservationAuthority/16> a tern:IRI,
tern:Value ;
rdfs:label "Conservation Jurisdiction = WA" ;
rdfs:label "Conservation Authority = WA" ;
rdf:value <https://sws.geonames.org/2058645/> .

<http://createme.org/value/dataGeneralizations/14> a tern:Text,
Expand Down
49 changes: 24 additions & 25 deletions abis_mapping/templates/incidental_occurrence_data_v3/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,8 @@ def apply_mapping_row(
sample_sequence = utils.rdf.uri(f"sample/sequence/{row_num}", base_iri)
threat_status_observation = utils.rdf.uri(f"observation/threatStatus/{row_num}", base_iri)
threat_status_value = utils.rdf.uri(f"value/threatStatus/{row_num}", base_iri)
# TODO change to conservation authority?
conservation_jurisdiction_attribute = utils.rdf.uri(f"attribute/conservationJurisdiction/{row_num}", base_iri) # noqa: E501
conservation_jurisdiction_value = utils.rdf.uri(f"value/conservationJurisdiction/{row_num}", base_iri)
conservation_authority_attribute = utils.rdf.uri(f"attribute/conservationAuthority/{row_num}", base_iri) # noqa: E501
conservation_authority_value = utils.rdf.uri(f"value/conservationAuthority/{row_num}", base_iri)
provider_determined_by = utils.rdf.uri(f"provider/{row['threatStatusDeterminedBy']}", base_iri)
provider_record_id_datatype = utils.rdf.uri(
internal_id=f"datatype/recordID/{row['providerRecordIDSource']}",
Expand Down Expand Up @@ -813,7 +812,7 @@ def apply_mapping_row(
accepted_name_usage=accepted_name_usage_value,
scientific_name=text_scientific_name,
threat_status_value=threat_status_value,
jurisdiction_attribute=conservation_jurisdiction_attribute,
authority_attribute=conservation_authority_attribute,
determined_by=provider_determined_by,
graph=graph,
)
Expand All @@ -826,18 +825,18 @@ def apply_mapping_row(
graph=graph,
)

# Add Conservation Jurisdiction Attribute
self.add_conservation_jurisdiction_attribute(
uri=conservation_jurisdiction_attribute,
# Add Conservation Authority Attribute
self.add_conservation_authority_attribute(
uri=conservation_authority_attribute,
row=row,
dataset=dataset,
conservation_jurisdiction_value=conservation_jurisdiction_value,
conservation_authority_value=conservation_authority_value,
graph=graph,
)

# Add Conservation Jurisdiction Value
self.add_conservation_jurisdiction_value(
uri=conservation_jurisdiction_value,
# Add Conservation Authority Value
self.add_conservation_authority_value(
uri=conservation_authority_value,
row=row,
graph=graph,
)
Expand Down Expand Up @@ -2915,7 +2914,7 @@ def add_threat_status_observation(
accepted_name_usage: rdflib.URIRef,
scientific_name: rdflib.URIRef,
threat_status_value: rdflib.URIRef,
jurisdiction_attribute: rdflib.URIRef,
authority_attribute: rdflib.URIRef,
determined_by: rdflib.URIRef,
graph: rdflib.Graph,
) -> None:
Expand All @@ -2931,7 +2930,7 @@ def add_threat_status_observation(
this node
threat_status_value (rdflib.URIRef): Threat Status Value associated
with this node
jurisdiction_attribute (rdflib.URIRef): Conservation Jurisdiction
authority_attribute (rdflib.URIRef): Conservation Authority
Attribute associated with this node
determined_by (rdflib.URIRef): Determined By Provider associated
with this node
Expand Down Expand Up @@ -2969,7 +2968,7 @@ def add_threat_status_observation(
graph.add((uri, rdflib.SOSA.hasResult, threat_status_value))
graph.add((uri, rdflib.SOSA.hasSimpleResult, rdflib.Literal(row["threatStatus"])))
graph.add((uri, rdflib.SOSA.observedProperty, CONCEPT_CONSERVATION_STATUS))
graph.add((uri, rdflib.PROV.wasInfluencedBy, jurisdiction_attribute))
graph.add((uri, rdflib.PROV.wasInfluencedBy, authority_attribute))
graph.add((uri, rdflib.SOSA.usedProcedure, term))
temporal_entity = rdflib.BNode()
graph.add((uri, rdflib.TIME.hasTime, temporal_entity))
Expand Down Expand Up @@ -3028,42 +3027,42 @@ def add_threat_status_value(
graph.add((uri, rdflib.RDFS.label, rdflib.Literal(f"Conservation status = {row['threatStatus']}")))
graph.add((uri, rdflib.RDF.value, term))

def add_conservation_jurisdiction_attribute(
def add_conservation_authority_attribute(
self,
uri: rdflib.URIRef,
row: frictionless.Row,
dataset: rdflib.URIRef,
conservation_jurisdiction_value: rdflib.URIRef,
conservation_authority_value: rdflib.URIRef,
graph: rdflib.Graph,
) -> None:
"""Adds Conservation Jurisdiction Attribute to the Graph
"""Adds Conservation Authority Attribute to the Graph
Args:
uri (rdflib.URIRef): URI to use for this node.
row (frictionless.Row): Row to retrieve data from
dataset (rdflib.URIRef): Dataset this belongs to
conservation_jurisdiction_value (rdflib.URIRef): Conservation
Jurisdiction Value associated with this node
conservation_authority_value (rdflib.URIRef): Conservation
Authority Value associated with this node
graph (rdflib.Graph): Graph to add to
"""
# Check Existence
if not row["conservationAuthority"]:
return

# Conservation Jurisdiction Attribute
# Conservation Authority Attribute
graph.add((uri, a, utils.namespaces.TERN.Attribute))
graph.add((uri, rdflib.VOID.inDataset, dataset))
graph.add((uri, utils.namespaces.TERN.attribute, CONCEPT_CONSERVATION_JURISDICTION))
graph.add((uri, utils.namespaces.TERN.hasSimpleValue, rdflib.Literal(row["conservationAuthority"])))
graph.add((uri, utils.namespaces.TERN.hasValue, conservation_jurisdiction_value))
graph.add((uri, utils.namespaces.TERN.hasValue, conservation_authority_value))

def add_conservation_jurisdiction_value(
def add_conservation_authority_value(
self,
uri: rdflib.URIRef,
row: frictionless.Row,
graph: rdflib.Graph,
) -> None:
"""Adds Conservation Jurisdiction Value to the Graph
"""Adds Conservation Authority Value to the Graph
Args:
uri (rdflib.URIRef): URI to use for this node
Expand All @@ -3081,9 +3080,9 @@ def add_conservation_jurisdiction_value(
term = vocab(graph=graph).get(row["conservationAuthority"])

# Construct Label
label = f"Conservation Jurisdiction = {row['conservationAuthority']}"
label = f"Conservation Authority = {row['conservationAuthority']}"

# Conservation Jurisdiction Value
# Conservation Authority Value
graph.add((uri, a, utils.namespaces.TERN.IRI))
graph.add((uri, a, utils.namespaces.TERN.Value))
graph.add((uri, rdflib.RDFS.label, rdflib.Literal(label)))
Expand Down

0 comments on commit 0df5d59

Please sign in to comment.