refs #1858. Added description into imageImageRepositort
testing/ogcore-api/pipeline/head There was a failure building this commit
Details
testing/ogcore-api/pipeline/head There was a failure building this commit
Details
parent
097c6a710e
commit
927677ddc0
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20250407063100 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE image_image_repository ADD description VARCHAR(255) DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE image_image_repository DROP description');
|
||||
}
|
||||
}
|
|
@ -51,10 +51,17 @@ class ResponseController extends AbstractOgRepositoryController
|
|||
$imageImageRepository = $this->getImageImageRepository($trace);
|
||||
if (!$imageImageRepository) return $this->jsonResponseError('Image not found', Response::HTTP_NOT_FOUND, $trace);
|
||||
|
||||
$imageImageRepository->setStatus(ImageStatus::SUCCESS);
|
||||
$this->entityManager->persist($imageImageRepository);
|
||||
|
||||
if ($data['success'] !== true) {
|
||||
$this->updateTraceStatus($trace, TraceStatus::FAILED, $data['output'] ?? 'Action failed');
|
||||
return new JsonResponse(['message' => 'Success'], Response::HTTP_OK);
|
||||
}
|
||||
|
||||
if ($setFullsum) {
|
||||
$imageImageRepository->setImageFullsum($data['image_id']);
|
||||
}
|
||||
$imageImageRepository->setStatus(ImageStatus::SUCCESS);
|
||||
|
||||
$this->entityManager->persist($imageImageRepository);
|
||||
$this->updateTraceStatus($trace, TraceStatus::SUCCESS);
|
||||
|
|
|
@ -12,13 +12,8 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
|
||||
final class ImageImageRepositoryInput
|
||||
{
|
||||
#[Assert\NotNull]
|
||||
#[Groups(['image-image-repository:write'])]
|
||||
public ?ImageRepositoryOutput $imageRepository = null;
|
||||
|
||||
#[Assert\NotNull]
|
||||
#[Groups(['image-image-repository:write'])]
|
||||
public ?string $status = '';
|
||||
public ?string $description = '';
|
||||
|
||||
public function __construct(?ImageImageRepository $imageImageRepository = null)
|
||||
{
|
||||
|
@ -26,8 +21,7 @@ final class ImageImageRepositoryInput
|
|||
return;
|
||||
}
|
||||
|
||||
$this->imageRepository = new ImageRepositoryOutput($imageImageRepository->getRepository());
|
||||
$this->status = $imageImageRepository->getStatus();
|
||||
$this->description = $imageImageRepository->getDescription();
|
||||
}
|
||||
|
||||
public function createOrUpdateEntity(?ImageImageRepository $imageImageRepository = null): ImageImageRepository
|
||||
|
@ -36,8 +30,7 @@ final class ImageImageRepositoryInput
|
|||
$imageImageRepository = new ImageImageRepository();
|
||||
}
|
||||
|
||||
$imageImageRepository->setRepository($this->imageRepository);
|
||||
$imageImageRepository->setStatus($this->status);
|
||||
$imageImageRepository->setDescription($this->description);
|
||||
|
||||
return $imageImageRepository;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,9 @@ class ImageImageRepositoryOutput extends AbstractOutput
|
|||
#[Groups(['image-image-repository:read', 'image:read'])]
|
||||
public ?string $datasize = null;
|
||||
|
||||
#[Groups(['image-image-repository:read', 'image:read'])]
|
||||
public ?string $description = null;
|
||||
|
||||
#[Groups(['image:read', 'image-image-repository:read'])]
|
||||
public ?int $version = null;
|
||||
|
||||
|
@ -51,6 +54,7 @@ class ImageImageRepositoryOutput extends AbstractOutput
|
|||
$this->status = $imageImageRepository->getStatus();
|
||||
$this->imageFullsum = $imageImageRepository->getImageFullsum();
|
||||
$this->datasize = $imageImageRepository->getDatasize();
|
||||
$this->description = $imageImageRepository->getDescription();
|
||||
$this->createdAt = $imageImageRepository->getCreatedAt();
|
||||
$this->createdBy = $imageImageRepository->getCreatedBy();
|
||||
}
|
||||
|
|
|
@ -32,6 +32,9 @@ class ImageImageRepository extends AbstractEntity
|
|||
#[ORM\Column(nullable: true)]
|
||||
private ?int $version = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $description = null;
|
||||
|
||||
public function getImage(): ?Image
|
||||
{
|
||||
return $this->image;
|
||||
|
@ -115,4 +118,16 @@ class ImageImageRepository extends AbstractEntity
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription(?string $description): static
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,16 +18,16 @@ use App\Dto\Output\ImageOutput;
|
|||
use App\Entity\ImageImageRepository;
|
||||
use App\Repository\ImageRepository;
|
||||
use App\Repository\ImageRepositoryRepository as ImageRepositoryRepository;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
|
||||
readonly class ImageProcessor implements ProcessorInterface
|
||||
{
|
||||
public function __construct(
|
||||
private ImageRepositoryRepository $imageRepositoryRepository,
|
||||
private ImageRepository $imageRepository,
|
||||
private ValidatorInterface $validator,
|
||||
private CreateImageAction $createImageActionController,
|
||||
private RenameAction $renameActionController,
|
||||
private KernelInterface $kernel,
|
||||
)
|
||||
{
|
||||
}
|
||||
|
@ -72,7 +72,11 @@ readonly class ImageProcessor implements ProcessorInterface
|
|||
} else {
|
||||
$image = $data->createOrUpdateEntity($entity);
|
||||
|
||||
$response = $this->createImageActionController->__invoke($image);
|
||||
if ($this->kernel->getEnvironment() !== 'test') {
|
||||
$response = $this->createImageActionController->__invoke($image);
|
||||
}
|
||||
|
||||
$this->validator->validate($image);
|
||||
$this->imageRepository->save($image);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Patch;
|
|||
use ApiPlatform\Metadata\Put;
|
||||
use ApiPlatform\State\Pagination\TraversablePaginator;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
use App\Dto\Input\ImageImageRepositoryInput;
|
||||
use App\Dto\Output\ImageImageRepositoryOutput;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
|
@ -26,6 +27,9 @@ readonly class ImageImageRepositoryProvider implements ProviderInterface
|
|||
switch ($operation){
|
||||
case $operation instanceof GetCollection:
|
||||
return $this->provideCollection($operation, $uriVariables, $context);
|
||||
case $operation instanceof Patch:
|
||||
case $operation instanceof Put:
|
||||
return $this->provideInput($operation, $uriVariables, $context);
|
||||
case $operation instanceof Get:
|
||||
return $this->provideItem($operation, $uriVariables, $context);
|
||||
}
|
||||
|
@ -53,4 +57,15 @@ readonly class ImageImageRepositoryProvider implements ProviderInterface
|
|||
|
||||
return new ImageImageRepositoryOutput($item);
|
||||
}
|
||||
|
||||
public function provideInput(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
|
||||
{
|
||||
if (isset($uriVariables['uuid'])) {
|
||||
$item = $this->itemProvider->provide($operation, $uriVariables, $context);
|
||||
|
||||
return $item !== null ? new ImageImageRepositoryInput($item) : null;
|
||||
}
|
||||
|
||||
return new ImageImageRepositoryInput();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue