server/src/app/Models/Document.php
author ymh <ymh.work@gmail.com>
Sat, 06 Aug 2016 21:27:53 +0700
changeset 260 64caee7ce38d
parent 169 8fddc113095e
child 277 bd4bc1db4f40
permissions -rw-r--r--
Split document model in document and document results
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
namespace CorpusParole\Models;
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
use Config;
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
use CorpusParole\Libraries\Utils;
18
f2a40bbc27f6 add rdf mapper + merger + basic database model
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
     6
use CorpusParole\Libraries\CocoonUtils;
3
2b3247d02769 Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
     7
use CorpusParole\Libraries\RdfModel\RdfModelResource;
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 3
diff changeset
     8
use JsonSerializable;
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
use Log;
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 3
diff changeset
    10
use EasyRdf\Literal;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 3
diff changeset
    11
use EasyRdf\Resource;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 3
diff changeset
    12
use EasyRdf\Graph;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 3
diff changeset
    13
use EasyRdf\Isomorphic;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 3
diff changeset
    14
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
/**
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 3
diff changeset
    17
 * Model class for Document. Inherit from EasyRd\Resource
3
2b3247d02769 Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    18
 * SELECT DISTINCT ?g WHERE {GRAPH ?g {?s ?p ?o}}
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
 */
260
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    20
class Document extends DocumentBase {
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
    public function __construct($uri, $graph = null) {
169
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
    23
        //                print($graph->dump('html'));
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 3
diff changeset
    24
        parent::__construct($uri, $graph);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
    27
    private $publishers = null;
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
    28
    private $mediaArray = null;
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
    29
    private $transcript = false;
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
    30
    private $contributors = null;
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 128
diff changeset
    31
    private $subjects = null;
169
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
    32
    private $geoInfo = false;
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
    33
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
    34
    protected function clearMemoizationCache() {
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
    35
        parent::clearMemoizationCache();
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
    36
        $this->publishers = null;
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
    37
        $this->mediaArray = null;
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
    38
        $this->contributors = null;
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 128
diff changeset
    39
        $this->subjects = null;
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
    40
        $this->transcript = false;
169
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
    41
        $this->geoInfo = false;
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    44
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
    45
    private function parseWebResources() {
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
    46
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
    47
        $this->mediaArray = [];
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
    48
        $this->transcript = null;
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
    49
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
    50
        $master = $this->get('<http://www.europeana.eu/schemas/edm/isShownBy>');
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
    51
        $masterUrl = is_null($master)?null:$master->getUri();
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
    52
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
    53
        foreach($this->graph->allOfType("<http://www.europeana.eu/schemas/edm/WebResource>") as $webResource) {
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
    54
            $formatLit = $webResource->getLiteral("dc11:format");
260
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    55
            $format = is_null($formatLit)?null:$formatLit->getValue();
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    56
            if(is_null($format)) {
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    57
                throw new ModelsException("parseWebResources: No dc:11 format on web resource");
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    58
            }
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    59
260
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    60
            if(0 === strpos($format, 'audio/') ||
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    61
               0 === strpos($format, 'video/') ||
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    62
               0 === strpos($format, 'Sampling:') ) {
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    63
                array_push(
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    64
                    $this->mediaArray,
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    65
                    new MediaResource(
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    66
                        $webResource->getUri(),
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    67
                        $this->graph,
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    68
                        (($webResource->getUri() === $masterUrl)?true:false))
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    69
                );
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    70
            } else if(
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    71
                0 === strpos($format, 'application/xml') ||
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    72
                0 === strpos($format, 'application/pdf') ) {
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    73
                $this->transcript = new TranscriptResource($webResource->getUri(), $this->graph);
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    74
            }
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    75
            else {
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    76
                throw new ModelsException("parseWebResources: unknown format");
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
    77
            }
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
    78
        }
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
    80
    }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
    81
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
    public function getMediaArray() {
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
    84
        if(is_null($this->mediaArray)) {
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
    85
            $this->parseWebResources();
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 3
diff changeset
    86
        }
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
    87
        return $this->mediaArray;
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
    public function getTypes() {
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
    91
        return $this->getProvidedCHO()->all('dc11:type');
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
    public function getDiscourseTypes() {
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
        return array_values(array_filter($this->getTypes(), function($v) {
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
    96
            return $v instanceof Literal && $v->getDatatypeUri() === Config::get('corpusparole.olac_discourse_type')['uri'];
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
        }));
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
    public function getOtherTypes() {
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
        $res = array_values(array_filter($this->getTypes(), function($v) {
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   102
            return $v instanceof Resource || $v->getDatatypeUri() !== Config::get('corpusparole.olac_discourse_type')['uri'];
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
        }));
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
        return $res;
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
163
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 145
diff changeset
   107
    public function getTranscript() {
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   108
        if($this->transcript === false) {
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   109
            $this->parseWebResources();
163
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 145
diff changeset
   110
        }
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   111
        return $this->transcript;
163
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 145
diff changeset
   112
    }
59c68fc4848e Add transcript api endpoint
ymh <ymh.work@gmail.com>
parents: 145
diff changeset
   113
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   114
    public function getContributors() {
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   115
        if(is_null($this->contributors)) {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   116
            $this->contributors = array_reduce(
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   117
                CocoonUtils::OLAC_ROLES,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   118
                function($res, $olacRole) {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   119
                    return array_merge(
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   120
                        $res,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   121
                        array_map(
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   122
                            function($olacValue) use ($olacRole) {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   123
                                return [
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   124
                                    'name' => ($olacValue instanceof Literal)?$olacValue->getValue():null,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   125
                                    'nameLiteral' => ($olacValue instanceof Literal)?$olacValue:null,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   126
                                    'url' => ($olacValue instanceof Resource)?$olacValue->getUri():null,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   127
                                    'role' => $olacRole
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   128
                                ];
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   129
                            },
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   130
                            $this->getProvidedCHO()->all("<$olacRole>")
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   131
                        )
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   132
                    );
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   133
                },
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   134
                []
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   135
            );
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   136
        }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   137
        return $this->contributors;
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   138
    }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   139
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   140
    /**
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   141
     * change contributors list
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   142
     */
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   143
    public function setContributors($contributors) {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   144
        $delta = $this->startDelta();
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   145
        //remove old,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   146
        foreach ($this->getContributors() as $contribDef) {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   147
            $value = null;
145
49b75287c30b correct backoffocie with new handle if format
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
   148
            if (empty($contribDef['url'])) {
49b75287c30b correct backoffocie with new handle if format
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
   149
                if(empty($contribDef['nameLiteral'])) {
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   150
                    $value = new Literal($contribDef['name']);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   151
                } else {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   152
                    $value = $contribDef['nameLiteral'];
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   153
                }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   154
            } else {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   155
                $value = new Resource($contribDef['url']);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   156
            }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   157
            $this->getProvidedCHO()->delete($contribDef['role'], $value);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   158
            $delta->getDeletedGraph()->add($this->getProvidedCHO(), $contribDef['role'], $value);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   159
        }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   160
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   161
        //put new
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   162
        foreach ($contributors as $newContribDef) {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   163
            $value = null;
145
49b75287c30b correct backoffocie with new handle if format
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
   164
            if (empty($newContribDef['url'])) {
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   165
                $value = new Literal($newContribDef['name'], "fr", null);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   166
            } else {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   167
                $value = new Resource($newContribDef['url']);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   168
            }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   169
            $this->getProvidedCHO()->add($newContribDef['role'], $value);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   170
            $delta->getAddedGraph()->add($this->getProvidedCHO(), $newContribDef['role'], $value);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   171
        }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   172
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   173
        $this->contributors = null;
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   174
20
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   175
    }
a9b98b16b053 add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   176
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   177
    /**
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   178
     * change discourse type list
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   179
     */
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
    public function updateDiscourseTypes(array $discoursesTypes) {
3
2b3247d02769 Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   181
2b3247d02769 Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   182
        $this->startDelta();
2b3247d02769 Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
   183
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   184
        //delete
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
        foreach($this->getDiscourseTypes() as $discourseType) {
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   186
            $literalValue = new Literal($discourseType, null, Config::get('corpusparole.olac_discourse_type')['uri']);
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   187
            $this->getProvidedCHO()->delete('dc11:type', $literalValue);
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   188
            $this->currentDelta->getDeletedGraph()->add($this->getProvidedCHO(), 'dc11:type', new Literal($discourseType, null, Config::get('corpusparole.olac_discourse_type')['uri']));
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
        }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   191
        // and re-add them
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
        foreach($discoursesTypes as $dType) {
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   193
            $this->getProvidedCHO()->add('dc11:type', new Literal($dType, null, Config::get('corpusparole.olac_discourse_type')['uri']));
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   194
            $this->currentDelta->getAddedGraph()->add($this->getProvidedCHO(), 'dc11:type', new Literal($dType, null, Config::get('corpusparole.olac_discourse_type')['uri']));
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
        }
19
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   196
eadaf0b8f02e Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   197
        $this->clearMemoizationCache();
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 128
diff changeset
   200
    /**
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 128
diff changeset
   201
     * Get subjects list
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 128
diff changeset
   202
     */
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 128
diff changeset
   203
    public function getSubjects() {
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 128
diff changeset
   204
        if(is_null($this->subjects)) {
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 128
diff changeset
   205
            $this->subjects = $this->getProvidedCHO()->all('<http://purl.org/dc/elements/1.1/subject>');
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 128
diff changeset
   206
        }
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 128
diff changeset
   207
        return $this->subjects;
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 128
diff changeset
   208
    }
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 128
diff changeset
   209
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   210
    /**
169
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   211
     *
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   212
     */
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   213
    public function getGeoInfo() {
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   214
        if($this->geoInfo === false) {
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   215
            $places = $this->getProvidedCHO()->all('<http://purl.org/dc/terms/spatial>');
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   216
            $this->geoInfo = null;
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   217
            if($places) {
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   218
                $this->geoInfo = new GeoResource($places[0]->getUri(), $this->graph);
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   219
            }
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   220
        }
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   221
        return $this->geoInfo;
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   222
    }
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   223
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   224
    /**
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   225
     * change subjecs list
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   226
     */
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   227
    public function setSubjects($subjects) {
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   228
        $delta = $this->startDelta();
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   229
        //remove old,
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   230
        foreach ($this->getSubjects() as $subject) {
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   231
            $this->getProvidedCHO()->delete('<http://purl.org/dc/elements/1.1/subject>', $subject);
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   232
            $delta->getDeletedGraph()->add($this->getProvidedCHO(), 'http://purl.org/dc/elements/1.1/subject', $subject);
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   233
        }
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   234
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   235
        //put new
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   236
        foreach ($subjects as $newSubject) {
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   237
            $value = null;
141
c0e8626a271c literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   238
            if(is_string($newSubject) && filter_var($newSubject, FILTER_VALIDATE_URL)) {
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   239
                $value = new Resource($newSubject);
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   240
            }
141
c0e8626a271c literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   241
            elseif (is_string($newSubject)) {
c0e8626a271c literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   242
                $value = new Literal($newSubject, null, null);
c0e8626a271c literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   243
            } elseif(is_array($newSubject)) {
c0e8626a271c literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents: 138
diff changeset
   244
                $value = new Literal(isset($newSubject['value'])?$newSubject['value']:null, isset($newSubject['lang'])?$newSubject['lang']:null, isset($newSubject['datatype'])?$newSubject['value']:null);
138
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   245
            }
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   246
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   247
            $this->getProvidedCHO()->add('http://purl.org/dc/elements/1.1/subject', $value);
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   248
            $delta->getAddedGraph()->add($this->getProvidedCHO(), 'http://purl.org/dc/elements/1.1/subject', $value);
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   249
        }
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   250
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   251
        $this->subjects = null;
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   252
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   253
    }
3079cbf80006 add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents: 130
diff changeset
   254
260
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   255
    public function getPublishers() {
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   256
        if(is_null($this->publishers)) {
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   257
            try {
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   258
                $this->publishers = $this->getProvidedCHO()->all('dc11:publisher');
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   259
            } catch(\Exception $e) {
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   260
               $this->publishers = [];
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   261
            }
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   262
        }
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   263
        return $this->publishers;
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   264
    }
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   265
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   266
    public function getPublishersValues() {
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   267
        $publishers = $this->getPublishers();
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   268
        return array_map(
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   269
            function($v) { return Utils::processLiteralResourceOrString($v); },
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   270
            $this->getPublishers()
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   271
        );
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   272
    }
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   273
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   274
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   275
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
    public function isIsomorphic($doc) {
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 3
diff changeset
   277
        return Isomorphic::isomorphic($this->graph, $doc->graph);
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
    /*
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
     * Clone document.
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
     * clone also the innerDocumenent
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
     */
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
    public function __clone() {
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   285
        if(!is_null($this->graph)) {
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   286
            $this->graph = new Graph($this->graph->getUri(), $this->graph->toRdfPhp());
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   287
        }
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 3
diff changeset
   288
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 3
diff changeset
   289
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 3
diff changeset
   290
    public function jsonSerialize() {
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   291
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   292
        $res = parent::jsonSerialize();
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   293
        if($this->graph) {
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   294
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   295
            $mediaArray =  is_null($this->getMediaArray())?
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   296
                        null:
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   297
                        array_combine(
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   298
                            array_map(function($m) { return $m->getUrl(); }, $this->getMediaArray()),
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   299
                            array_map(
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   300
                                function($m) {
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   301
                                    return $m->jsonSerialize();},
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   302
                                $this->getMediaArray()
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   303
                            )
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   304
                        );
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   305
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   306
            $transcript = is_null($this->getTranscript())?null:$this->getTranscript()->jsonSerialize();
169
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   307
            $geoInfo = is_null($this->getGeoInfo())?null:$this->getGeoInfo()->jsonSerialize();
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 3
diff changeset
   308
260
64caee7ce38d Split document model in document and document results
ymh <ymh.work@gmail.com>
parents: 169
diff changeset
   309
            $publishers = $this->getPublishersValues();
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 3
diff changeset
   310
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   311
            $contributors = array_map(
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   312
                function($c) { unset($c['nameLiteral']); return $c; },
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   313
                $this->getContributors()
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   314
            );
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   315
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 128
diff changeset
   316
            $subjects = array_map(
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 128
diff changeset
   317
                function($s) { return Utils::processLiteralResourceOrString($s); },
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 128
diff changeset
   318
                $this->getSubjects()
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 128
diff changeset
   319
            );
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 128
diff changeset
   320
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   321
            $res = array_merge($res, [
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents: 3
diff changeset
   322
                'publishers' => $publishers,
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   323
                'contributors' => $contributors,
130
fac22d8c2df8 add subjects to model + simple display on bo + add command to downloads documents to fixtures for test
ymh <ymh.work@gmail.com>
parents: 128
diff changeset
   324
                'subjects' => $subjects,
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   325
                'transcript' => $transcript,
169
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   326
                'mediaArray'=> $mediaArray,
8fddc113095e Correct proble on geo info merging + add geo resource
ymh <ymh.work@gmail.com>
parents: 168
diff changeset
   327
                'geoInfo' => $geoInfo
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   328
            ]);
128
bc18286e55b2 remove resolve lexvo on server in the api
ymh <ymh.work@gmail.com>
parents: 125
diff changeset
   329
168
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   330
        }
17f10b56c079 improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents: 163
diff changeset
   331
        return $res;
128
bc18286e55b2 remove resolve lexvo on server in the api
ymh <ymh.work@gmail.com>
parents: 125
diff changeset
   332
2
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
    }
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
00e2916104fe Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
}