-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.groovy
46 lines (39 loc) · 2.08 KB
/
test.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
import org.aksw.conjure.cli.main.FactoryBeanObject
import org.aksw.jena_sparql_api.common.DefaultPrefixes
import org.aksw.jena_sparql_api.conjure.dataref.rdf.api.DataRefOp
import org.aksw.jena_sparql_api.conjure.dataset.algebra.OpData
import org.aksw.jena_sparql_api.conjure.dataset.algebra.OpUpdateRequest
import org.aksw.jena_sparql_api.conjure.fluent.ConjureBuilderImpl
import org.aksw.jena_sparql_api.conjure.fluent.ConjureContext
import org.aksw.jena_sparql_api.conjure.job.api.Job
import org.aksw.jena_sparql_api.conjure.traversal.api.OpTraversalSelf
import org.aksw.jena_sparql_api.stmt.SparqlStmtParserImpl
import org.apache.jena.query.Syntax
import org.apache.jena.rdf.model.ModelFactory
// Useful information about bean definitions in groovy:
// https://spring.io/blog/2014/03/03/groovy-bean-configuration-in-spring-framework-4
//url = "http://localhost/~raven/test.hdt"
//ctx = new ConjureContext()
cj = new ConjureBuilderImpl()
ctx = cj.getContext()
ctxModel = ctx.getModel()
parser = ctx.getSparqlStmtParser()
//parser = SparqlStmtParserImpl.create(Syntax.syntaxARQ, DefaultPrefixes.prefixes, false)
model = ModelFactory.createDefaultModel()
//v = OpVar.create(model, "dataRef");
varName = "dataRef"
beans {
dataref FactoryBeanObject, DataRefOp.create(
OpUpdateRequest.create(model, OpData.create(model),
parser.apply("INSERT DATA { <http://mydata> dataid:group eg:mygrp ; dcat:distribution [ dcat:downloadURL <file:///home/raven/public_html/buggy1.hdt> ] }").toString()));
job FactoryBeanObject, Job.create(ctxModel)
.setOp(
cj.coalesce(
cj.fromVar(varName).hdtHeader().construct("CONSTRUCT WHERE { ?s <http://rdfs.org/ns/void#triples> ?o }"),
cj.fromVar(varName).hdtHeader().construct("CONSTRUCT WHERE { ?s <http://purl.org/HDT/hdt#triplesnumTriples> ?o }"),
cj.fromVar(varName).tripleCount().cache())
.construct("CONSTRUCT { ?s <http://rdfs.org/ns/void#triples> ?fix } { ?s <http://rdfs.org/ns/void#triples> ?o BIND(xsd:decimal(STR(?o)) AS ?fix) }")
.getOp())
.addJobBinding("datasetId", OpTraversalSelf.create(ctxModel))
;
}