server/src/app/Libraries/Sparql/SparqlClient.php
changeset 158 366509ae2f37
parent 109 d22ed5792f8e
child 277 bd4bc1db4f40
equal deleted inserted replaced
157:1f9853178fcd 158:366509ae2f37
   119         );
   119         );
   120 
   120 
   121     }
   121     }
   122 
   122 
   123     public function add(Graph $graph) {
   123     public function add(Graph $graph) {
   124         $this->updateData('INSERT', $graph);
   124         return $this->updateData('INSERT', $graph);
   125     }
   125     }
   126 
   126 
   127     public function delete(Graph $graph) {
   127     public function delete(Graph $graph) {
   128         $this->updateData('DELETE', $graph);
   128         return $this->updateData('DELETE', $graph);
       
   129     }
       
   130 
       
   131     public function deleteWhere($whereClauses, string $graphUri = null) {
       
   132 
       
   133         if(is_array($whereClause)) {
       
   134             $whereClause = implode(" .", $whereClause);
       
   135         }
       
   136 
       
   137         if($graphUri) {
       
   138             $whereClause = "GRAPH <$graphUri> { $whereClause }";
       
   139         }
       
   140 
       
   141         $query = "DELETE WHERE { $whereClause }";
       
   142 
       
   143         // doc : http://rdf4j.org/doc/4/articles/REST-API/transaction-operations.docbook?view
       
   144         // cf. bug : https://openrdf.atlassian.net/browse/SES-2295
       
   145         // and PR https://bitbucket.org/openrdf/sesame/commits/62b680d8650caca7bc1673f6aaac48a5b6e85d23?at=2.8.x
       
   146         // The put form has been chosen over the post, because it seems that this is the form choosed in the sesame http client
       
   147         $resp = $this->getHttpClient()->put(
       
   148             $this->currentTransactionUrl, [
       
   149                 'headers' => ["Content-Type" => "application/sparql-update; charset=utf-8"],
       
   150                 'query' => ['action' => 'UPDATE'],
       
   151                 'body' => $query,
       
   152             ]
       
   153         );
       
   154 
       
   155         return $resp;
       
   156 
   129     }
   157     }
   130 
   158 
   131     /** Make a query to the SPARQL endpoint
   159     /** Make a query to the SPARQL endpoint
   132      *
   160      *
   133      * Just call and return EasyRdf\Sparql\Client::query
   161      * Just call and return EasyRdf\Sparql\Client::query