server/src/app/Models/DocumentResult.php
changeset 275 a4d8618c2f1b
parent 260 64caee7ce38d
child 319 78990a8a069b
equal deleted inserted replaced
274:53a6985443f8 275:a4d8618c2f1b
    21     }
    21     }
    22 
    22 
    23     private $publishers = false;
    23     private $publishers = false;
    24     private $duration = false;
    24     private $duration = false;
    25     private $durationMs = -1;
    25     private $durationMs = -1;
       
    26     private $transcriptUrl = false;
    26 
    27 
    27     protected function clearMemoizationCache() {
    28     protected function clearMemoizationCache() {
    28         parent::clearMemoizationCache();
    29         parent::clearMemoizationCache();
    29         $this->publishers = false;
    30         $this->publishers = false;
    30         $this->duration = false;
    31         $this->duration = false;
    31         $this->$durationMs = -1;
    32         $this->durationMs = -1;
       
    33         $this->transcriptUrl = false;
    32 
    34 
    33     }
    35     }
    34 
    36 
    35     public function getPublishers() {
    37     public function getPublishers() {
    36         if($this->publishers === false) {
    38         if($this->publishers === false) {
    64             $this->durationMs = Utils::iso8601IntervalToMillis($this->getDuration());
    66             $this->durationMs = Utils::iso8601IntervalToMillis($this->getDuration());
    65         }
    67         }
    66         return $this->durationMs;
    68         return $this->durationMs;
    67     }
    69     }
    68 
    70 
       
    71     public function getTranscriptUrl() {
       
    72         if($this->transcriptUrl === false) {
       
    73             try {
       
    74                 $this->transcriptUrl = $this->getProvidedCHO()->getLiteral("<".config('corpusparole.corpus_ontology_url').'transcript'.">");
       
    75             } catch(\Exception $e) {
       
    76                 $this->transcriptUrl = null;
       
    77             }
       
    78         }
       
    79         return is_null($this->transcriptUrl)?null:$this->transcriptUrl->getValue();
       
    80     }
       
    81 
    69     public function jsonSerialize() {
    82     public function jsonSerialize() {
    70 
    83 
    71         $res = parent::jsonSerialize();
    84         $res = parent::jsonSerialize();
    72 
    85 
    73         if($this->graph) {
    86         if($this->graph) {
    74             $res = array_merge($res, [
    87             $res = array_merge($res, [
    75                 'publishers' => $this->getPublishersValue(),
    88                 'publishers' => $this->getPublishersValue(),
    76                 'duration' => $this->getDurationValue()
    89                 'duration' => $this->getDurationValue(),
       
    90                 'transcript_url' => $this->getTranscriptUrl()
    77             ]);
    91             ]);
    78         }
    92         }
    79         return $res;
    93         return $res;
    80     }
    94     }
    81 }
    95 }