author | ymh <ymh.work@gmail.com> |
Fri, 04 Mar 2016 10:08:52 +0100 | |
changeset 138 | 3079cbf80006 |
parent 130 | fac22d8c2df8 |
child 141 | c0e8626a271c |
permissions | -rw-r--r-- |
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 |
*/ |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
20 |
class Document extends RdfModelResource implements JsonSerializable { |
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) { |
122 | 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 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
27 |
private $id = null; |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
28 |
|
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
29 |
// memoization |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
30 |
private $providedCHO = null; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
31 |
private $title = false; |
28 | 32 |
private $lang = null; |
125 | 33 |
private $langResolved = null; |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
34 |
private $publishers = null; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
35 |
private $mediaArray = null; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
36 |
private $issued = null; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
37 |
private $modified = null; |
28 | 38 |
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
|
39 |
private $subjects = null; |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
40 |
|
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
41 |
public function getProvidedCHO() { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
42 |
if(is_null($this->providedCHO)) { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
43 |
$this->providedCHO = $this->get("<http://www.europeana.eu/schemas/edm/aggregatedCHO>"); |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
44 |
} |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
45 |
return $this->providedCHO; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
46 |
} |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
47 |
|
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
48 |
private function clearMemoizationCache() { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
49 |
$this->providedCHO = null; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
50 |
$this->title = false; |
28 | 51 |
$this->lang = null; |
125 | 52 |
$this->langResolved = null; |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
53 |
$this->publishers = null; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
54 |
$this->mediaArray = null; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
55 |
$this->issued = null; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
56 |
$this->modified = null; |
28 | 57 |
$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
|
58 |
$this->subjects = null; |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
59 |
} |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
60 |
|
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
61 |
public function getId() { |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
62 |
if(is_null($this->id)) { |
122 | 63 |
$ids = $this->getProvidedCHO()->all('<http://purl.org/dc/elements/1.1/identifier>'); |
64 |
foreach ($ids as $id) { |
|
65 |
if($id instanceof Literal && strpos($id->getValue(), config('corpusparole.corpus_id_scheme')) === 0) { |
|
66 |
$this->id = $id->getValue(); |
|
67 |
} |
|
68 |
} |
|
115 | 69 |
if(is_null($this->id)) { |
70 |
$this->id = CocoonUtils::getIdFromCorpusUri($this->uri); |
|
71 |
} |
|
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
72 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
73 |
return $this->id; |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
74 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
75 |
|
28 | 76 |
public function getLanguage() { |
77 |
if(is_null($this->lang)) { |
|
78 |
try { |
|
79 |
$langs = $this->getProvidedCHO()->all('<http://purl.org/dc/elements/1.1/language>'); |
|
80 |
if(count($langs) > 0) { |
|
81 |
$this->lang = $langs[0]; |
|
82 |
} |
|
83 |
} catch(\Exception $e) { |
|
84 |
$this->lang = null; |
|
85 |
} |
|
86 |
} |
|
87 |
return $this->lang; |
|
88 |
} |
|
89 |
||
90 |
public function getLanguageValue() { |
|
91 |
$lang = $this->getLanguage(); |
|
92 |
if($lang instanceof Resource) { |
|
93 |
return $lang->getUri(); |
|
94 |
} else if($lan instanceof Literal) { |
|
95 |
return $lang->getValue(); |
|
96 |
} |
|
97 |
return null; |
|
98 |
} |
|
99 |
||
125 | 100 |
public function getLanguageResolved() { |
101 |
return $this->langResolved; |
|
102 |
} |
|
103 |
public function setLanguageResolved($languageResolved) { |
|
104 |
$this->langResolved = $languageResolved; |
|
105 |
} |
|
106 |
||
107 |
||
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
108 |
public function getTitle() { |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
109 |
if($this->title === false) { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
110 |
try { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
111 |
$this->title = $this->getProvidedCHO()->getLiteral('<http://purl.org/dc/elements/1.1/title>'); |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
112 |
} catch(\Exception $e) { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
113 |
$this->title = null; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
114 |
} |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
115 |
} |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
116 |
return $this->title; |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
117 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
118 |
|
28 | 119 |
public function setTitle($value, $lang="fr") { |
120 |
$oldTitle = $this->getTitle(); |
|
121 |
if($oldTitle && $oldTitle->getValue() != $value && $oldTitle->getLang() != $lang) { |
|
122 |
$literalTitle = new Literal($value, $lang, null); |
|
123 |
$this->setSimpleProperty($this->getProvidedCHO(), 'http://purl.org/dc/elements/1.1/title', $oldTitle, $literalTitle); |
|
124 |
//clear cache |
|
125 |
$this->title = false; |
|
126 |
} |
|
127 |
} |
|
128 |
||
20
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
129 |
public function getTitleValue() { |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
130 |
$title = $this->getTitle(); |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
131 |
return is_null($title)?null:$title->getValue(); |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
132 |
} |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
133 |
|
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
134 |
public function getPublishers() { |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
135 |
if(is_null($this->publishers)) { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
136 |
try { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
137 |
$this->publishers = $this->getProvidedCHO()->all('dc11:publisher'); |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
138 |
} catch(\Exception $e) { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
139 |
$this->publishers = []; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
140 |
} |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
141 |
} |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
142 |
return $this->publishers; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
143 |
} |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
144 |
|
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
145 |
public function getIssued() { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
146 |
if(is_null($this->issued)) { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
147 |
try { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
148 |
$this->issued = $this->getProvidedCHO()->getLiteral("<http://purl.org/dc/terms/issued>"); |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
149 |
} catch(\Exception $e) { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
150 |
$this->issued = null; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
151 |
} |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
152 |
} |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
153 |
return $this->issued; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
154 |
} |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
155 |
|
20
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
156 |
public function getIssuedValue() { |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
157 |
$issued = $this->getIssued(); |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
158 |
return is_null($issued)?null:$issued->getValue(); |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
159 |
} |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
160 |
|
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
161 |
public function getModified() { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
162 |
if(is_null($this->modified)) { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
163 |
try { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
164 |
$this->modified = $this->getProvidedCHO()->getLiteral("<http://purl.org/dc/terms/modified>"); |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
165 |
if(is_null($this->modified)) { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
166 |
$this->modified = $this->getIssued(); |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
167 |
} |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
168 |
} catch(\Exception $e) { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
169 |
$this->modified = null; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
170 |
} |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
171 |
} |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
172 |
return $this->modified; |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
173 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
174 |
|
20
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
175 |
public function getModifiedValue() { |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
176 |
$modified = $this->getModified(); |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
177 |
return is_null($modified)?null:$modified->getValue(); |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
178 |
} |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
179 |
|
138
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
180 |
public function setModified($value = null) { |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
181 |
if(is_null($value)) { |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
182 |
$value = gmdate(\DateTime::ATOM); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
183 |
} elseif ($value instanceof \DateTime) { |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
184 |
$value = $value->format(\DateTime::ATOM); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
185 |
} |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
186 |
$value = preg_replace('/[\+\-]00(\:?)00$/', 'Z', $value); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
187 |
|
28 | 188 |
$modified = $this->getModified(); |
138
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
189 |
if($value && (!$modified || $modified->getValue() !== $value) ) { |
28 | 190 |
|
138
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
191 |
$newModified = new Literal($value, null, "http://purl.org/dc/terms/W3CDTF"); |
28 | 192 |
$this->setSimpleProperty($this->getProvidedCHO(), 'http://purl.org/dc/terms/modified', $modified, $newModified); |
193 |
||
194 |
$this->modified = null; |
|
195 |
} |
|
196 |
} |
|
197 |
||
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
198 |
public function getMediaArray() { |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
199 |
|
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
200 |
if(is_null($this->mediaArray)) { |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
201 |
//TODO: add media type |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
202 |
$this->mediaArray = []; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
203 |
|
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
204 |
$master = $this->get('<http://www.europeana.eu/schemas/edm/isShownBy>'); |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
205 |
$masterUrl = is_null($master)?null:$master->getUri(); |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
206 |
|
111
af85c436048f
change edm:WebResources to edm:WebResources
ymh <ymh.work@gmail.com>
parents:
28
diff
changeset
|
207 |
foreach($this->graph->allOfType("<http://www.europeana.eu/schemas/edm/WebResource>") as $webResource) { |
20
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
208 |
$extent = $webResource->getLiteral("<http://purl.org/dc/terms/extent>"); |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
209 |
$extent = is_null($extent)?null:$extent->getValue(); |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
210 |
$extent_ms = Utils::iso8601IntervalToMillis($extent); |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
211 |
$format = $webResource->getLiteral("dc11:format"); |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
212 |
|
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
213 |
$this->mediaArray[$webResource->getUri()] = [ |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
214 |
'url' => $webResource->getUri(), |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
215 |
'format' => is_null($format)?null:$format->getValue(), |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
216 |
'extent' => $extent, |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
217 |
'extent_ms' => $extent_ms, |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
218 |
'master' => (($webResource->getUri() === $masterUrl)?true:false) |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
219 |
]; |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
220 |
} |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
221 |
} |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
222 |
return $this->mediaArray; |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
223 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
224 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
225 |
public function getTypes() { |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
226 |
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
|
227 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
228 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
229 |
public function getDiscourseTypes() { |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
230 |
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
|
231 |
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
|
232 |
})); |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
233 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
234 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
235 |
public function getOtherTypes() { |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
236 |
$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
|
237 |
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
|
238 |
})); |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
239 |
return $res; |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
240 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
241 |
|
20
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
242 |
public function getContributors() { |
28 | 243 |
if(is_null($this->contributors)) { |
244 |
$this->contributors = array_reduce( |
|
245 |
CocoonUtils::OLAC_ROLES, |
|
246 |
function($res, $olacRole) { |
|
247 |
return array_merge( |
|
248 |
$res, |
|
249 |
array_map( |
|
250 |
function($olacValue) use ($olacRole) { |
|
251 |
return [ |
|
252 |
'name' => ($olacValue instanceof Literal)?$olacValue->getValue():null, |
|
253 |
'nameLiteral' => ($olacValue instanceof Literal)?$olacValue:null, |
|
254 |
'url' => ($olacValue instanceof Resource)?$olacValue->getUri():null, |
|
255 |
'role' => $olacRole |
|
256 |
]; |
|
257 |
}, |
|
258 |
$this->getProvidedCHO()->all("<$olacRole>") |
|
259 |
) |
|
260 |
); |
|
261 |
}, |
|
262 |
[] |
|
263 |
); |
|
264 |
} |
|
265 |
return $this->contributors; |
|
266 |
} |
|
267 |
||
268 |
/** |
|
269 |
* change contributors list |
|
270 |
*/ |
|
271 |
public function setContributors($contributors) { |
|
272 |
$delta = $this->startDelta(); |
|
273 |
//remove old, |
|
274 |
foreach ($this->getContributors() as $contribDef) { |
|
275 |
$value = null; |
|
276 |
if (is_null($contribDef['url'])) { |
|
277 |
if(is_null($contribDef['nameLiteral'])) { |
|
278 |
$value = new Literal($contribDef['name']); |
|
279 |
} else { |
|
280 |
$value = $contribDef['nameLiteral']; |
|
281 |
} |
|
282 |
} else { |
|
283 |
$value = new Resource($contribDef['url']); |
|
284 |
} |
|
285 |
$this->getProvidedCHO()->delete($contribDef['role'], $value); |
|
286 |
$delta->getDeletedGraph()->add($this->getProvidedCHO(), $contribDef['role'], $value); |
|
287 |
} |
|
288 |
||
289 |
//put new |
|
290 |
foreach ($contributors as $newContribDef) { |
|
291 |
$value = null; |
|
292 |
if (is_null($newContribDef['url'])) { |
|
293 |
$value = new Literal($newContribDef['name'], "fr", null); |
|
294 |
} else { |
|
295 |
$value = new Resource($newContribDef['url']); |
|
296 |
} |
|
297 |
$this->getProvidedCHO()->add($newContribDef['role'], $value); |
|
298 |
$delta->getAddedGraph()->add($this->getProvidedCHO(), $newContribDef['role'], $value); |
|
299 |
} |
|
300 |
||
301 |
$this->contributors = null; |
|
302 |
||
20
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
303 |
} |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
304 |
|
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
305 |
/** |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
306 |
* change discourse type list |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
307 |
*/ |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
308 |
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
|
309 |
|
2b3247d02769
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
310 |
$this->startDelta(); |
2b3247d02769
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
311 |
|
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
312 |
//delete |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
313 |
foreach($this->getDiscourseTypes() as $discourseType) { |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
314 |
$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
|
315 |
$this->getProvidedCHO()->delete('dc11:type', $literalValue); |
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
316 |
$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
|
317 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
318 |
|
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
319 |
// 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
|
320 |
foreach($discoursesTypes as $dType) { |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
321 |
$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
|
322 |
$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
|
323 |
} |
19
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
324 |
|
eadaf0b8f02e
Bo conception step. back to ember page
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
325 |
$this->clearMemoizationCache(); |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
326 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
327 |
|
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
|
328 |
/** |
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
|
329 |
* 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
|
330 |
*/ |
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
|
331 |
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
|
332 |
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
|
333 |
$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
|
334 |
} |
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
|
335 |
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
|
336 |
} |
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
|
337 |
|
138
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
338 |
/** |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
339 |
* 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
|
340 |
*/ |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
341 |
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
|
342 |
$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
|
343 |
//remove old, |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
344 |
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
|
345 |
$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
|
346 |
$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
|
347 |
} |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
348 |
|
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
349 |
//put new |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
350 |
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
|
351 |
$value = null; |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
352 |
if(filter_var($newSubject, FILTER_VALIDATE_URL)) { |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
353 |
$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
|
354 |
} |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
355 |
else { |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
356 |
$value = new Literal($newSubject, "fr", null); |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
357 |
} |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
358 |
|
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
359 |
$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
|
360 |
$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
|
361 |
} |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
362 |
|
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
363 |
$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
|
364 |
|
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
365 |
} |
3079cbf80006
add subjects save + set modified date when saing document in rest api
ymh <ymh.work@gmail.com>
parents:
130
diff
changeset
|
366 |
|
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
367 |
public function isIsomorphic($doc) { |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
368 |
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
|
369 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
370 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
371 |
/* |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
372 |
* Clone document. |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
373 |
* clone also the innerDocumenent |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
374 |
*/ |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
375 |
public function __clone() { |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
376 |
|
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
377 |
$this->graph = new Graph($this->graph->getUri(), $this->graph->toRdfPhp()); |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
378 |
} |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
379 |
|
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
380 |
public function jsonSerialize() { |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
381 |
if(!$this->graph) { |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
382 |
return [ |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
383 |
'id' => $this->getId(), |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
384 |
]; |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
385 |
} else { |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
386 |
$mediaArray = array_map( |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
387 |
function($m) { |
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
|
388 |
$f = Utils::processLiteralResourceOrString($m['format']); |
20
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
389 |
$res = $m; |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
390 |
$res['format'] = $f; |
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
391 |
return $res;}, |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
392 |
$this->getMediaArray() |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
393 |
); |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
394 |
|
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
395 |
$publishers = array_map( |
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
|
396 |
function($v) { return Utils::processLiteralResourceOrString($v); }, |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
397 |
$this->getPublishers() |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
398 |
); |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
399 |
|
28 | 400 |
$contributors = array_map( |
401 |
function($c) { unset($c['nameLiteral']); return $c; }, |
|
402 |
$this->getContributors() |
|
403 |
); |
|
404 |
||
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
|
405 |
$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
|
406 |
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
|
407 |
$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
|
408 |
); |
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
|
409 |
|
128
bc18286e55b2
remove resolve lexvo on server in the api
ymh <ymh.work@gmail.com>
parents:
125
diff
changeset
|
410 |
$res = [ |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
411 |
'id' => $this->getId(), |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
412 |
'uri' => $this->getUri(), |
20
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
413 |
'title' => $this->getTitleValue(), |
28 | 414 |
'language' => $this->getLanguageValue(), |
20
a9b98b16b053
add contributor list + edition pane
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
415 |
'modified' => $this->getModifiedValue(), |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
416 |
'publishers' => $publishers, |
28 | 417 |
'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
|
418 |
'subjects' => $subjects, |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
419 |
'mediaArray'=> $mediaArray |
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
420 |
]; |
128
bc18286e55b2
remove resolve lexvo on server in the api
ymh <ymh.work@gmail.com>
parents:
125
diff
changeset
|
421 |
|
bc18286e55b2
remove resolve lexvo on server in the api
ymh <ymh.work@gmail.com>
parents:
125
diff
changeset
|
422 |
if($this->language_resolved) { |
bc18286e55b2
remove resolve lexvo on server in the api
ymh <ymh.work@gmail.com>
parents:
125
diff
changeset
|
423 |
$res['language_resolved'] = $this->getLanguageResolved(); |
bc18286e55b2
remove resolve lexvo on server in the api
ymh <ymh.work@gmail.com>
parents:
125
diff
changeset
|
424 |
} |
bc18286e55b2
remove resolve lexvo on server in the api
ymh <ymh.work@gmail.com>
parents:
125
diff
changeset
|
425 |
|
bc18286e55b2
remove resolve lexvo on server in the api
ymh <ymh.work@gmail.com>
parents:
125
diff
changeset
|
426 |
return $res; |
4
f55970e41793
first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
427 |
} |
2
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
428 |
} |
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
429 |
|
00e2916104fe
Migrate to php 5.6 + Laravel 5.1 + add phpunit test
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
430 |
} |