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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
package rsacomb
/* Java imports */
import java.util.HashMap
import tech.oxfordsemantic.jrdfox.Prefixes
import tech.oxfordsemantic.jrdfox.logic.IRI
import tech.oxfordsemantic.jrdfox.client.{
ConnectionFactory,
ServerConnection,
DataStoreConnection
}
object RDFoxUtil {
implicit def owlapi2rdfox(iri: org.semanticweb.owlapi.model.IRI): IRI = {
IRI.create(iri.getIRIString())
}
implicit def owlapi2rdfox(iri: String): IRI = {
IRI.create(iri)
}
def openConnection(
dataStore: String
): (ServerConnection, DataStoreConnection) = {
/* Create local server connection
*/
val serverUrl = "rdfox:local"
val role = ""
val password = ""
val server =
ConnectionFactory.newServerConnection(serverUrl, role, password)
/* Create datastore connection
*/
val parameters = new HashMap[String, String]()
parameters.put("owl-in-rdf-support", "relaxed")
//parameters.put("equality", "noUNA")
server.createDataStore(dataStore, "par-complex-nn", parameters)
val data = server.newDataStoreConnection(dataStore)
(server, data)
}
def submitQuery(
data: DataStoreConnection,
prefixes: Prefixes,
query: String
): Unit = {
println(s"\n{ $query }")
val cursor = data.createCursor(
prefixes,
query,
new HashMap[String, String]()
);
var mul = cursor.open()
while (mul > 0) {
val res0 = cursor.getResource(0)
val res1 = cursor.getResource(1)
println(s"Answer: $res0 $res1")
mul = cursor.advance()
}
cursor.close();
}
def closeConnection(
server: ServerConnection,
data: DataStoreConnection
): Unit = {
server.close();
data.close();
}
} // object RDFox
|