-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidate.groovy
51 lines (44 loc) · 1.25 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
@Grab(group='io.github.egonw.bacting', module='managers-rdf', version='0.3.2')
import org.apache.jena.shex.ShexStatus
workspaceRoot = ".."
root = "fdp"
rdf = new net.bioclipse.managers.RDFManager(workspaceRoot);
clazz = args[3]
file = args[2]
shape = args[0]
shapeRes = args[1]
store = rdf.createInMemoryStore(true);
store = rdf.importFile(store, "/${root}/${file}", "TURTLE")
report = rdf.validateAllOfType(
store,
"/${root}/shapes/${shape}",
shapeRes,
clazz
)
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 " ],"
println " \"nonconformant\": ["
report.forEachReport { reportEntry ->
status = reportEntry.status
reason = reportEntry.reason
focusNode = reportEntry.focus
switch (status) {
case ShexStatus.nonconformant :
println " {\n \"class\": \"${focusNode}\",\n \"status\": \"${status}\",\n \"reason\": \"${reason}\"\n },"
}
}
println " {}"
println " ]"
println "}"