Passed
Push — master ( f02d33...dc5694 )
by Ralf
19:35
created

MetadataObject::isFileLabelField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
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
/**
18
 * MetadataObject
19
 */
20
class MetadataObject extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity implements MetadataMandatoryInterface
21
{
22
23
    /**
24
     * name
25
     *
26
     * @var string
27
     */
28
    protected $name = '';
29
30
    /**
31
     * displayName
32
     *
33
     * @var string
34
     */
35
    protected $displayName = '';
36
37
    /**
38
     * maxIteration
39
     *
40
     * @var integer
41
     */
42
    protected $maxIteration = 0;
43
44
    /**
45
     * mandatory
46
     *
47
     * @var string
48
     */
49
    protected $mandatory = '';
50
51
    /**
52
     * mapping
53
     *
54
     * @var string
55
     */
56
    protected $mapping = '';
57
58
    /**
59
     * inputField
60
     *
61
     * @var integer
62
     */
63
    protected $inputField = 0;
64
65
    /**
66
     * @var string
67
     */
68
    protected $objectType = '';
69
    /**
70
     * depositLicense
71
     *
72
     * @var int
73
     */
74
    protected $depositLicense = '';
75
76
    /**
77
     * JSON mapping
78
     *
79
     * @var string
80
     */
81
    protected $jsonMapping = '';
82
83
    const input    = 0;
84
    const textarea = 1;
85
    const select   = 2;
86
    const checkbox = 3;
87
    const hidden   = 4;
88
    const textareaMarkdown = 10;
89
    const INPUTDROPDOWN = 100;
90
    const FILE_UPLOAD = 200;
91
92
    const INPUT_DATA_TYPE_REGEXP = "REGEXP";
93
    const INPUT_DATA_TYPE_DATE   = "DATE";
94
95
    /**
96
     * dataType
97
     *
98
     * @var string
99
     */
100
    protected $dataType;
101
102
    /**
103
     * modsExtension
104
     *
105
     * @var boolean
106
     */
107
    protected $modsExtension = false;
108
109
    /**
110
     * inputOptionList
111
     *
112
     * @var \EWW\Dpf\Domain\Model\InputOptionList
113
     */
114
    protected $inputOptionList = null;
115
116
    /**
117
     * fillOutService
118
     *
119
     * @var string
120
     */
121
    protected $fillOutService = '';
122
123
    const FILL_OUT_SERVICE_URN = 'urn';
124
    const FILL_OUT_SERVICE_GND = 'gnd';
125
126
    /**
127
     * @var string
128
     */
129
    protected $gndFieldUid = '';
130
131
    /**
132
     * accessRestrictionRoles
133
     *
134
     * @var string
135
     */
136
    protected $accessRestrictionRoles = '';
137
138
    /**
139
     * consent
140
     *
141
     * @var boolean
142
     */
143
    protected $consent;
144
145
    /**
146
     * defaultValue
147
     *
148
     * @var string
149
     */
150
    protected $defaultValue;
151
152
    /**
153
     * validation
154
     *
155
     * @var string
156
     */
157
    protected $validation = '';
158
159
    /**
160
     * max input length
161
     *
162
     * @var integer
163
     */
164
    protected $maxInputLength = 0;
165
166
    /**
167
     * Embargo field option
168
     *
169
     * @var boolean
170
     */
171
    protected $embargo;
172
173
    /**
174
     * fis mapping
175
     *
176
     * @var string
177
     */
178
    protected $fisPersonMapping = '';
179
180
    /**
181
     * fis mapping
182
     *
183
     * @var string
184
     */
185
    protected $fisOrganisationMapping = '';
186
187
    /**
188
     * gnd mapping
189
     *
190
     * @var string
191
     */
192
    protected $gndPersonMapping = '';
193
194
    /**
195
     * gnd mapping
196
     *
197
     * @var string
198
     */
199
    protected $gndOrganisationMapping = '';
200
201
    /**
202
     * ror mapping
203
     *
204
     * @var string
205
     */
206
    protected $rorMapping = '';
207
208
    /**
209
     * zdb mapping
210
     *
211
     * @var string
212
     */
213
    protected $zdbMapping = '';
214
215
    /**
216
     * unpaywall mapping
217
     * @var string
218
     */
219
    protected $unpaywallMapping = '';
220
221
    /**
222
     * orcid person mapping
223
     * @var string
224
     */
225
    protected $orcidPersonMapping = '';
226
227
    /**
228
     * help text
229
     *
230
     * @var string
231
     */
232
    protected $helpText = '';
233
234
    /**
235
     * Returns the name
236
     *
237
     * @return string $name
238
     */
239
    public function getName()
240
    {
241
        return $this->name;
242
    }
243
244
    /**
245
     * Sets the name
246
     *
247
     * @param string $name
248
     * @return void
249
     */
250
    public function setName($name)
251
    {
252
        $this->name = $name;
253
    }
254
255
    /**
256
     * Returns the displayName
257
     *
258
     * @return string $displayName
259
     */
260
    public function getDisplayName()
261
    {
262
        return $this->displayName;
263
    }
264
265
    /**
266
     * Sets the displayName
267
     *
268
     * @param string $displayName
269
     * @return void
270
     */
271
    public function setDisplayName($displayName)
272
    {
273
        $this->displayName = $displayName;
274
    }
275
276
    /**
277
     * Returns the maxIteration
278
     *
279
     * @return integer $maxIteration
280
     */
281
    public function getMaxIteration()
282
    {
283
        if ($this->isRepeatable()) {
284
            return $this->maxIteration;
285
        }
286
        return 1;
287
    }
288
289
    /**
290
     * Sets the maxIteration
291
     *
292
     * @param integer $maxIteration
293
     * @return void
294
     */
295
    public function setMaxIteration($maxIteration)
296
    {
297
        if ($this->isRepeatable()) {
298
            $this->maxIteration = $maxIteration;
299
        } else {
300
            $this->maxIteration = 1;
301
        }
302
    }
303
304
    /**
305
     * Returns the mandatory
306
     *
307
     * @return string $mandatory
308
     */
309
    public function getMandatory()
310
    {
311
        return $this->mandatory;
312
    }
313
314
    /**
315
     * Sets the mandatory
316
     *
317
     * @param string $mandatory
318
     * @return void
319
     */
320
    public function setMandatory($mandatory)
321
    {
322
        $this->mandatory = $mandatory;
323
    }
324
325
    /**
326
     * Returns the modsExtension
327
     *
328
     * @return boolean $modsExtension
329
     */
330
    public function getModsExtension()
331
    {
332
        return $this->modsExtension;
333
    }
334
335
    /**
336
     * Sets the modsExtension
337
     *
338
     * @param boolean $modsExtension
339
     * @return void
340
     */
341
    public function setModsExtension($modsExtension)
342
    {
343
        $this->modsExtension = boolval($modsExtension);
344
    }
345
346
    /**
347
     * Returns the boolean state of modsExtension
348
     *
349
     * @return boolean
350
     */
351
    public function isModsExtension()
352
    {
353
        return $this->modsExtension;
354
    }
355
356
    /**
357
     * Returns the mapping
358
     *
359
     * @return string $mapping
360
     */
361
    public function getMapping()
362
    {
363
        return $this->mapping;
364
    }
365
366
    /**
367
     * Sets the mapping
368
     *
369
     * @param string $mapping
370
     * @return void
371
     */
372
    public function setMapping($mapping)
373
    {
374
        $this->mapping = $mapping;
375
    }
376
377
    /**
378
     * Returns the relative mapping
379
     *
380
     * @return string $relativeMapping
381
     */
382
    public function getRelativeMapping()
383
    {
384
        return trim($this->mapping, " /");
385
    }
386
387
    /**
388
     * Returns the inputField
389
     *
390
     * @return integer $inputField
391
     */
392
    public function getInputField()
393
    {
394
        return $this->inputField;
395
    }
396
397
    /**
398
     * Sets the inputField
399
     *
400
     * @param integer $inputField
401
     * @return void
402
     */
403
    public function setInputField($inputField)
404
    {
405
        $this->inputField = $inputField;
406
    }
407
408
    /**
409
     * Returns always NULL because an Object never has children.
410
     *
411
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\EWW\Dpf\Domain\Model\MetadataObject> $metadataObject
412
     */
413
    public function getChildren()
414
    {
415
        return null;
416
    }
417
418
    /**
419
     * Returns the inputOptionList
420
     *
421
     * @return \EWW\Dpf\Domain\Model\InputOptionList $inputOptionList
422
     */
423
    public function getInputOptionList()
424
    {
425
        return $this->inputOptionList;
426
    }
427
428
    /**
429
     * Sets the inputOptionList
430
     *
431
     * @param \EWW\Dpf\Domain\Model\InputOptionList $inputOptionList
432
     * @return void
433
     */
434
    public function setInputOptionList(\EWW\Dpf\Domain\Model\InputOptionList $inputOptionList)
435
    {
436
        $this->inputOptionList = $inputOptionList;
437
    }
438
439
    /**
440
     * Returns the fillOutService
441
     *
442
     * @return string $fillOutService
443
     */
444
    public function getFillOutService()
445
    {
446
        return $this->fillOutService;
447
    }
448
449
    /**
450
     * Sets the fillOutService
451
     *
452
     * @param string $fillOutService
453
     * @return void
454
     */
455
    public function setFillOutService($fillOutService)
456
    {
457
        $this->fillOutService = $fillOutService;
458
    }
459
460
    /**
461
     * Returns the accessRestrictionRoles
462
     *
463
     * @return array $accessRestrictionRoles
464
     */
465
    public function getAccessRestrictionRoles()
466
    {
467
        if ($this->accessRestrictionRoles) {
468
            return array_map('trim', explode(',', $this->accessRestrictionRoles));
469
        } else {
470
            return array();
471
        }
472
    }
473
474
    /**
475
     * Sets the accessRestrictionRoles
476
     *
477
     * @param array $accessRestrictionRoles
478
     * @return void
479
     */
480
    public function setAccessRestrictionRoles($accessRestrictionRoles)
481
    {
482
        $this->accessRestrictionRoles = implode(',', $accessRestrictionRoles);
483
    }
484
485
    /**
486
     * Returns the consent
487
     *
488
     * @return boolean $consent
489
     */
490
    public function getConsent()
491
    {
492
        return $this->consent;
493
    }
494
495
    /**
496
     * Sets the consent
497
     *
498
     * @param boolean $consent
499
     * @return void
500
     */
501
    public function setConsent($consent)
502
    {
503
        $this->consent = boolval($consent);
504
    }
505
506
    /**
507
     * Returns the defaultValue
508
     *
509
     * @return string $defaultValue
510
     */
511
    public function getDefaultValue()
512
    {
513
        return $this->defaultValue;
514
    }
515
516
    /**
517
     * Sets the defaultValue
518
     *
519
     * @param string $defaultValue
520
     * @return void
521
     */
522
    public function setDefaultValue($defaultValue)
523
    {
524
        $this->defaultValue = $defaultValue;
525
    }
526
527
    /**
528
     * Returns the validation
529
     *
530
     * @return string $validation
531
     */
532
    public function getValidation()
533
    {
534
        return $this->validation;
535
    }
536
537
    /**
538
     * Sets the validation
539
     *
540
     * @param string $validation
541
     * @return void
542
     */
543
    public function setValidation($validation)
544
    {
545
        $this->validation = $validation;
546
    }
547
548
    /**
549
     * Returns the dataType
550
     *
551
     * @return string $dataType
552
     */
553
    public function getDataType()
554
    {
555
        return $this->dataType;
556
    }
557
558
    /**
559
     * Sets the dataType
560
     *
561
     * @param string $dataType
562
     * @return void
563
     */
564
    public function setDataType($dataType)
565
    {
566
        $this->dataType = $dataType;
567
    }
568
569
    /**
570
     * @return string
571
     */
572
    public function getGndFieldUid()
573
    {
574
        return $this->gndFieldUid;
575
    }
576
577
    /**
578
     * @param string $gndFieldUid
579
     */
580
    public function setGndFieldUid($gndFieldUid)
581
    {
582
        $this->gndFieldUid = $gndFieldUid;
583
    }
584
585
    /**
586
     * @return integer
587
     */
588
    public function getMaxInputLength()
589
    {
590
        if ($this->maxInputLength == 0) {
591
            if ($this->inputField == self::input) {
592
                return 255;
593
            } else {
594
                return 2048;
595
            }
596
        } else {
597
            return $this->maxInputLength;
598
        }
599
    }
600
601
    /**
602
     * @return integer
603
     */
604
    public function setMaxInputLength($maxInputLength)
605
    {
606
        $this->maxInputLength = $maxInputLength;
607
    }
608
609
    /**
610
     * @return bool
611
     */
612
    public function getEmbargo(): bool
613
    {
614
        return $this->embargo;
615
    }
616
617
    /**
618
     * @param bool $embargo
619
     */
620
    public function setEmbargo(bool $embargo)
621
    {
622
        $this->embargo = boolval($embargo);
623
    }
624
625
    /**
626
     * @return string
627
     */
628
    public function getFisPersonMapping(): string
629
    {
630
        return $this->fisPersonMapping;
631
    }
632
633
    /**
634
     * @param string $fisPersonMapping
635
     */
636
    public function setFisPersonMapping(string $fisPersonMapping): void
637
    {
638
        $this->fisPersonMapping = $fisPersonMapping;
639
    }
640
641
    /**
642
     * @return string
643
     */
644
    public function getFisOrganisationMapping(): string
645
    {
646
        return $this->fisOrganisationMapping;
647
    }
648
649
    /**
650
     * @param string $fisOrganisationMapping
651
     */
652
    public function setFisOrganisationMapping(string $fisOrganisationMapping): void
653
    {
654
        $this->fisOrganisationMapping = $fisOrganisationMapping;
655
    }
656
657
    /**
658
     * @return string
659
     */
660
    public function getRorMapping(): string
661
    {
662
        return $this->rorMapping;
663
    }
664
665
    /**
666
     * @param string $rorMapping
667
     */
668
    public function setRorMapping(string $rorMapping)
669
    {
670
        $this->rorMapping = $rorMapping;
671
    }
672
673
    /**
674
     * @return string
675
     */
676
    public function getZdbMapping(): string
677
    {
678
        return $this->zdbMapping;
679
    }
680
681
    /**
682
     * @param string $zdbMapping
683
     */
684
    public function setZdbMapping(string $zdbMapping): void
685
    {
686
        $this->zdbMapping = $zdbMapping;
687
    }
688
689
    /**
690
     * @return string
691
     */
692
    public function getUnpaywallMapping(): string
693
    {
694
        return $this->unpaywallMapping;
695
    }
696
697
    /**
698
     * @param string $unpaywallMapping
699
     */
700
    public function setUnpaywallMapping(string $unpaywallMapping): void
701
    {
702
        $this->unpaywallMapping = $unpaywallMapping;
703
    }
704
705
    /**
706
     * @return string
707
     */
708
    public function getObjectType(): string
709
    {
710
        return $this->objectType;
711
    }
712
    /**
713
     * Gets the jsonMapping
714
     *
715
     * @return string
716
     */
717
    public function getJsonMapping(): string
718
    {
719
        return $this->jsonMapping;
720
    }
721
722
    /**
723
     * Sets the jsonMapping
724
     *
725
     * @param string $jsonMapping
726
     */
727
    public function setJsonMapping(string $jsonMapping): void
728
    {
729
        $this->jsonMapping = $jsonMapping;
730
    }
731
    /**
732
     * @param string $objectType
733
     */
734
    public function setObjectType(string $objectType): void
735
    {
736
        $this->objectType = $objectType;
737
    }
738
739
    /**
740
     * @return string
741
     */
742
    public function getGndPersonMapping(): string
743
    {
744
        return $this->gndPersonMapping;
745
    }
746
747
    /**
748
     * @param string $gndPersonMapping
749
     */
750
    public function setGndPersonMapping(string $gndPersonMapping): void
751
    {
752
        $this->gndPersonMapping = $gndPersonMapping;
753
    }
754
755
    /**
756
     * @return string
757
     */
758
    public function getGndOrganisationMapping(): string
759
    {
760
        return $this->gndOrganisationMapping;
761
    }
762
763
    /**
764
     * @param string $gndOrganisationMapping
765
     */
766
    public function setGndOrganisationMapping(string $gndOrganisationMapping): void
767
    {
768
        $this->gndOrganisationMapping = $gndOrganisationMapping;
769
    }
770
771
    /**
772
     * @return string
773
     */
774
    public function getOrcidPersonMapping(): string
775
    {
776
        return $this->orcidPersonMapping;
777
    }
778
779
    /**
780
     * @param string $orcidPersonMapping
781
     */
782
    public function setOrcidPersonMapping(string $orcidPersonMapping): void
783
    {
784
        $this->orcidPersonMapping = $orcidPersonMapping;
785
    }
786
787
788
    /**
789
     * @return int
790
     */
791
    public function getDepositLicense(): int
792
    {
793
        return $this->depositLicense;
794
    }
795
796
    /**
797
     * @param int $depositLicense
798
     */
799
    public function setDepositLicense($depositLicense): void
800
    {
801
        $this->depositLicense = $depositLicense;
802
    }
803
804
    /**
805
     * @return string
806
     */
807
    public function getHelpText(): string
808
    {
809
        return $this->helpText;
810
    }
811
812
    /**
813
     * @param string $helpText
814
     */
815
    public function setHelpText(string $helpText): void
816
    {
817
        $this->helpText = $helpText;
818
    }
819
820
    /**
821
     * @return bool
822
     */
823
    public function isUploadField()
824
    {
825
        return $this->getInputField() == self::FILE_UPLOAD;
826
    }
827
828
    /**
829
     * @return bool
830
     */
831
    public function isFileLabelField()
832
    {
833
        return $this->getObjectType() == 'fileLabel';
834
    }
835
836
    /**
837
     * @return bool
838
     */
839
    public function isFileDownloadField()
840
    {
841
        return $this->getObjectType() == 'fileDownload';
842
    }
843
844
    /**
845
     * @return bool
846
     */
847
    public function isFileArchiveField()
848
    {
849
        return $this->getObjectType() == 'fileArchive';
850
    }
851
852
    protected function isRepeatable() {
853
        return !in_array($this->getObjectType(), ['fileDownload','fileArchive','fileLabel'])
854
            && $this->getInputField() != self::FILE_UPLOAD;
855
    }
856
}
857