From f651af26938710825410599999bd3d72fff6298c Mon Sep 17 00:00:00 2001 From: Lincoln Puzey Date: Wed, 20 Nov 2024 14:21:44 +0800 Subject: [PATCH] BDRSPS-1048 Add extra fields mapping for site visit template --- .../survey_site_visit_data_v2/mapping.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/abis_mapping/templates/survey_site_visit_data_v2/mapping.py b/abis_mapping/templates/survey_site_visit_data_v2/mapping.py index 872ef00c..7beee2d6 100644 --- a/abis_mapping/templates/survey_site_visit_data_v2/mapping.py +++ b/abis_mapping/templates/survey_site_visit_data_v2/mapping.py @@ -235,6 +235,10 @@ def apply_mapping( data=data, full_schema=True, ) + extra_schema = self.extra_fields_schema( + data=data, + full_schema=False, + ) # Construct Resource resource = frictionless.Resource( @@ -273,6 +277,7 @@ def apply_mapping( row=row, dataset=dataset_iri, graph=graph, + extra_schema=extra_schema, base_iri=base_iri, ) graph_has_data = True @@ -295,6 +300,7 @@ def apply_mapping_row( row: frictionless.Row, dataset: rdflib.URIRef, graph: rdflib.Graph, + extra_schema: frictionless.Schema, base_iri: rdflib.Namespace | None, ) -> None: """Applies mapping for a row in the Survey Site Visit Data template. @@ -303,6 +309,7 @@ def apply_mapping_row( row: Row to be processed in the dataset. dataset: Dataset IRI this row is a part of. graph: Graph to map row into. + extra_schema: Schema of extra fields. base_iri: Optional base IRI to use for mapping. """ # variables starting with row_ are values from the row. @@ -535,6 +542,14 @@ def apply_mapping_row( graph=graph, ) + # Add extra fields + self.add_extra_fields_json( + subject_uri=uri_site_visit_activity, + row=row, + graph=graph, + extra_schema=extra_schema, + ) + def add_site_visit_activity( self, *,