server/src/app/Models/Document.php
changeset 277 bd4bc1db4f40
parent 260 64caee7ce38d
child 371 0365fd9977a4
equal deleted inserted replaced
276:ef32bf573d9c 277:bd4bc1db4f40
    37         $this->mediaArray = null;
    37         $this->mediaArray = null;
    38         $this->contributors = null;
    38         $this->contributors = null;
    39         $this->subjects = null;
    39         $this->subjects = null;
    40         $this->transcript = false;
    40         $this->transcript = false;
    41         $this->geoInfo = false;
    41         $this->geoInfo = false;
       
    42     }
       
    43 
       
    44     protected function additionalDeltaLists() {
       
    45 
       
    46         $geoInfo = $this->getGeoInfo();
       
    47         $geoInfoDeltas = is_null($geoInfo)?[]:$geoInfo->getDeltaList();
       
    48         return empty($geoInfoDeltas)?[]:[$geoInfoDeltas,];
    42     }
    49     }
    43 
    50 
    44 
    51 
    45     private function parseWebResources() {
    52     private function parseWebResources() {
    46 
    53 
   206         }
   213         }
   207         return $this->subjects;
   214         return $this->subjects;
   208     }
   215     }
   209 
   216 
   210     /**
   217     /**
   211      *
   218      * get the GeoInfoObject
       
   219      * Ths returned object should be limited for read only activities.
       
   220      * If it needs to be edited use the addGeoInfo method.
   212      */
   221      */
   213     public function getGeoInfo() {
   222     public function getGeoInfo() {
   214         if($this->geoInfo === false) {
   223         if($this->geoInfo === false) {
   215             $places = $this->getProvidedCHO()->all('<http://purl.org/dc/terms/spatial>');
   224             $places = $this->getProvidedCHO()->all('<http://purl.org/dc/terms/spatial>');
   216             $this->geoInfo = null;
   225             $this->geoInfo = null;
   217             if($places) {
   226             if($places) {
   218                 $this->geoInfo = new GeoResource($places[0]->getUri(), $this->graph);
   227                 $this->geoInfo = new GeoResource($places[0]->getUri(), $this->graph, $this->getProvidedCHO());
   219             }
   228             }
   220         }
   229         }
       
   230         return $this->geoInfo;
       
   231     }
       
   232 
       
   233     public function addGeoInfo() {
       
   234         $geoInfo = $this->getGeoInfo();
       
   235         if(!is_null($geoInfo)) {
       
   236             // if there already is a geo info, just return it.
       
   237             $geoInfo->setReadOnly(false);
       
   238             $geoInfo->setNeedDelete(true);
       
   239             return $geoInfo;
       
   240          }
       
   241 
       
   242         $this->geoInfo = false;
       
   243 
       
   244         $geoinfoNode = $this->getGraph()->newBNode("http://www.europeana.eu/schemas/edm/Place");
       
   245         $this->getProvidedCHO()->addResource("http://purl.org/dc/terms/spatial", $geoinfoNode);
       
   246 
       
   247         $this->geoInfo = new GeoResource($geoinfoNode->getUri(), $this->graph, $this->getProvidedCHO());
       
   248         $this->geoInfo->setReadOnly(false);
       
   249         $this->geoInfo->setNeedDelete(false);
       
   250 
   221         return $this->geoInfo;
   251         return $this->geoInfo;
   222     }
   252     }
   223 
   253 
   224     /**
   254     /**
   225      * change subjecs list
   255      * change subjecs list