-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathSubDecision.php
More file actions
275 lines (251 loc) · 6.7 KB
/
SubDecision.php
File metadata and controls
275 lines (251 loc) · 6.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<?php
declare(strict_types=1);
namespace Decision\Model;
use Decision\Extensions\Doctrine\MeetingTypesType;
use Decision\Model\Enums\MeetingTypes;
use Decision\Model\SubDecision\Abrogation;
use Decision\Model\SubDecision\Annulment;
use Decision\Model\SubDecision\Board\Discharge as BoardDischarge;
use Decision\Model\SubDecision\Board\Installation as BoardInstallation;
use Decision\Model\SubDecision\Board\Release as BoardRelease;
use Decision\Model\SubDecision\Discharge;
use Decision\Model\SubDecision\Financial\Budget;
use Decision\Model\SubDecision\Financial\Statement;
use Decision\Model\SubDecision\Foundation;
use Decision\Model\SubDecision\FoundationReference;
use Decision\Model\SubDecision\Installation;
use Decision\Model\SubDecision\Key\Granting as KeyGranting;
use Decision\Model\SubDecision\Key\Withdrawal as KeyWithdrawal;
use Decision\Model\SubDecision\Other;
use Decision\Model\SubDecision\Reappointment;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\DiscriminatorColumn;
use Doctrine\ORM\Mapping\DiscriminatorMap;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\InheritanceType;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
/**
* SubDecision model.
*
* @psalm-type SubDecisionGdprArrayType = array{
* meeting_type: string,
* meeting_number: int,
* decision_point: int,
* decision_number: int,
* subdecision_sequence: int,
* ...,
* }
*/
#[Entity]
#[InheritanceType(value: 'SINGLE_TABLE')]
#[DiscriminatorColumn(
name: 'type',
type: 'string',
)]
#[DiscriminatorMap(
value: [
'foundation' => Foundation::class,
'abrogation' => Abrogation::class,
'installation' => Installation::class,
'reappointment' => Reappointment::class,
'discharge' => Discharge::class,
'financial_budget' => Budget::class,
'financial_statement' => Statement::class,
'other' => Other::class,
'annulment' => Annulment::class,
'board_installation' => BoardInstallation::class,
'board_release' => BoardRelease::class,
'board_discharge' => BoardDischarge::class,
'foundationreference' => FoundationReference::class,
'key_granting' => KeyGranting::class,
'key_withdraw' => KeyWithdrawal::class,
],
)]
abstract class SubDecision
{
/**
* Decision.
*/
#[ManyToOne(
targetEntity: Decision::class,
inversedBy: 'subdecisions',
)]
#[JoinColumn(
name: 'meeting_type',
referencedColumnName: 'meeting_type',
)]
#[JoinColumn(
name: 'meeting_number',
referencedColumnName: 'meeting_number',
)]
#[JoinColumn(
name: 'decision_point',
referencedColumnName: 'point',
)]
#[JoinColumn(
name: 'decision_number',
referencedColumnName: 'number',
)]
protected Decision $decision;
/**
* Meeting type.
*
* NOTE: This is a hack to make the decision a primary key here.
*/
#[Id]
#[Column(type: MeetingTypesType::NAME)]
protected MeetingTypes $meeting_type;
/**
* Meeting number.
*
* NOTE: This is a hack to make the decision a primary key here.
*/
#[Id]
#[Column(type: 'integer')]
protected int $meeting_number;
/**
* Decision point.
*
* NOTE: This is a hack to make the decision a primary key here.
*/
#[Id]
#[Column(type: 'integer')]
protected int $decision_point;
/**
* Decision number.
*
* NOTE: This is a hack to make the decision a primary key here.
*/
#[Id]
#[Column(type: 'integer')]
protected int $decision_number;
/**
* Sub decision sequence number.
*/
#[Id]
#[Column(type: 'integer')]
protected int $sequence;
/**
* Content.
*/
#[Column(type: 'text')]
protected string $content;
/**
* The member involved in this sub-decision.
*
* Not all sub-decisions require this, as such it is nullable. However, sub-decisions that need the guarantee that
* this is not null or need to specify an inverse side can do so using an association override.
*/
#[ManyToOne(targetEntity: Member::class)]
#[JoinColumn(
name: 'lidnr',
referencedColumnName: 'lidnr',
nullable: true,
)]
protected ?Member $member = null;
/**
* Get the decision.
*/
public function getDecision(): Decision
{
return $this->decision;
}
/**
* Set the decision.
*/
public function setDecision(Decision $decision): void
{
$decision->addSubdecision($this);
$this->meeting_type = $decision->getMeetingType();
$this->meeting_number = $decision->getMeetingNumber();
$this->decision_point = $decision->getPoint();
$this->decision_number = $decision->getNumber();
$this->decision = $decision;
}
/**
* Get the meeting type.
*/
public function getMeetingType(): MeetingTypes
{
return $this->meeting_type;
}
/**
* Get the meeting number.
*/
public function getMeetingNumber(): int
{
return $this->meeting_number;
}
/**
* Get the decision point number.
*/
public function getDecisionPoint(): int
{
return $this->decision_point;
}
/**
* Get the decision number.
*/
public function getDecisionNumber(): int
{
return $this->decision_number;
}
/**
* Get the sequence number.
*/
public function getSequence(): int
{
return $this->sequence;
}
/**
* Set the sequence number.
*/
public function setSequence(int $sequence): void
{
$this->sequence = $sequence;
}
/**
* Get the member.
*/
public function getMember(): ?Member
{
return $this->member;
}
/**
* Set the member.
*/
public function setMember(Member $member): void
{
$this->member = $member;
}
/**
* Get the content.
*/
public function getContent(): string
{
return $this->content;
}
/**
* Set the content.
*/
public function setContent(string $content): void
{
$this->content = $content;
}
/**
* @return SubDecisionGdprArrayType
*/
public function toGdprArray(): array
{
return [
'meeting_type' => $this->getMeetingType()->value,
'meeting_number' => $this->getMeetingNumber(),
'decision_point' => $this->getDecisionPoint(),
'decision_number' => $this->getDecisionNumber(),
'subdecision_sequence' => $this->getSequence(),
'content' => $this->getContent(),
];
}
}