|
1
|
|
|
<?php |
|
2
|
|
|
/* Copyright (C) 2015 Michael Giesler, Stephan Kreutzer |
|
3
|
|
|
* |
|
4
|
|
|
* This file is part of Dembelo. |
|
5
|
|
|
* |
|
6
|
|
|
* Dembelo is free software: you can redistribute it and/or modify |
|
7
|
|
|
* it under the terms of the GNU Affero General Public License as published by |
|
8
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
9
|
|
|
* (at your option) any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* Dembelo is distributed in the hope that it will be useful, |
|
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14
|
|
|
* GNU Affero General Public License 3 for more details. |
|
15
|
|
|
* |
|
16
|
|
|
* You should have received a copy of the GNU Affero General Public License 3 |
|
17
|
|
|
* along with Dembelo. If not, see <http://www.gnu.org/licenses/>. |
|
18
|
|
|
* |
|
19
|
|
|
* @package DembeloMain |
|
20
|
|
|
*/ |
|
21
|
|
|
namespace DembeloMain\Document; |
|
22
|
|
|
|
|
23
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
24
|
|
|
use Doctrine\Common\Collections\Collection; |
|
25
|
|
|
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB; |
|
26
|
|
|
use Doctrine\ODM\MongoDB\Mapping\Annotations\ReferenceMany; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Class Textnode |
|
30
|
|
|
* |
|
31
|
|
|
* @MongoDB\Document |
|
32
|
|
|
* @MongoDB\Document(repositoryClass="\DembeloMain\Model\Repository\Doctrine\ODM\TextNodeRepository") |
|
33
|
|
|
*/ |
|
34
|
|
|
class Textnode |
|
35
|
|
|
{ |
|
36
|
|
|
public const STATUS_INACTIVE = 0; |
|
37
|
|
|
public const STATUS_ACTIVE = 1; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @MongoDB\Id |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $id; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @MongoDB\Field(type="date") |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $created; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @MongoDb\Field(type="object_id") |
|
51
|
|
|
*/ |
|
52
|
|
|
protected $topicId; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @MongoDB\Field(type="int") |
|
56
|
|
|
*/ |
|
57
|
|
|
protected $status; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @MongoDB\Field(type="string") |
|
61
|
|
|
*/ |
|
62
|
|
|
protected $text; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @MongoDB\Field(type="string") |
|
66
|
|
|
*/ |
|
67
|
|
|
protected $textHyphenated; |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @MongoDB\Field(type="boolean") |
|
71
|
|
|
*/ |
|
72
|
|
|
protected $access; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @MongoDB\Field(type="hash") |
|
76
|
|
|
*/ |
|
77
|
|
|
protected $metadata = []; |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @MongoDB\Field(type="object_id") |
|
81
|
|
|
*/ |
|
82
|
|
|
protected $licenseeId; |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @var TextnodeHitch[]|Collection |
|
86
|
|
|
* |
|
87
|
|
|
* @ReferenceMany(targetDocument="TextnodeHitch", mappedBy="targetTextnode") |
|
88
|
|
|
*/ |
|
89
|
|
|
protected $parentHitches; |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @var TextnodeHitch[]|Collection |
|
93
|
|
|
* |
|
94
|
|
|
* @ReferenceMany(targetDocument="TextnodeHitch", mappedBy="sourceTextnode") |
|
95
|
|
|
*/ |
|
96
|
|
|
protected $childHitches; |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @MongoDB\Field(type="object_id") |
|
100
|
|
|
*/ |
|
101
|
|
|
protected $importfileId; |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* @MongoDB\Field(type="string") |
|
105
|
|
|
*/ |
|
106
|
|
|
protected $twineId; |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @MongoDB\Field(type="string") |
|
110
|
|
|
*/ |
|
111
|
|
|
protected $arbitraryId; |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* Textnode constructor. |
|
115
|
|
|
*/ |
|
116
|
40 |
|
public function __construct() |
|
117
|
|
|
{ |
|
118
|
40 |
|
$this->childHitches = new ArrayCollection(); |
|
119
|
40 |
|
$this->parentHitches = new ArrayCollection(); |
|
120
|
40 |
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* gets the timestamp of creation |
|
124
|
|
|
* |
|
125
|
|
|
* @return \DateTime |
|
126
|
|
|
*/ |
|
127
|
2 |
|
public function getCreated() |
|
128
|
|
|
{ |
|
129
|
2 |
|
return $this->created; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* sets the timestamp of creation |
|
134
|
|
|
* |
|
135
|
|
|
* @param string $created |
|
136
|
|
|
*/ |
|
137
|
3 |
|
public function setCreated($created) |
|
138
|
|
|
{ |
|
139
|
3 |
|
$this->created = $created; |
|
140
|
3 |
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* @return String|null |
|
144
|
|
|
*/ |
|
145
|
5 |
|
public function getTopicId(): ?string |
|
146
|
|
|
{ |
|
147
|
5 |
|
return $this->topicId; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* @param String $topicId |
|
152
|
|
|
* |
|
153
|
|
|
* @return void |
|
154
|
|
|
*/ |
|
155
|
7 |
|
public function setTopicId($topicId): void |
|
156
|
|
|
{ |
|
157
|
7 |
|
$this->topicId = $topicId; |
|
158
|
7 |
|
} |
|
159
|
|
|
|
|
160
|
|
|
/** |
|
161
|
|
|
* @return integer |
|
162
|
|
|
*/ |
|
163
|
3 |
|
public function getStatus(): int |
|
164
|
|
|
{ |
|
165
|
3 |
|
return $this->status; |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* @param integer $status |
|
170
|
|
|
* |
|
171
|
|
|
* @return void |
|
172
|
|
|
*/ |
|
173
|
8 |
|
public function setStatus(int $status): void |
|
174
|
|
|
{ |
|
175
|
8 |
|
$this->status = $status; |
|
176
|
8 |
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* gets the mongodb id |
|
180
|
|
|
* |
|
181
|
|
|
* @return string |
|
182
|
|
|
*/ |
|
183
|
8 |
|
public function getId(): ?string |
|
184
|
|
|
{ |
|
185
|
8 |
|
return $this->id; |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
/** |
|
189
|
|
|
* sets the mongoDB id |
|
190
|
|
|
* |
|
191
|
|
|
* @param string $id |
|
192
|
|
|
* |
|
193
|
|
|
* @return void |
|
194
|
|
|
*/ |
|
195
|
2 |
|
public function setId(string $id): void |
|
196
|
|
|
{ |
|
197
|
2 |
|
$this->id = $id; |
|
198
|
2 |
|
} |
|
199
|
|
|
|
|
200
|
|
|
/** |
|
201
|
|
|
* gets the textnode's text |
|
202
|
|
|
* |
|
203
|
|
|
* @return string |
|
204
|
|
|
*/ |
|
205
|
3 |
|
public function getText() |
|
206
|
|
|
{ |
|
207
|
3 |
|
return $this->text; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* sets the textnode's text |
|
212
|
|
|
* |
|
213
|
|
|
* @param string $text |
|
214
|
|
|
* |
|
215
|
|
|
* @return void |
|
216
|
|
|
*/ |
|
217
|
2 |
|
public function setText(string $text): void |
|
218
|
|
|
{ |
|
219
|
2 |
|
$this->text = $text; |
|
220
|
2 |
|
} |
|
221
|
|
|
|
|
222
|
|
|
/** |
|
223
|
|
|
* gets the textnode's hyphenated text |
|
224
|
|
|
* |
|
225
|
|
|
* @return string |
|
226
|
|
|
*/ |
|
227
|
2 |
|
public function getTextHyphenated(): ?string |
|
228
|
|
|
{ |
|
229
|
2 |
|
return $this->textHyphenated; |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
/** |
|
233
|
|
|
* sets the textnode's hyphenated text |
|
234
|
|
|
* |
|
235
|
|
|
* @param string $textHyphenated |
|
236
|
|
|
*/ |
|
237
|
2 |
|
public function setTextHyphenated($textHyphenated): void |
|
238
|
|
|
{ |
|
239
|
2 |
|
$this->textHyphenated = $textHyphenated; |
|
240
|
2 |
|
} |
|
241
|
|
|
|
|
242
|
|
|
/** |
|
243
|
|
|
* gets the textnode's metadata |
|
244
|
|
|
* |
|
245
|
|
|
* @return array |
|
246
|
|
|
*/ |
|
247
|
3 |
|
public function getMetadata(): ?array |
|
248
|
|
|
{ |
|
249
|
3 |
|
return $this->metadata; |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
/** |
|
253
|
|
|
* sets the textnode's metadata |
|
254
|
|
|
* |
|
255
|
|
|
* @param array $metadata |
|
256
|
|
|
*/ |
|
257
|
3 |
|
public function setMetadata(array $metadata) |
|
258
|
|
|
{ |
|
259
|
3 |
|
$this->metadata = $metadata; |
|
260
|
3 |
|
} |
|
261
|
|
|
|
|
262
|
|
|
/** |
|
263
|
|
|
* sets the textnode's licensee ID |
|
264
|
|
|
* |
|
265
|
|
|
* @param String $licenseeId |
|
266
|
|
|
*/ |
|
267
|
3 |
|
public function setLicenseeId($licenseeId) |
|
268
|
|
|
{ |
|
269
|
3 |
|
$this->licenseeId = $licenseeId; |
|
270
|
3 |
|
} |
|
271
|
|
|
|
|
272
|
|
|
/** |
|
273
|
|
|
* gets the textnode's licensee ID |
|
274
|
|
|
* |
|
275
|
|
|
* @return String |
|
276
|
|
|
*/ |
|
277
|
2 |
|
public function getLicenseeId() |
|
278
|
|
|
{ |
|
279
|
2 |
|
return $this->licenseeId; |
|
280
|
|
|
} |
|
281
|
|
|
|
|
282
|
|
|
/** |
|
283
|
|
|
* sets the access parameter |
|
284
|
|
|
* |
|
285
|
|
|
* @param bool $access true if this Textnode is a start textnode |
|
286
|
|
|
* from which a reading path begins. |
|
287
|
|
|
*/ |
|
288
|
3 |
|
public function setAccess($access) |
|
289
|
|
|
{ |
|
290
|
3 |
|
$this->access = (bool) $access; |
|
291
|
3 |
|
} |
|
292
|
|
|
|
|
293
|
|
|
/** |
|
294
|
|
|
* gets the access parameter |
|
295
|
|
|
* |
|
296
|
|
|
* @return bool true|false true, if this Textnode is a start textnode |
|
297
|
|
|
* from which a reading path begins. |
|
298
|
|
|
*/ |
|
299
|
3 |
|
public function getAccess() |
|
300
|
|
|
{ |
|
301
|
3 |
|
return $this->access; |
|
302
|
|
|
} |
|
303
|
|
|
|
|
304
|
|
|
/** |
|
305
|
|
|
* @return TextnodeHitch[]|Collection |
|
306
|
|
|
*/ |
|
307
|
5 |
|
public function getChildHitches(): Collection |
|
308
|
|
|
{ |
|
309
|
5 |
|
return $this->childHitches; |
|
310
|
|
|
} |
|
311
|
|
|
|
|
312
|
|
|
/** |
|
313
|
|
|
* @return TextnodeHitch[]|Collection |
|
314
|
|
|
*/ |
|
315
|
1 |
|
public function getParentHitches(): Collection |
|
316
|
|
|
{ |
|
317
|
1 |
|
return $this->parentHitches; |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
/** |
|
321
|
|
|
* sets the importfile ID |
|
322
|
|
|
* |
|
323
|
|
|
* @param string $importfileId |
|
324
|
|
|
*/ |
|
325
|
6 |
|
public function setImportfileId($importfileId) |
|
326
|
|
|
{ |
|
327
|
6 |
|
$this->importfileId = $importfileId; |
|
328
|
6 |
|
} |
|
329
|
|
|
|
|
330
|
|
|
/** |
|
331
|
|
|
* returns importfile ID |
|
332
|
|
|
* |
|
333
|
|
|
* @return string |
|
334
|
|
|
*/ |
|
335
|
3 |
|
public function getImportfileId() |
|
336
|
|
|
{ |
|
337
|
3 |
|
return $this->importfileId; |
|
338
|
|
|
} |
|
339
|
|
|
|
|
340
|
|
|
/** |
|
341
|
|
|
* sets the twine ID |
|
342
|
|
|
* |
|
343
|
|
|
* @param string $twineId |
|
344
|
|
|
*/ |
|
345
|
5 |
|
public function setTwineId($twineId) |
|
346
|
|
|
{ |
|
347
|
5 |
|
$this->twineId = $twineId; |
|
348
|
5 |
|
} |
|
349
|
|
|
|
|
350
|
|
|
/** |
|
351
|
|
|
* returns twine ID |
|
352
|
|
|
* |
|
353
|
|
|
* @return string |
|
354
|
|
|
*/ |
|
355
|
3 |
|
public function getTwineId() |
|
356
|
|
|
{ |
|
357
|
3 |
|
return $this->twineId; |
|
358
|
|
|
} |
|
359
|
|
|
|
|
360
|
|
|
/** |
|
361
|
|
|
* sets the arbitrary ID |
|
362
|
|
|
* |
|
363
|
|
|
* @param string $arbitraryId |
|
364
|
|
|
*/ |
|
365
|
17 |
|
public function setArbitraryId($arbitraryId) |
|
366
|
|
|
{ |
|
367
|
17 |
|
$this->arbitraryId = $arbitraryId; |
|
368
|
17 |
|
} |
|
369
|
|
|
|
|
370
|
|
|
/** |
|
371
|
|
|
* returns arbitrary ID |
|
372
|
|
|
* |
|
373
|
|
|
* @return string |
|
374
|
|
|
*/ |
|
375
|
9 |
|
public function getArbitraryId() |
|
376
|
|
|
{ |
|
377
|
9 |
|
return $this->arbitraryId; |
|
378
|
|
|
} |
|
379
|
|
|
|
|
380
|
|
|
/** |
|
381
|
|
|
* returns true if textnode is a finance node |
|
382
|
|
|
* |
|
383
|
|
|
* @return bool |
|
384
|
|
|
*/ |
|
385
|
4 |
|
public function isFinanceNode(): bool |
|
386
|
|
|
{ |
|
387
|
4 |
|
return $this->getChildHitches()->isEmpty(); |
|
388
|
|
|
} |
|
389
|
|
|
} |
|
390
|
|
|
|