server/src/app/Models/Document.php
changeset 122 b37fde30dd4a
parent 115 34ffc04cef62
child 125 e550b10fe3ca
equal deleted inserted replaced
121:08c99d286e7c 122:b37fde30dd4a
    18  * SELECT DISTINCT ?g WHERE {GRAPH ?g {?s ?p ?o}}
    18  * SELECT DISTINCT ?g WHERE {GRAPH ?g {?s ?p ?o}}
    19  */
    19  */
    20 class Document extends RdfModelResource implements JsonSerializable {
    20 class Document extends RdfModelResource implements JsonSerializable {
    21 
    21 
    22     public function __construct($uri, $graph = null) {
    22     public function __construct($uri, $graph = null) {
       
    23         //print($graph->dump('html'));
    23         parent::__construct($uri, $graph);
    24         parent::__construct($uri, $graph);
    24     }
    25     }
    25 
    26 
    26     private $id = null;
    27     private $id = null;
    27 
    28 
    53         $this->contributors = null;
    54         $this->contributors = null;
    54     }
    55     }
    55 
    56 
    56     public function getId() {
    57     public function getId() {
    57         if(is_null($this->id)) {
    58         if(is_null($this->id)) {
    58             $this->id = $this->getProvidedCHO()->get('<http://purl.org/dc/terms/identifier>');
    59             $ids = $this->getProvidedCHO()->all('<http://purl.org/dc/elements/1.1/identifier>');
       
    60             foreach ($ids as $id) {
       
    61                 if($id instanceof Literal && strpos($id->getValue(), config('corpusparole.corpus_id_scheme')) === 0) {
       
    62                     $this->id = $id->getValue();
       
    63                 }
       
    64             }
    59             if(is_null($this->id)) {
    65             if(is_null($this->id)) {
    60                 $this->id = CocoonUtils::getIdFromCorpusUri($this->uri);
    66                 $this->id = CocoonUtils::getIdFromCorpusUri($this->uri);
    61             }
    67             }
    62         }
    68         }
    63         return $this->id;
    69         return $this->id;