<?php
// @deprecated
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Trait\TimestampableEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
/**
* The most generic type of item.
*
* @see https://schema.org/Thing
*
* @author Jordi Fernandes Alves <jfadev@gmail.com>
*/
#[ORM\Entity]
#[ApiResource(
iri: 'Operation',
itemOperations: [
'get' => ['normalization_context' => ['groups' => 'operation:item:get', 'enable_max_depth' => true]],
'put' => [
'normalization_context' => ['groups' => 'operation:item:put', 'enable_max_depth' => true],
'denormalization_context' => ['groups' => 'operation:item:put', 'enable_max_depth' => true],
],
'delete' => [],
],
collectionOperations: [
'get' => [
'normalization_context' => [
'groups' => ['operation:collection:get'],
'enable_max_depth' => true,
],
],
'post' => [
'normalization_context' => ['groups' => 'operation:collection:post', 'enable_max_depth' => true],
'denormalization_context' => ['groups' => 'operation:collection:post', 'enable_max_depth' => true],
],
],
)]
class Operation
{
use TimestampableEntity;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'NONE')]
#[ORM\Column(type: 'uuid', unique: true)]
#[ApiProperty(iri: 'https://schema.org/identifier')]
#[Groups(['operation:item:get', 'operation:collection:get'])]
private ?UuidInterface $id = null;
/**
* @var string|null
*
* @see _:operationType
*/
#[ORM\Column(type: 'string', nullable: false)]
#[ApiProperty(iri: 'https://schema.org/operationType')]
#[Groups(['operation:item:get', 'operation:item:put', 'operation:collection:post'])]
#[Assert\NotBlank] // Asegura que no esté vacío
private ?string $operationType = null;
/**
* @var string|null
*
* @see _:status
*/
#[ORM\Column(type: 'string', nullable: false)]
#[ApiProperty(iri: 'https://schema.org/status')]
#[Groups(['operation:item:get', 'operation:item:put', 'operation:collection:post'])]
#[Assert\NotBlank] // Asegura que no esté vacío
private ?string $status = null;
/** @see _:contract */
#[ORM\OneToOne(targetEntity: 'App\Entity\Contract')]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['operation:item:get', 'operation:item:put', 'operation:collection:post'])]
private ?Contract $contract = null;
/** @see _:schedule */
#[ORM\OneToOne(targetEntity: 'App\Entity\OperationSchedule')]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['operation:item:get', 'operation:item:put', 'operation:collection:post'])]
private ?OperationSchedule $schedule = null;
/** @see _:incidents */
#[ORM\ManyToMany(targetEntity: 'App\Entity\Incident')]
#[ORM\InverseJoinColumn(unique: true)]
#[Groups(['operation:item:get', 'operation:item:put'])]
private Collection $incidents;
/** @see _:notifications */
#[ORM\ManyToMany(targetEntity: 'App\Entity\Notification')]
#[ORM\InverseJoinColumn(unique: true)]
#[Groups(['operation:item:get', 'operation:item:put'])]
private Collection $notifications;
public function __construct()
{
$this->id = Uuid::uuid4();
$this->incidents = new ArrayCollection();
$this->notifications = new ArrayCollection();
}
public function getId(): ?UuidInterface
{
return $this->id;
}
/**
* @param string|null $operationType
*/
public function setOperationType(?string $operationType): void
{
$this->operationType = $operationType;
}
/**
* @return string|null
*/
public function getOperationType(): ?string
{
return $this->operationType;
}
/**
* @param string|null $status
*/
public function setStatus(?string $status): void
{
$this->status = $status;
}
/**
* @return string|null
*/
public function getStatus(): ?string
{
return $this->status;
}
public function setContract(?Contract $contract): void
{
$this->contract = $contract;
}
public function getContract(): ?Contract
{
return $this->contract;
}
public function setSchedule(?OperationSchedule $schedule): void
{
$this->schedule = $schedule;
}
public function getSchedule(): ?OperationSchedule
{
return $this->schedule;
}
public function addIncident(Incident $incident): void
{
$this->incidents[] = $incident;
}
public function removeIncident(Incident $incident): void
{
$this->incidents->removeElement($incident);
}
public function getIncidents(): Collection
{
return $this->incidents;
}
public function addNotification(Notification $notification): void
{
$this->notifications[] = $notification;
}
public function removeNotification(Notification $notification): void
{
$this->notifications->removeElement($notification);
}
public function getNotifications(): Collection
{
return $this->notifications;
}
}