<?php
namespace App\Entity;
use App\Entity\AccessRisk;
use App\Entity\ActivityAme;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\SerializedName;
/**
* @ORM\Entity(repositoryClass="App\Repository\AlertRepository")
*/
class Alert
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Cluster")
* @ORM\JoinColumn(nullable=false)
*/
private $cluster;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\EventReason")
* @ORM\JoinColumn(nullable=false)
*/
private $eventReason;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Actor")
* @ORM\JoinColumn(nullable=false)
*/
private $primarySource;
/**
* @ORM\Column(type="datetime")
* @Groups({"public", "alert:register"})
*/
private $startDate;
/**
* @ORM\Column(type="text")
* @Groups({"public", "alert:register"})
*/
private $description;
/**
* @ORM\Column(type="datetime")
*/
private $creationDate;
/**
* @ORM\Column(type="boolean")
*/
private $isDeleted;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups("public")
*/
private $axe;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"public", "alert:register"})
*/
private $secondarySource;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User")
* @ORM\JoinColumn(nullable=false)
*/
private $userCreate;
/**
* @ORM\OneToMany(targetEntity="App\Entity\AlertDetail", mappedBy="alert")
* @Groups("public")
*/
private $alertDetails;
/**
* @ORM\OneToMany(targetEntity=Process::class, mappedBy="alert")
* @Groups("public")
*/
private $processes;
/**
* @ORM\OneToMany(targetEntity=AlertDocument::class, mappedBy="alert")
* @Groups("public")
*/
private $alertDocuments;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Groups("public")
*/
private $isValid;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isAvorte;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $comment;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $dateAvorte;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
private $userAvorte;
/**
* @ORM\OneToMany(targetEntity=Movement::class, mappedBy="alert")
*/
private $movements;
/**
* @ORM\ManyToOne(targetEntity=AccessRisk::class)
* @Groups("public")
*/
private $accessRisk;
/**
* @ORM\ManyToOne(targetEntity=Process::class)
* @Groups("public")
*/
private $statut;
/**
* @ORM\ManyToOne(targetEntity=Severity::class)
* @Groups("public")
*/
private $severity;
/**
* @ORM\ManyToOne(targetEntity=AlertDetail::class)
* @Groups("public")
*/
private $alertDetail;
/**
* @ORM\ManyToOne(targetEntity=Crisis::class, inversedBy="alerts")
*/
private $crisis;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isIdp;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $deleted_date;
/**
* @ORM\ManyToMany(targetEntity=ActivityAme::class, mappedBy="alerts")
*/
private $activityAmes;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups("public")
*/
private $accessRiskComment;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $displacedEval;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $returnedEval;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $affectedEval;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $householdEval;
/**
* @ORM\ManyToOne(targetEntity=Pcode::class, inversedBy="alerts")
* @ORM\JoinColumn(nullable=false)
*/
private $country;
/**
* @ORM\ManyToOne(targetEntity=Severity::class, inversedBy="alertsSeverity")
*/
private $severity_alert;
/**
* @ORM\Column(type="decimal", precision=5, scale=3, nullable=true)
* @Groups({"public", "alert:register"})
*/
private $severityAlertRrm;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $displacedEvalHousehold;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $returnedEvalHousehold;
/**
* @ORM\ManyToOne(targetEntity=EventSousType::class)
*/
private $eventSousType;
/**
* @ORM\ManyToOne(targetEntity=AlertAccommodation::class)
*/
private $accommodation;
// /**
// * @ORM\ManyToOne(targetEntity=Movement::class, inversedBy="alerts")
// */
// private $pdi;
private int $alertId ;
private int $clusterId ;
private string $clusterName;
private string $primarySourceAcronyme;
private string $primarySourceLabel;
private string $eventReseaonLabel;
private string $adminId;
private string $statut_alert;
private string $statut_date;
/**
* @ORM\ManyToOne(targetEntity=MovementCategory::class, inversedBy="alerts")
*/
private $movementCategory;
public function __construct()
{
$this->isDeleted = false;
$this->creationDate = new \DateTime();
// $this->startDate = new \DateTime();
//$this->userCreate = $user;
//$this->alertDetails = new ArrayCollection();
$this->processes = new ArrayCollection();
$this->alertDocuments = new ArrayCollection();
$this->movements = new ArrayCollection();
$this->activityAmes = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCluster(): ?Cluster
{
return $this->cluster;
}
public function setCluster(?Cluster $cluster): self
{
$this->cluster = $cluster;
return $this;
}
public function getEventReason(): ?EventReason
{
return $this->eventReason;
}
public function setEventReason(?EventReason $eventReason): self
{
$this->eventReason = $eventReason;
return $this;
}
public function getStartDate(): ?\DateTimeInterface
{
return $this->startDate;
}
public function setStartDate(\DateTimeInterface $startDate): self
{
$this->startDate = $startDate;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
public function getCreationDate(): ?\DateTimeInterface
{
return $this->creationDate;
}
public function setCreationDate(\DateTimeInterface $creationDate): self
{
$this->creationDate = $creationDate;
return $this;
}
public function getIsDeleted(): ?bool
{
return $this->isDeleted;
}
public function setIsDeleted(bool $isDeleted): self
{
$this->isDeleted = $isDeleted;
return $this;
}
public function getAxe(): ?string
{
return $this->axe;
}
public function setAxe(?string $axe): self
{
$this->axe = $axe;
return $this;
}
public function getSecondarySource(): ?string
{
return $this->secondarySource;
}
public function setSecondarySource(?string $secondarySource): self
{
$this->secondarySource = $secondarySource;
return $this;
}
public function getPrimarySource(): ?Actor
{
return $this->primarySource;
}
public function setPrimarySource(?Actor $primarySource): self
{
$this->primarySource = $primarySource;
return $this;
}
public function getUserCreate(): ?User
{
return $this->userCreate;
}
public function setUserCreate(?User $userCreate): self
{
$this->userCreate = $userCreate;
return $this;
}
/**
* @return Collection|AlertDetail[]
*/
public function getAlertDetails(): Collection
{
return $this->alertDetails;
}
public function addAlertDetail(AlertDetail $alertDetail): self
{
if (!$this->alertDetails->contains($alertDetail)) {
$this->alertDetails[] = $alertDetail;
$alertDetail->setAlert($this);
}
return $this;
}
public function removeAlertDetail(AlertDetail $alertDetail): self
{
if ($this->alertDetails->contains($alertDetail)) {
$this->alertDetails->removeElement($alertDetail);
// set the owning side to null (unless already changed)
if ($alertDetail->getAlert() === $this) {
$alertDetail->setAlert(null);
}
}
return $this;
}
/**
* @return Collection|Process[]
*/
public function getProcesses(): Collection
{
return $this->processes;
}
public function addProcess(Process $process): self
{
if (!$this->processes->contains($process)) {
$this->processes[] = $process;
$process->setAlert($this);
}
return $this;
}
public function removeProcess(Process $process): self
{
if ($this->processes->contains($process)) {
$this->processes->removeElement($process);
// set the owning side to null (unless already changed)
if ($process->getAlert() === $this) {
$process->setAlert(null);
}
}
return $this;
}
/**
* @return Collection|AlertDocument[]
*/
public function getAlertDocuments(): Collection
{
return $this->alertDocuments;
}
public function addAlertDocument(AlertDocument $alertDocument): self
{
if (!$this->alertDocuments->contains($alertDocument)) {
$this->alertDocuments[] = $alertDocument;
$alertDocument->setAlert($this);
}
return $this;
}
public function removeAlertDocument(AlertDocument $alertDocument): self
{
if ($this->alertDocuments->contains($alertDocument)) {
$this->alertDocuments->removeElement($alertDocument);
// set the owning side to null (unless already changed)
if ($alertDocument->getAlert() === $this) {
$alertDocument->setAlert(null);
}
}
return $this;
}
public function getIsValid(): ?bool
{
return $this->isValid;
}
public function setIsValid(?bool $isValid): self
{
$this->isValid = $isValid;
return $this;
}
public function getIsAvorte(): ?bool
{
return $this->isAvorte;
}
public function setIsAvorte(?bool $isAvorte): self
{
$this->isAvorte = $isAvorte;
return $this;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): self
{
$this->comment = $comment;
return $this;
}
public function getDateAvorte(): ?\DateTimeInterface
{
return $this->dateAvorte;
}
public function setDateAvorte(\DateTimeInterface $dateAvorte): self
{
$this->dateAvorte = $dateAvorte;
return $this;
}
public function getUserAvorte(): ?User
{
return $this->userAvorte;
}
public function setUserAvorte(?User $userAvorte): self
{
$this->userAvorte = $userAvorte;
return $this;
}
/**
* @return Collection|Movement[]
*/
public function getMovements(): Collection
{
return $this->movements;
}
public function addMovement(Movement $movement): self
{
if (!$this->movements->contains($movement)) {
$this->movements[] = $movement;
$movement->setAlert($this);
}
return $this;
}
public function removeMovement(Movement $movement): self
{
if ($this->movements->contains($movement)) {
$this->movements->removeElement($movement);
// set the owning side to null (unless already changed)
if ($movement->getAlert() === $this) {
$movement->setAlert(null);
}
}
return $this;
}
public function getAccessRisk(): ?AccessRisk
{
return $this->accessRisk;
}
public function setAccessRisk(?AccessRisk $accessRisk): self
{
$this->accessRisk = $accessRisk;
return $this;
}
public function getStatut(): ?Process
{
return $this->statut;
}
public function setStatut(?Process $statut): self
{
$this->statut = $statut;
return $this;
}
public function getSeverity(): ?Severity
{
return $this->severity;
}
public function setSeverity(?Severity $severity): self
{
$this->severity = $severity;
return $this;
}
public function getAlertDetail(): ?AlertDetail
{
return $this->alertDetail;
}
public function setAlertDetail(?AlertDetail $alertDetail): self
{
$this->alertDetail = $alertDetail;
return $this;
}
public function getCrisis(): ?Crisis
{
return $this->crisis;
}
public function setCrisis(?Crisis $crisis): self
{
$this->crisis = $crisis;
return $this;
}
// public function getPdi(): ?Movement
// {
// return $this->pdi;
// }
// public function setPdi(?Movement $pdi): self
// {
// $this->pdi = $pdi;
// return $this;
// }
public function getIsIdp(): ?bool
{
return $this->isIdp;
}
public function setIsIdp(?bool $isIdp): self
{
$this->isIdp = $isIdp;
return $this;
}
public function getDeletedDate(): ?\DateTimeInterface
{
return $this->deleted_date;
}
public function setDeletedDate(?\DateTimeInterface $deleted_date): self
{
$this->deleted_date = $deleted_date;
return $this;
}
public function getAlertSumPerson($alertDetail)
{
$sum = 0;
foreach ($alertDetail as $detail) {
$sum += $detail->getDisplaced();
}
return $sum;
}
public function getAlertSumHousehold($alertDetail)
{
$sum = 0;
foreach ($alertDetail as $detail) {
$sum += $detail->getHousehold();
}
return $sum;
}
public function getAlertSumDisplaced($alertDetail)
{
$sum = 0;
foreach ($alertDetail as $detail) {
$sum += $detail->getDisplaced();
}
return $sum;
}
public function getAlertSumReturned($alertDetail)
{
$sum = 0;
foreach ($alertDetail as $detail) {
$sum += $detail->getReturned();
}
return $sum;
}
/**
* @return Collection|ActivityAme[]
*/
public function getActivityAmes(): Collection
{
return $this->activityAmes;
}
public function addActivityAme(ActivityAme $activityAme): self
{
if (!$this->activityAmes->contains($activityAme)) {
$this->activityAmes[] = $activityAme;
$activityAme->addAlert($this);
}
return $this;
}
public function removeActivityAme(ActivityAme $activityAme): self
{
if ($this->activityAmes->removeElement($activityAme)) {
$activityAme->removeAlert($this);
}
return $this;
}
public function getAccessRiskComment(): ?string
{
return $this->accessRiskComment;
}
public function setAccessRiskComment(string $accessRiskComment): self
{
$this->accessRiskComment = $accessRiskComment;
return $this;
}
public function getDisplacedEval(): ?int
{
return $this->displacedEval;
}
public function setDisplacedEval(?int $displacedEval): self
{
$this->displacedEval = $displacedEval;
return $this;
}
public function getReturnedEval(): ?int
{
return $this->returnedEval;
}
public function setReturnedEval(?int $returnedEval): self
{
$this->returnedEval = $returnedEval;
return $this;
}
public function getAffectedEval(): ?int
{
return $this->affectedEval;
}
public function setAffectedEval(?int $affectedEval): self
{
$this->affectedEval = $affectedEval;
return $this;
}
public function getHouseholdEval(): ?int
{
return $this->householdEval;
}
public function setHouseholdEval(?int $householdEval): self
{
$this->householdEval = $householdEval;
return $this;
}
public function getCountry(): ?Pcode
{
return $this->country;
}
public function setCountry(?Pcode $country): self
{
$this->country = $country;
return $this;
}
public function getSeverityAlert(): ?Severity
{
return $this->severity_alert;
}
public function setSeverityAlert(?Severity $severity_alert): self
{
$this->severity_alert = $severity_alert;
return $this;
}
public function getSeverityAlertRrm(): ?string
{
return $this->severityAlertRrm;
}
public function setSeverityAlertRrm(?string $severityAlertRrm): self
{
$this->severityAlertRrm = $severityAlertRrm;
return $this;
}
public function getDisplacedEvalHousehold(): ?int
{
return $this->displacedEvalHousehold;
}
public function setDisplacedEvalHousehold(?int $displacedEvalHousehold): self
{
$this->displacedEvalHousehold = $displacedEvalHousehold;
return $this;
}
public function getReturnedEvalHousehold(): ?int
{
return $this->returnedEvalHousehold;
}
public function setReturnedEvalHousehold(?int $returnedEvalHousehold): self
{
$this->returnedEvalHousehold = $returnedEvalHousehold;
return $this;
}
public function getEventSousType(): ?EventSousType
{
return $this->eventSousType;
}
public function setEventSousType(?EventSousType $eventSousType): self
{
$this->eventSousType = $eventSousType;
return $this;
}
public function getAccommodation(): ?AlertAccommodation
{
return $this->accommodation;
}
public function setAccommodation(?AlertAccommodation $accommodation): self
{
$this->accommodation = $accommodation;
return $this;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("alert_id")
*/
public function getAlertId(): int
{
return $this->getId() ;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("eventReason_label")
*/
public function getEventReasonLabel(): string
{
return $this->eventReason ? $this->eventReason->getLabel() : null;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("primarySource_label")
*/
public function getPrimarySourceLabel(): string
{
return $this->primarySource ? $this->primarySource->getLabelFr() : null;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("primarySource_acronyme")
*/
public function getPrimarySourceAcronyme(): string
{
return $this->primarySource ? $this->primarySource->getAcronymFr() : null;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("cluter_id")
*/
public function getClusterId(): int
{
return $this->cluster ? $this->cluster->getId() : null;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("cluster_name")
*/
public function getClusterName(): string
{
return $this->cluster ? $this->cluster->getLabel() : null;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("admin1_id")
*/
public function getAdmin1Id(): string
{
if($this->getAlertDetail() && $this->getAlertDetail()->getAdmin1() && $this->getAlertDetail()->getAdmin1()->getId() )
{
$admin1Id = $this->getAlertDetail()->getAdmin1()->getId();
}
else {
$admin1Id = null;
}
return $admin1Id;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("admin1_Label")
*/
public function getAdmin1Label(): string
{
if($this->getAlertDetail() && $this->getAlertDetail()->getAdmin1() && $this->getAlertDetail()->getAdmin1()->getLabel() )
{
$admin1Label = $this->getAlertDetail()->getAdmin1()->getLabel();
}
else {
$admin1Label = null;
}
return $admin1Label;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("admin2_id")
*/
public function getAdmin2Id(): string
{
if($this->getAlertDetail() && $this->getAlertDetail()->getAdmin2() && $this->getAlertDetail()->getAdmin2()->getId() )
{
$admin2Id = $this->getAlertDetail()->getAdmin2()->getId();
}
else {
$admin2Id = null;
}
return $admin2Id;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("admin2_Label")
*/
public function getAdmin2Label(): string
{
if($this->getAlertDetail() && $this->getAlertDetail()->getAdmin2() && $this->getAlertDetail()->getAdmin2()->getLabel() )
{
$admin2Label = $this->getAlertDetail()->getAdmin2()->getLabel();
}
else {
$admin2Label = null;
}
return $admin2Label;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("admin3_id")
*/
public function getAdmin3Id(): string
{
if($this->getAlertDetail() && $this->getAlertDetail()->getAdmin3() && $this->getAlertDetail()->getAdmin3()->getId() )
{
$admin3Id = $this->getAlertDetail()->getAdmin3()->getId();
}
else {
$admin3Id = null;
}
return $admin3Id;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("admin3_Label")
*/
public function getAdmin3Label(): string
{
if($this->getAlertDetail() && $this->getAlertDetail()->getAdmin3() && $this->getAlertDetail()->getAdmin3()->getLabel() )
{
$admin3Label = $this->getAlertDetail()->getAdmin3()->getLabel();
}
else {
$admin3Label = null;
}
return $admin3Label;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("health_Zone_Id")
*/
public function getHealthZoneId(): string
{
if($this->getAlertDetail() && $this->getAlertDetail()->getHealthZone() && $this->getAlertDetail()->getHealthZone()->getId() )
{
$healthZoneId = $this->getAlertDetail()->getHealthZone()->getId();
}
else {
$healthZoneId = null;
}
return $healthZoneId;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("healthZone_Label")
*/
public function getHealthZoneLabel(): string
{
if($this->getAlertDetail() && $this->getAlertDetail()->getHealthZone() && $this->getAlertDetail()->getHealthZone()->getLabel() )
{
$healthZoneLabel = $this->getAlertDetail()->getHealthZone()->getLabel();
}
else {
$healthZoneLabel = null;
}
return $healthZoneLabel;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("displaced")
*/
public function getDisplaced(): int
{
if($this->getAlertDetail() && $this->getAlertDetail()->getDisplaced() && $this->getAlertDetail()->getDisplaced() )
{
$diplaced = $this->getAlertDetail()->getDisplaced();
}
else {
$diplaced = null;
}
return $diplaced;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("statut_Alert")
*/
public function getStatutLabel(): string
{
if($this->getStatut() && $this->getStatut()->getWorkflow()->getDescription() && $this->getStatut()->getWorkflow()->getDescription() )
{
$statutLabel = $this->getStatut()->getWorkflow()->getDescription();
}
else {
$statutLabel = null;
}
return $statutLabel;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("statut_Date")
*/
public function getStatutDate(): DateTime
{
if($this->getStatut() && $this->getStatut()->getDatecreate() && $this->getStatut()->getDatecreate() )
{
$statut_date = $this->getStatut()->getDatecreate();
}
else {
$statut_date = null;
}
return $statut_date;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("returned")
*/
public function getRetuned(): int
{
if($this->getAlertDetail() && $this->getAlertDetail()->getReturned() && $this->getAlertDetail()->getReturned() )
{
$returned = $this->getAlertDetail()->getReturned();
}
else {
$returned = null;
}
return $returned;
}
/**
* @Groups({"public", "alert:register"})
* @SerializedName("affected")
*/
public function getAffected(): int
{
if($this->getAlertDetail() && $this->getAlertDetail()->getAffected() && $this->getAlertDetail()->getAffected() )
{
$affected = $this->getAlertDetail()->getAffected();
}
else {
$affected = null;
}
return $affected;
}
public function getMovementCategory(): ?MovementCategory
{
return $this->movementCategory;
}
public function setMovementCategory(?MovementCategory $movementCategory): self
{
$this->movementCategory = $movementCategory;
return $this;
}
}