~ performs sparql update on POST
authorAlexandre Bertails <bertails@gmail.com>
Thu, 25 Aug 2011 23:38:49 -0400
changeset 2 2f238399a8a2
parent 1 0ee905706f84
child 3 11415916f517
~ performs sparql update on POST
src/main/scala/Main.scala
src/test/scala/Test.scala
--- a/src/main/scala/Main.scala	Thu Aug 25 23:10:58 2011 -0400
+++ b/src/main/scala/Main.scala	Thu Aug 25 23:38:49 2011 -0400
@@ -13,6 +13,7 @@
 import org.slf4j.{Logger, LoggerFactory}
 
 import com.hp.hpl.jena.rdf.model._
+import com.hp.hpl.jena.query._
 import com.hp.hpl.jena.update._
 
 // holds some Unfiltered plans
@@ -45,13 +46,11 @@
           val bodyStream = Body.stream(req)
           /* http://openjena.org/ARQ/javadoc/com/hp/hpl/jena/update/UpdateFactory.html */
           val update:UpdateRequest = UpdateFactory.read(bodyStream)
-          val graphStore:GraphStore = GraphStoreFactory.create(model)
-          val processor:UpdateProcessor = UpdateExecutionFactory.create(update, graphStore)
-          val result:Model = processor.getGraphStore.toDataset.getDefaultModel
+          UpdateAction.execute(update, model)
           Ok ~> new ResponseStreamer {
             def stream(os:OutputStream):Unit = {
               val lang = "TURTLE"
-              result.write(os, lang)
+              model.write(os, lang)
             }
           }
         }
--- a/src/test/scala/Test.scala	Thu Aug 25 23:10:58 2011 -0400
+++ b/src/test/scala/Test.scala	Thu Aug 25 23:38:49 2011 -0400
@@ -22,26 +22,24 @@
     }
   }
 
-  val update = host / "/People/Berners-Lee/card#i"
+  val update = host / "People/Berners-Lee/card#i"
     
   val sparqlAdd =
 """
 PREFIX dc: <http://purl.org/dc/elements/1.1/>
-PREFIX foaf: <http://xmlns.com/foaf/0.1/>
 INSERT DATA
 { 
   <http://example/book1> dc:title "A new book" ;
                          dc:creator "A.N.Other" .
-  <http://www.w3.org/data#W3C>
-      foaf:member <http://www.w3.org/People/Alexandre/> .
 }
 """
 
   "SPARQL UPDATE on TimBL's FOAF profile" should {
     "return something new" in {
       val body:String = Http(post(timBL, sparqlAdd) as_str)
-      println(body)
-      body must be matching ".*Alexandre.*"
+      // println(body)
+      body must be matching ".*A new book.*"
+//      println("here")
     }
   }