# HG changeset patch # User ymh # Date 1486393502 -3600 # Node ID 7b2dcd2b31c1860c6f6c603d98fd0f24f84883f2 # Parent 4f507ba2bb4c911e5ac4d472476b0c1062d48406 add rights, Prepare #0025746 diff -r 4f507ba2bb4c -r 7b2dcd2b31c1 server/src/app/Models/Document.php --- a/server/src/app/Models/Document.php Mon Feb 06 15:22:39 2017 +0100 +++ b/server/src/app/Models/Document.php Mon Feb 06 16:05:02 2017 +0100 @@ -33,6 +33,7 @@ private $descriptions = null; private $geoInfo = false; private $alternativeTitle = false; + private $rights = false; protected function clearMemoizationCache() { parent::clearMemoizationCache(); @@ -44,6 +45,7 @@ $this->descriptions = null; $this->transcript = false; $this->geoInfo = false; + $this->rights = false; } protected function additionalDeltaLists() { @@ -345,6 +347,26 @@ return is_null($alternativeTitle)?null:$alternativeTitle->getValue(); } + + /** + * Get Rights + */ + public function getRights() { + if($this->rights === false) { + try { + $this->rights = $this->getResource(''); + } catch(\Exception $e) { + $this->rights = null; + } + } + return $this->rights; + } + + public function getRightsValue() { + $rights = $this->getRights(); + return is_null($rights)?null:$rights->getUri(); + } + public function isIsomorphic($doc) { return Isomorphic::isomorphic($this->graph, $doc->graph); } @@ -408,6 +430,7 @@ 'geoInfo' => $geoInfo, 'descriptions' => $descriptions, 'alternativeTitle' => $this->getAlternativeTitleValue(), + 'rights' => $this->getRightsValue() ]); } diff -r 4f507ba2bb4c -r 7b2dcd2b31c1 server/src/tests/Models/DocumentTest.php --- a/server/src/tests/Models/DocumentTest.php Mon Feb 06 15:22:39 2017 +0100 +++ b/server/src/tests/Models/DocumentTest.php Mon Feb 06 16:05:02 2017 +0100 @@ -431,7 +431,7 @@ [ "id", "uri", "title", "languages", "modified", "issued", "created", "publishers", "contributors", "subjects", "types", "transcript", "mediaArray", "geoInfo", "descriptions", - "alternativeTitle" ], + "alternativeTitle", "rights"], array_keys($json) ); $this->assertEquals(sprintf('%1$s/crdo-CFPP2000_35_SOUNDid', config('corpusparole.handle_prefix')), $json['id']);