server/src/app/Models/Document.php
changeset 374 c622fa18eb32
parent 371 0365fd9977a4
child 377 52169c718513
equal deleted inserted replaced
373:e952c8a31a2b 374:c622fa18eb32
    98         return $this->getProvidedCHO()->all('dc11:type');
    98         return $this->getProvidedCHO()->all('dc11:type');
    99     }
    99     }
   100 
   100 
   101     public function getDiscourseTypes() {
   101     public function getDiscourseTypes() {
   102         return array_values(array_filter($this->getTypes(), function($v) {
   102         return array_values(array_filter($this->getTypes(), function($v) {
   103             return $v instanceof Literal && $v->getDatatypeUri() === Config::get('corpusparole.olac_discourse_type')['uri'];
   103             return $v instanceof Resource && preg_match(config('corpusparole.bnf_ark_url_regexp'), $v->getUri());
   104         }));
   104         }));
   105     }
   105     }
   106 
   106 
   107     public function getOtherTypes() {
   107     public function getOtherTypes() {
   108         $res = array_values(array_filter($this->getTypes(), function($v) {
   108         $res = array_values(array_filter($this->getTypes(), function($v) {
   109             return $v instanceof Resource || $v->getDatatypeUri() !== Config::get('corpusparole.olac_discourse_type')['uri'];
   109             return !($v instanceof Resource) || !preg_match(config('corpusparole.bnf_ark_url_regexp'), $v->getUri());
   110         }));
   110         }));
   111         return $res;
   111         return $res;
   112     }
   112     }
   113 
   113 
   114     public function getTranscript() {
   114     public function getTranscript() {
   188 
   188 
   189         $this->startDelta();
   189         $this->startDelta();
   190 
   190 
   191         //delete
   191         //delete
   192         foreach($this->getDiscourseTypes() as $discourseType) {
   192         foreach($this->getDiscourseTypes() as $discourseType) {
   193             $literalValue = new Literal($discourseType, null, Config::get('corpusparole.olac_discourse_type')['uri']);
   193             $this->getProvidedCHO()->delete('dc11:type', $discourseType);
   194             $this->getProvidedCHO()->delete('dc11:type', $literalValue);
   194             $this->currentDelta->getDeletedGraph()->addResource($this->getProvidedCHO(), 'dc11:type', $discourseType->getUri());
   195             $this->currentDelta->getDeletedGraph()->add($this->getProvidedCHO(), 'dc11:type', new Literal($discourseType, null, Config::get('corpusparole.olac_discourse_type')['uri']));
       
   196         }
   195         }
   197 
   196 
   198         // and re-add them
   197         // and re-add them
   199         foreach($discoursesTypes as $dType) {
   198         foreach($discoursesTypes as $dType) {
   200             $this->getProvidedCHO()->add('dc11:type', new Literal($dType, null, Config::get('corpusparole.olac_discourse_type')['uri']));
   199             $this->getProvidedCHO()->addResource('dc11:type', $dType);
   201             $this->currentDelta->getAddedGraph()->add($this->getProvidedCHO(), 'dc11:type', new Literal($dType, null, Config::get('corpusparole.olac_discourse_type')['uri']));
   200             $this->currentDelta->getAddedGraph()->addResource($this->getProvidedCHO(), 'dc11:type', $dType);
   202         }
   201         }
   203 
   202 
   204         $this->clearMemoizationCache();
   203         $this->clearMemoizationCache();
   205     }
   204     }
   206 
   205