refs #433. FUncionality hierarchy
parent
579d5284b6
commit
f186e9d481
|
@ -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 Version20240619083230 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('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_IP ON client (ip)');
|
||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_MAC ON client (mac)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('DROP INDEX UNIQ_IDENTIFIER_IP ON client');
|
||||
$this->addSql('DROP INDEX UNIQ_IDENTIFIER_MAC ON client');
|
||||
}
|
||||
}
|
|
@ -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 Version20240619084701 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 client ADD validation TINYINT(1) DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE client DROP validation');
|
||||
}
|
||||
}
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\Dto\Input;
|
||||
|
||||
use App\Dto\Output\HardwareProfileOutput;
|
||||
use App\Dto\Output\MenuOutput;
|
||||
use App\Entity\HardwareProfile;
|
||||
use App\Entity\Menu;
|
||||
use App\Entity\NetworkSettings;
|
||||
|
@ -16,9 +18,11 @@ class NetworkSettingsInput
|
|||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $proxy = null;
|
||||
|
||||
#[Assert\Ip()]
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $dns = null;
|
||||
|
||||
#[Assert\Ip()]
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $netmask = null;
|
||||
|
||||
|
@ -32,6 +36,7 @@ class NetworkSettingsInput
|
|||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $p2pMode = null;
|
||||
|
||||
#[Assert\GreaterThan(0)]
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?int $p2pTime = null;
|
||||
|
||||
|
@ -39,6 +44,7 @@ class NetworkSettingsInput
|
|||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $mcastIp = null;
|
||||
|
||||
#[Assert\GreaterThan(0)]
|
||||
#[Groups(['organizational-write:write'])]
|
||||
public ?int $mcastSpeed = null;
|
||||
|
||||
|
@ -51,10 +57,10 @@ class NetworkSettingsInput
|
|||
public ?string $mcastMode = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?Menu $menu = null;
|
||||
public ?MenuOutput $menu = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?HardwareProfile $hardwareProfile = null;
|
||||
public ?HardwareProfileOutput $hardwareProfile = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?bool $validation = null;
|
||||
|
@ -76,8 +82,15 @@ class NetworkSettingsInput
|
|||
$this->mcastSpeed = $networkSettings->getMcastSpeed();
|
||||
$this->mcastPort = $networkSettings->getMcastPort();
|
||||
$this->mcastMode = $networkSettings->getMcastMode();
|
||||
$this->menu = $networkSettings->getMenu();
|
||||
$this->hardwareProfile = $networkSettings->getHardwareProfile();
|
||||
|
||||
if ($networkSettings->getMenu()) {
|
||||
$this->menu = new MenuOutput($networkSettings->getMenu());
|
||||
}
|
||||
|
||||
if ($networkSettings->getHardwareProfile()) {
|
||||
$this->hardwareProfile = new HardwareProfileOutput($networkSettings->getHardwareProfile());
|
||||
}
|
||||
|
||||
$this->validation = $networkSettings->getValidation();
|
||||
}
|
||||
|
||||
|
@ -98,8 +111,15 @@ class NetworkSettingsInput
|
|||
$networkSettings->setMcastSpeed($this->mcastSpeed);
|
||||
$networkSettings->setMcastPort($this->mcastPort);
|
||||
$networkSettings->setMcastMode($this->mcastMode);
|
||||
$networkSettings->setMenu($this->menu);
|
||||
$networkSettings->setHardwareProfile($this->hardwareProfile);
|
||||
|
||||
if ($this->menu) {
|
||||
$networkSettings->setMenu($this->menu->getEntity());
|
||||
}
|
||||
|
||||
if ($this->hardwareProfile) {
|
||||
$networkSettings->setHardwareProfile($this->hardwareProfile->getEntity());
|
||||
}
|
||||
|
||||
$networkSettings->setValidation($this->validation);
|
||||
|
||||
return $networkSettings;
|
||||
|
|
|
@ -24,6 +24,19 @@ class OrganizationalUnitInput
|
|||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $description = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $location = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?bool $projector = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?bool $board = null;
|
||||
|
||||
#[Assert\GreaterThan(0)]
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?int $capacity = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $comments = null;
|
||||
|
||||
|
@ -46,6 +59,10 @@ class OrganizationalUnitInput
|
|||
$this->parent = new OrganizationalUnitOutput($organizationalUnit->getParent());
|
||||
}
|
||||
$this->description = $organizationalUnit->getDescription();
|
||||
$this->location = $organizationalUnit->getLocation();
|
||||
$this->projector = $organizationalUnit->isProjector();
|
||||
$this->board = $organizationalUnit->isBoard();
|
||||
$this->capacity = $organizationalUnit->getCapacity();
|
||||
$this->comments = $organizationalUnit->getComments();
|
||||
$this->type = $organizationalUnit->getType();
|
||||
if ($organizationalUnit->getNetworkSettings()){
|
||||
|
@ -64,6 +81,10 @@ class OrganizationalUnitInput
|
|||
$organizationalUnit->setParent($this->parent->getEntity());
|
||||
}
|
||||
$organizationalUnit->setDescription($this->description);
|
||||
$organizationalUnit->setLocation($this->location);
|
||||
$organizationalUnit->setProjector($this->projector);
|
||||
$organizationalUnit->setBoard($this->board);
|
||||
$organizationalUnit->setCapacity($this->capacity);
|
||||
$organizationalUnit->setComments($this->comments);
|
||||
$organizationalUnit->setType($this->type);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
|||
#[Get(shortName: 'NetworkSettings')]
|
||||
final class NetworkSettingsOutput extends AbstractOutput
|
||||
{
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
#[Groups(['network-settings:read'])]
|
||||
public ?string $proxy = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
|
@ -42,6 +42,15 @@ final class NetworkSettingsOutput extends AbstractOutput
|
|||
#[Groups(['organizational-unit:read'])]
|
||||
public ?string $mcastMode = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
public ?MenuOutput $menu = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
public ?HardwareProfileOutput $hardwareProfile = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
public ?bool $validation = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
public \DateTime $createdAt;
|
||||
|
||||
|
@ -63,6 +72,16 @@ final class NetworkSettingsOutput extends AbstractOutput
|
|||
$this->mcastSpeed = $networkSettings->getMcastSpeed();
|
||||
$this->mcastPort = $networkSettings->getMcastPort();
|
||||
$this->mcastMode = $networkSettings->getMcastMode();
|
||||
|
||||
if ($networkSettings->getMenu()) {
|
||||
$this->menu = new MenuOutput($networkSettings->getMenu());
|
||||
}
|
||||
|
||||
if ($networkSettings->getHardwareProfile()) {
|
||||
$this->hardwareProfile = new HardwareProfileOutput($networkSettings->getHardwareProfile());
|
||||
}
|
||||
|
||||
$this->validation = $networkSettings->getValidation();
|
||||
$this->createdAt = $networkSettings->getCreatedAt();
|
||||
$this->createdBy = $networkSettings->getCreatedBy();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,18 @@ final class OrganizationalUnitOutput extends AbstractOutput
|
|||
#[Groups(['organizational-unit:read'])]
|
||||
public ?string $comments = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
public ?string $location = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
public ?bool $projector = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
public ?bool $board = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
public ?int $capacity = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
public string $type;
|
||||
|
||||
|
@ -45,6 +57,10 @@ final class OrganizationalUnitOutput extends AbstractOutput
|
|||
|
||||
$this->name = $organizationalUnit->getName();
|
||||
$this->comments = $organizationalUnit->getComments();
|
||||
$this->location = $organizationalUnit->getLocation();
|
||||
$this->projector = $organizationalUnit->isProjector();
|
||||
$this->board = $organizationalUnit->isBoard();
|
||||
$this->capacity = $organizationalUnit->getCapacity();
|
||||
$this->type = $organizationalUnit->getType();
|
||||
$this->networkSettings = $organizationalUnit->getNetworkSettings() ? new NetworkSettingsOutput($organizationalUnit->getNetworkSettings()) : null;
|
||||
$this->clients = $organizationalUnit->getClients()->toArray();
|
||||
|
|
|
@ -6,8 +6,13 @@ use App\Repository\ClientRepository;
|
|||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
||||
#[ORM\Entity(repositoryClass: ClientRepository::class)]
|
||||
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_IP', fields: ['ip'])]
|
||||
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_MAC', fields: ['mac'])]
|
||||
#[UniqueEntity(fields: ['ip'], message: 'This IP address is already in use.')]
|
||||
#[UniqueEntity(fields: ['mac'], message: 'This MAC address is already in use.')]
|
||||
class Client extends AbstractEntity
|
||||
{
|
||||
use NameableTrait;
|
||||
|
@ -45,6 +50,9 @@ class Client extends AbstractEntity
|
|||
#[ORM\ManyToOne]
|
||||
private ?HardwareProfile $hardwareProfile = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?bool $validation = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
@ -188,4 +196,16 @@ class Client extends AbstractEntity
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getValidation(): ?bool
|
||||
{
|
||||
return $this->validation;
|
||||
}
|
||||
|
||||
public function setValidation(?bool $validation): static
|
||||
{
|
||||
$this->validation = $validation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -315,4 +315,20 @@ class OrganizationalUnit extends AbstractEntity
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function updateNetworkSettingsRecursively(?NetworkSettings $networkSettings): void
|
||||
{
|
||||
$this->setNetworkSettings($networkSettings);
|
||||
|
||||
/** @var Client $client */
|
||||
foreach ($this->getClients() as $client) {
|
||||
$client->setMenu($networkSettings->getMenu());
|
||||
$client->setHardwareProfile($networkSettings->getHardwareProfile());
|
||||
$client->setValidation($networkSettings->getValidation());
|
||||
}
|
||||
|
||||
foreach ($this->getOrganizationalUnits() as $childUnit) {
|
||||
$childUnit->updateNetworkSettingsRecursively($networkSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\OrganizationalUnit;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
class ChangeClientNetworkSettingsService
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function __invoke(OrganizationalUnit $organizationalUnit): void
|
||||
{
|
||||
$organizationalUnit->updateNetworkSettingsRecursively($organizationalUnit->GetNetworkSettings());
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Post;
|
|||
use ApiPlatform\Metadata\Put;
|
||||
use ApiPlatform\State\ProcessorInterface;
|
||||
use ApiPlatform\Validator\ValidatorInterface;
|
||||
use App\Dto\Input\ChangeOrganizationalUnitInput;
|
||||
use App\Dto\Input\MenuInput;
|
||||
use App\Dto\Input\OrganizationalUnitClassroomGroupInput;
|
||||
use App\Dto\Input\OrganizationalUnitClassroomInput;
|
||||
|
@ -17,14 +18,15 @@ use App\Dto\Input\OrganizationalUnitInput;
|
|||
use App\Dto\Input\OrganizationalUnitRootInput;
|
||||
use App\Dto\Output\OrganizationalUnitOutput;
|
||||
use App\Repository\OrganizationalUnitRepository;
|
||||
use App\Service\ChangeClientNetworkSettingsService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
class OrganizationalUnitProcessor implements ProcessorInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly OrganizationalUnitRepository $organizationalUnitRepository,
|
||||
private readonly ValidatorInterface $validator,
|
||||
private readonly EntityManagerInterface $entityManager
|
||||
private readonly OrganizationalUnitRepository $organizationalUnitRepository,
|
||||
private readonly ValidatorInterface $validator,
|
||||
private readonly ChangeClientNetworkSettingsService $changeClientNetworkSettingsService,
|
||||
)
|
||||
{
|
||||
}
|
||||
|
@ -62,6 +64,8 @@ class OrganizationalUnitProcessor implements ProcessorInterface
|
|||
$this->validator->validate($organizationalUnit, ['groups' => ['organizational-unit:write']]);
|
||||
$this->organizationalUnitRepository->save($organizationalUnit);
|
||||
|
||||
$this->changeClientNetworkSettingsService->__invoke($organizationalUnit);
|
||||
|
||||
return new OrganizationalUnitOutput($organizationalUnit);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue