refs #433. Hierarchy property
parent
26f4595b2a
commit
f64fbecd2e
|
@ -0,0 +1,18 @@
|
|||
resources:
|
||||
App\Entity\NetworkSettings:
|
||||
output: App\Dto\Output\NetworkSettingsOutput
|
||||
operations:
|
||||
ApiPlatform\Metadata\GetCollection:
|
||||
provider: App\State\Provider\MenuProvider
|
||||
filters:
|
||||
- 'api_platform.filter.menu.order'
|
||||
- 'api_platform.filter.menu.search'
|
||||
ApiPlatform\Metadata\Get:
|
||||
provider: App\State\Provider\MenuProvider
|
||||
|
||||
properties:
|
||||
App\Entity\NetworkSettings:
|
||||
id:
|
||||
identifier: false
|
||||
uuid:
|
||||
identifier: true
|
|
@ -7,6 +7,7 @@ resources:
|
|||
groups: ['default', 'organizational-unit:read']
|
||||
denormalization_context:
|
||||
groups: ['organizational-unit:write']
|
||||
|
||||
operations:
|
||||
ApiPlatform\Metadata\GetCollection:
|
||||
provider: App\State\Provider\OrganizationalUnitProvider
|
||||
|
@ -18,35 +19,8 @@ resources:
|
|||
provider: App\State\Provider\OrganizationalUnitProvider
|
||||
validationContext:
|
||||
groups: ['organizational-unit:patch' ]
|
||||
|
||||
ApiPlatform\Metadata\Post: ~
|
||||
ApiPlatform\Metadata\Delete: ~
|
||||
organizational_unit_root:
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
uriTemplate: /organizational-units/root
|
||||
input: App\Dto\Input\OrganizationalUnitRootInput
|
||||
output: App\Dto\Output\OrganizationalUnitOutput
|
||||
|
||||
organizational_unit_classroom_group:
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
uriTemplate: /organizational-units/classroom-group
|
||||
input: App\Dto\Input\OrganizationalUnitClassroomGroupInput
|
||||
output: App\Dto\Output\OrganizationalUnitOutput
|
||||
|
||||
organizational_unit_classroom:
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
uriTemplate: /organizational-units/classroom
|
||||
input: App\Dto\Input\OrganizationalUnitClassroomInput
|
||||
output: App\Dto\Output\OrganizationalUnitOutput
|
||||
|
||||
organizational_unit_client_group:
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
uriTemplate: /organizational-units/client-group
|
||||
input: App\Dto\Input\OrganizationalUnitClientGroupInput
|
||||
output: App\Dto\Output\OrganizationalUnitOutput
|
||||
|
||||
properties:
|
||||
App\Entity\OrganizationalUnit:
|
||||
|
|
|
@ -9,7 +9,6 @@ resources:
|
|||
groups: ['user:write']
|
||||
operations:
|
||||
ApiPlatform\Metadata\GetCollection:
|
||||
security: 'is_granted("ROLE_SUPER_ADMIN")'
|
||||
provider: App\State\Provider\UserProvider
|
||||
filters:
|
||||
- 'api_platform.filter.user.order'
|
||||
|
|
|
@ -64,3 +64,8 @@ services:
|
|||
bind:
|
||||
$collectionProvider: '@api_platform.doctrine.orm.state.collection_provider'
|
||||
$itemProvider: '@api_platform.doctrine.orm.state.item_provider'
|
||||
|
||||
App\State\Provider\NetworkSettingsProvider:
|
||||
bind:
|
||||
$collectionProvider: '@api_platform.doctrine.orm.state.collection_provider'
|
||||
$itemProvider: '@api_platform.doctrine.orm.state.item_provider'
|
|
@ -1,33 +0,0 @@
|
|||
<?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 Version20240612105731 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 CHANGE name name VARCHAR(255) NOT NULL');
|
||||
$this->addSql('ALTER TABLE network_settings CHANGE mcast_speed mcast_speed INT DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE network_settings CHANGE mcast_speed mcast_speed INT NOT NULL');
|
||||
$this->addSql('ALTER TABLE client CHANGE name name VARCHAR(255) DEFAULT NULL');
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?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 Version20240612111552 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 CHANGE name name VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE hardware CHANGE name name VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE organizational_unit CHANGE name name VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE user_group CHANGE name name 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 hardware CHANGE name name VARCHAR(255) NOT NULL');
|
||||
$this->addSql('ALTER TABLE user_group CHANGE name name VARCHAR(255) NOT NULL');
|
||||
$this->addSql('ALTER TABLE organizational_unit CHANGE name name VARCHAR(255) NOT NULL');
|
||||
$this->addSql('ALTER TABLE client CHANGE name name VARCHAR(255) NOT NULL');
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
<?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 Version20240613090444 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 TABLE menu (id INT AUTO_INCREMENT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, title VARCHAR(255) NOT NULL, resolution VARCHAR(255) NOT NULL, comments VARCHAR(255) DEFAULT NULL, public_url VARCHAR(255) DEFAULT NULL, private_url VARCHAR(255) DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_7D053A93D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('ALTER TABLE client ADD menu_id INT DEFAULT NULL, CHANGE name name VARCHAR(255) NOT NULL');
|
||||
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455CCD7E912 FOREIGN KEY (menu_id) REFERENCES menu (id)');
|
||||
$this->addSql('CREATE INDEX IDX_C7440455CCD7E912 ON client (menu_id)');
|
||||
$this->addSql('ALTER TABLE hardware CHANGE name name VARCHAR(255) NOT NULL');
|
||||
$this->addSql('ALTER TABLE organizational_unit CHANGE name name VARCHAR(255) NOT NULL');
|
||||
$this->addSql('ALTER TABLE user_group CHANGE name name VARCHAR(255) NOT 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 FOREIGN KEY FK_C7440455CCD7E912');
|
||||
$this->addSql('DROP TABLE menu');
|
||||
$this->addSql('ALTER TABLE hardware CHANGE name name VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE user_group CHANGE name name VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE organizational_unit CHANGE name name VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('DROP INDEX IDX_C7440455CCD7E912 ON client');
|
||||
$this->addSql('ALTER TABLE client DROP menu_id, CHANGE name name VARCHAR(255) DEFAULT NULL');
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<?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 Version20240614082024 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 TABLE `partition` (id INT AUTO_INCREMENT NOT NULL, client_id INT DEFAULT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, disk_number INT DEFAULT NULL, partition_number INT DEFAULT NULL, partition_code VARCHAR(255) DEFAULT NULL, size INT NOT NULL, cache_content VARCHAR(255) DEFAULT NULL, filesystem VARCHAR(255) DEFAULT NULL, os_name VARCHAR(255) NOT NULL, memory_usage INT NOT NULL, UNIQUE INDEX UNIQ_9EB910E4D17F50A6 (uuid), INDEX IDX_9EB910E419EB6921 (client_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('ALTER TABLE `partition` ADD CONSTRAINT FK_9EB910E419EB6921 FOREIGN KEY (client_id) REFERENCES client (id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE `partition` DROP FOREIGN KEY FK_9EB910E419EB6921');
|
||||
$this->addSql('DROP TABLE `partition`');
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
|
|||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20240611090540 extends AbstractMigration
|
||||
final class Version20240617113606 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
|
@ -20,24 +20,28 @@ final class Version20240611090540 extends AbstractMigration
|
|||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE TABLE client (id INT AUTO_INCREMENT NOT NULL, organizational_unit_id INT DEFAULT NULL, hardware_profile_id INT DEFAULT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, serial_number VARCHAR(255) DEFAULT NULL, netiface VARCHAR(255) DEFAULT NULL, net_driver VARCHAR(255) DEFAULT NULL, mac VARCHAR(255) DEFAULT NULL, ip VARCHAR(255) DEFAULT NULL, status VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_C7440455D17F50A6 (uuid), INDEX IDX_C7440455FB84408A (organizational_unit_id), INDEX IDX_C7440455CFA495C1 (hardware_profile_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE client (id INT AUTO_INCREMENT NOT NULL, organizational_unit_id INT DEFAULT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, serial_number VARCHAR(255) DEFAULT NULL, netiface VARCHAR(255) DEFAULT NULL, net_driver VARCHAR(255) DEFAULT NULL, mac VARCHAR(255) DEFAULT NULL, ip VARCHAR(255) DEFAULT NULL, status VARCHAR(255) DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_C7440455D17F50A6 (uuid), INDEX IDX_C7440455FB84408A (organizational_unit_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE hardware (id INT AUTO_INCREMENT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, description VARCHAR(255) DEFAULT NULL, type VARCHAR(255) DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_FE99E9E0D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE hardware_profile (id INT AUTO_INCREMENT NOT NULL, organizational_unit_id INT DEFAULT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, description VARCHAR(255) DEFAULT NULL, comments VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_2D9A2460D17F50A6 (uuid), INDEX IDX_2D9A2460FB84408A (organizational_unit_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE hardware_profile_hardware (hardware_profile_id INT NOT NULL, hardware_id INT NOT NULL, INDEX IDX_18C7E12CFA495C1 (hardware_profile_id), INDEX IDX_18C7E12C9CC762B (hardware_id), PRIMARY KEY(hardware_profile_id, hardware_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE network_settings (id INT AUTO_INCREMENT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, proxy VARCHAR(255) DEFAULT NULL, dns VARCHAR(255) DEFAULT NULL, netmask VARCHAR(255) DEFAULT NULL, router VARCHAR(255) DEFAULT NULL, ntp VARCHAR(255) DEFAULT NULL, p2p_time INT DEFAULT NULL, p2p_mode VARCHAR(255) DEFAULT NULL, mcast_ip VARCHAR(255) DEFAULT NULL, mcast_speed INT NOT NULL, mcast_mode VARCHAR(255) DEFAULT NULL, mcast_port INT DEFAULT NULL, UNIQUE INDEX UNIQ_48869B54D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE menu (id INT AUTO_INCREMENT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, title VARCHAR(255) NOT NULL, resolution VARCHAR(255) NOT NULL, comments VARCHAR(255) DEFAULT NULL, public_url VARCHAR(255) DEFAULT NULL, private_url VARCHAR(255) DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_7D053A93D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE network_settings (id INT AUTO_INCREMENT NOT NULL, menu_id INT DEFAULT NULL, hardware_profile_id INT DEFAULT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, proxy VARCHAR(255) DEFAULT NULL, dns VARCHAR(255) DEFAULT NULL, netmask VARCHAR(255) DEFAULT NULL, router VARCHAR(255) DEFAULT NULL, ntp VARCHAR(255) DEFAULT NULL, p2p_time INT DEFAULT NULL, p2p_mode VARCHAR(255) DEFAULT NULL, mcast_ip VARCHAR(255) DEFAULT NULL, mcast_speed INT DEFAULT NULL, mcast_mode VARCHAR(255) DEFAULT NULL, mcast_port INT DEFAULT NULL, validation TINYINT(1) DEFAULT NULL, UNIQUE INDEX UNIQ_48869B54D17F50A6 (uuid), INDEX IDX_48869B54CCD7E912 (menu_id), INDEX IDX_48869B54CFA495C1 (hardware_profile_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE organizational_unit (id INT AUTO_INCREMENT NOT NULL, parent_id INT DEFAULT NULL, network_settings_id INT DEFAULT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, description VARCHAR(255) DEFAULT NULL, comments VARCHAR(255) DEFAULT NULL, path VARCHAR(255) DEFAULT NULL, level INT DEFAULT NULL, slug VARCHAR(255) DEFAULT NULL, type VARCHAR(255) NOT NULL, location VARCHAR(255) DEFAULT NULL, projector TINYINT(1) DEFAULT NULL, board TINYINT(1) DEFAULT NULL, capacity INT DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_749AEB2DD17F50A6 (uuid), INDEX IDX_749AEB2D727ACA70 (parent_id), INDEX IDX_749AEB2D9B9A36D0 (network_settings_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE `partition` (id INT AUTO_INCREMENT NOT NULL, client_id INT DEFAULT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, disk_number INT DEFAULT NULL, partition_number INT DEFAULT NULL, partition_code VARCHAR(255) DEFAULT NULL, size INT NOT NULL, cache_content VARCHAR(255) DEFAULT NULL, filesystem VARCHAR(255) DEFAULT NULL, os_name VARCHAR(255) NOT NULL, memory_usage INT NOT NULL, UNIQUE INDEX UNIQ_9EB910E4D17F50A6 (uuid), INDEX IDX_9EB910E419EB6921 (client_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE refresh_tokens (id INT AUTO_INCREMENT NOT NULL, refresh_token VARCHAR(128) NOT NULL, username VARCHAR(255) NOT NULL, valid DATETIME NOT NULL, UNIQUE INDEX UNIQ_9BACE7E1C74F2195 (refresh_token), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, username VARCHAR(180) NOT NULL, roles JSON NOT NULL COMMENT \'(DC2Type:json)\', password VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_8D93D649D17F50A6 (uuid), UNIQUE INDEX UNIQ_IDENTIFIER_USERNAME (username), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE user_organizational_unit (user_id INT NOT NULL, organizational_unit_id INT NOT NULL, INDEX IDX_5E59845FA76ED395 (user_id), INDEX IDX_5E59845FFB84408A (organizational_unit_id), PRIMARY KEY(user_id, organizational_unit_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE user_group (id INT AUTO_INCREMENT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, permissions JSON NOT NULL COMMENT \'(DC2Type:json)\', name VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_8F02BF9DD17F50A6 (uuid), UNIQUE INDEX UNIQ_IDENTIFIER_NAME (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE user_group_user (user_group_id INT NOT NULL, user_id INT NOT NULL, INDEX IDX_3AE4BD51ED93D47 (user_group_id), INDEX IDX_3AE4BD5A76ED395 (user_id), PRIMARY KEY(user_group_id, user_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455FB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id)');
|
||||
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455CFA495C1 FOREIGN KEY (hardware_profile_id) REFERENCES hardware_profile (id)');
|
||||
$this->addSql('ALTER TABLE hardware_profile ADD CONSTRAINT FK_2D9A2460FB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id)');
|
||||
$this->addSql('ALTER TABLE hardware_profile_hardware ADD CONSTRAINT FK_18C7E12CFA495C1 FOREIGN KEY (hardware_profile_id) REFERENCES hardware_profile (id) ON DELETE CASCADE');
|
||||
$this->addSql('ALTER TABLE hardware_profile_hardware ADD CONSTRAINT FK_18C7E12C9CC762B FOREIGN KEY (hardware_id) REFERENCES hardware (id) ON DELETE CASCADE');
|
||||
$this->addSql('ALTER TABLE network_settings ADD CONSTRAINT FK_48869B54CCD7E912 FOREIGN KEY (menu_id) REFERENCES menu (id)');
|
||||
$this->addSql('ALTER TABLE network_settings ADD CONSTRAINT FK_48869B54CFA495C1 FOREIGN KEY (hardware_profile_id) REFERENCES hardware_profile (id)');
|
||||
$this->addSql('ALTER TABLE organizational_unit ADD CONSTRAINT FK_749AEB2D727ACA70 FOREIGN KEY (parent_id) REFERENCES organizational_unit (id) ON DELETE SET NULL');
|
||||
$this->addSql('ALTER TABLE organizational_unit ADD CONSTRAINT FK_749AEB2D9B9A36D0 FOREIGN KEY (network_settings_id) REFERENCES network_settings (id)');
|
||||
$this->addSql('ALTER TABLE `partition` ADD CONSTRAINT FK_9EB910E419EB6921 FOREIGN KEY (client_id) REFERENCES client (id)');
|
||||
$this->addSql('ALTER TABLE user_organizational_unit ADD CONSTRAINT FK_5E59845FA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
|
||||
$this->addSql('ALTER TABLE user_organizational_unit ADD CONSTRAINT FK_5E59845FFB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id) ON DELETE CASCADE');
|
||||
$this->addSql('ALTER TABLE user_group_user ADD CONSTRAINT FK_3AE4BD51ED93D47 FOREIGN KEY (user_group_id) REFERENCES user_group (id) ON DELETE CASCADE');
|
||||
|
@ -48,12 +52,14 @@ final class Version20240611090540 extends AbstractMigration
|
|||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455FB84408A');
|
||||
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455CFA495C1');
|
||||
$this->addSql('ALTER TABLE hardware_profile DROP FOREIGN KEY FK_2D9A2460FB84408A');
|
||||
$this->addSql('ALTER TABLE hardware_profile_hardware DROP FOREIGN KEY FK_18C7E12CFA495C1');
|
||||
$this->addSql('ALTER TABLE hardware_profile_hardware DROP FOREIGN KEY FK_18C7E12C9CC762B');
|
||||
$this->addSql('ALTER TABLE network_settings DROP FOREIGN KEY FK_48869B54CCD7E912');
|
||||
$this->addSql('ALTER TABLE network_settings DROP FOREIGN KEY FK_48869B54CFA495C1');
|
||||
$this->addSql('ALTER TABLE organizational_unit DROP FOREIGN KEY FK_749AEB2D727ACA70');
|
||||
$this->addSql('ALTER TABLE organizational_unit DROP FOREIGN KEY FK_749AEB2D9B9A36D0');
|
||||
$this->addSql('ALTER TABLE `partition` DROP FOREIGN KEY FK_9EB910E419EB6921');
|
||||
$this->addSql('ALTER TABLE user_organizational_unit DROP FOREIGN KEY FK_5E59845FA76ED395');
|
||||
$this->addSql('ALTER TABLE user_organizational_unit DROP FOREIGN KEY FK_5E59845FFB84408A');
|
||||
$this->addSql('ALTER TABLE user_group_user DROP FOREIGN KEY FK_3AE4BD51ED93D47');
|
||||
|
@ -62,8 +68,10 @@ final class Version20240611090540 extends AbstractMigration
|
|||
$this->addSql('DROP TABLE hardware');
|
||||
$this->addSql('DROP TABLE hardware_profile');
|
||||
$this->addSql('DROP TABLE hardware_profile_hardware');
|
||||
$this->addSql('DROP TABLE menu');
|
||||
$this->addSql('DROP TABLE network_settings');
|
||||
$this->addSql('DROP TABLE organizational_unit');
|
||||
$this->addSql('DROP TABLE `partition`');
|
||||
$this->addSql('DROP TABLE refresh_tokens');
|
||||
$this->addSql('DROP TABLE user');
|
||||
$this->addSql('DROP TABLE user_organizational_unit');
|
|
@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
|
|||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20240614082735 extends AbstractMigration
|
||||
final class Version20240618062825 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
|
@ -20,16 +20,20 @@ final class Version20240614082735 extends AbstractMigration
|
|||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455CCD7E912');
|
||||
$this->addSql('DROP INDEX IDX_C7440455CCD7E912 ON client');
|
||||
$this->addSql('ALTER TABLE client ADD menu VARCHAR(255) DEFAULT NULL, DROP menu_id');
|
||||
$this->addSql('ALTER TABLE client ADD menu_id INT DEFAULT NULL, ADD hardware_profile_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455CCD7E912 FOREIGN KEY (menu_id) REFERENCES menu (id)');
|
||||
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455CFA495C1 FOREIGN KEY (hardware_profile_id) REFERENCES hardware_profile (id)');
|
||||
$this->addSql('CREATE INDEX IDX_C7440455CCD7E912 ON client (menu_id)');
|
||||
$this->addSql('CREATE INDEX IDX_C7440455CFA495C1 ON client (hardware_profile_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE client ADD menu_id INT DEFAULT NULL, DROP menu');
|
||||
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455CCD7E912 FOREIGN KEY (menu_id) REFERENCES menu (id)');
|
||||
$this->addSql('CREATE INDEX IDX_C7440455CCD7E912 ON client (menu_id)');
|
||||
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455CCD7E912');
|
||||
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455CFA495C1');
|
||||
$this->addSql('DROP INDEX IDX_C7440455CCD7E912 ON client');
|
||||
$this->addSql('DROP INDEX IDX_C7440455CFA495C1 ON client');
|
||||
$this->addSql('ALTER TABLE client DROP menu_id, DROP hardware_profile_id');
|
||||
}
|
||||
}
|
|
@ -46,14 +46,11 @@ final class ClientInput
|
|||
#[ApiProperty(description: 'The organizational unit of the client')]
|
||||
public ?OrganizationalUnitOutput $organizationalUnit = null;
|
||||
|
||||
#[Assert\NotNull]
|
||||
#[Groups(['client:write', 'client:patch'])]
|
||||
#[ApiProperty(description: 'The hardware profile of the client')]
|
||||
public ?HardwareProfileOutput $hardwareProfile = null;
|
||||
#[Groups(['client:write'])]
|
||||
public ?MenuOutput $menu = null;
|
||||
|
||||
#[Groups(['client:write'])]
|
||||
#[ApiProperty(description: 'The menu of the client')]
|
||||
public ?MenuOutput $menu = null;
|
||||
public ?HardwareProfileOutput $hardwareProfile = null;
|
||||
|
||||
public function __construct(?Client $client = null)
|
||||
{
|
||||
|
@ -65,12 +62,18 @@ final class ClientInput
|
|||
$this->serialNumber = $client->getSerialNumber();
|
||||
$this->netiface = $client->getNetiface();
|
||||
$this->organizationalUnit = new OrganizationalUnitOutput($client->getOrganizationalUnit());
|
||||
$this->hardwareProfile = new HardwareProfileOutput($client->getHardwareProfile());
|
||||
$this->menu = new MenuOutput($client->getMenu());
|
||||
$this->netDriver = $client->getNetDriver();
|
||||
$this->mac = $client->getMac();
|
||||
$this->ip = $client->getIp();
|
||||
$this->status = $client->getStatus();
|
||||
|
||||
if ($client->getMenu()) {
|
||||
$this->menu = new MenuOutput($client->getMenu());
|
||||
}
|
||||
|
||||
if ($client->getHardwareProfile()) {
|
||||
$this->hardwareProfile = new HardwareProfileOutput($client->getHardwareProfile());
|
||||
}
|
||||
}
|
||||
|
||||
public function createOrUpdateEntity(?Client $client = null): Client
|
||||
|
@ -83,16 +86,12 @@ final class ClientInput
|
|||
$client->setSerialNumber($this->serialNumber);
|
||||
$client->setNetiface($this->netiface);
|
||||
$client->setOrganizationalUnit($this->organizationalUnit->getEntity());
|
||||
$client->setHardwareProfile($this->hardwareProfile->getEntity());
|
||||
|
||||
if ($this->menu) {
|
||||
$client->setMenu($this->menu->getEntity());
|
||||
}
|
||||
|
||||
$client->setNetDriver($this->netDriver);
|
||||
$client->setMac($this->mac);
|
||||
$client->setIp($this->ip);
|
||||
$client->setStatus($this->status);
|
||||
$client->setMenu($this->menu?->getEntity());
|
||||
$client->setHardwareProfile($this->hardwareProfile?->getEntity());
|
||||
|
||||
return $client;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dto\Input;
|
||||
|
||||
use App\Entity\HardwareProfile;
|
||||
use App\Entity\Menu;
|
||||
use App\Entity\NetworkSettings;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
class NetworkSettingsInput
|
||||
{
|
||||
#[Groups(['organizational-write:read'])]
|
||||
public ?string $proxy = null;
|
||||
|
||||
#[Groups(['organizational-write:read'])]
|
||||
public ?string $dns = null;
|
||||
|
||||
#[Groups(['organizational-write:read'])]
|
||||
public ?string $netmask = null;
|
||||
|
||||
#[Groups(['organizational-write:read'])]
|
||||
public ?string $router = null;
|
||||
|
||||
#[Groups(['organizational-write:read'])]
|
||||
public ?string $ntp = null;
|
||||
|
||||
#[Groups(['organizational-write:read'])]
|
||||
public ?string $p2pMode = null;
|
||||
|
||||
#[Groups(['organizational-write:read'])]
|
||||
public ?int $p2pTime = null;
|
||||
|
||||
#[Groups(['organizational-write:read'])]
|
||||
public ?string $mcastIp = null;
|
||||
|
||||
#[Groups(['organizational-write:read'])]
|
||||
public ?int $mcastSpeed = null;
|
||||
|
||||
#[Groups(['organizational-write:read'])]
|
||||
public ?int $mcastPort = null;
|
||||
|
||||
#[Groups(['organizational-write:read'])]
|
||||
public ?string $mcastMode = null;
|
||||
|
||||
#[Groups(['organizational-write:read'])]
|
||||
public ?Menu $menu = null;
|
||||
|
||||
#[Groups(['organizational-write:read'])]
|
||||
public ?HardwareProfile $hardwareProfile = null;
|
||||
|
||||
#[Groups(['organizational-write:read'])]
|
||||
public ?bool $validation = null;
|
||||
|
||||
public function __construct(?NetworkSettings $networkSettings = null)
|
||||
{
|
||||
if (!$networkSettings) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->proxy = $networkSettings->getProxy();
|
||||
$this->dns = $networkSettings->getDns();
|
||||
$this->netmask = $networkSettings->getNetmask();
|
||||
$this->router = $networkSettings->getRouter();
|
||||
$this->ntp = $networkSettings->getNtp();
|
||||
$this->p2pMode = $networkSettings->getP2pMode();
|
||||
$this->p2pTime = $networkSettings->getP2pTime();
|
||||
$this->mcastIp = $networkSettings->getMcastIp();
|
||||
$this->mcastSpeed = $networkSettings->getMcastSpeed();
|
||||
$this->mcastPort = $networkSettings->getMcastPort();
|
||||
$this->mcastMode = $networkSettings->getMcastMode();
|
||||
$this->menu = $networkSettings->getMenu();
|
||||
$this->hardwareProfile = $networkSettings->getHardwareProfile();
|
||||
$this->validation = $networkSettings->getValidation();
|
||||
}
|
||||
|
||||
public function createOrUpdateEntity(?NetworkSettings $networkSettings = null): NetworkSettings
|
||||
{
|
||||
if (!$networkSettings) {
|
||||
$networkSettings = new NetworkSettings();
|
||||
}
|
||||
|
||||
$networkSettings->setProxy($this->proxy);
|
||||
$networkSettings->setDns($this->dns);
|
||||
$networkSettings->setNetmask($this->netmask);
|
||||
$networkSettings->setRouter($this->router);
|
||||
$networkSettings->setNtp($this->ntp);
|
||||
$networkSettings->setP2pMode($this->p2pMode);
|
||||
$networkSettings->setP2pTime($this->p2pTime);
|
||||
$networkSettings->setMcastIp($this->mcastIp);
|
||||
$networkSettings->setMcastSpeed($this->mcastSpeed);
|
||||
$networkSettings->setMcastPort($this->mcastPort);
|
||||
$networkSettings->setMcastMode($this->mcastMode);
|
||||
$networkSettings->setMenu($this->menu);
|
||||
$networkSettings->setHardwareProfile($this->hardwareProfile);
|
||||
$networkSettings->setValidation($this->validation);
|
||||
|
||||
return $networkSettings;
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dto\Input;
|
||||
|
||||
use App\Entity\OrganizationalUnit;
|
||||
use App\Model\OrganizationalUnitTypes;
|
||||
|
||||
final class OrganizationalUnitClassroomGroupInput extends OrganizationalUnitInput
|
||||
{
|
||||
public function __construct(?OrganizationalUnit $organizationalUnit = null)
|
||||
{
|
||||
parent::__construct($organizationalUnit, OrganizationalUnitTypes::CLASSROOMS_GROUP);
|
||||
}
|
||||
}
|
|
@ -1,123 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dto\Input;
|
||||
|
||||
use App\Dto\Output\OrganizationalUnitOutput;
|
||||
use App\Entity\NetworkSettings;
|
||||
use App\Entity\OrganizationalUnit;
|
||||
use App\Model\OrganizationalUnitTypes;
|
||||
use App\Validator\Constraints\OrganizationalUnitClassroomMulticastMode;
|
||||
use App\Validator\Constraints\OrganizationalUnitClassroomMulticastPort;
|
||||
use App\Validator\Constraints\OrganizationalUnitClassroomP2pMode;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
final class OrganizationalUnitClassroomInput extends OrganizationalUnitInput
|
||||
{
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $location = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?bool $projector = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?bool $board = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?int $capacity = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $proxy = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $dns = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $netmask = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $router = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $ntp = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
#[OrganizationalUnitClassroomP2pMode]
|
||||
public ?string $p2pMode = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?int $p2pTime = null;
|
||||
|
||||
#[Assert\Ip]
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $mcastIp = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?int $mcastSpeed = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
#[OrganizationalUnitClassroomMulticastPort]
|
||||
public ?int $mcastPort = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
#[OrganizationalUnitClassroomMulticastMode]
|
||||
public ?string $mcastMode = null;
|
||||
|
||||
public function __construct(?OrganizationalUnit $organizationalUnit = null)
|
||||
{
|
||||
parent::__construct($organizationalUnit, OrganizationalUnitTypes::CLASSROOM);
|
||||
|
||||
if (!$organizationalUnit) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->location = $organizationalUnit->getLocation();
|
||||
$this->projector = $organizationalUnit->isProjector();
|
||||
$this->board = $organizationalUnit->isBoard();
|
||||
$this->capacity = $organizationalUnit->getCapacity();
|
||||
$this->proxy = $organizationalUnit->getNetworkSettings()->getProxy();
|
||||
$this->dns = $organizationalUnit->getNetworkSettings()->getDns();
|
||||
$this->netmask = $organizationalUnit->getNetworkSettings()->getNetmask();
|
||||
$this->router = $organizationalUnit->getNetworkSettings()->getRouter();
|
||||
$this->ntp = $organizationalUnit->getNetworkSettings()->getNtp();
|
||||
$this->p2pMode = $organizationalUnit->getNetworkSettings()->getP2pMode();
|
||||
$this->p2pTime = $organizationalUnit->getNetworkSettings()->getP2pTime();
|
||||
$this->mcastIp = $organizationalUnit->getNetworkSettings()->getMcastIp();
|
||||
$this->mcastSpeed = $organizationalUnit->getNetworkSettings()->getMcastSpeed();
|
||||
$this->mcastPort = $organizationalUnit->getNetworkSettings()->getMcastPort();
|
||||
$this->mcastMode = $organizationalUnit->getNetworkSettings()->getMcastMode();
|
||||
}
|
||||
|
||||
public function createOrUpdateEntity(
|
||||
?OrganizationalUnit $organizationalUnit = null,
|
||||
?EntityManagerInterface $entityManager = null
|
||||
): OrganizationalUnit
|
||||
{
|
||||
$organizationalUnit = parent::createOrUpdateEntity($organizationalUnit);
|
||||
|
||||
$organizationalUnit->setType(OrganizationalUnitTypes::CLASSROOM);
|
||||
$organizationalUnit->setLocation($this->location);
|
||||
$organizationalUnit->setProjector($this->projector);
|
||||
$organizationalUnit->setBoard($this->board);
|
||||
$organizationalUnit->setCapacity($this->capacity);
|
||||
|
||||
$networkSettings = new NetworkSettings();
|
||||
$networkSettings->setProxy($this->proxy);
|
||||
$networkSettings->setDns($this->dns);
|
||||
$networkSettings->setNetmask($this->netmask);
|
||||
$networkSettings->setRouter($this->router);
|
||||
$networkSettings->setNtp($this->ntp);
|
||||
$networkSettings->setP2pMode($this->p2pMode);
|
||||
$networkSettings->setP2pTime($this->p2pTime);
|
||||
$networkSettings->setMcastIp($this->mcastIp);
|
||||
$networkSettings->setMcastSpeed($this->mcastSpeed);
|
||||
$networkSettings->setMcastPort($this->mcastPort);
|
||||
$networkSettings->setMcastMode($this->mcastMode);
|
||||
$entityManager->persist($networkSettings);
|
||||
|
||||
$organizationalUnit->setNetworkSettings($networkSettings);
|
||||
|
||||
return $organizationalUnit;
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dto\Input;
|
||||
|
||||
use App\Entity\OrganizationalUnit;
|
||||
use App\Model\OrganizationalUnitTypes;
|
||||
|
||||
final class OrganizationalUnitClientGroupInput extends OrganizationalUnitInput
|
||||
{
|
||||
public function __construct(?OrganizationalUnit $organizationalUnit = null)
|
||||
{
|
||||
parent::__construct($organizationalUnit, OrganizationalUnitTypes::CLIENTS_GROUP);
|
||||
}
|
||||
}
|
|
@ -22,7 +22,13 @@ class OrganizationalUnitInput
|
|||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $comments = null;
|
||||
|
||||
public function __construct(?OrganizationalUnit $organizationalUnit = null, private readonly ?string $type = null)
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $type = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?NetworkSettingsInput $networkSettings = null;
|
||||
|
||||
public function __construct(?OrganizationalUnit $organizationalUnit = null)
|
||||
{
|
||||
if (!$organizationalUnit) {
|
||||
return;
|
||||
|
@ -34,6 +40,10 @@ class OrganizationalUnitInput
|
|||
}
|
||||
$this->description = $organizationalUnit->getDescription();
|
||||
$this->comments = $organizationalUnit->getComments();
|
||||
$this->type = $organizationalUnit->getType();
|
||||
if ($organizationalUnit->getNetworkSettings()){
|
||||
$this->networkSettings = new NetworkSettingsInput($organizationalUnit->getNetworkSettings());
|
||||
}
|
||||
}
|
||||
|
||||
public function createOrUpdateEntity(?OrganizationalUnit $organizationalUnit = null): OrganizationalUnit
|
||||
|
@ -50,6 +60,10 @@ class OrganizationalUnitInput
|
|||
$organizationalUnit->setComments($this->comments);
|
||||
$organizationalUnit->setType($this->type);
|
||||
|
||||
if ($this->networkSettings){
|
||||
$organizationalUnit->setNetworkSettings($this->networkSettings->createOrUpdateEntity($organizationalUnit->getNetworkSettings()));
|
||||
}
|
||||
|
||||
return $organizationalUnit;
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dto\Input;
|
||||
|
||||
use App\Entity\OrganizationalUnit;
|
||||
use App\Model\OrganizationalUnitTypes;
|
||||
|
||||
final class OrganizationalUnitRootInput extends OrganizationalUnitInput
|
||||
{
|
||||
public function __construct(?OrganizationalUnit $organizationalUnit = null)
|
||||
{
|
||||
parent::__construct($organizationalUnit, OrganizationalUnitTypes::ORGANIZATIONAL_UNIT);
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Dto\Output;
|
||||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use App\Entity\Client;
|
||||
use App\Entity\Partition;
|
||||
|
@ -23,16 +24,13 @@ final class ClientOutput extends AbstractOutput
|
|||
public ?OrganizationalUnitOutput $organizationalUnit = null;
|
||||
|
||||
#[Groups(['client:read'])]
|
||||
public ?HardwareProfileOutput $hardwareProfile = null;
|
||||
public array $partitions = [];
|
||||
|
||||
#[Groups(['client:read'])]
|
||||
public ?MenuOutput $menu = null;
|
||||
|
||||
/**
|
||||
* @var Partition[]
|
||||
*/
|
||||
#[Groups(['client:read'])]
|
||||
public array $partitions = [];
|
||||
public ?HardwareProfileOutput $hardwareProfile = null;
|
||||
|
||||
#[Groups(['client:read'])]
|
||||
public \DateTime $createdAt;
|
||||
|
@ -47,19 +45,17 @@ final class ClientOutput extends AbstractOutput
|
|||
$this->name = $client->getName();
|
||||
$this->serialNumber = $client->getSerialNumber();
|
||||
$this->netiface = $client->getNetiface();
|
||||
|
||||
if ($client->getOrganizationalUnit()) {
|
||||
$this->organizationalUnit = new OrganizationalUnitOutput($client->getOrganizationalUnit());
|
||||
}
|
||||
if($client->getHardwareProfile()) {
|
||||
$this->hardwareProfile = new HardwareProfileOutput($client->getHardwareProfile());
|
||||
}
|
||||
if($client->getMenu()) {
|
||||
$this->menu = new MenuOutput($client->getMenu());
|
||||
}
|
||||
|
||||
foreach ($client->getPartitions() as $partition) {
|
||||
$this->partitions[] = new PartitionOutput($partition);
|
||||
}
|
||||
$this->partitions = $client->getPartitions()->map(
|
||||
fn(Partition $partition) => new PartitionOutput($partition)
|
||||
)->toArray();
|
||||
|
||||
$this->menu = $client->getMenu() ? new MenuOutput($client->getMenu()) : null;
|
||||
$this->hardwareProfile = $client->getHardwareProfile() ? new HardwareProfileOutput($client->getHardwareProfile()) : null;
|
||||
|
||||
$this->createdAt = $client->getCreatedAt();
|
||||
$this->createdBy = $client->getCreatedBy();
|
||||
|
|
|
@ -2,10 +2,12 @@
|
|||
|
||||
namespace App\Dto\Output;
|
||||
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use App\Entity\NetworkSettings;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
final class NetworkSettingsOutput
|
||||
#[Get(shortName: 'NetworkSettings')]
|
||||
final class NetworkSettingsOutput extends AbstractOutput
|
||||
{
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
public ?string $proxy = null;
|
||||
|
@ -48,6 +50,8 @@ final class NetworkSettingsOutput
|
|||
|
||||
public function __construct(NetworkSettings $networkSettings)
|
||||
{
|
||||
parent::__construct($networkSettings);
|
||||
|
||||
$this->proxy = $networkSettings->getProxy();
|
||||
$this->dns = $networkSettings->getDns();
|
||||
$this->netmask = $networkSettings->getNetmask();
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace App\Dto\Output;
|
||||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use App\Entity\ClientProperties;
|
||||
use App\Entity\OrganizationalUnit;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
|
@ -25,9 +27,10 @@ final class OrganizationalUnitOutput extends AbstractOutput
|
|||
public string $path;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
public ?NetworkSettingsOutput $networkSettings = null;
|
||||
|
||||
#[Groups(['user:read'])]
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
public array $clients = [];
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
|
||||
namespace App\Dto\Output;
|
||||
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use App\Entity\Partition;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
#[Get(shortName: 'Partition')]
|
||||
class PartitionOutput extends AbstractOutput
|
||||
{
|
||||
#[Groups(['partition:read'])]
|
||||
#[Groups(['partition:read', 'client:read'])]
|
||||
public ?int $diskNumber = null;
|
||||
|
||||
#[Groups(['partition:read'])]
|
||||
|
@ -16,7 +18,7 @@ class PartitionOutput extends AbstractOutput
|
|||
#[Groups(['partition:read'])]
|
||||
public ?string $partitionCode = null;
|
||||
|
||||
#[Groups(['partition:read'])]
|
||||
#[Groups(['partition:read', 'client:read'])]
|
||||
public ?int $size = null;
|
||||
|
||||
#[Groups(['partition:read'])]
|
||||
|
@ -25,12 +27,9 @@ class PartitionOutput extends AbstractOutput
|
|||
#[Groups(['partition:read'])]
|
||||
public ?string $filesystem = null;
|
||||
|
||||
#[Groups(['partition:read'])]
|
||||
#[Groups(['partition:read', 'client:read'])]
|
||||
public ?string $osName = null;
|
||||
|
||||
#[Groups(['partition:read'])]
|
||||
public ?ClientOutput $client = null;
|
||||
|
||||
#[Groups(['partition:read'])]
|
||||
public ?int $memoryUsage = null;
|
||||
|
||||
|
@ -45,7 +44,6 @@ class PartitionOutput extends AbstractOutput
|
|||
$this->cacheContent = $partition->getCacheContent();
|
||||
$this->filesystem = $partition->getFilesystem();
|
||||
$this->osName = $partition->getOsName();
|
||||
$this->client = new ClientOutput($partition->getClient());
|
||||
$this->memoryUsage = $partition->getMemoryUsage() / 100;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,19 +33,18 @@ class Client extends AbstractEntity
|
|||
#[ORM\ManyToOne(inversedBy: 'clients')]
|
||||
private ?OrganizationalUnit $organizationalUnit = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'clients')]
|
||||
private ?HardwareProfile $hardwareProfile = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'clients')]
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?Menu $menu = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Partition>
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'client', targetEntity: Partition::class)]
|
||||
private Collection $partitions;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
private ?Menu $menu = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
private ?HardwareProfile $hardwareProfile = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
@ -136,30 +135,6 @@ class Client extends AbstractEntity
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getHardwareProfile(): ?HardwareProfile
|
||||
{
|
||||
return $this->hardwareProfile;
|
||||
}
|
||||
|
||||
public function setHardwareProfile(?HardwareProfile $hardwareProfile): static
|
||||
{
|
||||
$this->hardwareProfile = $hardwareProfile;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMenu(): ?Menu
|
||||
{
|
||||
return $this->menu;
|
||||
}
|
||||
|
||||
public function setMenu(?Menu $menu): static
|
||||
{
|
||||
$this->menu = $menu;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Partition>
|
||||
*/
|
||||
|
@ -189,4 +164,28 @@ class Client extends AbstractEntity
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMenu(): ?Menu
|
||||
{
|
||||
return $this->menu;
|
||||
}
|
||||
|
||||
public function setMenu(?Menu $menu): static
|
||||
{
|
||||
$this->menu = $menu;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHardwareProfile(): ?HardwareProfile
|
||||
{
|
||||
return $this->hardwareProfile;
|
||||
}
|
||||
|
||||
public function setHardwareProfile(?HardwareProfile $hardwareProfile): static
|
||||
{
|
||||
$this->hardwareProfile = $hardwareProfile;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class HardwareProfile extends AbstractEntity
|
|||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $comments = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'hardwareProfiles')]
|
||||
#[ORM\ManyToOne(targetEntity: OrganizationalUnit::class)]
|
||||
private ?OrganizationalUnit $organizationalUnit = null;
|
||||
|
||||
/**
|
||||
|
|
|
@ -111,7 +111,6 @@ class Menu extends AbstractEntity
|
|||
{
|
||||
if (!$this->clients->contains($client)) {
|
||||
$this->clients->add($client);
|
||||
$client->setMenu($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
|
@ -49,6 +49,17 @@ class NetworkSettings extends AbstractEntity
|
|||
#[ORM\OneToMany(mappedBy: 'networkSettings', targetEntity: OrganizationalUnit::class)]
|
||||
private Collection $organizationalUnits;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Menu::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?Menu $menu = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: HardwareProfile::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?HardwareProfile $hardwareProfile = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?bool $validation = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
@ -222,8 +233,39 @@ class NetworkSettings extends AbstractEntity
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
public function getMenu(): ?Menu
|
||||
{
|
||||
return $this->getId() ? (string) $this->getId() : '';
|
||||
return $this->menu;
|
||||
}
|
||||
|
||||
public function setMenu(?Menu $menu): static
|
||||
{
|
||||
$this->menu = $menu;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHardwareProfile(): ?HardwareProfile
|
||||
{
|
||||
return $this->hardwareProfile;
|
||||
}
|
||||
|
||||
public function setHardwareProfile(?HardwareProfile $hardwareProfile): static
|
||||
{
|
||||
$this->hardwareProfile = $hardwareProfile;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getValidation(): ?bool
|
||||
{
|
||||
return $this->validation;
|
||||
}
|
||||
|
||||
public function setValidation(?bool $validation): static
|
||||
{
|
||||
$this->validation = $validation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class OrganizationalUnit extends AbstractEntity
|
|||
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
|
||||
private Collection $organizationalUnits;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: NetworkSettings::class, inversedBy: 'organizationalUnits')]
|
||||
#[ORM\ManyToOne(targetEntity: NetworkSettings::class, inversedBy: 'organizationalUnits', cascade: ['persist'])]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?NetworkSettings $networkSettings = null;
|
||||
|
||||
|
@ -75,19 +75,12 @@ class OrganizationalUnit extends AbstractEntity
|
|||
#[ORM\Column(nullable: true)]
|
||||
private ?int $capacity = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, HardwareProfile>
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'organizationalUnit', targetEntity: HardwareProfile::class)]
|
||||
private Collection $hardwareProfiles;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->organizationalUnits = new ArrayCollection();
|
||||
$this->users = new ArrayCollection();
|
||||
$this->clients = new ArrayCollection();
|
||||
$this->hardwareProfiles = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
|
@ -319,34 +312,4 @@ class OrganizationalUnit extends AbstractEntity
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, HardwareProfile>
|
||||
*/
|
||||
public function getHardwareProfiles(): Collection
|
||||
{
|
||||
return $this->hardwareProfiles;
|
||||
}
|
||||
|
||||
public function addHardwareProfile(HardwareProfile $hardwareProfile): static
|
||||
{
|
||||
if (!$this->hardwareProfiles->contains($hardwareProfile)) {
|
||||
$this->hardwareProfiles->add($hardwareProfile);
|
||||
$hardwareProfile->setOrganizationalUnit($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeHardwareProfile(HardwareProfile $hardwareProfile): static
|
||||
{
|
||||
if ($this->hardwareProfiles->removeElement($hardwareProfile)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($hardwareProfile->getOrganizationalUnit() === $this) {
|
||||
$hardwareProfile->setOrganizationalUnit(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace App\Factory;
|
||||
|
||||
use App\Entity\Menu;
|
||||
use App\Repository\MenuRepository;
|
||||
use Zenstruck\Foundry\ModelFactory;
|
||||
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
|
||||
use Zenstruck\Foundry\Persistence\Proxy;
|
||||
use Zenstruck\Foundry\Persistence\ProxyRepositoryDecorator;
|
||||
|
||||
/**
|
||||
* @extends PersistentProxyObjectFactory<Menu>
|
||||
*/
|
||||
final class MenuFactory extends ModelFactory
|
||||
{
|
||||
/**
|
||||
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#factories-as-services
|
||||
*
|
||||
* @todo inject services if required
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public static function class(): string
|
||||
{
|
||||
return Menu::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#model-factories
|
||||
*/
|
||||
protected function getDefaults(): array
|
||||
{
|
||||
return [
|
||||
'createdAt' => self::faker()->dateTime(),
|
||||
'name' => self::faker()->text(255),
|
||||
'resolution' => self::faker()->text(255),
|
||||
'title' => self::faker()->text(255),
|
||||
'updatedAt' => self::faker()->dateTime(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization
|
||||
*/
|
||||
protected function initialize(): self
|
||||
{
|
||||
return $this
|
||||
// ->afterInstantiate(function(Menu $menu): void {})
|
||||
;
|
||||
}
|
||||
|
||||
protected static function getClass(): string
|
||||
{
|
||||
return Menu::class;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace App\Factory;
|
||||
|
||||
use App\Entity\Partition;
|
||||
use App\Repository\PartitionRepository;
|
||||
use Zenstruck\Foundry\ModelFactory;
|
||||
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
|
||||
use Zenstruck\Foundry\Persistence\Proxy;
|
||||
use Zenstruck\Foundry\Persistence\ProxyRepositoryDecorator;
|
||||
|
||||
/**
|
||||
* @extends PersistentProxyObjectFactory<Partition>
|
||||
*/
|
||||
final class PartitionFactory extends ModelFactory
|
||||
{
|
||||
/**
|
||||
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#factories-as-services
|
||||
*
|
||||
* @todo inject services if required
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public static function class(): string
|
||||
{
|
||||
return Partition::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#model-factories
|
||||
*
|
||||
* @todo add your default values here
|
||||
*/
|
||||
protected function getDefaults(): array
|
||||
{
|
||||
return [
|
||||
'createdAt' => self::faker()->dateTime(),
|
||||
'memoryUsage' => self::faker()->randomNumber(),
|
||||
'osName' => self::faker()->text(255),
|
||||
'size' => self::faker()->randomNumber(),
|
||||
'updatedAt' => self::faker()->dateTime()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization
|
||||
*/
|
||||
protected function initialize(): self
|
||||
{
|
||||
return $this// ->afterInstantiate(function(Partition $partition): void {})
|
||||
;
|
||||
}
|
||||
|
||||
protected static function getClass(): string
|
||||
{
|
||||
return Partition::class;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\ClientProperties;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<ClientProperties>
|
||||
*/
|
||||
class ClientPropertiesRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, ClientProperties::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return ClientProperties[] Returns an array of ClientProperties objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('c')
|
||||
// ->andWhere('c.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('c.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?ClientProperties
|
||||
// {
|
||||
// return $this->createQueryBuilder('c')
|
||||
// ->andWhere('c.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
|
@ -26,7 +26,7 @@ class ClientProcessor implements ProcessorInterface
|
|||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): ClientOutput
|
||||
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): ClientOutput|null
|
||||
{
|
||||
switch ($operation){
|
||||
case $operation instanceof Post:
|
||||
|
|
|
@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Post;
|
|||
use ApiPlatform\Metadata\Put;
|
||||
use ApiPlatform\State\ProcessorInterface;
|
||||
use ApiPlatform\Validator\ValidatorInterface;
|
||||
use App\Dto\Input\MenuInput;
|
||||
use App\Dto\Input\OrganizationalUnitClassroomGroupInput;
|
||||
use App\Dto\Input\OrganizationalUnitClassroomInput;
|
||||
use App\Dto\Input\OrganizationalUnitClientGroupInput;
|
||||
|
@ -48,16 +49,8 @@ class OrganizationalUnitProcessor implements ProcessorInterface
|
|||
*/
|
||||
private function processCreateOrUpdate($data, Operation $operation, array $uriVariables = [], array $context = []): OrganizationalUnitOutput
|
||||
{
|
||||
if (!($data instanceof OrganizationalUnitRootInput) &&
|
||||
!($data instanceof OrganizationalUnitClassroomInput) &&
|
||||
!($data instanceof OrganizationalUnitClientGroupInput) &&
|
||||
!($data instanceof OrganizationalUnitClassroomGroupInput)) {
|
||||
throw new \Exception(sprintf('data is not an instance of %s, %s, %s, or %s',
|
||||
OrganizationalUnitRootInput::class,
|
||||
OrganizationalUnitClassroomInput::class,
|
||||
OrganizationalUnitInput::class,
|
||||
OrganizationalUnitClassroomGroupInput::class
|
||||
));
|
||||
if (!($data instanceof OrganizationalUnitInput)) {
|
||||
throw new \Exception(sprintf('data is not instance of %s', OrganizationalUnitInput::class));
|
||||
}
|
||||
|
||||
$entity = null;
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace App\State\Provider;
|
||||
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\Metadata\Patch;
|
||||
use ApiPlatform\Metadata\Put;
|
||||
use ApiPlatform\State\Pagination\TraversablePaginator;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
use App\Dto\Input\ClientInput;
|
||||
use App\Dto\Input\HardwareInput;
|
||||
use App\Dto\Output\ClientOutput;
|
||||
use App\Dto\Output\HardwareOutput;
|
||||
use App\Dto\Output\NetworkSettingsOutput;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class NetworkSettingsProvider implements ProviderInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ProviderInterface $collectionProvider,
|
||||
private readonly ProviderInterface $itemProvider
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
|
||||
{
|
||||
switch ($operation){
|
||||
case $operation instanceof GetCollection:
|
||||
return $this->provideCollection($operation, $uriVariables, $context);
|
||||
case $operation instanceof Get:
|
||||
return $this->provideItem($operation, $uriVariables, $context);
|
||||
}
|
||||
}
|
||||
|
||||
private function provideCollection(Operation $operation, array $uriVariables = [], array $context = []): object
|
||||
{
|
||||
$paginator = $this->collectionProvider->provide($operation, $uriVariables, $context);
|
||||
|
||||
$items = new \ArrayObject();
|
||||
foreach ($paginator->getIterator() as $item){
|
||||
$items[] = new NetworkSettingsOutput($item);
|
||||
}
|
||||
|
||||
return new TraversablePaginator($items, $paginator->getCurrentPage(), $paginator->getItemsPerPage(), $paginator->getTotalItems());
|
||||
}
|
||||
|
||||
public function provideItem(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
|
||||
{
|
||||
$item = $this->itemProvider->provide($operation, $uriVariables, $context);
|
||||
|
||||
if (!$item) {
|
||||
throw new NotFoundHttpException('Hardware not found');
|
||||
}
|
||||
|
||||
return new NetworkSettingsOutput($item);
|
||||
}
|
||||
|
||||
}
|
|
@ -14,6 +14,7 @@ use App\Dto\Input\OrganizationalUnitClassroomInput;
|
|||
use App\Dto\Input\OrganizationalUnitClientGroupInput;
|
||||
use App\Dto\Input\OrganizationalUnitInput;
|
||||
use App\Dto\Input\OrganizationalUnitRootInput;
|
||||
use App\Dto\Input\PartitionInput;
|
||||
use App\Dto\Input\UserGroupInput;
|
||||
use App\Dto\Output\OrganizationalUnitOutput;
|
||||
use App\Entity\OrganizationalUnit;
|
||||
|
@ -67,28 +68,12 @@ class OrganizationalUnitProvider implements ProviderInterface
|
|||
|
||||
public function provideInput(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
|
||||
{
|
||||
$input = null;
|
||||
|
||||
if (isset($uriVariables['uuid'])) {
|
||||
$item = $this->itemProvider->provide($operation, $uriVariables, $context);
|
||||
|
||||
if ( $item !== null ) {
|
||||
switch ($item->getType()) {
|
||||
case OrganizationalUnitTypes::ORGANIZATIONAL_UNIT:
|
||||
$input = new OrganizationalUnitRootInput($item);
|
||||
break;
|
||||
case OrganizationalUnitTypes::CLASSROOMS_GROUP:
|
||||
$input = new OrganizationalUnitClassroomGroupInput($item);
|
||||
break;
|
||||
case OrganizationalUnitTypes::CLIENTS_GROUP:
|
||||
$input = new OrganizationalUnitClientGroupInput($item);
|
||||
break;
|
||||
case OrganizationalUnitTypes::CLASSROOM;
|
||||
$input = new OrganizationalUnitClassroomInput($item);
|
||||
}
|
||||
return $item !== null ? new OrganizationalUnitInput($item) : null;
|
||||
}
|
||||
|
||||
return $input;
|
||||
}
|
||||
return new OrganizationalUnitInput();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Functional;
|
|||
use App\Entity\Client;
|
||||
use App\Entity\HardwareProfile;
|
||||
use App\Entity\OrganizationalUnit;
|
||||
use App\Entity\User;
|
||||
use App\Entity\UserGroup;
|
||||
use App\Factory\ClientFactory;
|
||||
use App\Factory\HardwareProfileFactory;
|
||||
|
@ -93,11 +94,14 @@ class ClientTest extends AbstractTest
|
|||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
*/
|
||||
public function testUpdateUserGroup(): void
|
||||
public function testUpdateClient(): void
|
||||
{
|
||||
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||
|
||||
ClientFactory::createOne(['name' => self::CLIENT_UPDATE, 'serialNumber' => '123abc']);
|
||||
$ou = OrganizationalUnitFactory::createOne(['type' => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT]);
|
||||
$hp = HardwareProfileFactory::createOne(['description' => self::HW_PROFILE]);
|
||||
|
||||
ClientFactory::createOne(['name' => self::CLIENT_UPDATE, 'serialNumber' => '123abc', 'organizationalUnit' => $ou, 'hardwareProfile' => $hp]);
|
||||
$iri = $this->findIriBy(Client::class, ['name' => self::CLIENT_UPDATE]);
|
||||
|
||||
$this->createClientWithCredentials()->request('PUT', $iri, ['json' => [
|
||||
|
@ -112,4 +116,30 @@ class ClientTest extends AbstractTest
|
|||
'serialNumber' => '987zyx'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws DecodingExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function testDeleteClient(): void
|
||||
{
|
||||
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||
|
||||
$ou = OrganizationalUnitFactory::createOne(['type' => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT]);
|
||||
$hp = HardwareProfileFactory::createOne(['description' => self::HW_PROFILE]);
|
||||
|
||||
ClientFactory::createOne(['name' => self::CLIENT_DELETE, 'serialNumber' => '123abc', 'organizationalUnit' => $ou, 'hardwareProfile' => $hp]);
|
||||
$iri = $this->findIriBy(Client::class, ['name' => self::CLIENT_DELETE]);
|
||||
|
||||
$this->createClientWithCredentials()->request('DELETE', $iri);
|
||||
$this->assertResponseStatusCodeSame(204);
|
||||
$this->assertNull(
|
||||
static::getContainer()->get('doctrine')->getRepository(Client::class)->findOneBy(['name' => self::CLIENT_DELETE])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
|
||||
namespace Functional;
|
||||
|
||||
use App\Entity\Client;
|
||||
use App\Entity\HardwareProfile;
|
||||
use App\Entity\Menu;
|
||||
use App\Entity\OrganizationalUnit;
|
||||
use App\Entity\User;
|
||||
use App\Factory\ClientFactory;
|
||||
use App\Factory\HardwareProfileFactory;
|
||||
use App\Factory\MenuFactory;
|
||||
use App\Factory\OrganizationalUnitFactory;
|
||||
use App\Factory\UserFactory;
|
||||
use App\Model\OrganizationalUnitTypes;
|
||||
use App\Model\UserGroupPermissions;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
|
||||
class MenuTest extends AbstractTest
|
||||
{
|
||||
CONST string USER_ADMIN = 'ogadmin';
|
||||
CONST string MENU_CREATE = 'test-menu-create';
|
||||
CONST string MENU_UPDATE = 'test-menu-update';
|
||||
CONST string MENU_DELETE = 'test-menu-delete';
|
||||
|
||||
/**
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws DecodingExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
*/
|
||||
public function testGetCollectionMenus(): void
|
||||
{
|
||||
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||
|
||||
MenuFactory::createMany(10);
|
||||
|
||||
$this->createClientWithCredentials()->request('GET', '/menus');
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
|
||||
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
|
||||
$this->assertJsonContains([
|
||||
'@context' => '/contexts/Menu',
|
||||
'@id' => '/menus',
|
||||
'@type' => 'hydra:Collection',
|
||||
'hydra:totalItems' => 10,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws DecodingExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
*/
|
||||
public function testCreateMenu(): void
|
||||
{
|
||||
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||
|
||||
$this->createClientWithCredentials()->request('POST', '/menus',['json' => [
|
||||
'name' => self::MENU_CREATE,
|
||||
'title' => self::MENU_CREATE,
|
||||
'resolution' => "1920x1080",
|
||||
]]);
|
||||
|
||||
$this->assertResponseStatusCodeSame(201);
|
||||
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
|
||||
$this->assertJsonContains([
|
||||
'@context' => '/contexts/MenuOutput',
|
||||
'@type' => 'Menu',
|
||||
'name' => self::MENU_CREATE,
|
||||
'title' => self::MENU_CREATE,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws DecodingExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
*/
|
||||
public function testUpdateMenu(): void
|
||||
{
|
||||
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||
|
||||
MenuFactory::createOne(['name' => self::MENU_UPDATE, 'title' => self::MENU_UPDATE, 'resolution' => "1920x1080"]);
|
||||
$iri = $this->findIriBy(Menu::class, ['name' => self::MENU_UPDATE]);
|
||||
|
||||
$this->createClientWithCredentials()->request('PUT', $iri, ['json' => [
|
||||
'name' => self::MENU_UPDATE,
|
||||
'resolution' => '1080x768'
|
||||
]]);
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
$this->assertJsonContains([
|
||||
'@id' => $iri,
|
||||
'name' => self::MENU_UPDATE,
|
||||
'resolution' => '1080x768'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws DecodingExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function testDeleteMenu(): void
|
||||
{
|
||||
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||
|
||||
MenuFactory::createOne(['name' => self::MENU_DELETE, 'title' => self::MENU_DELETE, 'resolution' => "1920x1080"]);
|
||||
$iri = $this->findIriBy(Menu::class, ['name' => self::MENU_DELETE]);
|
||||
|
||||
$this->createClientWithCredentials()->request('DELETE', $iri);
|
||||
$this->assertResponseStatusCodeSame(204);
|
||||
$this->assertNull(
|
||||
static::getContainer()->get('doctrine')->getRepository(Menu::class)->findOneBy(['name' => self::MENU_DELETE])
|
||||
);
|
||||
}
|
||||
}
|
|
@ -56,12 +56,13 @@ class OrganizationalUnitTest extends AbstractTest
|
|||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
*/
|
||||
public function testCreateOrganizationalUnitRoot(): void
|
||||
public function testCreateOrganizationalUnit(): void
|
||||
{
|
||||
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||
|
||||
$this->createClientWithCredentials()->request('POST', '/organizational-units/root',['json' => [
|
||||
$this->createClientWithCredentials()->request('POST', '/organizational-units',['json' => [
|
||||
'name' => self::ORGANIZATIONAL_UNIT_CREATE,
|
||||
'type' => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT,
|
||||
]]);
|
||||
|
||||
$this->assertResponseStatusCodeSame(201);
|
||||
|
@ -74,81 +75,6 @@ class OrganizationalUnitTest extends AbstractTest
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws DecodingExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
*/
|
||||
public function testCreateOrganizationalUnitClassroomGroup(): void
|
||||
{
|
||||
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||
|
||||
$this->createClientWithCredentials()->request('POST', '/organizational-units/classroom-group',['json' => [
|
||||
'name' => self::ORGANIZATIONAL_UNIT_CREATE,
|
||||
]]);
|
||||
|
||||
$this->assertResponseStatusCodeSame(201);
|
||||
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
|
||||
$this->assertJsonContains([
|
||||
'@context' => '/contexts/OrganizationalUnitOutput',
|
||||
'@type' => 'OrganizationalUnit',
|
||||
'name' => self::ORGANIZATIONAL_UNIT_CREATE,
|
||||
'type' => OrganizationalUnitTypes::CLASSROOMS_GROUP,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws DecodingExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
*/
|
||||
public function testCreateOrganizationalUnitClassroom(): void
|
||||
{
|
||||
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||
|
||||
$this->createClientWithCredentials()->request('POST', '/organizational-units/classroom',['json' => [
|
||||
'name' => self::ORGANIZATIONAL_UNIT_CREATE,
|
||||
]]);
|
||||
|
||||
$this->assertResponseStatusCodeSame(201);
|
||||
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
|
||||
$this->assertJsonContains([
|
||||
'@context' => '/contexts/OrganizationalUnitOutput',
|
||||
'@type' => 'OrganizationalUnit',
|
||||
'name' => self::ORGANIZATIONAL_UNIT_CREATE,
|
||||
'type' => OrganizationalUnitTypes::CLASSROOM,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws DecodingExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
*/
|
||||
public function testCreateOrganizationalUnitClientGroup(): void
|
||||
{
|
||||
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||
|
||||
$this->createClientWithCredentials()->request('POST', '/organizational-units/client-group',['json' => [
|
||||
'name' => self::ORGANIZATIONAL_UNIT_CREATE,
|
||||
]]);
|
||||
|
||||
$this->assertResponseStatusCodeSame(201);
|
||||
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
|
||||
$this->assertJsonContains([
|
||||
'@context' => '/contexts/OrganizationalUnitOutput',
|
||||
'@type' => 'OrganizationalUnit',
|
||||
'name' => self::ORGANIZATIONAL_UNIT_CREATE,
|
||||
'type' => OrganizationalUnitTypes::CLIENTS_GROUP,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws DecodingExceptionInterface
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace Functional;
|
||||
|
||||
use App\Factory\MenuFactory;
|
||||
use App\Factory\PartitionFactory;
|
||||
use App\Factory\UserFactory;
|
||||
use App\Model\UserGroupPermissions;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
|
||||
class PartitionTest extends AbstractTest
|
||||
{
|
||||
CONST string USER_ADMIN = 'ogadmin';
|
||||
CONST string PARTITION_CREATE = 'test-partition-create';
|
||||
CONST string PARTITION_UPDATE = 'test-partition-update';
|
||||
CONST string PARTITION_DELETE = 'test-partition-delete';
|
||||
|
||||
/**
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws DecodingExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
*/
|
||||
public function testGetCollectionPartitions(): void
|
||||
{
|
||||
UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]);
|
||||
|
||||
PartitionFactory::createMany(10);
|
||||
|
||||
$this->createClientWithCredentials()->request('GET', '/partitions');
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
|
||||
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
|
||||
$this->assertJsonContains([
|
||||
'@context' => '/contexts/Partition',
|
||||
'@id' => '/partitions',
|
||||
'@type' => 'hydra:Collection',
|
||||
'hydra:totalItems' => 10,
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue