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