--- a/server/src/app/Libraries/Sparql/SparqlClient.php Mon Apr 25 14:05:17 2016 +0200
+++ b/server/src/app/Libraries/Sparql/SparqlClient.php Sat May 07 10:06:26 2016 +0200
@@ -121,11 +121,39 @@
}
public function add(Graph $graph) {
- $this->updateData('INSERT', $graph);
+ return $this->updateData('INSERT', $graph);
}
public function delete(Graph $graph) {
- $this->updateData('DELETE', $graph);
+ return $this->updateData('DELETE', $graph);
+ }
+
+ public function deleteWhere($whereClauses, string $graphUri = null) {
+
+ if(is_array($whereClause)) {
+ $whereClause = implode(" .", $whereClause);
+ }
+
+ if($graphUri) {
+ $whereClause = "GRAPH <$graphUri> { $whereClause }";
+ }
+
+ $query = "DELETE WHERE { $whereClause }";
+
+ // doc : http://rdf4j.org/doc/4/articles/REST-API/transaction-operations.docbook?view
+ // cf. bug : https://openrdf.atlassian.net/browse/SES-2295
+ // and PR https://bitbucket.org/openrdf/sesame/commits/62b680d8650caca7bc1673f6aaac48a5b6e85d23?at=2.8.x
+ // The put form has been chosen over the post, because it seems that this is the form choosed in the sesame http client
+ $resp = $this->getHttpClient()->put(
+ $this->currentTransactionUrl, [
+ 'headers' => ["Content-Type" => "application/sparql-update; charset=utf-8"],
+ 'query' => ['action' => 'UPDATE'],
+ 'body' => $query,
+ ]
+ );
+
+ return $resp;
+
}
/** Make a query to the SPARQL endpoint