-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathDecision.php
More file actions
243 lines (216 loc) · 4.83 KB
/
Decision.php
File metadata and controls
243 lines (216 loc) · 4.83 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
<?php
declare(strict_types=1);
namespace Decision\Model;
use Decision\Extensions\Doctrine\MeetingTypesType;
use Decision\Model\Enums\MeetingTypes;
use Decision\Model\SubDecision\Annulment;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\OneToOne;
use Doctrine\ORM\Mapping\OrderBy;
/**
* Decision model.
*/
#[Entity]
class Decision
{
/**
* Meeting.
*/
#[ManyToOne(
targetEntity: Meeting::class,
inversedBy: 'decisions',
)]
#[JoinColumn(
name: 'meeting_type',
referencedColumnName: 'type',
nullable: false,
)]
#[JoinColumn(
name: 'meeting_number',
referencedColumnName: 'number',
nullable: false,
)]
protected Meeting $meeting;
/**
* Meeting type.
*
* NOTE: This is a hack to make the meeting a primary key here.
*/
#[Id]
#[Column(type: MeetingTypesType::NAME)]
protected MeetingTypes $meeting_type;
/**
* Meeting number.
*
* NOTE: This is a hack to make the meeting a primary key here.
*/
#[Id]
#[Column(type: 'integer')]
protected int $meeting_number;
/**
* Point in the meeting in which the decision was made.
*/
#[Id]
#[Column(type: 'integer')]
protected int $point;
/**
* Decision number.
*/
#[Id]
#[Column(type: 'integer')]
protected int $number;
/**
* Content.
*
* Generated from subdecisions.
*/
#[Column(type: 'text')]
protected string $content;
/**
* Subdecisions.
*
* @var Collection<array-key, SubDecision>
*/
#[OneToMany(
targetEntity: SubDecision::class,
mappedBy: 'decision',
cascade: ['persist', 'remove'],
)]
#[OrderBy(value: ['sequence' => 'ASC'])]
protected Collection $subdecisions;
/**
* Annulled by.
*/
#[OneToOne(
targetEntity: Annulment::class,
mappedBy: 'target',
)]
protected ?Annulment $annulledBy = null;
public function __construct()
{
$this->subdecisions = new ArrayCollection();
}
/**
* Set the meeting.
*/
public function setMeeting(Meeting $meeting): void
{
$meeting->addDecision($this);
$this->meeting_type = $meeting->getType();
$this->meeting_number = $meeting->getNumber();
$this->meeting = $meeting;
}
/**
* 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 meeting.
*/
public function getMeeting(): Meeting
{
return $this->meeting;
}
/**
* Set the point number.
*/
public function setPoint(int $point): void
{
$this->point = $point;
}
/**
* Get the point number.
*/
public function getPoint(): int
{
return $this->point;
}
/**
* Set the decision number.
*/
public function setNumber(int $number): void
{
$this->number = $number;
}
/**
* Get the decision number.
*/
public function getNumber(): int
{
return $this->number;
}
/**
* Get decision content.
*/
public function getContent(): string
{
return $this->content;
}
/**
* Set decision content.
*/
public function setContent(string $content): void
{
$this->content = $content;
}
/**
* Get the subdecisions.
*
* @return Collection<array-key, SubDecision>
*/
public function getSubdecisions(): Collection
{
return $this->subdecisions;
}
/**
* Add a subdecision.
*/
public function addSubdecision(SubDecision $subdecision): void
{
$this->subdecisions[] = $subdecision;
}
/**
* Add multiple subdecisions.
*
* @param SubDecision[] $subdecisions
*/
public function addSubdecisions(array $subdecisions): void
{
foreach ($subdecisions as $subdecision) {
$this->addSubdecision($subdecision);
}
}
/**
* Get the subdecision by which this decision is annulled.
*
* Or null, if it wasn't annulled.
*/
public function getAnnulledBy(): ?Annulment
{
return $this->annulledBy;
}
/**
* Check if this decision is annulled by another decision.
*/
public function isAnnulled(): bool
{
return null !== $this->annulledBy;
}
}