Skip to content

Commit

Permalink
Merge pull request #354 from gaiaresources/BDRSPS-1086
Browse files Browse the repository at this point in the history
BDRSPS-1086 Don't create the record number datatype when there is no `recordNumber` field
  • Loading branch information
chungvl authored Dec 2, 2024
2 parents 860faf7 + db61ef0 commit 11771f6
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
providerRecordID,providerRecordIDSource,locality,decimalLatitude,decimalLongitude,geodeticDatum,coordinateUncertaintyInMeters,dataGeneralizations,eventDateStart,eventDateEnd,samplingProtocol,basisOfRecord,recordedBy,recordNumber,occurrenceStatus,habitat,establishmentMeans,organismRemarks,individualCount,organismQuantity,organismQuantityType,lifeStage,sex,reproductiveCondition,ownerRecordID,ownerRecordIDSource,collectionCode,catalogNumber,catalogNumberSource,otherCatalogNumbers,otherCatalogNumbersSource,preparations,preparedDate,associatedSequences,sequencingMethod,verbatimIdentification,dateIdentified,identifiedBy,identificationMethod,scientificName,identificationQualifier,identificationRemarks,acceptedNameUsage,kingdom,taxonRank,threatStatus,conservationAuthority,threatStatusCheckProtocol,threatStatusDateDetermined,threatStatusDeterminedBy,sensitivityCategory,sensitivityAuthority
1,WAM,Cowaramup Bay Road,-33.8,115.21,WGS84,,,26/09/2019,,,,Stream Environment and Water Pty Ltd,,,,,,,,,,,,,,,,,,,,,,,Calothamnus lateralis var. crassus,,Stream Environment and Water Pty Ltd,,Calothamnus lateralis var. crassus,,,,Plantae,,,,,,,,
2,WAM,Cowaramup Bay Road,-33.86,115.01,WGS84,,,26/09/2019,,,,Stream Environment and Water Pty Ltd,,,,,,,,,,,,,,,,,,,,,,,Boronia anceps,,Stream Environment and Water Pty Ltd,,Boronia anceps,,,,Plantae,,,,,,,,
3,WAM,Cowaramup Bay Road,-33.86,115.01,WGS84,,,26/09/2019,,,,Stream Environment and Water Pty Ltd,,,,,,,,,,,,,,,,,,,,,,,Boronia anceps,,Stream Environment and Water Pty Ltd,,Boronia anceps,,,,Plantae,,,,,,,,
2,WAM,Cowaramup Bay Road,-33.86,115.01,WGS84,,,26/09/2019,,,,,PE:12:8831,,,,,,,,,,,,,,,,,,,,,,Boronia anceps,,Stream Environment and Water Pty Ltd,,Boronia anceps,,,,Plantae,,,,,,,,
3,WAM,Cowaramup Bay Road,-33.86,115.01,WGS84,,,26/09/2019,,,,Test Pty Ltd,,,,,,,,,,,,,,,,,,,,,,,Boronia anceps,,Stream Environment and Water Pty Ltd,,Boronia anceps,,,,Plantae,,,,,,,,
4,WAM,Cowaramup Bay Road,-33.86,115.01,WGS84,,,26/09/2019,,,,Stream Environment and Water Pty Ltd,,,,,,,,,,,,,,,,,,,,,,,Boronia anceps,,Stream Environment and Water Pty Ltd,,Boronia anceps,,,,Plantae,,,,,,,,
5,WAM,Cowaramup Bay Road,-33.86,114.99,WGS84,,,26/09/2019,,,,Stream Environment and Water Pty Ltd,,,,,,,,,,,,,,,,,,,,,,,Banksia sessilis var. cordata,,Stream Environment and Water Pty Ltd,,Banksia sessilis var. cordata,,,,Plantae,,,,,,,,
6,WAM,Cowaramup Bay Road,-33.86,114.99,WGS84,,,26/09/2019,,,,Stream Environment and Water Pty Ltd,,,,,,,,,,,,,,,,,,,,,,,Banksia sessilis var. cordata,,Stream Environment and Water Pty Ltd,,Banksia sessilis var. cordata,,,,Plantae,,,,,,,,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,9 @@
<https://linked.data.gov.au/dataset/bdr/orgs/BHP> a prov:Agent ;
schema:name "BHP" .

<https://linked.data.gov.au/dataset/bdr/orgs/Test-Pty-Ltd> a prov:Agent ;
schema:name "Test Pty Ltd" .

<https://linked.data.gov.au/dataset/bdr/orgs/WA-BIO> a prov:Agent ;
schema:name "WA-BIO" .

Expand Down Expand Up @@ -1530,8 +1533,8 @@

<http://createme.org/occurrence/2> a dwc:Occurrence,
tern:FeatureOfInterest ;
prov:wasAssociatedWith <https://linked.data.gov.au/dataset/bdr/orgs/Stream-Environment-and-Water-Pty-Ltd> ;
sosa:usedProcedure <https://linked.data.gov.au/def/nrm/a8db263e-7a39-5b85-a5d2-8e1af7ce1e39> ;
schema:identifier "PE:12:8831" ;
schema:isPartOf <http://createme.org/dataset/Example-Incidental-Occurrence-Dataset> ;
schema:spatial _:N489292b7f1191795326ddd2200000003 ;
schema:temporal [ a time:TemporalEntity ;
Expand All @@ -1542,7 +1545,7 @@

<http://createme.org/occurrence/3> a dwc:Occurrence,
tern:FeatureOfInterest ;
prov:wasAssociatedWith <https://linked.data.gov.au/dataset/bdr/orgs/Stream-Environment-and-Water-Pty-Ltd> ;
prov:wasAssociatedWith <https://linked.data.gov.au/dataset/bdr/orgs/Test-Pty-Ltd> ;
sosa:usedProcedure <https://linked.data.gov.au/def/nrm/a8db263e-7a39-5b85-a5d2-8e1af7ce1e39> ;
schema:isPartOf <http://createme.org/dataset/Example-Incidental-Occurrence-Dataset> ;
schema:spatial _:N489292b7f1191795326ddd2200000006 ;
Expand Down
14 changes: 9 additions & 5 deletions abis_mapping/templates/incidental_occurrence_data_v3/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def apply_mapping_row(
self.add_record_number_datatype(
uri=record_number_datatype,
provider=provider_recorded_by,
value=recorded_by,
row=row,
graph=graph,
)

Expand Down Expand Up @@ -1851,7 +1851,7 @@ def add_record_number_datatype(
self,
uri: rdflib.URIRef | None,
provider: rdflib.URIRef | None,
value: str | None,
row: frictionless.Row,
graph: rdflib.Graph,
) -> None:
"""Adds record number datatype to the graph.
Expand All @@ -1861,19 +1861,23 @@ def add_record_number_datatype(
or None if uri wasn't created.
provider (rdflib.URIRef | None): The corresponding
provider uri.
value (str | None): Raw value provided in row.
row (frictionless.Row): Row from the template.
graph (rdflib.Graph): Graph to be modified.
"""
# Check subject provided
if uri is None:
return

# if no recordNumber, don't create this datatype because it would be unused.
if not row["recordNumber"]:
return

# Add type
graph.add((uri, a, rdflib.RDFS.Datatype))

# Add label
if value is not None:
graph.add((uri, rdflib.SKOS.prefLabel, rdflib.Literal(f"{value} recordNumber")))
if recorded_by := row["recordedBy"]:
graph.add((uri, rdflib.SKOS.prefLabel, rdflib.Literal(f"{recorded_by} recordNumber")))

# Add definition
graph.add(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
providerRecordID,providerRecordIDSource,locality,decimalLatitude,decimalLongitude,geodeticDatum,coordinateUncertaintyInMeters,dataGeneralizations,eventDateStart,eventDateEnd,samplingProtocol,basisOfRecord,recordedBy,recordNumber,occurrenceStatus,habitat,establishmentMeans,organismRemarks,individualCount,organismQuantity,organismQuantityType,lifeStage,sex,reproductiveCondition,ownerRecordID,ownerRecordIDSource,collectionCode,catalogNumber,catalogNumberSource,otherCatalogNumbers,otherCatalogNumbersSource,preparations,preparedDate,associatedSequences,sequencingMethod,verbatimIdentification,dateIdentified,identifiedBy,identificationMethod,scientificName,identificationQualifier,identificationRemarks,acceptedNameUsage,kingdom,taxonRank,threatStatus,conservationAuthority,threatStatusCheckProtocol,threatStatusDateDetermined,threatStatusDeterminedBy,sensitivityCategory,sensitivityAuthority,surveyID,siteID,siteVisitID
1,WAM,Cowaramup Bay Road,-33.8,115.21,WGS84,,,26/09/2019,,,,Stream Environment and Water Pty Ltd,,,,,,,,,,,,,,,,,,,,,,,Calothamnus lateralis var. crassus,,Stream Environment and Water Pty Ltd,,Calothamnus lateralis var. crassus,,,,Plantae,,,,,,,,,,,
2,WAM,Cowaramup Bay Road,-33.86,115.01,WGS84,,,26/09/2019,,,,Stream Environment and Water Pty Ltd,,,,,,,,,,,,,,,,,,,,,,,Boronia anceps,,Stream Environment and Water Pty Ltd,,Boronia anceps,,,,Plantae,,,,,,,,,,,
3,WAM,Cowaramup Bay Road,-33.86,115.01,WGS84,,,26/09/2019,,,,Stream Environment and Water Pty Ltd,,,,,,,,,,,,,,,,,,,,,,,Boronia anceps,,Stream Environment and Water Pty Ltd,,Boronia anceps,,,,Plantae,,,,,,,,,,,
2,WAM,Cowaramup Bay Road,-33.86,115.01,WGS84,,,26/09/2019,,,,,PE:12:8831,,,,,,,,,,,,,,,,,,,,,,Boronia anceps,,Stream Environment and Water Pty Ltd,,Boronia anceps,,,,Plantae,,,,,,,,,,,
3,WAM,Cowaramup Bay Road,-33.86,115.01,WGS84,,,26/09/2019,,,,Test Pty Ltd,,,,,,,,,,,,,,,,,,,,,,,Boronia anceps,,Stream Environment and Water Pty Ltd,,Boronia anceps,,,,Plantae,,,,,,,,,,,
4,WAM,Cowaramup Bay Road,-33.86,115.01,WGS84,,,26/09/2019,,,,Stream Environment and Water Pty Ltd,,,,,,,,,,,,,,,,,,,,,,,Boronia anceps,,Stream Environment and Water Pty Ltd,,Boronia anceps,,,,Plantae,,,,,,,,,,,
5,WAM,Cowaramup Bay Road,-33.86,114.99,WGS84,,,26/09/2019,,,,Stream Environment and Water Pty Ltd,,,,,,,,,,,,,,,,,,,,,,,Banksia sessilis var. cordata,,Stream Environment and Water Pty Ltd,,Banksia sessilis var. cordata,,,,Plantae,,,,,,,,,,,
6,WAM,Cowaramup Bay Road,-33.86,114.99,WGS84,,,26/09/2019,,,,Stream Environment and Water Pty Ltd,,,,,,,,,,,,,,,,,,,,,,,Banksia sessilis var. cordata,,Stream Environment and Water Pty Ltd,,Banksia sessilis var. cordata,,,,Plantae,,,,,,,,,,,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,9 @@
<https://linked.data.gov.au/dataset/bdr/orgs/BHP> a prov:Agent ;
schema:name "BHP" .

<https://linked.data.gov.au/dataset/bdr/orgs/Test-Pty-Ltd> a prov:Agent ;
schema:name "Test Pty Ltd" .

<https://linked.data.gov.au/dataset/bdr/orgs/WA-BIO> a prov:Agent ;
schema:name "WA-BIO" .

Expand Down Expand Up @@ -1527,8 +1530,8 @@

<http://createme.org/occurrence/2> a dwc:Occurrence,
tern:FeatureOfInterest ;
prov:wasAssociatedWith <https://linked.data.gov.au/dataset/bdr/orgs/Stream-Environment-and-Water-Pty-Ltd> ;
sosa:usedProcedure <https://linked.data.gov.au/def/nrm/a8db263e-7a39-5b85-a5d2-8e1af7ce1e39> ;
schema:identifier "PE:12:8831" ;
schema:isPartOf <http://createme.org/Survey/1>,
<http://createme.org/dataset/Example-Systematic-Survey-Occurrence-Dataset> ;
schema:spatial _:N1dddcc66c58fa593aae7f72f00000003 ;
Expand All @@ -1540,7 +1543,7 @@

<http://createme.org/occurrence/3> a dwc:Occurrence,
tern:FeatureOfInterest ;
prov:wasAssociatedWith <https://linked.data.gov.au/dataset/bdr/orgs/Stream-Environment-and-Water-Pty-Ltd> ;
prov:wasAssociatedWith <https://linked.data.gov.au/dataset/bdr/orgs/Test-Pty-Ltd> ;
sosa:usedProcedure <https://linked.data.gov.au/def/nrm/a8db263e-7a39-5b85-a5d2-8e1af7ce1e39> ;
schema:isPartOf <http://createme.org/Survey/1>,
<http://createme.org/dataset/Example-Systematic-Survey-Occurrence-Dataset> ;
Expand Down
14 changes: 9 additions & 5 deletions abis_mapping/templates/survey_occurrence_data_v2/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ def apply_mapping_row(
self.add_record_number_datatype(
uri=record_number_datatype,
provider=provider_recorded_by,
value=recorded_by,
row=row,
graph=graph,
)

Expand Down Expand Up @@ -2189,7 +2189,7 @@ def add_record_number_datatype(
self,
uri: rdflib.URIRef | None,
provider: rdflib.URIRef | None,
value: str | None,
row: frictionless.Row,
graph: rdflib.Graph,
) -> None:
"""Adds record number datatype to the graph.
Expand All @@ -2198,19 +2198,23 @@ def add_record_number_datatype(
or None if uri wasn't created.
provider (rdflib.URIRef | None): The corresponding
provider uri.
value (str | None): Raw value provided in row.
row (frictionless.Row): Row from the template.
graph (rdflib.Graph): Graph to be modified.
"""
# Check subject provided
if uri is None:
return

# if no recordNumber, don't create this datatype because it would be unused.
if not row["recordNumber"]:
return

# Add type
graph.add((uri, a, rdflib.RDFS.Datatype))

# Add label
if value is not None:
graph.add((uri, rdflib.SKOS.prefLabel, rdflib.Literal(f"{value} recordNumber")))
if recorded_by := row["recordedBy"]:
graph.add((uri, rdflib.SKOS.prefLabel, rdflib.Literal(f"{recorded_by} recordNumber")))

# Add definition
graph.add(
Expand Down

0 comments on commit 11771f6

Please sign in to comment.