|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* (c) Kitodo. Key to digital objects e.V. <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* This file is part of the Kitodo and TYPO3 projects. |
|
7
|
|
|
* |
|
8
|
|
|
* @license GNU General Public License version 3 or later. |
|
9
|
|
|
* For the full copyright and license information, please read the |
|
10
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Kitodo\Dlf\Domain\Model; |
|
14
|
|
|
|
|
15
|
|
|
use TYPO3\CMS\Extbase\Annotation as Extbase; |
|
16
|
|
|
use TYPO3\CMS\Extbase\Persistence\ObjectStorage; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* This specifies a way how a metadatum (``tx_dlf_metadata``) may be encoded in a specific data format (``tx_dlf_format``). |
|
20
|
|
|
* |
|
21
|
|
|
* For instance, the title of a document may be obtained from either the MODS |
|
22
|
|
|
* title field, or from the TEIHDR caption. This is modeled as two ``tx_dlf_metadaformat`` |
|
23
|
|
|
* that refer to the same ``tx_dlf_metadata`` but different ``tx_dlf_format``. |
|
24
|
|
|
* |
|
25
|
|
|
* This contains the xpath expressions on the model 'Metadata'. |
|
26
|
|
|
* |
|
27
|
|
|
* @package TYPO3 |
|
28
|
|
|
* @subpackage dlf |
|
29
|
|
|
* @access public |
|
30
|
|
|
*/ |
|
31
|
|
|
class MetadataFormat extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* UID of the ``tx_dlf_metadata`` that is encoded by this metadata entry. |
|
35
|
|
|
* |
|
36
|
|
|
* @var int |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $parentId; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* UID of the ``tx_dlf_format`` in which this metadata entry is encoded. |
|
42
|
|
|
* |
|
43
|
|
|
* @var int |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $encoded; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* XPath/JSONPath expression to extract the metadatum (relative to the data format root). |
|
49
|
|
|
* |
|
50
|
|
|
* @var string |
|
51
|
|
|
*/ |
|
52
|
|
|
protected $xpath; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* XPath/JSONPath expression to extract sorting variant (suffixed ``_sorting``) of the metadatum. |
|
56
|
|
|
* |
|
57
|
|
|
* @var string |
|
58
|
|
|
*/ |
|
59
|
|
|
protected $xpathSorting; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Collection of ``tx_dlf_metadatasubentries`` specified with this metadata entry. |
|
63
|
|
|
* |
|
64
|
|
|
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Kitodo\Dlf\Domain\Model\MetadataSubentry> |
|
65
|
|
|
* @Extbase\ORM\Lazy |
|
66
|
|
|
* @Extbase\ORM\Cascade("remove") |
|
67
|
|
|
*/ |
|
68
|
|
|
protected $subentries; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Whether or not the field is mandatory. Not used at the moment (originally planned to be used in METS validator). |
|
72
|
|
|
* |
|
73
|
|
|
* @var int |
|
74
|
|
|
*/ |
|
75
|
|
|
protected $mandatory; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* constructor |
|
79
|
|
|
*/ |
|
80
|
|
|
public function __construct() |
|
81
|
|
|
{ |
|
82
|
|
|
// Do not remove the next line: It would break the functionality |
|
83
|
|
|
$this->initStorageObjects(); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
protected function initStorageObjects() |
|
87
|
|
|
{ |
|
88
|
|
|
$this->subentries = new ObjectStorage(); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @return int |
|
93
|
|
|
*/ |
|
94
|
|
|
public function getParentId(): int |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->parentId; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @param int $parentId |
|
101
|
|
|
*/ |
|
102
|
|
|
public function setParentId(int $parentId): void |
|
103
|
|
|
{ |
|
104
|
|
|
$this->parentId = $parentId; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @return int |
|
109
|
|
|
*/ |
|
110
|
|
|
public function getEncoded(): int |
|
111
|
|
|
{ |
|
112
|
|
|
return $this->encoded; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @param int $encoded |
|
117
|
|
|
*/ |
|
118
|
|
|
public function setEncoded(int $encoded): void |
|
119
|
|
|
{ |
|
120
|
|
|
$this->encoded = $encoded; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @return string |
|
125
|
|
|
*/ |
|
126
|
|
|
public function getXpath(): string |
|
127
|
|
|
{ |
|
128
|
|
|
return $this->xpath; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* @param string $xpath |
|
133
|
|
|
*/ |
|
134
|
|
|
public function setXpath(string $xpath): void |
|
135
|
|
|
{ |
|
136
|
|
|
$this->xpath = $xpath; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @return string |
|
141
|
|
|
*/ |
|
142
|
|
|
public function getXpathSorting(): string |
|
143
|
|
|
{ |
|
144
|
|
|
return $this->xpathSorting; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* @param string $xpathSorting |
|
149
|
|
|
*/ |
|
150
|
|
|
public function setXpathSorting(string $xpathSorting): void |
|
151
|
|
|
{ |
|
152
|
|
|
$this->xpathSorting = $xpathSorting; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
public function getSubentries() |
|
156
|
|
|
{ |
|
157
|
|
|
return $this->subentries; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
public function setSubentries(ObjectStorage $subentries): void |
|
161
|
|
|
{ |
|
162
|
|
|
$this->subentries = $subentries; |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
/** |
|
166
|
|
|
* Adds a Subentry |
|
167
|
|
|
* |
|
168
|
|
|
* @param \Kitodo\Dlf\Domain\Model\MetadataSubentry $subentry |
|
169
|
|
|
* |
|
170
|
|
|
* @return void |
|
171
|
|
|
*/ |
|
172
|
|
|
public function addSubentry(MetadataSubentry $subentry) |
|
173
|
|
|
{ |
|
174
|
|
|
$this->subentries->attach($subentry); |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* Removes a Subentry |
|
179
|
|
|
* |
|
180
|
|
|
* @param \Kitodo\Dlf\Domain\Model\MetadataSubentry $subentryToRemove |
|
181
|
|
|
* |
|
182
|
|
|
* @return void |
|
183
|
|
|
*/ |
|
184
|
|
|
public function removeSubentry(MetadataSubentry $subentryToRemove) |
|
185
|
|
|
{ |
|
186
|
|
|
$this->subentries->detach($subentryToRemove); |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* @return int |
|
191
|
|
|
*/ |
|
192
|
|
|
public function getMandatory(): int |
|
193
|
|
|
{ |
|
194
|
|
|
return $this->mandatory; |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* @param int $mandatory |
|
199
|
|
|
*/ |
|
200
|
|
|
public function setMandatory(int $mandatory): void |
|
201
|
|
|
{ |
|
202
|
|
|
$this->mandatory = $mandatory; |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
} |
|
206
|
|
|
|