refs #2916. Fixed models entity
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
000bcb7714
commit
2d11a84141
|
|
@ -0,0 +1,39 @@
|
|||
<?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 Version20260406092549 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 software_profile DROP FOREIGN KEY FK_B70C3C9BFB84408A');
|
||||
$this->addSql('DROP INDEX IDX_B70C3C9BFB84408A ON software_profile');
|
||||
$this->addSql('ALTER TABLE software_profile ADD image_id INT DEFAULT NULL, DROP organizational_unit_id');
|
||||
$this->addSql('ALTER TABLE software_profile ADD CONSTRAINT FK_B70C3C9B3DA5256D FOREIGN KEY (image_id) REFERENCES image (id)');
|
||||
$this->addSql('CREATE INDEX IDX_B70C3C9B3DA5256D ON software_profile (image_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE software_profile DROP FOREIGN KEY FK_B70C3C9B3DA5256D');
|
||||
$this->addSql('DROP INDEX IDX_B70C3C9B3DA5256D ON software_profile');
|
||||
$this->addSql('ALTER TABLE software_profile ADD organizational_unit_id INT NOT NULL, DROP image_id');
|
||||
$this->addSql('ALTER TABLE software_profile ADD CONSTRAINT FK_B70C3C9BFB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id)');
|
||||
$this->addSql('CREATE INDEX IDX_B70C3C9BFB84408A ON software_profile (organizational_unit_id)');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?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 Version20260406092901 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 command_task DROP FOREIGN KEY FK_F3D475A8FB84408A');
|
||||
$this->addSql('ALTER TABLE command_task ADD CONSTRAINT FK_F3D475A8FB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id) ON DELETE SET NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE command_task DROP FOREIGN KEY FK_F3D475A8FB84408A');
|
||||
$this->addSql('ALTER TABLE command_task ADD CONSTRAINT FK_F3D475A8FB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id)');
|
||||
}
|
||||
}
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
namespace App\Dto\Input;
|
||||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use App\Dto\Output\ImageOutput;
|
||||
use App\Dto\Output\OperativeSystemOutput;
|
||||
use App\Dto\Output\OrganizationalUnitOutput;
|
||||
use App\Entity\SoftwareProfile;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
|
|
@ -19,8 +19,8 @@ final class SoftwareProfileInput
|
|||
public ?string $comments = null;
|
||||
|
||||
#[Groups(['software-profile:write'])]
|
||||
#[ApiProperty(description: 'The organizational unit of the software profile')]
|
||||
public ?OrganizationalUnitOutput $organizationalUnit = null;
|
||||
#[ApiProperty(description: 'The image of the software profile')]
|
||||
public ?ImageOutput $image = null;
|
||||
|
||||
#[Groups(['software-profile:write'])]
|
||||
#[ApiProperty(description: 'The operative system of the software profile')]
|
||||
|
|
@ -35,8 +35,8 @@ final class SoftwareProfileInput
|
|||
|
||||
$this->description = $softwareProfile->getDescription();
|
||||
$this->comments = $softwareProfile->getComments();
|
||||
if($softwareProfile->getOrganizationalUnit()) {
|
||||
$this->organizationalUnit = new OrganizationalUnitOutput($softwareProfile->getOrganizationalUnit());
|
||||
if ($softwareProfile->getImage()) {
|
||||
$this->image = new ImageOutput($softwareProfile->getImage());
|
||||
}
|
||||
|
||||
if($softwareProfile->getOperativeSystem()) {
|
||||
|
|
@ -52,9 +52,7 @@ final class SoftwareProfileInput
|
|||
|
||||
$softwareProfile->setDescription($this->description);
|
||||
$softwareProfile->setComments($this->comments);
|
||||
if ($this->organizationalUnit) {
|
||||
$softwareProfile->setOrganizationalUnit($this->organizationalUnit->getEntity());
|
||||
}
|
||||
$softwareProfile->setImage($this->image?->getEntity());
|
||||
|
||||
if ($this->operativeSystem) {
|
||||
$softwareProfile->setOperativeSystem($this->operativeSystem->getEntity());
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ final class ImageOutput extends AbstractOutput
|
|||
parent::__construct($image);
|
||||
|
||||
$this->name = $image->getName();
|
||||
$this->softwareProfile = $image->getSoftwareProfile() ? new SoftwareProfileOutput($image->getSoftwareProfile()) : null;
|
||||
$this->softwareProfile = $image->getSoftwareProfile() ? new SoftwareProfileOutput($image->getSoftwareProfile(), false) : null;
|
||||
|
||||
$this->imageRepositories = $image->getImageImageRepositories()->map(
|
||||
fn(ImageImageRepository $image) => new ImageImageRepositoryOutput($image)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use App\Entity\Software;
|
|||
use App\Entity\SoftwareProfile;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
|
||||
#[Get(shortName: 'SoftwareProfile')]
|
||||
final class SoftwareProfileOutput extends AbstractOutput
|
||||
{
|
||||
|
|
@ -27,10 +28,10 @@ final class SoftwareProfileOutput extends AbstractOutput
|
|||
|
||||
#[Groups(['software-profile:read'])]
|
||||
#[ApiProperty(
|
||||
description: 'La unidad organizativa asociada',
|
||||
description: 'La imagen asociada al perfil de software',
|
||||
example: null
|
||||
)]
|
||||
public ?OrganizationalUnitOutput $organizationalUnit = null;
|
||||
public ?ImageOutput $image = null;
|
||||
|
||||
#[Groups(['software-profile:read'])]
|
||||
#[ApiProperty(
|
||||
|
|
@ -60,15 +61,15 @@ final class SoftwareProfileOutput extends AbstractOutput
|
|||
)]
|
||||
public ?string $createdBy = null;
|
||||
|
||||
public function __construct(SoftwareProfile $softwareProfile)
|
||||
public function __construct(SoftwareProfile $softwareProfile, bool $includeImage = true)
|
||||
{
|
||||
parent::__construct($softwareProfile);
|
||||
|
||||
$this->description = $softwareProfile->getDescription();
|
||||
$this->comments = $softwareProfile->getComments();
|
||||
|
||||
if($softwareProfile->getOrganizationalUnit()) {
|
||||
$this->organizationalUnit = new OrganizationalUnitOutput($softwareProfile->getOrganizationalUnit());
|
||||
if ($includeImage && $softwareProfile->getImage()) {
|
||||
$this->image = new ImageOutput($softwareProfile->getImage());
|
||||
}
|
||||
|
||||
if ($softwareProfile->getOperativeSystem()) {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class CommandTask extends AbstractEntity
|
|||
private ?array $parameters = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
|
||||
private ?OrganizationalUnit $organizationalUnit = null;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -78,12 +78,6 @@ class OrganizationalUnit extends AbstractEntity
|
|||
#[ORM\Column(nullable: true)]
|
||||
private ?int $capacity = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, SoftwareProfile>
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'organizationalUnit', targetEntity: SoftwareProfile::class)]
|
||||
private Collection $softwareProfiles;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'organizationalUnits')]
|
||||
private ?Subnet $subnet = null;
|
||||
|
||||
|
|
@ -106,7 +100,7 @@ class OrganizationalUnit extends AbstractEntity
|
|||
$this->organizationalUnits = new ArrayCollection();
|
||||
$this->users = new ArrayCollection();
|
||||
$this->clients = new ArrayCollection();
|
||||
$this->softwareProfiles = new ArrayCollection();
|
||||
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
|
|
@ -354,36 +348,6 @@ class OrganizationalUnit extends AbstractEntity
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, SoftwareProfile>
|
||||
*/
|
||||
public function getSoftwareProfiles(): Collection
|
||||
{
|
||||
return $this->softwareProfiles;
|
||||
}
|
||||
|
||||
public function addSoftwareProfile(SoftwareProfile $softwareProfile): static
|
||||
{
|
||||
if (!$this->softwareProfiles->contains($softwareProfile)) {
|
||||
$this->softwareProfiles->add($softwareProfile);
|
||||
$softwareProfile->setOrganizationalUnit($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeSoftwareProfile(SoftwareProfile $softwareProfile): static
|
||||
{
|
||||
if ($this->softwareProfiles->removeElement($softwareProfile)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($softwareProfile->getOrganizationalUnit() === $this) {
|
||||
$softwareProfile->setOrganizationalUnit(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSubnet(): ?Subnet
|
||||
{
|
||||
return $this->subnet;
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ class SoftwareProfile extends AbstractEntity
|
|||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $comments = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'softwareProfiles')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?OrganizationalUnit $organizationalUnit = null;
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?Image $image = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Software>
|
||||
|
|
@ -66,14 +66,14 @@ class SoftwareProfile extends AbstractEntity
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getOrganizationalUnit(): ?OrganizationalUnit
|
||||
public function getImage(): ?Image
|
||||
{
|
||||
return $this->organizationalUnit;
|
||||
return $this->image;
|
||||
}
|
||||
|
||||
public function setOrganizationalUnit(?OrganizationalUnit $organizationalUnit): static
|
||||
public function setImage(?Image $image): static
|
||||
{
|
||||
$this->organizationalUnit = $organizationalUnit;
|
||||
$this->image = $image;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Factory;
|
||||
|
||||
use App\Entity\SoftwareProfile;
|
||||
use App\Model\OrganizationalUnitTypes;
|
||||
use App\Factory\ImageFactory;
|
||||
use App\Repository\SoftwareProfileRepository;
|
||||
use Zenstruck\Foundry\ModelFactory;
|
||||
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
|
||||
|
|
@ -37,7 +37,7 @@ final class SoftwareProfileFactory extends ModelFactory
|
|||
'description' => self::faker()->text(255),
|
||||
'updatedAt' => self::faker()->dateTime(),
|
||||
'operativeSystem' => OperativeSystemFactory::createOne()->_save(),
|
||||
'organizationalUnit' => OrganizationalUnitFactory::createOne(['type' => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT])->_save(),
|
||||
'image' => ImageFactory::createOne()->_save(),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue