1
|
|
|
<?php |
2
|
|
|
namespace EWW\Dpf\Domain\Model; |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* This file is part of the TYPO3 CMS project. |
6
|
|
|
* |
7
|
|
|
* It is free software; you can redistribute it and/or modify it under |
8
|
|
|
* the terms of the GNU General Public License, either version 2 |
9
|
|
|
* of the License, or any later version. |
10
|
|
|
* |
11
|
|
|
* For the full copyright and license information, please read the |
12
|
|
|
* LICENSE.txt file that was distributed with this source code. |
13
|
|
|
* |
14
|
|
|
* The TYPO3 project - inspiring people to share! |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; |
18
|
|
|
use EWW\Dpf\Domain\Workflow\DocumentWorkflow; |
19
|
|
|
use EWW\Dpf\Helper\InternalFormat; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Document |
23
|
|
|
*/ |
24
|
|
|
class Document extends AbstractEntity |
25
|
|
|
{ |
26
|
|
|
// xml data size ist limited to 64 KB |
27
|
|
|
const XML_DATA_SIZE_LIMIT = 64 * 1024; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* title |
31
|
|
|
* |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $title = ''; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* authors |
38
|
|
|
* |
39
|
|
|
* @var string |
40
|
|
|
*/ |
41
|
|
|
protected $authors = ''; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* xmlData |
45
|
|
|
* |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
protected $xmlData = ''; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* slubInfoData |
52
|
|
|
* |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
protected $slubInfoData = ''; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* documentType |
59
|
|
|
* |
60
|
|
|
* @var \EWW\Dpf\Domain\Model\DocumentType |
61
|
|
|
*/ |
62
|
|
|
protected $documentType = null; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* objectIdentifier |
66
|
|
|
* |
67
|
|
|
* @var string |
68
|
|
|
*/ |
69
|
|
|
protected $objectIdentifier = ''; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* reservedObjectIdentifier |
73
|
|
|
* |
74
|
|
|
* @var string |
75
|
|
|
*/ |
76
|
|
|
protected $reservedObjectIdentifier; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* transferStatus |
80
|
|
|
* |
81
|
|
|
* @var string |
82
|
|
|
*/ |
83
|
|
|
protected $transferStatus; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* transferDate |
87
|
|
|
* |
88
|
|
|
* @var integer |
89
|
|
|
*/ |
90
|
|
|
protected $transferDate; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* changed |
94
|
|
|
* |
95
|
|
|
* @var boolean |
96
|
|
|
*/ |
97
|
|
|
protected $changed = false; |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* valid |
101
|
|
|
* |
102
|
|
|
* @var boolean |
103
|
|
|
*/ |
104
|
|
|
protected $valid = false; |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* |
108
|
|
|
* @var string $dateIssued |
109
|
|
|
*/ |
110
|
|
|
protected $dateIssued; |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* |
114
|
|
|
* @var string $processNumber |
115
|
|
|
*/ |
116
|
|
|
protected $processNumber = ''; |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @var bool $suggestion |
120
|
|
|
*/ |
121
|
|
|
protected $suggestion = false; |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* creator |
125
|
|
|
* |
126
|
|
|
* @var int |
127
|
|
|
*/ |
128
|
|
|
protected $creator = 0; |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* creation date |
132
|
|
|
* |
133
|
|
|
* @var string |
134
|
|
|
*/ |
135
|
|
|
protected $creationDate = ""; |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* state |
139
|
|
|
* |
140
|
|
|
* @var string |
141
|
|
|
*/ |
142
|
|
|
protected $state = DocumentWorkflow::STATE_NONE_NONE; |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* temporary |
146
|
|
|
* |
147
|
|
|
* @var boolean |
148
|
|
|
*/ |
149
|
|
|
protected $temporary = FALSE; |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* remoteLastModDate |
153
|
|
|
* |
154
|
|
|
* @var string |
155
|
|
|
*/ |
156
|
|
|
protected $remoteLastModDate = ''; |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* tstamp |
160
|
|
|
* |
161
|
|
|
* @var integer |
162
|
|
|
*/ |
163
|
|
|
protected $tstamp; |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* crdate |
167
|
|
|
* |
168
|
|
|
* @var integer |
169
|
|
|
*/ |
170
|
|
|
protected $crdate; |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @var string |
174
|
|
|
*/ |
175
|
|
|
protected $linkedUid = ''; |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @var string |
179
|
|
|
*/ |
180
|
|
|
protected $comment = ''; |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* date |
184
|
|
|
* |
185
|
|
|
* @var \DateTime |
186
|
|
|
*/ |
187
|
|
|
protected $embargoDate = null; |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* newlyAssignedFobIdentifiers |
191
|
|
|
* |
192
|
|
|
* @var array |
193
|
|
|
*/ |
194
|
|
|
protected $newlyAssignedFobIdentifiers = []; |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @var bool |
198
|
|
|
*/ |
199
|
|
|
protected $stateChange = false; |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* file |
203
|
|
|
* |
204
|
|
|
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\EWW\Dpf\Domain\Model\File> |
205
|
|
|
* @TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove") |
206
|
|
|
*/ |
207
|
|
|
protected $file = null; |
208
|
|
|
|
209
|
|
|
const TRANSFER_ERROR = "ERROR"; |
210
|
|
|
const TRANSFER_QUEUED = "QUEUED"; |
211
|
|
|
const TRANSFER_SENT = "SENT"; |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* __construct |
215
|
|
|
*/ |
216
|
|
|
public function __construct() |
217
|
|
|
{ |
218
|
|
|
//Do not remove the next line: It would break the functionality |
219
|
|
|
$this->initStorageObjects(); |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* Initializes all ObjectStorage properties |
224
|
|
|
* |
225
|
|
|
* @return void |
226
|
|
|
*/ |
227
|
|
|
protected function initStorageObjects() |
228
|
|
|
{ |
229
|
|
|
$this->file = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); |
230
|
|
|
$this->initCreationDate(); |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* Returns the title |
235
|
|
|
* |
236
|
|
|
* @return string $title |
237
|
|
|
*/ |
238
|
|
|
public function getTitle() |
239
|
|
|
{ |
240
|
|
|
return $this->title; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* Sets the title |
245
|
|
|
* |
246
|
|
|
* @param string $title |
247
|
|
|
* @return void |
248
|
|
|
*/ |
249
|
|
|
public function setTitle($title) |
250
|
|
|
{ |
251
|
|
|
$this->title = $title ?? ''; |
252
|
|
|
//htmlspecialchars_decode($title,ENT_QUOTES); |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* Returns the authors |
257
|
|
|
* |
258
|
|
|
* @return array $authors |
259
|
|
|
*/ |
260
|
|
|
public function getAuthors() |
261
|
|
|
{ |
262
|
|
|
$authors = @unserialize($this->authors); |
263
|
|
|
if (is_array($authors)) { |
264
|
|
|
return $authors; |
265
|
|
|
} else { |
266
|
|
|
return []; |
267
|
|
|
} |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* Sets the authors |
272
|
|
|
* |
273
|
|
|
* @param array $authors |
274
|
|
|
* @return void |
275
|
|
|
*/ |
276
|
|
|
public function setAuthors($authors) |
277
|
|
|
{ |
278
|
|
|
$this->authors = serialize($authors); |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
/** |
282
|
|
|
* Returns the xmlData |
283
|
|
|
* |
284
|
|
|
* @return string $xmlData |
285
|
|
|
*/ |
286
|
|
|
public function getXmlData() |
287
|
|
|
{ |
288
|
|
|
return $this->xmlData; |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* Sets the xmlData |
293
|
|
|
* |
294
|
|
|
* @param string $xmlData |
295
|
|
|
* @return void |
296
|
|
|
*/ |
297
|
|
|
public function setXmlData($xmlData) |
298
|
|
|
{ |
299
|
|
|
$this->xmlData = $xmlData; |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
/** |
303
|
|
|
* Returns the XML taking into account any existing embargo |
304
|
|
|
* |
305
|
|
|
* @return string |
306
|
|
|
*/ |
307
|
|
|
public function publicXml(): string |
308
|
|
|
{ |
309
|
|
|
$internalFormat = new InternalFormat($this->getXmlData()); |
310
|
|
|
$currentDate = new \DateTime('now'); |
311
|
|
|
if ($currentDate < $this->getEmbargoDate()) { |
312
|
|
|
$internalFormat->removeAllFiles(); |
313
|
|
|
} else { |
314
|
|
|
$internalFormat->completeFileData($this->getFile()); |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
return $internalFormat->getXml(); |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* Returns the slubInfoData |
322
|
|
|
* |
323
|
|
|
* @return string $slubInfoData |
324
|
|
|
*/ |
325
|
|
|
public function getSlubInfoData() |
326
|
|
|
{ |
327
|
|
|
return $this->slubInfoData; |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
/** |
331
|
|
|
* Sets the slubInfoData |
332
|
|
|
* |
333
|
|
|
* @return string $slubInfoData |
334
|
|
|
*/ |
335
|
|
|
public function setSlubInfoData($slubInfoData) |
336
|
|
|
{ |
337
|
|
|
$this->slubInfoData = $slubInfoData; |
338
|
|
|
} |
339
|
|
|
|
340
|
|
|
/** |
341
|
|
|
* Returns the documentType |
342
|
|
|
* |
343
|
|
|
* @return \EWW\Dpf\Domain\Model\DocumentType $documentType |
344
|
|
|
*/ |
345
|
|
|
public function getDocumentType() |
346
|
|
|
{ |
347
|
|
|
return $this->documentType; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
/** |
351
|
|
|
* Sets the documentType |
352
|
|
|
* |
353
|
|
|
* @param \EWW\Dpf\Domain\Model\DocumentType $documentType |
354
|
|
|
* @return void |
355
|
|
|
*/ |
356
|
|
|
public function setDocumentType(\EWW\Dpf\Domain\Model\DocumentType $documentType) |
357
|
|
|
{ |
358
|
|
|
$this->documentType = $documentType; |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
/** |
362
|
|
|
* Returns the objectIdentifier |
363
|
|
|
* |
364
|
|
|
* @return string |
365
|
|
|
*/ |
366
|
|
|
public function getObjectIdentifier() |
367
|
|
|
{ |
368
|
|
|
return $this->objectIdentifier; |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
/** |
372
|
|
|
* Sets the objectIdentifier |
373
|
|
|
* |
374
|
|
|
* @param string $objectIdentifier |
375
|
|
|
* @return void |
376
|
|
|
*/ |
377
|
|
|
public function setObjectIdentifier($objectIdentifier) |
378
|
|
|
{ |
379
|
|
|
// Due to uniqe key uc_object_identifier, which should ignore empty object identifiers. |
380
|
|
|
$this->objectIdentifier = empty($objectIdentifier)? null : $objectIdentifier; |
381
|
|
|
} |
382
|
|
|
|
383
|
|
|
/** |
384
|
|
|
* Returns the reservedObjectIdentifier |
385
|
|
|
* |
386
|
|
|
* @return string |
387
|
|
|
*/ |
388
|
|
|
public function getReservedObjectIdentifier() |
389
|
|
|
{ |
390
|
|
|
return $this->reservedObjectIdentifier; |
391
|
|
|
} |
392
|
|
|
|
393
|
|
|
/** |
394
|
|
|
* Sets the reservedObjectIdentifier |
395
|
|
|
* |
396
|
|
|
* @param string $reservedObjectIdentifier |
397
|
|
|
* @return void |
398
|
|
|
*/ |
399
|
|
|
public function setReservedObjectIdentifier($reservedObjectIdentifier) |
400
|
|
|
{ |
401
|
|
|
$this->reservedObjectIdentifier = $reservedObjectIdentifier; |
402
|
|
|
} |
403
|
|
|
|
404
|
|
|
/** |
405
|
|
|
* Returns the transferStatus |
406
|
|
|
* |
407
|
|
|
* @return string |
408
|
|
|
*/ |
409
|
|
|
public function getTransferStatus() |
410
|
|
|
{ |
411
|
|
|
return $this->transferStatus; |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
/** |
415
|
|
|
* Sets the transferStatus |
416
|
|
|
* |
417
|
|
|
* @param string |
418
|
|
|
* @return void |
419
|
|
|
*/ |
420
|
|
|
public function setTransferStatus($transferStatus) |
421
|
|
|
{ |
422
|
|
|
$this->transferStatus = $transferStatus; |
423
|
|
|
} |
424
|
|
|
|
425
|
|
|
/** |
426
|
|
|
* Returns the transferDate |
427
|
|
|
* |
428
|
|
|
* @return integer |
429
|
|
|
*/ |
430
|
|
|
public function getTransferDate() |
431
|
|
|
{ |
432
|
|
|
return $this->transferDate; |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
/** |
436
|
|
|
* Sets the transferDate |
437
|
|
|
* |
438
|
|
|
* @param integer $transferDate |
439
|
|
|
* @return void |
440
|
|
|
*/ |
441
|
|
|
public function setTransferDate($transferDate) |
442
|
|
|
{ |
443
|
|
|
$this->transferDate = $transferDate; |
444
|
|
|
} |
445
|
|
|
|
446
|
|
|
/** |
447
|
|
|
* Returns the transferErrorCode |
448
|
|
|
* |
449
|
|
|
* @var integer |
450
|
|
|
*/ |
451
|
|
|
public function getTransferErrorCode() |
452
|
|
|
{ |
453
|
|
|
return $this->transferErrorCode; |
454
|
|
|
} |
455
|
|
|
|
456
|
|
|
/** |
457
|
|
|
* Sets the transferErrorCode |
458
|
|
|
* |
459
|
|
|
* @param integer $transferErrorCode |
460
|
|
|
* @return void |
461
|
|
|
*/ |
462
|
|
|
public function setTransferErrorCode($transferErrorCode) |
463
|
|
|
{ |
464
|
|
|
$this->transferErrorCode = $transferErrorCode; |
|
|
|
|
465
|
|
|
} |
466
|
|
|
|
467
|
|
|
/** |
468
|
|
|
* Returns the transferResponse |
469
|
|
|
* |
470
|
|
|
* @var string |
471
|
|
|
*/ |
472
|
|
|
public function getTransferResponse() |
473
|
|
|
{ |
474
|
|
|
return $this->transferResponse; |
475
|
|
|
} |
476
|
|
|
|
477
|
|
|
/** |
478
|
|
|
* Sets the transferResponse |
479
|
|
|
* |
480
|
|
|
* @param string $transferResponse |
481
|
|
|
* @return void |
482
|
|
|
*/ |
483
|
|
|
public function setTransferResponse($transferResponse) |
484
|
|
|
{ |
485
|
|
|
$this->transferResponse = $transferResponse; |
|
|
|
|
486
|
|
|
} |
487
|
|
|
|
488
|
|
|
/** |
489
|
|
|
* Returns the transferHttpStatus |
490
|
|
|
* |
491
|
|
|
* @var integer |
492
|
|
|
*/ |
493
|
|
|
public function getTransferHttpStatus() |
494
|
|
|
{ |
495
|
|
|
return $this->transferHttpStatus; |
496
|
|
|
} |
497
|
|
|
|
498
|
|
|
/** |
499
|
|
|
* Sets the transferHttpStatus |
500
|
|
|
* |
501
|
|
|
* @param integer $transferHttpStatus |
502
|
|
|
* @return void |
503
|
|
|
*/ |
504
|
|
|
public function setTransferHttpStatus($transferHttpStatus) |
505
|
|
|
{ |
506
|
|
|
$this->transferHttpStatus = $transferHttpStatus; |
|
|
|
|
507
|
|
|
} |
508
|
|
|
|
509
|
|
|
/** |
510
|
|
|
* Adds a File |
511
|
|
|
* |
512
|
|
|
* @param \EWW\Dpf\Domain\Model\File $file |
513
|
|
|
* @return void |
514
|
|
|
*/ |
515
|
|
|
public function addFile(\EWW\Dpf\Domain\Model\File $file) |
516
|
|
|
{ |
517
|
|
|
$this->file->attach($file); |
518
|
|
|
} |
519
|
|
|
|
520
|
|
|
/** |
521
|
|
|
* Removes a File |
522
|
|
|
* |
523
|
|
|
* @param \EWW\Dpf\Domain\Model\File $fileToRemove The File to be removed |
524
|
|
|
* @return void |
525
|
|
|
*/ |
526
|
|
|
public function removeFile(\EWW\Dpf\Domain\Model\File $fileToRemove) |
527
|
|
|
{ |
528
|
|
|
$this->file->detach($fileToRemove); |
529
|
|
|
} |
530
|
|
|
|
531
|
|
|
/** |
532
|
|
|
* Returns the file |
533
|
|
|
* |
534
|
|
|
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\EWW\Dpf\Domain\Model\File> $file |
535
|
|
|
*/ |
536
|
|
|
public function getFile() |
537
|
|
|
{ |
538
|
|
|
return $this->file; |
539
|
|
|
} |
540
|
|
|
|
541
|
|
|
/** |
542
|
|
|
* Sets the file |
543
|
|
|
* |
544
|
|
|
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\EWW\Dpf\Domain\Model\File> $file |
545
|
|
|
* @return void |
546
|
|
|
*/ |
547
|
|
|
public function setFile(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $file) |
548
|
|
|
{ |
549
|
|
|
$this->file = $file; |
550
|
|
|
} |
551
|
|
|
|
552
|
|
|
/** |
553
|
|
|
* @param string $fileIdentifier |
554
|
|
|
* @return \EWW\Dpf\Domain\Model\File|null |
555
|
|
|
*/ |
556
|
|
|
public function getFileByFileIdentifier(string $fileIdentifier): ?\EWW\Dpf\Domain\Model\File |
557
|
|
|
{ |
558
|
|
|
foreach ($this->file as $file) { |
559
|
|
|
if ($file->getFileIdentifier() == $fileIdentifier) { |
560
|
|
|
return $file; |
561
|
|
|
} |
562
|
|
|
} |
563
|
|
|
return null; |
564
|
|
|
} |
565
|
|
|
|
566
|
|
|
/** |
567
|
|
|
* @return \EWW\Dpf\Domain\Model\File|null |
568
|
|
|
*/ |
569
|
|
|
public function getPrimaryFile(): ?\EWW\Dpf\Domain\Model\File |
570
|
|
|
{ |
571
|
|
|
/** @var File $file */ |
572
|
|
|
foreach ($this->file as $file) { |
573
|
|
|
if ($file->isPrimaryFile()) { |
574
|
|
|
return $file; |
575
|
|
|
} |
576
|
|
|
} |
577
|
|
|
return null; |
578
|
|
|
} |
579
|
|
|
|
580
|
|
|
/** |
581
|
|
|
* Has files |
582
|
|
|
*/ |
583
|
|
|
public function hasFiles() |
584
|
|
|
{ |
585
|
|
|
if (is_a($this->getFile(), '\TYPO3\CMS\Extbase\Persistence\ObjectStorage')) { |
586
|
|
|
foreach ($this->getFile() as $file) { |
587
|
|
|
/** @var File $file */ |
588
|
|
|
if (!$file->isFileGroupDeleted()) { |
589
|
|
|
return true; |
590
|
|
|
} |
591
|
|
|
} |
592
|
|
|
} |
593
|
|
|
|
594
|
|
|
return false; |
595
|
|
|
} |
596
|
|
|
|
597
|
|
|
/** |
598
|
|
|
* Returns the changed |
599
|
|
|
* |
600
|
|
|
* @return boolean $changed |
601
|
|
|
*/ |
602
|
|
|
public function getChanged() |
603
|
|
|
{ |
604
|
|
|
return $this->changed; |
605
|
|
|
} |
606
|
|
|
|
607
|
|
|
/** |
608
|
|
|
* Sets the changed |
609
|
|
|
* |
610
|
|
|
* @param boolean $changed |
611
|
|
|
* @return void |
612
|
|
|
*/ |
613
|
|
|
public function setChanged($changed) |
614
|
|
|
{ |
615
|
|
|
$this->changed = boolval($changed); |
616
|
|
|
} |
617
|
|
|
|
618
|
|
|
/** |
619
|
|
|
* Returns the valid |
620
|
|
|
* |
621
|
|
|
* @return boolean $valid |
622
|
|
|
*/ |
623
|
|
|
public function getValid() |
624
|
|
|
{ |
625
|
|
|
return $this->valid; |
626
|
|
|
} |
627
|
|
|
|
628
|
|
|
/** |
629
|
|
|
* Sets the valid |
630
|
|
|
* |
631
|
|
|
* @param boolean $valid |
632
|
|
|
* @return void |
633
|
|
|
*/ |
634
|
|
|
public function setValid($valid) |
635
|
|
|
{ |
636
|
|
|
$this->valid = boolval($valid); |
637
|
|
|
} |
638
|
|
|
|
639
|
|
|
/** |
640
|
|
|
* Gets the Issue Date |
641
|
|
|
* |
642
|
|
|
* @return string |
643
|
|
|
*/ |
644
|
|
|
public function getDateIssued() |
645
|
|
|
{ |
646
|
|
|
return empty($this->dateIssued) ? '' : $this->dateIssued; |
647
|
|
|
} |
648
|
|
|
|
649
|
|
|
/** |
650
|
|
|
* Sets the Issue Date |
651
|
|
|
* |
652
|
|
|
* @param string $dateIssued |
653
|
|
|
* @return void |
654
|
|
|
*/ |
655
|
|
|
public function setDateIssued($dateIssued) |
656
|
|
|
{ |
657
|
|
|
$this->dateIssued = empty($dateIssued) ? '' : $dateIssued; |
658
|
|
|
} |
659
|
|
|
|
660
|
|
|
|
661
|
|
|
/** |
662
|
|
|
* Returns the process number |
663
|
|
|
* |
664
|
|
|
* @return string |
665
|
|
|
*/ |
666
|
|
|
public function getProcessNumber() |
667
|
|
|
{ |
668
|
|
|
return $this->processNumber; |
669
|
|
|
} |
670
|
|
|
|
671
|
|
|
/** |
672
|
|
|
* Sets the process number |
673
|
|
|
* |
674
|
|
|
* @param string $processNumber |
675
|
|
|
* @return void |
676
|
|
|
*/ |
677
|
|
|
public function setProcessNumber($processNumber) |
678
|
|
|
{ |
679
|
|
|
$this->processNumber = trim($processNumber); |
680
|
|
|
} |
681
|
|
|
|
682
|
|
|
/** |
683
|
|
|
* Gets the submitter name of the document |
684
|
|
|
* |
685
|
|
|
* @return string |
686
|
|
|
*/ |
687
|
|
|
public function getSubmitterName() |
688
|
|
|
{ |
689
|
|
|
try { |
690
|
|
|
$internalFormat = new InternalFormat($this->getXmlData(), $this->getPid()); |
691
|
|
|
return $internalFormat->getSubmitterName(); |
692
|
|
|
} catch (\Exception $exception) { |
693
|
|
|
return ""; |
694
|
|
|
} |
695
|
|
|
} |
696
|
|
|
|
697
|
|
|
/** |
698
|
|
|
* Gets the primary urn of the document |
699
|
|
|
* |
700
|
|
|
* @return string |
701
|
|
|
*/ |
702
|
|
|
public function getPrimaryUrn() |
703
|
|
|
{ |
704
|
|
|
$internalFormat = new InternalFormat($this->getXmlData(), $this->getPid()); |
705
|
|
|
return $internalFormat->getPrimaryUrn(); |
|
|
|
|
706
|
|
|
} |
707
|
|
|
|
708
|
|
|
/** |
709
|
|
|
* Returns the creator feuser uid |
710
|
|
|
* |
711
|
|
|
* @return int |
712
|
|
|
*/ |
713
|
|
|
public function getCreator() |
714
|
|
|
{ |
715
|
|
|
return $this->creator? $this->creator : 0; |
716
|
|
|
} |
717
|
|
|
|
718
|
|
|
/** |
719
|
|
|
* Sets the creator feuser uid |
720
|
|
|
* |
721
|
|
|
* @param int $creator |
722
|
|
|
* @return void |
723
|
|
|
*/ |
724
|
|
|
public function setCreator($creator) |
725
|
|
|
{ |
726
|
|
|
$this->creator = $creator; |
727
|
|
|
} |
728
|
|
|
|
729
|
|
|
public function getState() |
730
|
|
|
{ |
731
|
|
|
return $this->state; |
732
|
|
|
} |
733
|
|
|
|
734
|
|
|
public function setState($state) |
735
|
|
|
{ |
736
|
|
|
$this->stateChange = $this->state != $state; |
737
|
|
|
$this->state = $state; |
738
|
|
|
} |
739
|
|
|
|
740
|
|
|
public function getRemoteState() |
741
|
|
|
{ |
742
|
|
|
$state = explode(':', $this->state); |
743
|
|
|
if (is_array($state) && array_key_exists(1, $state)) { |
744
|
|
|
return $state[1]; |
745
|
|
|
} |
746
|
|
|
return DocumentWorkflow::REMOTE_STATE_NONE; |
747
|
|
|
} |
748
|
|
|
|
749
|
|
|
public function getLocalState() { |
750
|
|
|
$state = explode(':', $this->state); |
751
|
|
|
if (is_array($state) && array_key_exists(0, $state)) { |
752
|
|
|
return $state[0]; |
753
|
|
|
} |
754
|
|
|
return DocumentWorkflow::LOCAL_STATE_NONE; |
755
|
|
|
} |
756
|
|
|
|
757
|
|
|
/** |
758
|
|
|
* Returns if a document is a temporary document. |
759
|
|
|
* |
760
|
|
|
* @return boolean $temporary |
761
|
|
|
*/ |
762
|
|
|
public function isTemporary() { |
763
|
|
|
return $this->temporary; |
764
|
|
|
} |
765
|
|
|
|
766
|
|
|
/** |
767
|
|
|
* Sets if a document is a temporary document or not. |
768
|
|
|
* |
769
|
|
|
* @param boolean $temporary |
770
|
|
|
* @return void |
771
|
|
|
*/ |
772
|
|
|
public function setTemporary($temporary) { |
773
|
|
|
$this->temporary = boolval($temporary); |
774
|
|
|
} |
775
|
|
|
|
776
|
|
|
/** |
777
|
|
|
* @return string |
778
|
|
|
*/ |
779
|
|
|
public function getRemoteLastModDate() |
780
|
|
|
{ |
781
|
|
|
return $this->remoteLastModDate; |
782
|
|
|
} |
783
|
|
|
|
784
|
|
|
/** |
785
|
|
|
* @param string $remoteLastModDate |
786
|
|
|
* @return void |
787
|
|
|
*/ |
788
|
|
|
public function setRemoteLastModDate($remoteLastModDate) |
789
|
|
|
{ |
790
|
|
|
$this->remoteLastModDate = $remoteLastModDate; |
791
|
|
|
} |
792
|
|
|
|
793
|
|
|
/** |
794
|
|
|
* @return integer |
795
|
|
|
*/ |
796
|
|
|
public function getTstamp() |
797
|
|
|
{ |
798
|
|
|
return $this->tstamp; |
799
|
|
|
} |
800
|
|
|
|
801
|
|
|
/** |
802
|
|
|
* @return integer |
803
|
|
|
*/ |
804
|
|
|
public function getPid() |
805
|
|
|
{ |
806
|
|
|
return $this->pid; |
807
|
|
|
} |
808
|
|
|
|
809
|
|
|
/** |
810
|
|
|
* @return bool |
811
|
|
|
*/ |
812
|
|
|
public function isSuggestion(): bool |
813
|
|
|
{ |
814
|
|
|
return $this->suggestion; |
815
|
|
|
} |
816
|
|
|
|
817
|
|
|
/** |
818
|
|
|
* @param bool $suggestion |
819
|
|
|
*/ |
820
|
|
|
public function setSuggestion(bool $suggestion) |
821
|
|
|
{ |
822
|
|
|
$this->suggestion = boolval($suggestion); |
823
|
|
|
} |
824
|
|
|
|
825
|
|
|
/** |
826
|
|
|
* @return string |
827
|
|
|
*/ |
828
|
|
|
public function getLinkedUid(): string |
829
|
|
|
{ |
830
|
|
|
return $this->linkedUid; |
831
|
|
|
} |
832
|
|
|
|
833
|
|
|
/** |
834
|
|
|
* @param string $linkedUid |
835
|
|
|
*/ |
836
|
|
|
public function setLinkedUid(string $linkedUid) |
837
|
|
|
{ |
838
|
|
|
$this->linkedUid = $linkedUid; |
839
|
|
|
} |
840
|
|
|
|
841
|
|
|
/** |
842
|
|
|
* @return string |
843
|
|
|
*/ |
844
|
|
|
public function getComment(): string |
845
|
|
|
{ |
846
|
|
|
return $this->comment; |
847
|
|
|
} |
848
|
|
|
|
849
|
|
|
/** |
850
|
|
|
* @param string $comment |
851
|
|
|
*/ |
852
|
|
|
public function setComment(string $comment) |
853
|
|
|
{ |
854
|
|
|
$this->comment = $comment; |
855
|
|
|
} |
856
|
|
|
|
857
|
|
|
/** |
858
|
|
|
* Copies the data of the given document object into the current document object. |
859
|
|
|
* |
860
|
|
|
* @param Document $documentToCopy |
861
|
|
|
* @return $this |
862
|
|
|
* @throws \TYPO3\CMS\Extbase\Reflection\Exception\PropertyNotAccessibleException |
863
|
|
|
*/ |
864
|
|
|
public function copy(Document $documentToCopy) { |
865
|
|
|
$availableProperties = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getGettablePropertyNames($documentToCopy); |
866
|
|
|
$newDocument = $this; |
867
|
|
|
|
868
|
|
|
foreach ($availableProperties as $propertyName) { |
869
|
|
|
if (\TYPO3\CMS\Extbase\Reflection\ObjectAccess::isPropertySettable($newDocument, $propertyName) |
870
|
|
|
&& !in_array($propertyName, array('uid','pid', 'file', 'comment', 'linkedUid', 'suggestion', 'creator'))) { |
871
|
|
|
|
872
|
|
|
$propertyValue = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getProperty($documentToCopy, $propertyName); |
873
|
|
|
\TYPO3\CMS\Extbase\Reflection\ObjectAccess::setProperty($newDocument, $propertyName, $propertyValue); |
874
|
|
|
} |
875
|
|
|
} |
876
|
|
|
|
877
|
|
|
return $this; |
878
|
|
|
} |
879
|
|
|
|
880
|
|
|
public function getNotes() { |
881
|
|
|
$internalFormat = new InternalFormat($this->getXmlData(), $this->getPid()); |
882
|
|
|
return $internalFormat->getNotes(); |
883
|
|
|
} |
884
|
|
|
|
885
|
|
|
/** |
886
|
|
|
* Gets the document Identifier |
887
|
|
|
* |
888
|
|
|
* @return string|int |
889
|
|
|
*/ |
890
|
|
|
public function getDocumentIdentifier() |
891
|
|
|
{ |
892
|
|
|
return $this->getObjectIdentifier()? $this->getObjectIdentifier() : $this->getUid(); |
893
|
|
|
} |
894
|
|
|
|
895
|
|
|
/** |
896
|
|
|
* Returns if a document is a working copy of a published document. |
897
|
|
|
* |
898
|
|
|
* @return bool |
899
|
|
|
*/ |
900
|
|
|
public function isWorkingCopy() |
901
|
|
|
{ |
902
|
|
|
return $this->getObjectIdentifier() && !$this->isTemporary() && !$this->isSuggestion(); |
903
|
|
|
} |
904
|
|
|
|
905
|
|
|
|
906
|
|
|
/** |
907
|
|
|
* Returns if a document is a temporary copy of a published document. |
908
|
|
|
* |
909
|
|
|
* @return bool |
910
|
|
|
*/ |
911
|
|
|
public function isTemporaryCopy() |
912
|
|
|
{ |
913
|
|
|
return $this->getObjectIdentifier() && $this->isTemporary() && !$this->isSuggestion(); |
914
|
|
|
} |
915
|
|
|
|
916
|
|
|
|
917
|
|
|
/** |
918
|
|
|
* Gets the publication year out of the mods-xml data. |
919
|
|
|
* |
920
|
|
|
* @return string|null |
921
|
|
|
*/ |
922
|
|
|
public function getPublicationYear() |
923
|
|
|
{ |
924
|
|
|
$internalFormat = new InternalFormat($this->getXmlData(), $this->getPid()); |
925
|
|
|
$year = $internalFormat->getPublishingYear(); |
926
|
|
|
return $year? $year : ""; |
927
|
|
|
} |
928
|
|
|
|
929
|
|
|
/** |
930
|
|
|
* Gets the source information out of the mods-xml data. |
931
|
|
|
* |
932
|
|
|
* @return string|null |
933
|
|
|
*/ |
934
|
|
|
public function getSourceDetails() |
935
|
|
|
{ |
936
|
|
|
$internalFormat = new InternalFormat($this->getXmlData(), $this->getPid()); |
937
|
|
|
$data = $internalFormat->getSourceDetails(); |
938
|
|
|
return $data; |
939
|
|
|
} |
940
|
|
|
|
941
|
|
|
/** |
942
|
|
|
* @return \DateTime|null |
943
|
|
|
*/ |
944
|
|
|
public function getEmbargoDate(): ?\DateTime |
945
|
|
|
{ |
946
|
|
|
return $this->embargoDate; |
947
|
|
|
} |
948
|
|
|
|
949
|
|
|
/** |
950
|
|
|
* @param \DateTime|null $embargoDate |
951
|
|
|
*/ |
952
|
|
|
public function setEmbargoDate(?\DateTime $embargoDate) |
953
|
|
|
{ |
954
|
|
|
$this->embargoDate = $embargoDate; |
955
|
|
|
} |
956
|
|
|
|
957
|
|
|
/** |
958
|
|
|
* @return array |
959
|
|
|
*/ |
960
|
|
|
public function getNewlyAssignedFobIdentifiers(): array |
961
|
|
|
{ |
962
|
|
|
return $this->newlyAssignedFobIdentifiers; |
963
|
|
|
} |
964
|
|
|
|
965
|
|
|
/** |
966
|
|
|
* @param array newlyAssignedFobIdentifiers |
|
|
|
|
967
|
|
|
*/ |
968
|
|
|
public function setNewlyAssignedFobIdentifiers(array $newlyAssignedFobIdentifiers): void |
969
|
|
|
{ |
970
|
|
|
$this->newlyAssignedFobIdentifiers = $newlyAssignedFobIdentifiers; |
971
|
|
|
} |
972
|
|
|
|
973
|
|
|
/** |
974
|
|
|
* @return array |
975
|
|
|
*/ |
976
|
|
|
public function getPreviouslyAssignedFobIdentifiers() |
977
|
|
|
{ |
978
|
|
|
return array_diff( |
979
|
|
|
$this->getAssignedFobIdentifiers(), $this->getNewlyAssignedFobIdentifiers() |
980
|
|
|
); |
981
|
|
|
} |
982
|
|
|
|
983
|
|
|
/** |
984
|
|
|
* @return array |
985
|
|
|
*/ |
986
|
|
|
public function getAssignedFobIdentifiers(): array |
987
|
|
|
{ |
988
|
|
|
$internalFormat = new InternalFormat($this->getXmlData(), $this->getPid()); |
989
|
|
|
return $internalFormat->getPersonFisIdentifiers(); |
990
|
|
|
} |
991
|
|
|
|
992
|
|
|
/** |
993
|
|
|
* @return bool |
994
|
|
|
*/ |
995
|
|
|
public function isStateChange(): bool |
996
|
|
|
{ |
997
|
|
|
return $this->stateChange; |
998
|
|
|
} |
999
|
|
|
|
1000
|
|
|
/** |
1001
|
|
|
* @return mixed |
1002
|
|
|
*/ |
1003
|
|
|
public function getDepositLicense() |
1004
|
|
|
{ |
1005
|
|
|
$internalFormat = new InternalFormat($this->getXmlData(), $this->getPid()); |
1006
|
|
|
$data = $internalFormat->getDepositLicense(); |
1007
|
|
|
return $data; |
1008
|
|
|
} |
1009
|
|
|
|
1010
|
|
|
/** |
1011
|
|
|
* @return string |
1012
|
|
|
*/ |
1013
|
|
|
public function getCreationDate(): string |
1014
|
|
|
{ |
1015
|
|
|
if ( |
1016
|
|
|
$this->getRemoteState() == DocumentWorkflow::REMOTE_STATE_NONE |
1017
|
|
|
&& empty($this->creationDate) |
1018
|
|
|
) { |
1019
|
|
|
$date = new \DateTime(); |
1020
|
|
|
$date->setTimestamp($this->crdate); |
1021
|
|
|
return $date->format(\DateTimeInterface::RFC3339_EXTENDED); |
1022
|
|
|
} |
1023
|
|
|
|
1024
|
|
|
return $this->creationDate; |
1025
|
|
|
} |
1026
|
|
|
|
1027
|
|
|
/** |
1028
|
|
|
* @param string $creationDate |
1029
|
|
|
*/ |
1030
|
|
|
public function setCreationDate(string $creationDate): void |
1031
|
|
|
{ |
1032
|
|
|
$this->creationDate = $creationDate; |
1033
|
|
|
} |
1034
|
|
|
|
1035
|
|
|
/** |
1036
|
|
|
* Initializes the creation date with the current date. |
1037
|
|
|
*/ |
1038
|
|
|
public function initCreationDate(): void |
1039
|
|
|
{ |
1040
|
|
|
$date = new \DateTime(); |
1041
|
|
|
$this->setCreationDate($date->format(\DateTimeInterface::RFC3339_EXTENDED)); |
1042
|
|
|
} |
1043
|
|
|
|
1044
|
|
|
/** |
1045
|
|
|
* @return bool |
1046
|
|
|
*/ |
1047
|
|
|
public function isClientChangeable() |
1048
|
|
|
{ |
1049
|
|
|
return ( |
1050
|
|
|
in_array( |
1051
|
|
|
$this->getState(), |
1052
|
|
|
[ |
1053
|
|
|
DocumentWorkflow::STATE_REGISTERED_NONE, |
1054
|
|
|
DocumentWorkflow::STATE_IN_PROGRESS_NONE, |
1055
|
|
|
DocumentWorkflow::STATE_POSTPONED_NONE, |
1056
|
|
|
DocumentWorkflow::STATE_DISCARDED_NONE |
1057
|
|
|
] |
1058
|
|
|
) && !$this->stateChange |
1059
|
|
|
); |
1060
|
|
|
} |
1061
|
|
|
} |
1062
|
|
|
|