src/Entity/Muestra.php line 57

  1. <?php
  2. namespace App\Entity;
  3. use Symfony\Component\Serializer\Annotation\Groups;
  4. use Ramsey\Uuid\Uuid;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Doctrine\DBAL\Types\Types;
  7. use App\Trait\UuidTrait;
  8. use App\Trait\TimestampableTrait;
  9. use App\Trait\BlameableTrait;
  10. use App\State\MuestraStateProcessor;
  11. use App\Repository\MuestraRepository;
  12. use ApiPlatform\Metadata\Put;
  13. use ApiPlatform\Metadata\Post;
  14. use ApiPlatform\Metadata\Patch;
  15. use ApiPlatform\Metadata\GetCollection;
  16. use ApiPlatform\Metadata\Get;
  17. use ApiPlatform\Metadata\Delete;
  18. use ApiPlatform\Metadata\ApiResource;
  19. use ApiPlatform\Metadata\ApiFilter;
  20. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  21. use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  22. use ApiPlatform\Doctrine\Orm\Filter\ExistsFilter;
  23. use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;
  24. #[ORM\Entity(repositoryClassMuestraRepository::class)]
  25. #[ApiResource(
  26.     operations: [
  27.         new GetCollection(paginationEnabledfalse),
  28.         new Post(validationContext: ['groups' => ['Default''muestra:create']], denormalizationContext: ['groups' => ['muestra:create']], processorMuestraStateProcessor::class),
  29.         new Get(),
  30.         new Put(denormalizationContext: ['groups' => ['muestra:update']]),
  31.         new Patch(denormalizationContext: ['groups' => ['muestra:update']]),
  32.         new Delete(),
  33.     ],
  34.     normalizationContext: ['groups' => ['muestra:read''uuid']],
  35. )]
  36. #[ApiFilter(
  37.     SearchFilter::class,
  38.     properties: [
  39.         'codigo' => 'exact',
  40.         'nombre' => 'exact'
  41.     ]
  42. )]
  43. #[ApiFilter(BooleanFilter::class, properties: ['original''repetida''reproducida'])]
  44. #[ApiFilter(ExistsFilter::class, properties: ['parent''sesion'])]
  45. #[ApiFilter(
  46.     OrderFilter::class,
  47.     properties: [
  48.         'nombre',
  49.         'codigo',
  50.         'producto.nombre',
  51.         'marca',
  52.     ]
  53. )]
  54. class Muestra
  55. {
  56.     public const MODULO 'muestras';
  57.     public const MODULO_SENSORIAL 'muestras_sensorial';
  58.     public const MODULO_ORGANOLEPTICO 'muestras_organoleptico';
  59.     public const MODULO_VINO 'Informe IAS-03 (vino)';
  60.     public const MODULO_VINO_VINAGRE 'Informe IAS-03 (vino + vinagre)';
  61.     public const MODULO_QUESO 'Informe IAS-03 (queso)';
  62.     use TimestampableTrait;
  63.     use BlameableTrait;
  64.     use UuidTrait;
  65.     #[Groups(['muestra:read''muestra:create''muestra:update''sesion:read''sesion:create''sesion:update'])]
  66.     #[ORM\Column(length255nullabletrue)]
  67.     private ?string $codigo null;
  68.     #[Groups(['muestra:read''muestra:create''muestra:update''sesion:read''sesion:create''sesion:update'])]
  69.     #[ORM\Column(length255nullabletrue)]
  70.     private ?string $codId null;
  71.     #[Groups(['muestra:read''muestra:create''muestra:update''sesion:read''sesion:create''sesion:update'])]
  72.     #[ORM\Column(length255nullabletrue)]
  73.     private ?string $nombre null;
  74.     #[Groups(['muestra:read''muestra:create''muestra:update''sesion:read''sesion:create''sesion:update'])]
  75.     #[ORM\ManyToOne]
  76.     #[ORM\JoinColumn(nullablefalse)]
  77.     private ?Producto $producto null;
  78.     #[Groups(['muestra:read''muestra:create''muestra:update''sesion:read''sesion:create''sesion:update'])]
  79.     #[ORM\Column(length255nullabletrue)]
  80.     private ?string $productor null;
  81.     #[Groups(['muestra:read''muestra:create''muestra:update''sesion:read''sesion:create''sesion:update'])]
  82.     #[ORM\Column(length255nullabletrue)]
  83.     private ?string $tipoProducto null;
  84.     #[Groups(['muestra:read''muestra:create''muestra:update''sesion:read''sesion:create''sesion:update'])]
  85.     #[ORM\Column(length255nullabletrue)]
  86.     private ?string $nInforme null;
  87.     #[Groups(['muestra:read''muestra:create''muestra:update''sesion:read''sesion:create''sesion:update'])]
  88.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  89.     private ?\DateTimeInterface $fecha null;
  90.     #[Groups(['muestra:read''muestra:create''muestra:update''sesion:read''sesion:create''sesion:update'])]
  91.     #[ORM\Column(nullabletrue)]
  92.     private ?bool $isResuelto null;
  93.     #[Groups(['muestra:read''muestra:create''muestra:update''sesion:read''sesion:create''sesion:update'])]
  94.     #[ORM\Column(nullabletrue)]
  95.     private array $fases = [];
  96.     #[Groups(['muestra:read''muestra:create''muestra:update''sesion:read''sesion:create''sesion:update'])]
  97.     #[ORM\Column(nullabletrue)]
  98.     private array $definicion = [];
  99.     #[Groups(['muestra:read'])]
  100.     #[ORM\ManyToOne]
  101.     #[ORM\JoinColumn(nullablefalse)]
  102.     private ?Empresa $empresa null;
  103.     #[Groups(['muestra:read''muestra:create''muestra:update''sesion:read''sesion:create''sesion:update'])]
  104.     #[ORM\Column(length255nullabletrue)]
  105.     private ?string $marca null;
  106.     #[Groups(['muestra:read''muestra:create''muestra:update''sesion:read''sesion:create''sesion:update'])]
  107.     #[ORM\ManyToOne(targetEntityself::class)]
  108.     #[ORM\JoinColumn(onDelete'SET NULL')]
  109.     private ?self $parent null;
  110.     #[Groups(['muestra:read''muestra:create''muestra:update''sesion:read''sesion:create''sesion:update'])]
  111.     #[ORM\Column(nullabletrue)]
  112.     private ?bool $repetida null;
  113.     #[Groups(['muestra:read''muestra:create''muestra:update''sesion:read''sesion:create''sesion:update'])]
  114.     #[ORM\Column(nullabletrue)]
  115.     private ?bool $reproducida null;
  116.     #[Groups(['muestra:read''sesion:read''sesion:create''sesion:update'])]
  117.     #[ORM\Column(nullabletrueoptions: ['default' => true])]
  118.     private ?bool $original null;
  119.     #[Groups(['muestra:read'])]
  120.     #[ORM\ManyToOne(inversedBy'muestras'cascade: ['persist'])]
  121.     #[ORM\JoinColumn(onDelete'SET NULL')]
  122.     private ?Sesion $sesion null;
  123.     #[ORM\Column(length255nullabletrue)]
  124.     #[Groups(['muestra:read''muestra:create''muestra:update''sesion:read''sesion:create''sesion:update'])]
  125.     private ?string $codigoAuditor null;
  126.     #[ORM\Column(length255nullabletrue)]
  127.     #[Groups(['muestra:read''muestra:create''muestra:update''sesion:read''sesion:create''sesion:update'])]
  128.     private ?string $fechaToma null;
  129.     #[ORM\Column(length255nullabletrue)]
  130.     #[Groups(['muestra:read''muestra:create''muestra:update''sesion:read''sesion:create''sesion:update'])]
  131.     private ?string $contraetiquetaPrecinta null;
  132.     public function __construct()
  133.     {
  134.         $this->uuid Uuid::uuid4()->toString();
  135.     }
  136.     public function getCodigo(): ?string
  137.     {
  138.         return $this->codigo;
  139.     }
  140.     public function setCodigo(?string $codigo): self
  141.     {
  142.         $this->codigo $codigo;
  143.         return $this;
  144.     }
  145.     public function getCodId(): ?string
  146.     {
  147.         return $this->codId;
  148.     }
  149.     public function setCodId(?string $codId): self
  150.     {
  151.         $this->codId $codId;
  152.         return $this;
  153.     }
  154.     public function getNombre(): ?string
  155.     {
  156.         return $this->nombre;
  157.     }
  158.     public function setNombre(?string $nombre): self
  159.     {
  160.         $this->nombre $nombre;
  161.         return $this;
  162.     }
  163.     public function getProducto(): ?Producto
  164.     {
  165.         return $this->producto;
  166.     }
  167.     public function setProducto(?Producto $producto): self
  168.     {
  169.         $this->producto $producto;
  170.         return $this;
  171.     }
  172.     public function getProductor(): ?string
  173.     {
  174.         return $this->productor;
  175.     }
  176.     public function setProductor(?string $productor): self
  177.     {
  178.         $this->productor $productor;
  179.         return $this;
  180.     }
  181.     public function getTipoProducto(): ?string
  182.     {
  183.         return $this->tipoProducto;
  184.     }
  185.     public function setTipoProducto(?string $tipoProducto): self
  186.     {
  187.         $this->tipoProducto $tipoProducto;
  188.         return $this;
  189.     }
  190.     public function getNInforme(): ?string
  191.     {
  192.         return $this->nInforme;
  193.     }
  194.     public function setNInforme(?string $nInforme): self
  195.     {
  196.         $this->nInforme $nInforme;
  197.         return $this;
  198.     }
  199.     public function getFecha(): ?\DateTimeInterface
  200.     {
  201.         return $this->fecha;
  202.     }
  203.     public function setFecha(?\DateTimeInterface $fecha): self
  204.     {
  205.         $this->fecha $fecha;
  206.         return $this;
  207.     }
  208.     public function isIsResuelto(): ?bool
  209.     {
  210.         return $this->isResuelto;
  211.     }
  212.     public function setIsResuelto(?bool $isResuelto): self
  213.     {
  214.         $this->isResuelto $isResuelto;
  215.         return $this;
  216.     }
  217.     public function getFases(): array
  218.     {
  219.         return $this->fases;
  220.     }
  221.     public function setFases(?array $fases): self
  222.     {
  223.         $this->fases $fases;
  224.         return $this;
  225.     }
  226.     public function getDefinicion(): array
  227.     {
  228.         return $this->definicion;
  229.     }
  230.     public function setDefinicion(?array $definicion): self
  231.     {
  232.         $this->definicion $definicion;
  233.         return $this;
  234.     }
  235.     public function getEmpresa(): ?Empresa
  236.     {
  237.         return $this->empresa;
  238.     }
  239.     public function setEmpresa(?Empresa $empresa): self
  240.     {
  241.         $this->empresa $empresa;
  242.         return $this;
  243.     }
  244.     public function getMarca(): ?string
  245.     {
  246.         return $this->marca;
  247.     }
  248.     public function setMarca(?string $marca): self
  249.     {
  250.         $this->marca $marca;
  251.         return $this;
  252.     }
  253.     public function getParent(): ?self
  254.     {
  255.         return $this->parent;
  256.     }
  257.     public function setParent(?self $parent): static
  258.     {
  259.         $this->parent $parent;
  260.         return $this;
  261.     }
  262.     public function isRepetida(): ?bool
  263.     {
  264.         return $this->repetida;
  265.     }
  266.     public function setRepetida(?bool $repetida): static
  267.     {
  268.         $this->repetida $repetida;
  269.         return $this;
  270.     }
  271.     public function isReproducida(): ?bool
  272.     {
  273.         return $this->reproducida;
  274.     }
  275.     public function setReproducida(?bool $reproducida): static
  276.     {
  277.         $this->reproducida $reproducida;
  278.         return $this;
  279.     }
  280.     public function isOriginal(): ?bool
  281.     {
  282.         return $this->original;
  283.     }
  284.     public function setOriginal(?bool $original): static
  285.     {
  286.         $this->original $original;
  287.         return $this;
  288.     }
  289.     public function getSesion(): ?Sesion
  290.     {
  291.         return $this->sesion;
  292.     }
  293.     public function setSesion(?Sesion $sesion): static
  294.     {
  295.         $this->sesion $sesion;
  296.         return $this;
  297.     }
  298.     public function getCodigoAuditor(): ?string
  299.     {
  300.         return $this->codigoAuditor;
  301.     }
  302.     public function setCodigoAuditor(?string $codigoAuditor): static
  303.     {
  304.         $this->codigoAuditor $codigoAuditor;
  305.         return $this;
  306.     }
  307.     public function getFechaToma(): ?string
  308.     {
  309.         return $this->fechaToma;
  310.     }
  311.     public function setFechaToma(?string $fechaToma): static
  312.     {
  313.         $this->fechaToma $fechaToma;
  314.         return $this;
  315.     }
  316.     public function getContraetiquetaPrecinta(): ?string
  317.     {
  318.         return $this->contraetiquetaPrecinta;
  319.     }
  320.     public function setContraetiquetaPrecinta(?string $contraetiquetaPrecinta): static
  321.     {
  322.         $this->contraetiquetaPrecinta $contraetiquetaPrecinta;
  323.         return $this;
  324.     }
  325. }