Skip to content

Commit

Permalink
Merge pull request #336 from gaiaresources/BDRSPS-1038
Browse files Browse the repository at this point in the history
BDRSPS-1038 Ensure that every chunk has a dataset type triple
  • Loading branch information
joecrowleygaia authored Nov 19, 2024
2 parents bb8759b + 7a673ee commit 28e38f7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,11 @@ def apply_mapping(
graph = utils.rdf.create_graph()

# Check if Dataset IRI Supplied
if not dataset_iri:
# Create Dataset IRI
if dataset_iri:
# If supplied, add just the dataset type.
graph.add((dataset_iri, a, utils.namespaces.TERN.Dataset))
else:
# If not supplied, create example "default" Dataset IRI
dataset_iri = utils.rdf.uri(f"dataset/{self.DATASET_DEFAULT_NAME}", base_iri)

# Add Example Default Dataset if not Supplied
Expand Down Expand Up @@ -221,6 +224,8 @@ def apply_mapping(

# Initialise New Graph
graph = utils.rdf.create_graph()
# Every chunk should have this node
graph.add((dataset_iri, a, utils.namespaces.TERN.Dataset))

# Yield
yield graph
Expand Down
7 changes: 5 additions & 2 deletions abis_mapping/templates/survey_metadata_v2/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,11 @@ def apply_mapping(
graph = utils.rdf.create_graph()

# Check if Dataset IRI Supplied
if not dataset_iri:
# Create Dataset IRI
if dataset_iri:
# If supplied, add just the dataset type.
graph.add((dataset_iri, a, utils.namespaces.TERN.Dataset))
else:
# If not supplied, create example "default" Dataset IRI
dataset_iri = utils.rdf.uri(f"dataset/{self.DATASET_DEFAULT_NAME}", base_iri)

# Add the default dataset
Expand Down
9 changes: 7 additions & 2 deletions abis_mapping/templates/survey_occurrence_data_v2/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,11 @@ def apply_mapping(
graph = utils.rdf.create_graph()

# Check if Dataset IRI Supplied
if not dataset_iri:
# Create Dataset IRI
if dataset_iri:
# If supplied, add just the dataset type.
graph.add((dataset_iri, a, utils.namespaces.TERN.Dataset))
else:
# If not supplied, create example "default" Dataset IRI
dataset_iri = utils.rdf.uri(f"dataset/{self.DATASET_DEFAULT_NAME}", base_iri)

# Add Example Default Dataset if not Supplied
Expand Down Expand Up @@ -346,6 +349,8 @@ def apply_mapping(

# Initialise New Graph
graph = utils.rdf.create_graph()
# Every chunk should have this node
graph.add((dataset_iri, a, utils.namespaces.TERN.Dataset))

# Yield
yield graph
Expand Down
7 changes: 5 additions & 2 deletions abis_mapping/templates/survey_site_data_v2/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,11 @@ def apply_mapping(
graph = utils.rdf.create_graph()

# Check if Dataset IRI Supplied
if not dataset_iri:
# Create Dataset IRI
if dataset_iri:
# If supplied, add just the dataset type.
graph.add((dataset_iri, a, utils.namespaces.TERN.Dataset))
else:
# If not supplied, create example "default" Dataset IRI
dataset_iri = utils.rdf.uri(f"dataset/{self.DATASET_DEFAULT_NAME}", base_iri)

# Add the default dataset
Expand Down
9 changes: 7 additions & 2 deletions abis_mapping/templates/survey_site_visit_data_v2/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,11 @@ def apply_mapping(
graph_has_data: bool = False

# Check if Dataset IRI Supplied
if not dataset_iri:
# Create Dataset IRI
if dataset_iri:
# If supplied, add just the dataset type.
graph.add((dataset_iri, a, utils.namespaces.TERN.Dataset))
else:
# If not supplied, create example "default" Dataset IRI
dataset_iri = utils.rdf.uri(f"dataset/{self.DATASET_DEFAULT_NAME}", base_iri)

# Add the default dataset
Expand Down Expand Up @@ -280,6 +283,8 @@ def apply_mapping(
# Initialise New Graph for next chunk
graph = utils.rdf.create_graph()
graph_has_data = False
# Every chunk should have this node
graph.add((dataset_iri, a, utils.namespaces.TERN.Dataset))

# yield final chunk, or whole graph if not chunking.
if chunk_size is None or graph_has_data:
Expand Down

0 comments on commit 28e38f7

Please sign in to comment.