Passed
Pull Request — master (#201)
by
unknown
09:49 queued 02:44
created

Document::getPrimaryUrn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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 EWW\Dpf\Domain\Workflow\DocumentWorkflow;
18
19
/**
20
 * Document
21
 */
22
class Document extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
23
{
24
    // xml data size ist limited to 64 KB
25
    const XML_DATA_SIZE_LIMIT = 64 * 1024;
26
27
    /**
28
     * title
29
     *
30
     * @var string
31
     */
32
    protected $title = '';
33
34
    /**
35
     * authors
36
     *
37
     * @var string
38
     */
39
    protected $authors = '';
40
41
    /**
42
     * xmlData
43
     *
44
     * @var string
45
     */
46
    protected $xmlData = '';
47
48
    /**
49
     * slubInfoData
50
     *
51
     * @var string
52
     */
53
    protected $slubInfoData = '';
54
55
    /**
56
     * documentType
57
     *
58
     * @var \EWW\Dpf\Domain\Model\DocumentType
59
     */
60
    protected $documentType = null;
61
62
    /**
63
     * objectIdentifier
64
     *
65
     * @var string
66
     */
67
    protected $objectIdentifier = '';
68
69
    /**
70
     * reservedObjectIdentifier
71
     *
72
     * @var string
73
     */
74
    protected $reservedObjectIdentifier;
75
76
    /**
77
     * transferStatus
78
     *
79
     * @var string
80
     */
81
    protected $transferStatus;
82
83
    /**
84
     *  transferDate
85
     *
86
     * @var integer
87
     */
88
    protected $transferDate;
89
90
    /**
91
     * changed
92
     *
93
     * @var boolean
94
     */
95
    protected $changed = false;
96
97
    /**
98
     * valid
99
     *
100
     * @var boolean
101
     */
102
    protected $valid = false;
103
104
    /**
105
     *
106
     * @var string $dateIssued
107
     */
108
    protected $dateIssued;
109
110
    /**
111
     *
112
     * @var string $processNumber
113
     */
114
    protected $processNumber = '';
115
116
    /**
117
     * @var bool $suggestion
118
     */
119
    protected $suggestion = false;
120
121
    /**
122
     * creator
123
     *
124
     * @var int
125
     */
126
    protected $creator = 0;
127
128
    /**
129
     * creation date
130
     *
131
     * @var string
132
     */
133
    protected $creationDate = "";
134
135
    /**
136
     * state
137
     *
138
     * @var string
139
     */
140
    protected $state = DocumentWorkflow::STATE_NONE_NONE;
141
142
    /**
143
     * temporary
144
     *
145
     * @var boolean
146
     */
147
    protected $temporary = FALSE;
148
149
    /**
150
     * remoteLastModDate
151
     *
152
     * @var string
153
     */
154
    protected $remoteLastModDate = '';
155
156
    /**
157
     * tstamp
158
     *
159
     * @var integer
160
     */
161
    protected $tstamp;
162
163
    /**
164
     * crdate
165
     *
166
     * @var integer
167
     */
168
    protected $crdate;
169
170
    /**
171
     * @var string
172
     */
173
    protected $linkedUid = '';
174
175
    /**
176
     * @var string
177
     */
178
    protected $comment = '';
179
180
    /**
181
     * date
182
     *
183
     * @var \DateTime
184
     */
185
    protected $embargoDate = null;
186
187
    /**
188
     * newlyAssignedFobIdentifiers
189
     *
190
     * @var array
191
     */
192
    protected $newlyAssignedFobIdentifiers = [];
193
194
    /**
195
     * @var bool
196
     */
197
    protected $stateChange = false;
198
199
    /**
200
     * file
201
     *
202
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\EWW\Dpf\Domain\Model\File>
203
     * @TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove")
204
     */
205
    protected $file = null;
206
207
    const TRANSFER_ERROR = "ERROR";
208
    const TRANSFER_QUEUED = "QUEUED";
209
    const TRANSFER_SENT = "SENT";
210
211
    /**
212
     * __construct
213
     */
214
    public function __construct()
215
    {
216
        //Do not remove the next line: It would break the functionality
217
        $this->initStorageObjects();
218
    }
219
220
    /**
221
     * Initializes all ObjectStorage properties
222
     *
223
     * @return void
224
     */
225
    protected function initStorageObjects()
226
    {
227
        $this->file = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
228
        $this->initCreationDate();
229
    }
230
231
    /**
232
     * Returns the title
233
     *
234
     * @return string $title
235
     */
236
    public function getTitle()
237
    {
238
        return $this->title;
239
    }
240
241
    /**
242
     * Sets the title
243
     *
244
     * @param string $title
245
     * @return void
246
     */
247
    public function setTitle($title)
248
    {
249
        $this->title = $title ?? '';
250
        //htmlspecialchars_decode($title,ENT_QUOTES);
251
    }
252
253
    /**
254
     * Returns the authors
255
     *
256
     * @return array $authors
257
     */
258
    public function getAuthors()
259
    {
260
        $authors = @unserialize($this->authors);
261
        if (is_array($authors)) {
262
            return $authors;
263
        } else {
264
            return [];
265
        }
266
    }
267
268
    /**
269
     * Sets the authors
270
     *
271
     * @param array $authors
272
     * @return void
273
     */
274
    public function setAuthors($authors)
275
    {
276
        $this->authors = serialize($authors);
277
    }
278
279
    /**
280
     * Returns the xmlData
281
     *
282
     * @return string $xmlData
283
     */
284
    public function getXmlData()
285
    {
286
        return $this->xmlData;
287
    }
288
289
    /**
290
     * Sets the xmlData
291
     *
292
     * @param string $xmlData
293
     * @return void
294
     */
295
    public function setXmlData($xmlData)
296
    {
297
        $this->xmlData = $xmlData;
298
    }
299
300
    /**
301
     * Returns the slubInfoData
302
     *
303
     * @return string $slubInfoData
304
     */
305
    public function getSlubInfoData()
306
    {
307
        return $this->slubInfoData;
308
    }
309
310
    /**
311
     * Sets the slubInfoData
312
     *
313
     * @return string $slubInfoData
314
     */
315
    public function setSlubInfoData($slubInfoData)
316
    {
317
        $this->slubInfoData = $slubInfoData;
318
    }
319
320
    /**
321
     * Returns the documentType
322
     *
323
     * @return \EWW\Dpf\Domain\Model\DocumentType $documentType
324
     */
325
    public function getDocumentType()
326
    {
327
        return $this->documentType;
328
    }
329
330
    /**
331
     * Sets the documentType
332
     *
333
     * @param \EWW\Dpf\Domain\Model\DocumentType $documentType
334
     * @return void
335
     */
336
    public function setDocumentType(\EWW\Dpf\Domain\Model\DocumentType $documentType)
337
    {
338
        $this->documentType = $documentType;
339
    }
340
341
    /**
342
     * Returns the objectIdentifier
343
     *
344
     * @return string
345
     */
346
    public function getObjectIdentifier()
347
    {
348
        return $this->objectIdentifier;
349
    }
350
351
    /**
352
     * Sets the objectIdentifier
353
     *
354
     * @param string $objectIdentifier
355
     * @return void
356
     */
357
    public function setObjectIdentifier($objectIdentifier)
358
    {
359
        // Due to uniqe key uc_object_identifier, which should ignore empty object identifiers.
360
        $this->objectIdentifier = empty($objectIdentifier)? null : $objectIdentifier;
361
    }
362
363
    /**
364
     * Returns the reservedObjectIdentifier
365
     *
366
     * @return string
367
     */
368
    public function getReservedObjectIdentifier()
369
    {
370
        return $this->reservedObjectIdentifier;
371
    }
372
373
    /**
374
     * Sets the reservedObjectIdentifier
375
     *
376
     * @param string $reservedObjectIdentifier
377
     * @return void
378
     */
379
    public function setReservedObjectIdentifier($reservedObjectIdentifier)
380
    {
381
        $this->reservedObjectIdentifier = $reservedObjectIdentifier;
382
    }
383
384
    /**
385
     * Returns the transferStatus
386
     *
387
     * @return string
388
     */
389
    public function getTransferStatus()
390
    {
391
        return $this->transferStatus;
392
    }
393
394
    /**
395
     * Sets the transferStatus
396
     *
397
     * @param string
398
     * @return void
399
     */
400
    public function setTransferStatus($transferStatus)
401
    {
402
        $this->transferStatus = $transferStatus;
403
    }
404
405
    /**
406
     * Returns the transferDate
407
     *
408
     * @return integer
409
     */
410
    public function getTransferDate()
411
    {
412
        return $this->transferDate;
413
    }
414
415
    /**
416
     * Sets the transferDate
417
     *
418
     * @param integer $transferDate
419
     * @return void
420
     */
421
    public function setTransferDate($transferDate)
422
    {
423
        $this->transferDate = $transferDate;
424
    }
425
426
    /**
427
     * Returns the transferErrorCode
428
     *
429
     * @var integer
430
     */
431
    public function getTransferErrorCode()
432
    {
433
        return $this->transferErrorCode;
434
    }
435
436
    /**
437
     * Sets the transferErrorCode
438
     *
439
     * @param integer $transferErrorCode
440
     * @return void
441
     */
442
    public function setTransferErrorCode($transferErrorCode)
443
    {
444
        $this->transferErrorCode = $transferErrorCode;
0 ignored issues
show
Bug Best Practice introduced by
The property transferErrorCode does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
445
    }
446
447
    /**
448
     * Returns the transferResponse
449
     *
450
     * @var string
451
     */
452
    public function getTransferResponse()
453
    {
454
        return $this->transferResponse;
455
    }
456
457
    /**
458
     * Sets the transferResponse
459
     *
460
     * @param string $transferResponse
461
     * @return void
462
     */
463
    public function setTransferResponse($transferResponse)
464
    {
465
        $this->transferResponse = $transferResponse;
0 ignored issues
show
Bug Best Practice introduced by
The property transferResponse does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
466
    }
467
468
    /**
469
     * Returns the transferHttpStatus
470
     *
471
     * @var integer
472
     */
473
    public function getTransferHttpStatus()
474
    {
475
        return $this->transferHttpStatus;
476
    }
477
478
    /**
479
     * Sets the transferHttpStatus
480
     *
481
     * @param integer $transferHttpStatus
482
     * @return void
483
     */
484
    public function setTransferHttpStatus($transferHttpStatus)
485
    {
486
        $this->transferHttpStatus = $transferHttpStatus;
0 ignored issues
show
Bug Best Practice introduced by
The property transferHttpStatus does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
487
    }
488
489
    /**
490
     * Adds a File
491
     *
492
     * @param \EWW\Dpf\Domain\Model\File $file
493
     * @return void
494
     */
495
    public function addFile(\EWW\Dpf\Domain\Model\File $file)
496
    {
497
        $this->file->attach($file);
498
    }
499
500
    /**
501
     * Removes a File
502
     *
503
     * @param \EWW\Dpf\Domain\Model\File $fileToRemove The File to be removed
504
     * @return void
505
     */
506
    public function removeFile(\EWW\Dpf\Domain\Model\File $fileToRemove)
507
    {
508
        $this->file->detach($fileToRemove);
509
    }
510
511
    /**
512
     * Returns the file
513
     *
514
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\EWW\Dpf\Domain\Model\File> $file
515
     */
516
    public function getFile()
517
    {
518
        return $this->file;
519
    }
520
521
    /**
522
     * Sets the file
523
     *
524
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\EWW\Dpf\Domain\Model\File> $file
525
     * @return void
526
     */
527
    public function setFile(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $file)
528
    {
529
        $this->file = $file;
530
    }
531
532
    /**
533
     * Get File Data
534
     *
535
     * @return array
536
     */
537
    public function getFileData()
538
    {
539
540
        $fileId = new \EWW\Dpf\Services\Transfer\FileId($this);
541
542
        $files = array();
543
544
        if (is_a($this->getFile(), '\TYPO3\CMS\Extbase\Persistence\ObjectStorage')) {
545
            foreach ($this->getFile() as $file) {
546
547
                if (!$file->isFileGroupDeleted()) {
548
549
                    $tmpFile = array(
550
                        'path' => $file->getUrl(),
551
                        'type' => $file->getContentType(),
552
                        'title' => (($file->getLabel()) ? $file->getLabel() : $file->getTitle()),
553
                        'download' => $file->getDownload(),
554
                        'archive' => $file->getArchive(),
555
                        'use' => '',
556
                        'id' => null,
557
                        'hasFLocat' => ($file->getStatus() == \EWW\Dpf\Domain\Model\File::STATUS_ADDED ||
558
                            $file->getStatus() == \EWW\Dpf\Domain\Model\File::STATUS_CHANGED),
559
                    );
560
561
                    $grpUSE = ($file->getDownload()) ? 'download' : 'original';
562
563
                    if ($file->getStatus() == \EWW\Dpf\Domain\Model\File::STATUS_DELETED) {
564
                        $dataStreamIdentifier = $file->getDatastreamIdentifier();
565
                        if (!empty($dataStreamIdentifier)) {
566
                            $tmpFile['id'] = $file->getDatastreamIdentifier();
567
                            $tmpFile['use'] = 'DELETE';
568
                            $files[$grpUSE][$file->getUid()] = $tmpFile;
569
                        }
570
                    } else {
571
                        $tmpFile['id'] = $fileId->getId($file);
572
                        $tmpFile['use'] = ($file->getArchive()) ? 'ARCHIVE' : '';
573
                        $files[$grpUSE][$file->getUid()] = $tmpFile;
574
                    }
575
                }
576
577
            }
578
        }
579
580
        return $files;
581
    }
582
583
    /**
584
     * Get Current File Data
585
     *
586
     * @return array
587
     */
588
    public function getCurrentFileData()
589
    {
590
591
        $fileId = new \EWW\Dpf\Services\Transfer\FileId($this);
592
593
        $files = array();
594
595
        if (is_a($this->getFile(), '\TYPO3\CMS\Extbase\Persistence\ObjectStorage')) {
596
            foreach ($this->getFile() as $file) {
597
598
                $tmpFile = array(
599
                    'path' => $file->getUrl(),
600
                    'type' => $file->getContentType(),
601
                    'title' => (($file->getLabel()) ? $file->getLabel() : $file->getTitle()),
602
                    'download' => $file->getDownload(),
603
                    'archive' => $file->getArchive(),
604
                    'use' => '',
605
                    'id' => null,
606
                    'hasFLocat' => ($file->getStatus() == \EWW\Dpf\Domain\Model\File::STATUS_ADDED ||
607
                        $file->getStatus() == \EWW\Dpf\Domain\Model\File::STATUS_CHANGED),
608
                );
609
610
                $grpUSE = ($file->getDownload()) ? 'download' : 'original';
611
612
                if ($file->getStatus() == \EWW\Dpf\Domain\Model\File::STATUS_DELETED) {
613
                    $dataStreamIdentifier = $file->getDatastreamIdentifier();
614
                    if (!empty($dataStreamIdentifier)) {
615
                        $tmpFile['id'] = $file->getDatastreamIdentifier();
616
                        $tmpFile['use'] = 'DELETE';
617
                        $files[$grpUSE][$file->getUid()] = $tmpFile;
618
                    }
619
                } else {
620
                    $tmpFile['id'] = $fileId->getId($file);
621
                    $tmpFile['use'] = ($file->getArchive()) ? 'ARCHIVE' : '';
622
                    $files[$grpUSE][$file->getUid()] = $tmpFile;
623
                }
624
625
            }
626
        }
627
628
        return $files;
629
630
    }
631
632
    /**
633
     * Returns the changed
634
     *
635
     * @return boolean $changed
636
     */
637
    public function getChanged()
638
    {
639
        return $this->changed;
640
    }
641
642
    /**
643
     * Sets the changed
644
     *
645
     * @param boolean $changed
646
     * @return void
647
     */
648
    public function setChanged($changed)
649
    {
650
        $this->changed = boolval($changed);
651
    }
652
653
    /**
654
     * Returns the valid
655
     *
656
     * @return boolean $valid
657
     */
658
    public function getValid()
659
    {
660
        return $this->valid;
661
    }
662
663
    /**
664
     * Sets the valid
665
     *
666
     * @param boolean $valid
667
     * @return void
668
     */
669
    public function setValid($valid)
670
    {
671
        $this->valid = boolval($valid);
672
    }
673
674
    /**
675
     * Gets the Issue Date
676
     *
677
     * @return string
678
     */
679
    public function getDateIssued()
680
    {
681
        return empty($this->dateIssued) ? '' : $this->dateIssued;
682
    }
683
684
    /**
685
     * Sets the Issue Date
686
     *
687
     * @param string $dateIssued
688
     * @return void
689
     */
690
    public function setDateIssued($dateIssued)
691
    {
692
        $this->dateIssued = empty($dateIssued) ? '' : $dateIssued;
693
    }
694
695
696
    /**
697
     * Returns the process number
698
     *
699
     * @return string
700
     */
701
    public function getProcessNumber()
702
    {
703
        return $this->processNumber;
704
    }
705
706
    /**
707
     * Sets the process number
708
     *
709
     * @param string $processNumber
710
     * @return void
711
     */
712
    public function setProcessNumber($processNumber)
713
    {
714
        $this->processNumber = trim($processNumber);
715
    }
716
717
718
    /**
719
     * Gets the submitter name of the document
720
     *
721
     * @return string
722
     */
723
    public function getSubmitterName()
724
    {
725
        try {
726
            $internalFormat = new \EWW\Dpf\Helper\InternalFormat($this->getXmlData());
727
            return $internalFormat->getSubmitterName();
728
        } catch (\Exception $exception) {
729
            return "";
730
        }
731
    }
732
733
    /**
734
     * Gets the primary urn of the document
735
     *
736
     * @return string
737
     */
738
    public function getPrimaryUrn()
739
    {
740
        $internalFormat = new \EWW\Dpf\Helper\InternalFormat($this->getXmlData());
741
        return $internalFormat->getPrimaryUrn();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $internalFormat->getPrimaryUrn() could also return false which is incompatible with the documented return type string. Did you maybe forget to handle an error condition?

If the returned type also contains false, it is an indicator that maybe an error condition leading to the specific return statement remains unhandled.

Loading history...
742
    }
743
744
    /**
745
     * Returns the creator feuser uid
746
     *
747
     * @return int
748
     */
749
    public function getCreator()
750
    {
751
        return $this->creator? $this->creator : 0;
752
    }
753
754
    /**
755
     * Sets the creator feuser uid
756
     *
757
     * @param int $creator
758
     * @return void
759
     */
760
    public function setCreator($creator)
761
    {
762
        $this->creator = $creator;
763
    }
764
765
    public function getState()
766
    {
767
        return $this->state;
768
    }
769
770
    public function setState($state)
771
    {
772
        $this->stateChange = $this->state != $state;
773
        $this->state = $state;
774
    }
775
776
    public function getRemoteState()
777
    {
778
        $state = explode(':', $this->state);
779
        if (is_array($state) && array_key_exists(1, $state)) {
780
            return $state[1];
781
        }
782
        return DocumentWorkflow::REMOTE_STATE_NONE;
783
    }
784
785
    public function getLocalState() {
786
        $state = explode(':', $this->state);
787
        if (is_array($state) && array_key_exists(0, $state)) {
788
            return $state[0];
789
        }
790
        return DocumentWorkflow::LOCAL_STATE_NONE;
791
    }
792
793
    /**
794
     * Returns if a document is a temporary document.
795
     *
796
     * @return boolean $temporary
797
     */
798
    public function isTemporary() {
799
        return $this->temporary;
800
    }
801
802
    /**
803
     * Sets if a document is a temporary document or not.
804
     *
805
     * @param boolean $temporary
806
     * @return void
807
     */
808
    public function setTemporary($temporary) {
809
        $this->temporary = boolval($temporary);
810
    }
811
812
    /**
813
     * @return string
814
     */
815
    public function getRemoteLastModDate()
816
    {
817
        return $this->remoteLastModDate;
818
    }
819
820
    /**
821
     * @param string $remoteLastModDate
822
     * @return void
823
     */
824
    public function setRemoteLastModDate($remoteLastModDate)
825
    {
826
        $this->remoteLastModDate = $remoteLastModDate;
827
    }
828
829
    /**
830
     * @return integer
831
     */
832
    public function getTstamp()
833
    {
834
        return $this->tstamp;
835
    }
836
837
    /**
838
     * @return integer
839
     */
840
    public function getCrdate()
841
    {
842
        return $this->crdate;
843
    }
844
845
    /**
846
     * @return bool
847
     */
848
    public function isSuggestion(): bool
849
    {
850
        return $this->suggestion;
851
    }
852
853
    /**
854
     * @param bool $suggestion
855
     */
856
    public function setSuggestion(bool $suggestion)
857
    {
858
        $this->suggestion = boolval($suggestion);
859
    }
860
861
    /**
862
     * @return string
863
     */
864
    public function getLinkedUid(): string
865
    {
866
        return $this->linkedUid;
867
    }
868
869
    /**
870
     * @param string $linkedUid
871
     */
872
    public function setLinkedUid(string $linkedUid)
873
    {
874
        $this->linkedUid = $linkedUid;
875
    }
876
877
    /**
878
     * @return string
879
     */
880
    public function getComment(): string
881
    {
882
        return $this->comment;
883
    }
884
885
    /**
886
     * @param string $comment
887
     */
888
    public function setComment(string $comment)
889
    {
890
        $this->comment = $comment;
891
    }
892
893
    /**
894
     * Copies the data of the given document object into the current document object.
895
     *
896
     * @param Document $documentToCopy
897
     * @return $this
898
     * @throws \TYPO3\CMS\Extbase\Reflection\Exception\PropertyNotAccessibleException
899
     */
900
    public function copy(Document $documentToCopy) {
901
        $availableProperties = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getGettablePropertyNames($documentToCopy);
902
        $newDocument = $this;
903
904
        foreach ($availableProperties as $propertyName) {
905
            if (\TYPO3\CMS\Extbase\Reflection\ObjectAccess::isPropertySettable($newDocument, $propertyName)
906
                && !in_array($propertyName, array('uid','pid', 'file', 'comment', 'linkedUid', 'suggestion', 'creator'))) {
907
908
                $propertyValue = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getProperty($documentToCopy, $propertyName);
909
                \TYPO3\CMS\Extbase\Reflection\ObjectAccess::setProperty($newDocument, $propertyName, $propertyValue);
910
            }
911
        }
912
913
        return $this;
914
    }
915
916
    public function getNotes() {
917
        $internalFormat = new \EWW\Dpf\Helper\InternalFormat($this->getXmlData());
918
        return $internalFormat->getNotes();
919
    }
920
921
    /**
922
     * Gets the document Identifier
923
     *
924
     * @return string|int
925
     */
926
    public function getDocumentIdentifier()
927
    {
928
        return $this->getObjectIdentifier()? $this->getObjectIdentifier() : $this->getUid();
929
    }
930
931
    /**
932
     * Returns if a document is a working copy of a published document.
933
     *
934
     * @return bool
935
     */
936
    public function isWorkingCopy()
937
    {
938
        return $this->getObjectIdentifier() && !$this->isTemporary() && !$this->isSuggestion();
939
    }
940
941
942
    /**
943
     * Returns if a document is a temporary copy of a published document.
944
     *
945
     * @return bool
946
     */
947
    public function isTemporaryCopy()
948
    {
949
        return $this->getObjectIdentifier() && $this->isTemporary() && !$this->isSuggestion();
950
    }
951
952
953
    /**
954
     * Gets the publication year out of the mods-xml data.
955
     *
956
     * @return string|null
957
     */
958
    public function getPublicationYear()
959
    {
960
        $internalFormat = new \EWW\Dpf\Helper\InternalFormat($this->getXmlData());
961
        $year =  $internalFormat->getPublishingYear();
962
        return $year? $year : "";
963
    }
964
965
    /*
966
     * Gets the main title out of the mods-xml data.
967
     *
968
     * @return string|null
969
     *
970
    public function getMainTitle()
971
    {
972
        $internalFormat = new \EWW\Dpf\Helper\InternalFormat($this->getXmlData());
973
        $title = $internalFormat->getTitle();
974
        return $title? $title : "";
975
    }
976
    */
977
978
979
    /**
980
     * Gets the source information out of the mods-xml data.
981
     *
982
     * @return string|null
983
     */
984
    public function getSourceDetails()
985
    {
986
        $internalFormat = new \EWW\Dpf\Helper\InternalFormat($this->getXmlData());
987
        $data = $internalFormat->getSourceDetails();
988
        return $data;
989
    }
990
991
    /**
992
     * @return \DateTime|null
993
     */
994
    public function getEmbargoDate(): ?\DateTime
995
    {
996
        return $this->embargoDate;
997
    }
998
999
    /**
1000
     * @param \DateTime|null $embargoDate
1001
     */
1002
    public function setEmbargoDate(?\DateTime $embargoDate)
1003
    {
1004
        $this->embargoDate = $embargoDate;
1005
    }
1006
1007
    /**
1008
     * @return array
1009
     */
1010
    public function getNewlyAssignedFobIdentifiers(): array
1011
    {
1012
        return $this->newlyAssignedFobIdentifiers;
1013
    }
1014
1015
    /**
1016
     * @param array newlyAssignedFobIdentifiers
0 ignored issues
show
Bug introduced by
The type EWW\Dpf\Domain\Model\newlyAssignedFobIdentifiers was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
1017
     */
1018
    public function setNewlyAssignedFobIdentifiers(array $newlyAssignedFobIdentifiers): void
1019
    {
1020
        $this->newlyAssignedFobIdentifiers = $newlyAssignedFobIdentifiers;
1021
    }
1022
1023
    /**
1024
     * @return array
1025
     */
1026
    public function getPreviouslyAssignedFobIdentifiers()
1027
    {
1028
        return array_diff(
1029
            $this->getAssignedFobIdentifiers(), $this->getNewlyAssignedFobIdentifiers()
1030
        );
1031
    }
1032
1033
    /**
1034
     * @return array
1035
     */
1036
    public function getAssignedFobIdentifiers(): array
1037
    {
1038
        $internalFormat = new \EWW\Dpf\Helper\InternalFormat($this->getXmlData());
1039
        return $internalFormat->getPersonFisIdentifiers();
1040
    }
1041
1042
    /**
1043
     * @return bool
1044
     */
1045
    public function isStateChange(): bool
1046
    {
1047
        return $this->stateChange;
1048
    }
1049
1050
    /**
1051
     * @return mixed
1052
     */
1053
    public function getDepositLicense()
1054
    {
1055
        $internalFormat = new \EWW\Dpf\Helper\InternalFormat($this->getXmlData());
1056
        $data = $internalFormat->getDepositLicense();
1057
        return $data;
1058
    }
1059
1060
    /**
1061
     * @return string
1062
     */
1063
    public function getCreationDate(): string
1064
    {
1065
        if (
1066
            $this->getRemoteState() == DocumentWorkflow::REMOTE_STATE_NONE
1067
            && empty($this->creationDate)
1068
        ) {
1069
            $date = new \DateTime();
1070
            $date->setTimestamp($this->crdate);
1071
            return $date->format(\DateTimeInterface::RFC3339_EXTENDED);
1072
        }
1073
1074
        return $this->creationDate;
1075
    }
1076
1077
    /**
1078
     * @param string $creationDate
1079
     */
1080
    public function setCreationDate(string $creationDate): void
1081
    {
1082
        $this->creationDate = $creationDate;
1083
    }
1084
1085
    /**
1086
     * Initializes the creation date with the current date.
1087
     */
1088
    public function initCreationDate(): void
1089
    {
1090
        $date = new \DateTime();
1091
        $this->setCreationDate($date->format(\DateTimeInterface::RFC3339_EXTENDED));
1092
    }
1093
}
1094