Skip to content

Commit

Permalink
Merge branch 'main' into refactor/use-Userservice-for-creating-a-new-…
Browse files Browse the repository at this point in the history
…User
  • Loading branch information
seakayone authored Feb 16, 2024
2 parents 38c8fca + 8b59d54 commit f0650e8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ object TestDatasetBuilder {

private def readToModel(turtle: String)(model: Model): Model = model.read(new StringReader(turtle), null, "TTL")

private def transactionalWrite(change: Model => Model)(ds: Dataset): Task[Dataset] = ZIO.attempt {
private def transactionalWrite(change: Model => Model, graph: String)(ds: Dataset): Task[Dataset] = ZIO.attempt {
ds.begin(ReadWrite.WRITE)
try {
change apply ds.getDefaultModel
change apply ds.getNamedModel(graph)
ds.commit()
} finally {
ds.end()
}
ds
}

private def datasetFromTurtle(turtle: String): Task[Dataset] =
createEmptyDataset.flatMap(transactionalWrite(readToModel(turtle)))
private def datasetFromTurtle(turtle: String, graph: String = "http://www.example.org/graph"): Task[Dataset] =
createEmptyDataset.flatMap(transactionalWrite(readToModel(turtle), graph))

def datasetFromTriG(trig: String): Task[Dataset] =
for {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.apache.jena.query.*
import org.apache.jena.rdf.model.Model
import org.apache.jena.rdf.model.ModelFactory
import org.apache.jena.riot.RDFDataMgr
import org.apache.jena.tdb.TDB
import org.apache.jena.tdb2.TDB2Factory
import org.apache.jena.update.UpdateExecutionFactory
import org.apache.jena.update.UpdateFactory
Expand Down Expand Up @@ -302,7 +303,10 @@ object TriplestoreServiceInMemory {
* Currently does not (yet) support create a [[Dataset]] which supports Lucene indexing.
* TODO: https://jena.apache.org/documentation/query/text-query.html#configuration-by-code
*/
val createEmptyDataset: UIO[Dataset] = ZIO.succeed(TDB2Factory.createDataset())
val createEmptyDataset: UIO[Dataset] =
ZIO
.succeed(TDB.getContext.set(TDB.symUnionDefaultGraph, true))
.as(TDB2Factory.createDataset())

val emptyDatasetRefLayer: ULayer[Ref[Dataset]] = ZLayer.fromZIO(createEmptyDataset.flatMap(Ref.make(_)))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,11 @@ object TriplestoreServiceInMemorySpec extends ZIOSpecDefault {
val updateQuery = s"""
|PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
|INSERT { <http://aNewArticle> a <${Biblio.Class.Article.value}> }
|WHERE { ?s ?p ?o }
|INSERT DATA {
| GRAPH <http://rdfh.ch/1234> {
| <http://aNewArticle> a <${Biblio.Class.Article.value}>
| }
|}
|""".stripMargin
val askQuery = s"""
|PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
Expand Down

0 comments on commit f0650e8

Please sign in to comment.