Skip to content

Commit 99f9b0d

Browse files
authored
Merge pull request crs4#152 from nfdi4plants/fix-cyclic-datasets
Fixed Check for link between root data entity an data entities
2 parents 7277042 + 244f398 commit 99f9b0d

4 files changed

Lines changed: 89 additions & 3 deletions

File tree

rocrate_validator/profiles/ro-crate/must/4_data_entity_metadata.ttl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,12 @@ ro-crate:DataEntityRequiredPropertiesShape a sh:NodeShape ;
137137
sh:property
138138
[
139139
a sh:PropertyShape ;
140-
sh:path [ sh:inversePath schema_org:hasPart ] ;
141-
sh:node schema_org:Dataset ;
142-
sh:minCount 1 ;
140+
# sh:path [ sh:inversePath schema_org:hasPart ] ;
141+
# sh:node schema_org:Dataset ;
142+
# sh:minCount 1 ;
143+
sh:path [ sh:oneOrMorePath [ sh:inversePath schema_org:hasPart ] ] ;
144+
sh:qualifiedValueShape [ sh:class ro-crate:RootDataEntity ] ;
145+
sh:qualifiedMinCount 1 ;
143146
sh:name "Data Entity MUST be directly referenced" ;
144147
sh:description """Check if the Data Entity is linked, either directly or indirectly, to the `Root Data Entity` using the `hasPart` (as defined in `schema.org`) property" """ ;
145148
# sh:message "A Data Entity MUST be directly or indirectly linked to the `Root Data Entity` through the `hasPart` property" ;
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"@context": [
3+
"https://w3id.org/ro/crate/1.1/context"
4+
],
5+
"@graph": [
6+
{
7+
"@id": "ro-crate-metadata.json",
8+
"@type": "CreativeWork",
9+
"conformsTo": {
10+
"@id": "https://w3id.org/ro/crate/1.1"
11+
},
12+
"about": {
13+
"@id": "./"
14+
}
15+
},
16+
{
17+
"@id": "./",
18+
"@type": "Dataset",
19+
"name": "Root",
20+
"description": "Root Dataset",
21+
"datePublished": "2024-05-17T01:04:52+01:00",
22+
"hasPart": [
23+
],
24+
"license": "CC-BY-4.0"
25+
},
26+
{
27+
"@id": "dataset1/file1.txt",
28+
"@type": "File",
29+
"description": "A file",
30+
"encodingFormat": "text/plain",
31+
"name": "file1.txt"
32+
},
33+
{
34+
"@id": "dataset2/file2.txt",
35+
"@type": "File",
36+
"description": "Another file",
37+
"encodingFormat": "text/plain",
38+
"name": "file2.txt"
39+
},
40+
{
41+
"@id": "dataset1/",
42+
"@type": "Dataset",
43+
"name": "Dataset 1",
44+
"description": "First dataset",
45+
"hasPart": [
46+
{
47+
"@id": "dataset1/file1.txt"
48+
},
49+
{
50+
"@id": "dataset2/"
51+
}
52+
]
53+
},
54+
{
55+
"@id": "dataset2/",
56+
"@type": "Dataset",
57+
"name": "Dataset 2",
58+
"description": "Second dataset",
59+
"hasPart": [
60+
{
61+
"@id": "dataset2/file2.txt"
62+
},
63+
{
64+
"@id": "dataset1/"
65+
}
66+
]
67+
}
68+
]
69+
}

tests/integration/profiles/ro-crate/test_data_entity_metadata.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ def test_data_entity_must_be_directly_linked():
4848
)
4949

5050

51+
def test_data_entity_not_linked():
52+
"""Test a RO-Crate with datasets not linked to the root data entity."""
53+
do_entity_test(
54+
paths.dataset_not_linked_to_root,
55+
models.Severity.REQUIRED,
56+
False,
57+
skip_checks=[SKIP_LOCAL_DATA_ENTITY_EXISTENCE_CHECK_IDENTIFIER]
58+
)
59+
60+
5161
def test_data_entity_must_be_indirectly_linked():
5262
"""Test a RO-Crate without a root data entity."""
5363
do_entity_test(

tests/ro_crates.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ def missing_hasPart_data_entity_reference(self) -> Path:
246246
def direct_hasPart_data_entity_reference(self) -> Path:
247247
return self.base_path / "valid_direct_hasPart_reference"
248248

249+
@property
250+
def dataset_not_linked_to_root(self) -> Path:
251+
return self.base_path / "cyclic_datasets"
252+
249253
@property
250254
def indirect_hasPart_data_entity_reference(self) -> Path:
251255
return self.base_path / "valid_indirect_hasPart_reference"

0 commit comments

Comments
 (0)