Skip to content

Commit 2dc2601

Browse files
committed
Fix shacl-closure in snippets not being used.
Add closure files to validation report.
1 parent 598e6af commit 2dc2601

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

ogc/bblocks/validate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ def validate_test_resources(bblock: BuildingBlock,
336336
require_fail=False,
337337
prefixes=example.get('prefixes'),
338338
file_format=snippet_language,
339+
additional_shacl_closures=snippet.get('shacl-closure'),
339340
)
340341
if example_result:
341342
all_results.append(example_result)

ogc/bblocks/validation/rdf.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,11 @@ def __init__(self, bblock: BuildingBlock, register: BuildingBlockRegister):
123123
self.shacl_errors.append(f"Error processing {shacl_file}: {str(e)}")
124124
inherited_shacl_shapes[shacl_bblock] = bblock_shacl_files
125125

126+
self.added_shacl_closures = []
126127
for shacl_closure in bblock.shaclClosures or ():
127128
try:
128129
self.closure_graph.parse(bblock.resolve_file(shacl_closure), format='turtle')
130+
self.added_shacl_closures.append(shacl_closure)
129131
except HTTPError as e:
130132
self.shacl_errors.append(f"Error retrieving {e.url}: {e}")
131133
except Exception as e:
@@ -364,7 +366,19 @@ def validate(self, filename: Path, output_filename: Path, report: ValidationRepo
364366
if not self.shacl_graphs:
365367
return None
366368

369+
if self.added_shacl_closures:
370+
report.add_entry(ValidationReportEntry(
371+
section=ValidationReportSection.SHACL,
372+
message="Using building block SHACL closures:\n - " + '\n - '.join(self.added_shacl_closures),
373+
is_error=False,
374+
))
375+
367376
if additional_shacl_closures:
377+
report.add_entry(ValidationReportEntry(
378+
section=ValidationReportSection.SHACL,
379+
message="Using snippet SHACL closures:\n - " + '\n - '.join(additional_shacl_closures),
380+
is_error=False,
381+
))
368382
additional_shacl_closures = [c if is_url(c) else self.bblock.files_path.joinpath(c)
369383
for c in additional_shacl_closures]
370384

0 commit comments

Comments
 (0)