server/src/app/Models/DocumentResult.php
changeset 275 a4d8618c2f1b
parent 260 64caee7ce38d
child 319 78990a8a069b
--- a/server/src/app/Models/DocumentResult.php	Mon Sep 05 18:45:47 2016 +0200
+++ b/server/src/app/Models/DocumentResult.php	Tue Sep 06 16:50:41 2016 +0200
@@ -23,12 +23,14 @@
     private $publishers = false;
     private $duration = false;
     private $durationMs = -1;
+    private $transcriptUrl = false;
 
     protected function clearMemoizationCache() {
         parent::clearMemoizationCache();
         $this->publishers = false;
         $this->duration = false;
-        $this->$durationMs = -1;
+        $this->durationMs = -1;
+        $this->transcriptUrl = false;
 
     }
 
@@ -66,6 +68,17 @@
         return $this->durationMs;
     }
 
+    public function getTranscriptUrl() {
+        if($this->transcriptUrl === false) {
+            try {
+                $this->transcriptUrl = $this->getProvidedCHO()->getLiteral("<".config('corpusparole.corpus_ontology_url').'transcript'.">");
+            } catch(\Exception $e) {
+                $this->transcriptUrl = null;
+            }
+        }
+        return is_null($this->transcriptUrl)?null:$this->transcriptUrl->getValue();
+    }
+
     public function jsonSerialize() {
 
         $res = parent::jsonSerialize();
@@ -73,7 +86,8 @@
         if($this->graph) {
             $res = array_merge($res, [
                 'publishers' => $this->getPublishersValue(),
-                'duration' => $this->getDurationValue()
+                'duration' => $this->getDurationValue(),
+                'transcript_url' => $this->getTranscriptUrl()
             ]);
         }
         return $res;