Passed
Pull Request — master (#211)
by
unknown
15:53
created

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