server/src/app/Libraries/Mappers/CocoonAbstractRdfMapper.php
changeset 19 eadaf0b8f02e
parent 18 f2a40bbc27f6
child 23 037687868bc4
equal deleted inserted replaced
18:f2a40bbc27f6 19:eadaf0b8f02e
    22 /**
    22 /**
    23  *
    23  *
    24  */
    24  */
    25 abstract class CocoonAbstractRdfMapper implements RdfMapper {
    25 abstract class CocoonAbstractRdfMapper implements RdfMapper {
    26 
    26 
    27     public function __construct(Graph $inputGraph) {
    27     public function __construct(Graph $inputGraph, $uri=null) {
    28         $this->inputGraph = $inputGraph;
    28         $this->inputGraph = $inputGraph;
    29         $this->uri = $inputGraph->getUri();
    29         $this->uri = is_null($uri)?$inputGraph->getUri():$uri;
    30         $this->outputGraphes = [];
    30         $this->outputGraphes = [];
    31     }
    31     }
    32 
    32 
    33     abstract protected function mapResource($res, $outputGraph);
    33     abstract protected function mapResource($res, $outputGraph);
    34     abstract protected function getResourceBaseId($res=null);
    34     abstract protected function getResourceBaseId($res=null);
   130 
   130 
   131     protected function mapCollections($res) {
   131     protected function mapCollections($res) {
   132         $collections = $res->all('dc:isPartOf');
   132         $collections = $res->all('dc:isPartOf');
   133         foreach($collections as $coll) {
   133         foreach($collections as $coll) {
   134             if($coll instanceof Resource) {
   134             if($coll instanceof Resource) {
   135                 $collectionGraph = new Graph($coll->getUri());
   135                 $collUri = $coll->getUri();
   136                 $this->outputGraphes[$coll->getUri()] = $collectionGraph;
   136                 if(strpos(strtolower($collUri), "collection", strlen(config('cocoon_doc_id_base_uri'))) !== FALSE) {
   137                 $collectionGraph->resource($coll->getUri(), 'edm:Collection');
   137                     $collectionGraph = new Graph($collUri);
       
   138                     $this->outputGraphes[$collUri] = $collectionGraph;
       
   139                     $collectionGraph->resource($collUri, 'edm:Collection');
       
   140                 }
   138             }
   141             }
   139         }
   142         }
   140     }
   143     }
   141 
   144 
   142 
   145