From b990a3d8946c6843b416bca4ad43347504e09ff3 Mon Sep 17 00:00:00 2001 From: jmbardallo Date: Wed, 8 Apr 2026 11:07:05 +0200 Subject: [PATCH] =?UTF-8?q?Partition:=20a=C3=B1adido=20campo=20deployDate?= =?UTF-8?q?=20a=20la=20BBDD=20extra=C3=ADdo=20autom=C3=A1ticamente=20y=20d?= =?UTF-8?q?e=20forma=20idempotente=20de=20la=20variable=20img=3D=20del=20g?= =?UTF-8?q?etConfiguration=20del=20cliente,=20y=20securizaci=C3=B3n=20de?= =?UTF-8?q?=20fallbacks=20a=20null=20por=20seguridad.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 10 +++++++++- src/Dto/Output/PartitionOutput.php | 8 ++++++++ src/Entity/Partition.php | 15 +++++++++++++++ src/Service/CreatePartitionService.php | 26 ++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78f39ea..39571c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,15 @@ # Changelog +## [1.4.0] - 2026-04-08 +### Added +- Entidad Partition: Añadido el campo deployDate expuesto mediante el DTO para registrar la fecha exacta de despliegue de imagen. +- CreatePartitionService: Inclusión de lógica idempotente que asocia la imagen y extrae su fecha real directamente del fichero /.ogimage enviado por el cliente en el parámetro img=. + +### Fixed +- Limpieza explícita del deployDate (null) en caso de que el inventario no informe de fecha o haya alteraciones en el payload para evitar desincronizaciones de trazas de la imagen subyacente. + ## [1.3.0] - 2026-03-31 ### Added -Añadida acción Refresh para actualizar el estado de un cliente o clientes. Se actualiza su configuración de discos y se recarga el ogBrowser por si hubiese cambio del menu. +- Añadida acción Refresh para actualizar el estado de un cliente o clientes. Se actualiza su configuración de discos y se recarga el ogBrowser por si hubiese cambio del menu. ## [1.2.11] - 2026-03-25 ### Added diff --git a/src/Dto/Output/PartitionOutput.php b/src/Dto/Output/PartitionOutput.php index 76e55e2..0063ba6 100644 --- a/src/Dto/Output/PartitionOutput.php +++ b/src/Dto/Output/PartitionOutput.php @@ -74,6 +74,13 @@ class PartitionOutput extends AbstractOutput )] public ?int $memoryUsage = null; + #[Groups(['partition:read', 'client:read'])] + #[ApiProperty( + description: 'Fecha de despliegue de la imagen', + example: '2025-01-01T00:00:00+00:00' + )] + public ?\DateTimeInterface $deployDate = null; + public function __construct(Partition $partition) { parent::__construct($partition); @@ -94,5 +101,6 @@ class PartitionOutput extends AbstractOutput } $this->memoryUsage = $partition->getMemoryUsage() / 100; + $this->deployDate = $partition->getDeployDate(); } } \ No newline at end of file diff --git a/src/Entity/Partition.php b/src/Entity/Partition.php index 3308da9..dde3700 100644 --- a/src/Entity/Partition.php +++ b/src/Entity/Partition.php @@ -43,6 +43,21 @@ class Partition extends AbstractEntity #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] private ?ImageImageRepository $image = null; + #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] + private ?\DateTimeInterface $deployDate = null; + + public function getDeployDate(): ?\DateTimeInterface + { + return $this->deployDate; + } + + public function setDeployDate(?\DateTimeInterface $deployDate): static + { + $this->deployDate = $deployDate; + + return $this; + } + public function getDiskNumber(): ?int { return $this->diskNumber; diff --git a/src/Service/CreatePartitionService.php b/src/Service/CreatePartitionService.php index b72fd91..5798fe8 100644 --- a/src/Service/CreatePartitionService.php +++ b/src/Service/CreatePartitionService.php @@ -63,6 +63,32 @@ class CreatePartitionService $partitionEntity->setOperativeSystem($operativeSystem); } } + + if (isset($cfg['img']) && $cfg['img'] !== '') { + $imgParts = explode(':', $cfg['img']); + $imgName = $imgParts[0]; + $imgDate = $imgParts[1] ?? null; + + $imageImageRepository = $this->entityManager->getRepository(\App\Entity\ImageImageRepository::class) + ->findOneBy(['name' => $imgName]); + + if ($imageImageRepository) { + $partitionEntity->setImage($imageImageRepository); + $partitionEntity->setDeployDate(null); + if ($imgDate) { + $dateObj = \DateTime::createFromFormat('YmdHi', $imgDate); + if ($dateObj) { + $partitionEntity->setDeployDate($dateObj); + } + } + } else { + $partitionEntity->setImage(null); + $partitionEntity->setDeployDate(null); + } + } elseif (isset($cfg['img']) && $cfg['img'] === '') { + $partitionEntity->setImage(null); + $partitionEntity->setDeployDate(null); + } $partitionEntity->setClient($clientEntity); $partitionEntity->setDiskNumber($cfg['disk']);