add alternativeTitle. Prepare #0025746
--- 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('<http://purl.org/dc/terms/alternative>');
+ } 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(),
]);
}
--- 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']);
--- 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));
}