-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidate.groovy
54 lines (46 loc) · 1.44 KB
/
validate.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// MIT, Copyright (c) Egon Willighagen
@Grab(group='io.github.egonw.bacting', module='managers-rdf', version='0.3.6')
import org.apache.jena.shex.ShexStatus
workspaceRoot = "."
rdf = new net.bioclipse.managers.RDFManager(workspaceRoot);
file = "/Output/RDF_Kin_Data_2022-Dec.ttl"
clazz = args[0]
type = args[1]
store = rdf.createInMemoryStore(true);
store = rdf.importFile(store, "${file}", "TURTLE")
report = rdf.validateAllOfType(
store,
"/shapes/${clazz}.shex",
"http://bigcat-um.github.io/KinRDF/shapes#${clazz}",
"${type}"
)
println "{"
println " \"target\": \"${clazz}\","
println " \"conformant\": ["
report.forEachReport { reportEntry ->
status = reportEntry.status
reason = reportEntry.reason
focusNode = reportEntry.focus
switch (status) {
case ShexStatus.conformant :
println " {\n \"class\": \"${focusNode}\",\n \"status\": \"${status}\"\n },"
}
}
println " {}"
println " ],"
nonconformantCounter = 0
println " \"nonconformant\": ["
report.forEachReport { reportEntry ->
status = reportEntry.status
reason = reportEntry.reason
focusNode = reportEntry.focus
switch (status) {
case ShexStatus.nonconformant :
nonconformantCounter = nonconformantCounter + 1
println " {\n \"class\": \"${focusNode}\",\n \"status\": \"${status}\",\n \"reason\": \"${reason}\"\n },"
}
}
println " {}"
println " ]"
println "}"
if (nonconformantCounter > 0) System.exit(1)