Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
64.52% |
20 / 31 |
|
72.00% |
18 / 25 |
CRAP | |
0.00% |
0 / 1 |
Notification | |
64.52% |
20 / 31 |
|
72.00% |
18 / 25 |
59.57 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
__toString | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 | |||
getId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getModule | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setModule | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getObject | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setObject | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getCollectivity | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setCollectivity | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getReadBy | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setReadBy | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getReadAt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setReadAt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getCreatedBy | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setCreatedBy | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getAction | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setAction | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getNotificationUsers | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setNotificationUsers | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getDpo | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setDpo | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getSubject | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setSubject | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * This file is part of the MADIS - RGPD Management application. |
5 | * |
6 | * @copyright Copyright (c) 2018-2019 Soluris - Solutions Numériques Territoriales Innovantes |
7 | * |
8 | * This program is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU Affero General Public License as published by |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * (at your option) any later version. |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU Affero General Public License for more details. |
17 | * |
18 | * You should have received a copy of the GNU Affero General Public License |
19 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
20 | */ |
21 | |
22 | declare(strict_types=1); |
23 | |
24 | namespace App\Domain\Notification\Model; |
25 | |
26 | use App\Application\Traits\Model\CreatorTrait; |
27 | use App\Application\Traits\Model\HistoryTrait; |
28 | use App\Domain\AIPD\Model\AnalyseImpact; |
29 | use App\Domain\Documentation\Model\Document; |
30 | use App\Domain\Maturity\Model\Maturity; |
31 | use App\Domain\Registry\Model\ConformiteOrganisation\Conformite; |
32 | use App\Domain\Registry\Model\ConformiteTraitement\ConformiteTraitement; |
33 | use App\Domain\Registry\Model\Contractor; |
34 | use App\Domain\Registry\Model\Mesurement; |
35 | use App\Domain\Registry\Model\Proof; |
36 | use App\Domain\Registry\Model\Request; |
37 | use App\Domain\Registry\Model\Treatment; |
38 | use App\Domain\Registry\Model\Violation; |
39 | use App\Domain\User\Model\Collectivity; |
40 | use App\Domain\User\Model\User; |
41 | use Doctrine\Common\Collections\Collection; |
42 | use Doctrine\ORM\Mapping as ORM; |
43 | use Ramsey\Uuid\Uuid; |
44 | use Ramsey\Uuid\UuidInterface; |
45 | |
46 | /** |
47 | * @ORM\Entity |
48 | */ |
49 | class Notification |
50 | { |
51 | use HistoryTrait; |
52 | use CreatorTrait; |
53 | |
54 | public const NOTIFICATION_DPO = 1; |
55 | public const NOTIFICATION_COLLECTIVITY = 2; |
56 | |
57 | public const MODULES = [ |
58 | Treatment::class => 'treatment', |
59 | Contractor::class => 'subcontractor', |
60 | Request::class => 'request', |
61 | Violation::class => 'violation', |
62 | Proof::class => 'proof', |
63 | Mesurement::class => 'protect_action', |
64 | Maturity::class => 'maturity', |
65 | ConformiteTraitement::class => 'treatment_conformity', |
66 | Conformite::class => 'organization_conformity', |
67 | AnalyseImpact::class => 'aipd', |
68 | Document::class => 'document', |
69 | User::class => 'user', |
70 | ]; |
71 | |
72 | /** |
73 | * @ORM\Id() |
74 | * |
75 | * @ORM\Column(type="uuid") |
76 | * |
77 | * @var UuidInterface |
78 | */ |
79 | private $id; |
80 | |
81 | /** |
82 | * @ORM\Column(type="string") |
83 | * |
84 | * @var string|null |
85 | */ |
86 | private $name; |
87 | |
88 | /** |
89 | * @ORM\Column(type="boolean") |
90 | */ |
91 | private ?bool $dpo; |
92 | |
93 | /** |
94 | * @ORM\Column(type="string") |
95 | * |
96 | * @var string|null |
97 | */ |
98 | private $module; |
99 | /** |
100 | * @ORM\Column(type="text", nullable=true) |
101 | */ |
102 | private ?string $subject; |
103 | |
104 | /** |
105 | * @ORM\Column(type="string") |
106 | * |
107 | * @var string|null |
108 | */ |
109 | private $action; |
110 | |
111 | /** |
112 | * @ORM\Column(type="object") |
113 | * |
114 | * @var object|null |
115 | */ |
116 | private $object; |
117 | |
118 | /** |
119 | * @var Collectivity|null |
120 | * |
121 | * @ORM\ManyToOne(targetEntity="App\Domain\User\Model\Collectivity") |
122 | * |
123 | * @ORM\JoinColumn(onDelete="SET NULL") |
124 | */ |
125 | private $collectivity; |
126 | |
127 | /** |
128 | * @ORM\ManyToOne(targetEntity="App\Domain\User\Model\User") |
129 | * |
130 | * @ORM\JoinColumn(onDelete="SET NULL") |
131 | */ |
132 | private ?User $readBy; |
133 | |
134 | /** |
135 | * @ORM\Column(type="datetime", name="read_at", nullable="true") |
136 | */ |
137 | private ?\DateTime $readAt = null; |
138 | |
139 | /** |
140 | * @ORM\ManyToOne(targetEntity="App\Domain\User\Model\User") |
141 | * |
142 | * @ORM\JoinColumn(onDelete="SET NULL") |
143 | */ |
144 | private ?User $createdBy; |
145 | |
146 | /** |
147 | * @ORM\OneToMany(mappedBy="notification", targetEntity="App\Domain\Notification\Model\NotificationUser", cascade={"persist", "remove"}) |
148 | */ |
149 | private Collection|array $notificationUsers = []; |
150 | |
151 | /** |
152 | * Category constructor. |
153 | * |
154 | * @throws \Exception |
155 | */ |
156 | public function __construct() |
157 | { |
158 | $this->id = Uuid::uuid4(); |
159 | $this->dpo = false; |
160 | $this->createdBy = null; |
161 | } |
162 | |
163 | public function __toString(): string |
164 | { |
165 | if (\is_null($this->getName())) { |
166 | return ''; |
167 | } |
168 | |
169 | if (\mb_strlen($this->getName()) > 150) { |
170 | return \mb_substr($this->getName(), 0, 150) . '...'; |
171 | } |
172 | |
173 | return $this->getName(); |
174 | } |
175 | |
176 | public function getId(): UuidInterface |
177 | { |
178 | return $this->id; |
179 | } |
180 | |
181 | public function getName(): ?string |
182 | { |
183 | return $this->name; |
184 | } |
185 | |
186 | public function setName(?string $name): void |
187 | { |
188 | $this->name = $name; |
189 | } |
190 | |
191 | public function getModule(): ?string |
192 | { |
193 | return $this->module; |
194 | } |
195 | |
196 | public function setModule(?string $module): void |
197 | { |
198 | $this->module = $module; |
199 | } |
200 | |
201 | public function getObject(): ?object |
202 | { |
203 | return $this->object; |
204 | } |
205 | |
206 | public function setObject(?object $object): void |
207 | { |
208 | $this->object = $object; |
209 | } |
210 | |
211 | public function getCollectivity(): ?Collectivity |
212 | { |
213 | return $this->collectivity; |
214 | } |
215 | |
216 | public function setCollectivity(?Collectivity $collectivity): void |
217 | { |
218 | $this->collectivity = $collectivity; |
219 | } |
220 | |
221 | public function getReadBy(): ?User |
222 | { |
223 | return $this->readBy; |
224 | } |
225 | |
226 | public function setReadBy(?User $readBy): void |
227 | { |
228 | $this->readBy = $readBy; |
229 | } |
230 | |
231 | public function getReadAt(): ?\DateTime |
232 | { |
233 | return $this->readAt; |
234 | } |
235 | |
236 | public function setReadAt(?\DateTime $readAt): void |
237 | { |
238 | $this->readAt = $readAt; |
239 | } |
240 | |
241 | public function getCreatedBy(): ?User |
242 | { |
243 | return $this->createdBy; |
244 | } |
245 | |
246 | public function setCreatedBy(?User $createdBy): void |
247 | { |
248 | $this->createdBy = $createdBy; |
249 | } |
250 | |
251 | public function getAction(): ?string |
252 | { |
253 | return $this->action; |
254 | } |
255 | |
256 | public function setAction(?string $action): void |
257 | { |
258 | $this->action = $action; |
259 | } |
260 | |
261 | public function getNotificationUsers(): array|Collection |
262 | { |
263 | return $this->notificationUsers; |
264 | } |
265 | |
266 | public function setNotificationUsers(array|Collection $notificationUsers): void |
267 | { |
268 | $this->notificationUsers = $notificationUsers; |
269 | } |
270 | |
271 | public function getDpo(): ?bool |
272 | { |
273 | return $this->dpo; |
274 | } |
275 | |
276 | public function setDpo(?bool $dpo): void |
277 | { |
278 | $this->dpo = $dpo; |
279 | } |
280 | |
281 | public function getSubject(): ?string |
282 | { |
283 | return $this->subject; |
284 | } |
285 | |
286 | public function setSubject(?string $subject): void |
287 | { |
288 | $this->subject = $subject; |
289 | } |
290 | } |