Migrate to php 5.6 + Laravel 5.1 + add phpunit test
authorymh <ymh.work@gmail.com>
Wed, 24 Jun 2015 01:36:46 +0200
changeset 3 2b3247d02769
parent 2 00e2916104fe
child 4 f55970e41793
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
server/src/app/Console/Commands/ImportCocoonRDF.php
server/src/app/Models/Document.php
server/src/app/Repositories/RdfDocumentRepository.php
--- a/server/src/app/Console/Commands/ImportCocoonRDF.php	Tue Jun 23 17:01:39 2015 +0200
+++ b/server/src/app/Console/Commands/ImportCocoonRDF.php	Wed Jun 24 01:36:46 2015 +0200
@@ -43,7 +43,8 @@
         echo("hello\n");
         libxml_use_internal_errors(true);
 
-        $gs = new \EasyRdf_GraphStore(Config::get('corpusparole.sesame_update_url'));
+        //$gs = new \EasyRdf_GraphStore(Config::get('corpusparole.sesame_update_url'));
+        $gs = new \EasyRdf_Sparql_Client(Config::get('corpusparole.sesame_query_url'), Config::get('corpusparole.sesame_update_url'));
 
         //$doc = new \EasyRdf_Graph("http://cocoon.huma-num.fr/exist/crdo/rdf/crdo-ESLO1_ENTCONT_203");
         //$doc->load();
--- a/server/src/app/Models/Document.php	Tue Jun 23 17:01:39 2015 +0200
+++ b/server/src/app/Models/Document.php	Wed Jun 24 01:36:46 2015 +0200
@@ -3,20 +3,20 @@
 
 use Config;
 use CorpusParole\Libraries\Utils;
+use CorpusParole\Libraries\RdfModel\RdfModelResource;
 use Log;
 
 /**
  * Model class for Document. Inherit from EasyRdf_Resource
+ * SELECT DISTINCT ?g WHERE {GRAPH ?g {?s ?p ?o}}
  */
-class Document extends \EasyRdf_Resource {
+class Document extends RdfModelResource {
 
     public function __construct($uri, $graph = null) {
-        parent::__construct($uri, $graph);
-        $this->innerDocument = $this->getResource('foaf:primaryTopic');
+        parent::__construct($uri, $graph, 'foaf:primaryTopic');
     }
 
     private $id = null;
-    private $innerDocument = null;
 
     public function getId() {
         if(is_null($this->id)) {
@@ -65,13 +65,18 @@
     }
 
     public function updateDiscourseTypes(array $discoursesTypes) {
+
+        $this->startDelta();
+
         foreach($this->getDiscourseTypes() as $discourseType) {
             $this->innerDocument->delete('dc11:type', $discourseType);
+            $this->currentDelta->deletedGraph->add($this->innerDocument, 'dc11:type', $discourseType);
         }
         // re-add them
 
         foreach($discoursesTypes as $dType) {
             $this->innerDocument->add('dc11:type', new \EasyRdf_Literal($dType, null, Config::get('constants.OLAC_DISCOURSE_TYPE')['uri']));
+            $this->currentDelta->addedGraph->add($this->innerDocument, 'dc11:type', $discourseType);
         }
     }
 
--- a/server/src/app/Repositories/RdfDocumentRepository.php	Tue Jun 23 17:01:39 2015 +0200
+++ b/server/src/app/Repositories/RdfDocumentRepository.php	Wed Jun 24 01:36:46 2015 +0200
@@ -14,7 +14,7 @@
     private $sparqlClient;
 
     function __construct() {
-        $this->sparqlClient = new \EasyRdf_Sparql_Client(Config::get('corpusparole.sesame_query_url'));
+        $this->sparqlClient = new \EasyRdf_Sparql_Client(Config::get('corpusparole.sesame_query_url'), Config::get('corpusparole.sesame_update_url'));
     }
 
     public function all() {