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 | #[ORM\Entity] |
47 | class Notification |
48 | { |
49 | use HistoryTrait; |
50 | use CreatorTrait; |
51 | |
52 | public const NOTIFICATION_DPO = 1; |
53 | public const NOTIFICATION_COLLECTIVITY = 2; |
54 | |
55 | public const MODULES = [ |
56 | Treatment::class => 'treatment', |
57 | Contractor::class => 'subcontractor', |
58 | Request::class => 'request', |
59 | Violation::class => 'violation', |
60 | Proof::class => 'proof', |
61 | Mesurement::class => 'protect_action', |
62 | Maturity::class => 'maturity', |
63 | ConformiteTraitement::class => 'treatment_conformity', |
64 | Conformite::class => 'organization_conformity', |
65 | AnalyseImpact::class => 'aipd', |
66 | Document::class => 'document', |
67 | User::class => 'user', |
68 | ]; |
69 | |
70 | #[ORM\Id()] |
71 | #[ORM\Column(type: 'uuid')] |
72 | private UuidInterface $id; |
73 | |
74 | #[ORM\Column(type: 'string')] |
75 | private ?string $name; |
76 | |
77 | #[ORM\Column(type: 'boolean')] |
78 | private ?bool $dpo; |
79 | |
80 | #[ORM\Column(type: 'string')] |
81 | private ?string $module; |
82 | |
83 | #[ORM\Column(type: 'text', nullable: true)] |
84 | private ?string $subject; |
85 | |
86 | #[ORM\Column(type: 'string')] |
87 | private ?string $action; |
88 | |
89 | #[ORM\Column(type: 'object', nullable: true)] |
90 | private ?object $object; |
91 | |
92 | #[ORM\ManyToOne(targetEntity: Collectivity::class)] |
93 | #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] |
94 | private ?Collectivity $collectivity; |
95 | |
96 | #[ORM\ManyToOne(targetEntity: User::class)] |
97 | #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] |
98 | private ?User $readBy; |
99 | |
100 | #[ORM\Column(name: 'read_at', type: 'datetime', nullable: true)] |
101 | private ?\DateTime $readAt = null; |
102 | |
103 | #[ORM\ManyToOne(targetEntity: User::class)] |
104 | #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] |
105 | private ?User $createdBy; |
106 | |
107 | #[ORM\OneToMany(mappedBy: 'notification', targetEntity: NotificationUser::class)] |
108 | private Collection|array $notificationUsers = []; |
109 | |
110 | /** |
111 | * Category constructor. |
112 | * |
113 | * @throws \Exception |
114 | */ |
115 | public function __construct() |
116 | { |
117 | $this->id = Uuid::uuid4(); |
118 | $this->dpo = false; |
119 | $this->createdBy = null; |
120 | } |
121 | |
122 | public function __toString(): string |
123 | { |
124 | if (\is_null($this->getName())) { |
125 | return ''; |
126 | } |
127 | |
128 | if (\mb_strlen($this->getName()) > 150) { |
129 | return \mb_substr($this->getName(), 0, 150) . '...'; |
130 | } |
131 | |
132 | return $this->getName(); |
133 | } |
134 | |
135 | public function getId(): UuidInterface |
136 | { |
137 | return $this->id; |
138 | } |
139 | |
140 | public function getName(): ?string |
141 | { |
142 | return $this->name; |
143 | } |
144 | |
145 | public function setName(?string $name): void |
146 | { |
147 | $this->name = $name; |
148 | } |
149 | |
150 | public function getModule(): ?string |
151 | { |
152 | return $this->module; |
153 | } |
154 | |
155 | public function setModule(?string $module): void |
156 | { |
157 | $this->module = $module; |
158 | } |
159 | |
160 | public function getObject(): ?object |
161 | { |
162 | return $this->object; |
163 | } |
164 | |
165 | public function setObject(?object $object): void |
166 | { |
167 | $this->object = $object; |
168 | } |
169 | |
170 | public function getCollectivity(): ?Collectivity |
171 | { |
172 | return $this->collectivity; |
173 | } |
174 | |
175 | public function setCollectivity(?Collectivity $collectivity): void |
176 | { |
177 | $this->collectivity = $collectivity; |
178 | } |
179 | |
180 | public function getReadBy(): ?User |
181 | { |
182 | return $this->readBy; |
183 | } |
184 | |
185 | public function setReadBy(?User $readBy): void |
186 | { |
187 | $this->readBy = $readBy; |
188 | } |
189 | |
190 | public function getReadAt(): ?\DateTime |
191 | { |
192 | return $this->readAt; |
193 | } |
194 | |
195 | public function setReadAt(?\DateTime $readAt): void |
196 | { |
197 | $this->readAt = $readAt; |
198 | } |
199 | |
200 | public function getCreatedBy(): ?User |
201 | { |
202 | return $this->createdBy; |
203 | } |
204 | |
205 | public function setCreatedBy(?User $createdBy): void |
206 | { |
207 | $this->createdBy = $createdBy; |
208 | } |
209 | |
210 | public function getAction(): ?string |
211 | { |
212 | return $this->action; |
213 | } |
214 | |
215 | public function setAction(?string $action): void |
216 | { |
217 | $this->action = $action; |
218 | } |
219 | |
220 | public function getNotificationUsers(): array|Collection |
221 | { |
222 | return $this->notificationUsers; |
223 | } |
224 | |
225 | public function setNotificationUsers(array|Collection $notificationUsers): void |
226 | { |
227 | $this->notificationUsers = $notificationUsers; |
228 | } |
229 | |
230 | public function getDpo(): ?bool |
231 | { |
232 | return $this->dpo; |
233 | } |
234 | |
235 | public function setDpo(?bool $dpo): void |
236 | { |
237 | $this->dpo = $dpo; |
238 | } |
239 | |
240 | public function getSubject(): ?string |
241 | { |
242 | return $this->subject; |
243 | } |
244 | |
245 | public function setSubject(?string $subject): void |
246 | { |
247 | $this->subject = $subject; |
248 | } |
249 | } |