Skip to content

Commit c037535

Browse files
authored
Merge pull request #133 from ErykKul/feature/cdi-previewer
Feature/cdi previewer
2 parents 99c2331 + 900ae4b commit c037535

File tree

10 files changed

+26679
-1
lines changed

10 files changed

+26679
-1
lines changed

6.1curlcommands.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,3 +1797,46 @@ curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin
17971797
## Beta Versions:
17981798
As updates and additions are made, they will be added to a /betatest sub-folder which will make them accessible to users via github.io without affecting people who are using the latest numbered release (e.g. v1.5). When previewers in the betatest branch are included in the next release (e.g. v1.6), sites may wish to change their registration of the tools to use the stable version as the betatest version may continue to receive changes.
17991799

1800+
### CDI Previewer
1801+
1802+
```bash
1803+
curl -X POST -H 'Content-type: application/json' http://localhost:8080/api/admin/externalTools -d \
1804+
'{
1805+
"displayName":"View CDI Metadata",
1806+
"description":"View DDI Cross-Domain Integration (CDI) metadata file using SHACL shapes.",
1807+
"toolName":"cdiPreviewer",
1808+
"scope":"file",
1809+
"types":["preview"],
1810+
"toolUrl":"https://gdcc.github.io/dataverse-previewers/previewers/betatest/CdiPreview.html",
1811+
"toolParameters": {
1812+
"queryParameters":[
1813+
{"fileid":"{fileId}"},
1814+
{"siteUrl":"{siteUrl}"},
1815+
{"datasetid":"{datasetId}"},
1816+
{"datasetversion":"{datasetVersion}"},
1817+
{"locale":"{localeCode}"}
1818+
]
1819+
},
1820+
"contentType":"application/ld+json; profile=\"http://www.w3.org/ns/json-ld#flattened http://www.w3.org/ns/json-ld#compacted https://ddialliance.org/specification/ddi-cdi/1.0\"",
1821+
"allowedApiCalls": [
1822+
{
1823+
"name": "retrieveFileContents",
1824+
"httpMethod": "GET",
1825+
"urlTemplate": "/api/v1/access/datafile/{fileId}?gbrecs=true",
1826+
"timeOut": 3600
1827+
},
1828+
{
1829+
"name": "downloadFile",
1830+
"httpMethod": "GET",
1831+
"urlTemplate": "/api/v1/access/datafile/{fileId}?gbrecs=false",
1832+
"timeOut": 3600
1833+
},
1834+
{
1835+
"name": "getDatasetVersionMetadata",
1836+
"httpMethod": "GET",
1837+
"urlTemplate": "/api/v1/datasets/{datasetId}/versions/{datasetVersion}",
1838+
"timeOut": 3600
1839+
}
1840+
]
1841+
}'
1842+
```

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ The Spreadsheet Previewer was contributed by [anncie-pcss](https://github.com/an
8484

8585
[Max Planck Digital Library](https://github.com/MPDL) contributed the ZIP Previewer.
8686

87-
[erykkul](https://github.com/erykkul) contributed the Markdown (MD) Previewer and the RO-Crate previewer.
87+
[erykkul](https://github.com/erykkul) contributed the Markdown (MD) Previewer, the RO-Crate previewer, and the CDI (DDI Cross-Domain Integration) previewer. The CDI previewer displays all JSON-LD data nodes and properties with real-time SHACL validation, smart property classification (required/optional/extra fields), support for complex nested objects, and editing capabilities. See [https://github.com/libis/cdi-viewer](https://github.com/libis/cdi-viewer) for the source code, documentation and implementation details.
8888

8989
[Jan Range](https://github.com/JR-1991) contributed the H5Web Previewer, Rich Html Previewer.
9090

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>CDI Data Viewer & Editor</title>
7+
8+
<!-- External CSS -->
9+
<link
10+
rel="stylesheet"
11+
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
12+
/>
13+
14+
<!-- External JavaScript Libraries -->
15+
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
16+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
17+
18+
<!-- CDI Viewer Application (ES6 modules with SHACL + SPARQL validation) -->
19+
<script src="lib/cdi-viewer.bundle.min.js"></script>
20+
</head>
21+
22+
<body>
23+
<script>loadBody()</script>
24+
</body>
25+
</html>

previewers/betatest/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"mdPreviewText": "Markdown Preview",
2323
"ncmlPreviewText": "NcML Preview",
2424
"rocratePreviewText": "RO-Crate Preview",
25+
"cdiPreviewText": "CDI Preview",
2526
"prev": "Previous",
2627
"next": "Next",
2728
"pageText": "Page:",

previewers/betatest/i18n/es.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"mdPreviewText": "Previsualización de Markdown",
2222
"ncmlPreviewText": "Previsualización de NcML",
2323
"rocratePreviewText": "Previsualización de RO-Crate",
24+
"cdiPreviewText": "Previsualización de CDI",
2425
"prev": "Anterior",
2526
"next": "Siguiente",
2627
"pageText": "Página:",

previewers/betatest/i18n/fr.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"mdPreviewText": "Aperçu Markdown",
2323
"ncmlPreviewText": "Aperçu NcML",
2424
"rocratePreviewText": "Aperçu RO-Crate",
25+
"cdiPreviewText": "Aperçu CDI",
2526
"prev": "Précédent",
2627
"next": "Suivant",
2728
"pageText": "Page:",

previewers/betatest/lib/cdi-viewer.bundle.min.js

Lines changed: 97 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
2+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
3+
@prefix sh: <http://www.w3.org/ns/shacl#> .
4+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
5+
@prefix schema: <http://schema.org/>.
6+
@prefix dcterms: <http://purl.org/dc/terms/>.
7+
@prefix cdifd: <https://cdif.org/validation/0.1/shacl#> .
8+
@base <https://www.ogc.org/rules/template/> .
9+
10+
cdifd:CDIFDatasetMandatoryShape a sh:NodeShape ;
11+
# only apply to elements that are child of root dataset
12+
sh:target [
13+
a sh:SPARQLTarget ;
14+
sh:prefixes (
15+
[ sh:prefix "schema" ; sh:namespace "http://schema.org/" ]
16+
[ sh:prefix "ex" ; sh:namespace "https://example.org/" ]
17+
);
18+
# do we need to deal with schema:Dataset with parent = @graph? pyshacl work with these rules
19+
# for graph serialization.
20+
sh:select """
21+
PREFIX schema: <http://schema.org/>
22+
PREFIX ex: <https://example.org/>
23+
SELECT ?this
24+
WHERE {
25+
?this a schema:Dataset .
26+
MINUS {
27+
?parent a schema:Dataset .
28+
?parent ?p ?this .
29+
FILTER (?parent != ?this)
30+
FILTER (?p != schema:about)
31+
}
32+
}
33+
""" ;
34+
] ;
35+
36+
sh:property
37+
cdifd:resourceIdentifierProperty,
38+
cdifd:nameProperty,
39+
cdifd:rightsProperty,
40+
cdifd:dateModifiedProperty
41+
.
42+
43+
cdifd:resourceIdentifierProperty
44+
# identifier for the resource described by the graph node, implement as either xsd:string or
45+
# schema:PropertyValue with required [either scheme:url or schema:value]
46+
a sh:PropertyShape ;
47+
sh:path schema:identifier ;
48+
sh:minCount 1 ;
49+
sh:or (
50+
[sh:datatype xsd:string ;]
51+
[sh:class schema:PropertyValue ;
52+
sh:property
53+
[sh:path schema:propertyID ;
54+
sh:datatype xsd:string ;
55+
sh:severity sh:Warning ;
56+
sh:message "If specifying an identifier via the PropertyValue, the scheme (authority, domain) within which the identifier is assigned and unique must be identifed, either by name or preferably using a URI. See https://registry.identifiers.org/registry"
57+
];
58+
sh:or (
59+
[sh:property
60+
[sh:path schema:url ;
61+
sh:datatype xsd:string ;
62+
sh:message "if possible, provide a resolvable URI that will provide a representation of the identified resource."
63+
]]
64+
[sh:property
65+
[sh:path schema:value ;
66+
sh:datatype xsd:string ;
67+
sh:message "The identifer string; include applicable prefix (e.g. doi:, ark:, http:, isbn:)"
68+
]]
69+
)
70+
]
71+
);
72+
sh:message "An identifier for the documented resource must be provided"
73+
.
74+
75+
cdifd:nameProperty
76+
# names must be a literal, .
77+
a sh:PropertyShape ;
78+
sh:path schema:name;
79+
sh:minCount 1 ;
80+
sh:datatype xsd:string ;
81+
sh:minLength 5 ;
82+
sh:message "a name for the person must be provided, and have a length of at least 5 characters."
83+
.
84+
85+
cdifd:rightsProperty
86+
a sh:PropertyShape ;
87+
# some indication of rights is required, either a license or statement on conditions of access
88+
sh:path [sh:alternativePath ( schema:license schema:conditionsOfAccess ) ];
89+
sh:or (
90+
[sh:nodeKind sh:IRI ]
91+
[sh:datatype xsd:string ]
92+
# use schema:CreativeWork to implement a labeled link, only URL is required, but schema:name is expected
93+
[sh:class schema:CreativeWork;
94+
sh:property
95+
[
96+
sh:path schema:url ;
97+
sh:minCount 1 ;
98+
sh:datatype xsd:string ;
99+
# sh:pattern "^[a-zA-Z][a-zA-Z0-9+.-]*:[^\\s]*$";
100+
sh:pattern "^https?:\\/\\/[^\\s]+$" ;
101+
sh:message "value must be a resolvable URL, but we aren't testing to see if the URL resolves..... Can't get xsd:anyURI to work with JSON Schema validation..."
102+
]
103+
]
104+
);
105+
sh:minCount 1 ;
106+
sh:message "To meet the requirements for FAIR data, information about licenses or other security, usage, or access limitations must be described"
107+
.
108+
109+
cdifd:dateModifiedProperty
110+
a sh:PropertyShape ;
111+
sh:path schema:dateModified;
112+
# pyshacl doesn't seem to work validating xsd:date or xsd:dateTime in JSON-LD
113+
# sh:datatype xsd:dateTime ;
114+
sh:minCount 1 ;
115+
sh:datatype xsd:string ;
116+
# messy regex to screen for ISO8601 formats
117+
sh:pattern "^[1-2][0-9]{3}-([0][1-9]|[1][0-2])(-([0-2][0-9]|[3][0-1])(T([0-1][0-9]|[2][0-3]):[0-5][0-9](:[0-5][0-9](Z|[+-][0-2][0-9]:[0-5][0-9])?)?)?)?$" ;
118+
sh:message "Date of most recent update to resource content is required, using ISO8601 format with at least a year and a month."
119+
.
120+
121+
cdifd:CDIFMetaMetadataShape
122+
a sh:NodeShape ;
123+
# only apply to dataset nodes that are 'about' a dataset node. Need to refine rule so 'about' is the
124+
# root node of the containing resource. Parent might be any of the allowed resource types for CDIF
125+
sh:target [
126+
a sh:SPARQLTarget ;
127+
sh:select """
128+
PREFIX schema: <http://schema.org/>
129+
SELECT ?this
130+
WHERE {
131+
?this a schema:Dataset ;
132+
schema:about ?parent.
133+
}
134+
""";
135+
] ;
136+
sh:nodeKind sh:IRI ;
137+
sh:property cdifd:metadataProfileProperty ;
138+
sh:property cdifd:metadataSubjectProperty ;
139+
sh:message "The target of the metadata record (about)."
140+
.
141+
142+
cdifd:metadataProfileProperty
143+
# Metadata needs to identify conventions followed in the serialization of this record.
144+
a sh:PropertyShape ;
145+
sh:path dcterms:conformsTo ;
146+
sh:minCount 1 ;
147+
sh:nodeKind sh:IRI ;
148+
sh:message "provide identifiers for specifications used in this record to provide guidance for machine agents processing the metadata record"
149+
.
150+
151+
cdifd:metadataSubjectProperty
152+
# Metadata needs to identify conventions followed in the serialization of this record.
153+
a sh:PropertyShape ;
154+
sh:path schema:about ;
155+
sh:nodeKind sh:IRI ;
156+
sh:minCount 1 ;
157+
sh:message "link to the target of the metadata metadata node using the about property"
158+
.

0 commit comments

Comments
 (0)