# HG changeset patch # User ymh # Date 1486390959 -3600 # Node ID 4f507ba2bb4c911e5ac4d472476b0c1062d48406 # Parent b5cff30efa0a411c6cee6cf9e04dedf72dd03b59 add alternativeTitle. Prepare #0025746 diff -r b5cff30efa0a -r 4f507ba2bb4c server/src/app/Models/Document.php --- a/server/src/app/Models/Document.php Mon Feb 06 14:36:25 2017 +0100 +++ b/server/src/app/Models/Document.php Mon Feb 06 15:22:39 2017 +0100 @@ -32,6 +32,7 @@ private $types = null; private $descriptions = null; private $geoInfo = false; + private $alternativeTitle = false; protected function clearMemoizationCache() { parent::clearMemoizationCache(); @@ -313,7 +314,7 @@ /** - * Get subjects list + * Get descriptions */ public function getDescriptions() { if(is_null($this->descriptions)) { @@ -325,6 +326,24 @@ return $this->descriptions; } + /** + * Get Alternative Title + */ + public function getAlternativeTitle() { + if($this->alternativeTitle === false) { + try { + $this->alternativeTitle = $this->getProvidedCHO()->getLiteral(''); + } catch(\Exception $e) { + $this->alternativeTitle = null; + } + } + return $this->alternativeTitle; + } + + public function getAlternativeTitleValue() { + $alternativeTitle = $this->getAlternativeTitle(); + return is_null($alternativeTitle)?null:$alternativeTitle->getValue(); + } public function isIsomorphic($doc) { return Isomorphic::isomorphic($this->graph, $doc->graph); @@ -387,7 +406,8 @@ 'transcript' => $transcript, 'mediaArray'=> $mediaArray, 'geoInfo' => $geoInfo, - 'descriptions' => $descriptions + 'descriptions' => $descriptions, + 'alternativeTitle' => $this->getAlternativeTitleValue(), ]); } diff -r b5cff30efa0a -r 4f507ba2bb4c server/src/tests/Models/DocumentTest.php --- a/server/src/tests/Models/DocumentTest.php Mon Feb 06 14:36:25 2017 +0100 +++ b/server/src/tests/Models/DocumentTest.php Mon Feb 06 15:22:39 2017 +0100 @@ -430,7 +430,8 @@ $this->assertEquals( [ "id", "uri", "title", "languages", "modified", "issued", "created", "publishers", "contributors", "subjects", "types", - "transcript", "mediaArray", "geoInfo", "descriptions" ], + "transcript", "mediaArray", "geoInfo", "descriptions", + "alternativeTitle" ], array_keys($json) ); $this->assertEquals(sprintf('%1$s/crdo-CFPP2000_35_SOUNDid', config('corpusparole.handle_prefix')), $json['id']); diff -r b5cff30efa0a -r 4f507ba2bb4c server/src/tests/Repositories/DocumentRepositoryIntegrationTest.php --- a/server/src/tests/Repositories/DocumentRepositoryIntegrationTest.php Mon Feb 06 14:36:25 2017 +0100 +++ b/server/src/tests/Repositories/DocumentRepositoryIntegrationTest.php Mon Feb 06 15:22:39 2017 +0100 @@ -82,7 +82,7 @@ $this->assertInstanceOf(Document::class, $res, "Result must be of type Document"); $this->assertEquals(config('corpusparole.corpus_id_scheme').'crdo-ALA_738', $res->getId(), 'id should be crdo-ALA_738' ); - $this->assertNotNull($res->getGraph(), "Graph shoul not be null"); + $this->assertNotNull($res->getGraph(), "Graph should not be null"); $this->assertEquals(config('corpusparole.corpus_doc_id_base_uri')."crdo-ALA_738",$res->getGraph()->getUri(), "uri of graph must be ".config('corpusparole.corpus_doc_id_base_uri')."crdo-ALA_738"); $this->assertTrue(EasyRdf\Isomorphic::isomorphic($res->getGraph(),$returnedGraph)); }