diff options
| author | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-12-02 16:28:07 +0000 |
|---|---|---|
| committer | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-12-02 16:41:42 +0000 |
| commit | 83330598df9a806508b2157a41f17a3faaddcd56 (patch) | |
| tree | 3c4516b86a43cb788d597728bb6d1ec041cd7f49 | |
| parent | d7ddf7fbd3dd887df12fbdad5bcf0ddf4a0ff829 (diff) | |
| download | RSAComb-83330598df9a806508b2157a41f17a3faaddcd56.tar.gz RSAComb-83330598df9a806508b2157a41f17a3faaddcd56.zip | |
Unify upload of rules and facts to RDFox datastore
This will also help if/when we are implementing transactions.
| -rw-r--r-- | src/main/scala/uk/ac/ox/cs/rsacomb/util/RDFoxUtil.scala | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/util/RDFoxUtil.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/util/RDFoxUtil.scala index f7abde3..193119f 100644 --- a/src/main/scala/uk/ac/ox/cs/rsacomb/util/RDFoxUtil.scala +++ b/src/main/scala/uk/ac/ox/cs/rsacomb/util/RDFoxUtil.scala | |||
| @@ -5,7 +5,8 @@ import tech.oxfordsemantic.jrdfox.Prefixes | |||
| 5 | import tech.oxfordsemantic.jrdfox.client.{ | 5 | import tech.oxfordsemantic.jrdfox.client.{ |
| 6 | ConnectionFactory, | 6 | ConnectionFactory, |
| 7 | ServerConnection, | 7 | ServerConnection, |
| 8 | DataStoreConnection | 8 | DataStoreConnection, |
| 9 | UpdateType | ||
| 9 | } | 10 | } |
| 10 | import tech.oxfordsemantic.jrdfox.formats.SPARQLParser | 11 | import tech.oxfordsemantic.jrdfox.formats.SPARQLParser |
| 11 | import tech.oxfordsemantic.jrdfox.logic.datalog.{ | 12 | import tech.oxfordsemantic.jrdfox.logic.datalog.{ |
| @@ -47,9 +48,8 @@ object RDFoxUtil { | |||
| 47 | * @return a tuple with the newly opened server and data store | 48 | * @return a tuple with the newly opened server and data store |
| 48 | * connections. | 49 | * connections. |
| 49 | * | 50 | * |
| 50 | * @see [[uk.ac.ox.cs.rsacomb.util.RDFoxUtil.closeConnection | 51 | * @see [[uk.ac.ox.cs.rsacomb.util.RDFoxUtil.closeConnection RDFoxUtil.closeConnection]] |
| 51 | * RDFoxUtil.closeConnection]] for | 52 | * for details on how to close an open connection. |
| 52 | * details on how to close an open connection. | ||
| 53 | */ | 53 | */ |
| 54 | def openConnection( | 54 | def openConnection( |
| 55 | datastore: String, | 55 | datastore: String, |
| @@ -66,6 +66,26 @@ object RDFoxUtil { | |||
| 66 | (server, data) | 66 | (server, data) |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | /** Adds a collection of rules to a data store. | ||
| 70 | * | ||
| 71 | * @param data datastore connection | ||
| 72 | * @param rules collection of rules to be added to the data store | ||
| 73 | */ | ||
| 74 | def addRules(data: DataStoreConnection, rules: Seq[Rule]): Unit = | ||
| 75 | data addRules rules | ||
| 76 | |||
| 77 | /** Adds a collection of facts to a data store. | ||
| 78 | * | ||
| 79 | * @param data datastore connection | ||
| 80 | * @param facts collection of facts to be added to the data store | ||
| 81 | */ | ||
| 82 | def addFacts(data: DataStoreConnection, facts: Seq[TupleTableAtom]): Unit = | ||
| 83 | data.importData( | ||
| 84 | UpdateType.ADDITION, | ||
| 85 | RSA.Prefixes, | ||
| 86 | facts.map(_.toString(Prefixes.s_emptyPrefixes)).mkString("", ".\n", ".") | ||
| 87 | ) | ||
| 88 | |||
| 69 | /** Parse a SELECT query from a string in SPARQL format. | 89 | /** Parse a SELECT query from a string in SPARQL format. |
| 70 | * | 90 | * |
| 71 | * @param query the string containing the SPARQL query | 91 | * @param query the string containing the SPARQL query |
