From 5173dc81f09afb4a7fa400dfd8b71ce0b91d3453 Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Thu, 17 Oct 2024 09:04:34 +0200 Subject: [PATCH] refs #955. New database fields --- config/api_platform/SoftwareProfile.yaml | 1 + config/services/api_platform.yaml | 24 +++++++++++++ ...grateSoftwareAndSoftwareProfileCommand.php | 4 +-- src/Dto/Input/PartitionArrayInput.php | 20 +++++++++++ src/Dto/Output/OperativeSystemOutput.php | 10 +++++- src/Dto/Output/SoftwareOutput.php | 2 +- src/Dto/Output/SoftwareProfileOutput.php | 8 +++++ src/OpenApi/OpenApiFactory.php | 35 ++++++++++++++++++- .../Processor/OrganizationalUnitProcessor.php | 4 --- .../Provider/SoftwareProfileProvider.php | 2 +- 10 files changed, 100 insertions(+), 10 deletions(-) create mode 100644 src/Dto/Input/PartitionArrayInput.php diff --git a/config/api_platform/SoftwareProfile.yaml b/config/api_platform/SoftwareProfile.yaml index f5c544c..b969510 100644 --- a/config/api_platform/SoftwareProfile.yaml +++ b/config/api_platform/SoftwareProfile.yaml @@ -13,6 +13,7 @@ resources: filters: - 'api_platform.filter.software.order' - 'api_platform.filter.software.search' + ApiPlatform\Metadata\Get: provider: App\State\Provider\SoftwareProfileProvider ApiPlatform\Metadata\Put: diff --git a/config/services/api_platform.yaml b/config/services/api_platform.yaml index 19567b8..395822c 100644 --- a/config/services/api_platform.yaml +++ b/config/services/api_platform.yaml @@ -86,6 +86,18 @@ services: arguments: [ { 'id': 'exact', 'name': 'exact', 'title': 'exact' } ] tags: [ 'api_platform.filter' ] + api_platform.filter.operative_system.order: + parent: 'api_platform.doctrine.orm.order_filter' + arguments: + $properties: { 'id': ~, 'name': ~ } + $orderParameterName: 'order' + tags: [ 'api_platform.filter' ] + + api_platform.filter.operative_system.search: + parent: 'api_platform.doctrine.orm.search_filter' + arguments: [ { 'id': 'exact', 'name': 'partial' } ] + tags: [ 'api_platform.filter' ] + api_platform.filter.organizational_unit.order: parent: 'api_platform.doctrine.orm.order_filter' arguments: @@ -149,6 +161,18 @@ services: arguments: [ { 'id': 'exact', 'name': 'partial', } ] tags: [ 'api_platform.filter' ] + api_platform.filter.software.order: + parent: 'api_platform.doctrine.orm.order_filter' + arguments: + $properties: { 'id': ~, 'name': ~ } + $orderParameterName: 'order' + tags: [ 'api_platform.filter' ] + + api_platform.filter.software.search: + parent: 'api_platform.doctrine.orm.search_filter' + arguments: [ { 'id': 'exact', 'name': 'partial', type: 'exact'} ] + tags: [ 'api_platform.filter' ] + api_platform.filter.subnet.order: parent: 'api_platform.doctrine.orm.order_filter' arguments: diff --git a/src/Command/Migration/MigrateSoftwareAndSoftwareProfileCommand.php b/src/Command/Migration/MigrateSoftwareAndSoftwareProfileCommand.php index a7c239b..8439278 100644 --- a/src/Command/Migration/MigrateSoftwareAndSoftwareProfileCommand.php +++ b/src/Command/Migration/MigrateSoftwareAndSoftwareProfileCommand.php @@ -142,10 +142,10 @@ class MigrateSoftwareAndSoftwareProfileCommand extends Command $output->writeln("PERFILES SOFTWARE RELACIONES TOTAL: ". count($softwareProfileRelations)); foreach ($softwareProfileRelations as $softwareProfileRelation){ $softwareProfileEntity = $softwareProfileRepository->findOneBy(['migrationId' => $softwareProfileRelation['idperfilsoft']]); - $softwareEntity = $softwareProfileRepository->findOneBy(['migrationId' => $softwareProfileRelation['idsoftware']]); + $softwareEntity = $softwareRepository->findOneBy(['migrationId' => $softwareProfileRelation['idsoftware']]); if ($softwareProfileEntity && $softwareEntity){ - $softwareProfileEntity->addHardwareCollection($softwareEntity); + $softwareProfileEntity->addSoftwareCollection($softwareEntity); $this->entityManager->persist($softwareProfileEntity); } } diff --git a/src/Dto/Input/PartitionArrayInput.php b/src/Dto/Input/PartitionArrayInput.php new file mode 100644 index 0000000..f4303d7 --- /dev/null +++ b/src/Dto/Input/PartitionArrayInput.php @@ -0,0 +1,20 @@ +name = $operativeSystem->getName(); + $this->createdAt = $operativeSystem->getCreatedAt(); + $this->createdBy = $operativeSystem->getCreatedBy(); } } \ No newline at end of file diff --git a/src/Dto/Output/SoftwareOutput.php b/src/Dto/Output/SoftwareOutput.php index 3c75152..20da642 100644 --- a/src/Dto/Output/SoftwareOutput.php +++ b/src/Dto/Output/SoftwareOutput.php @@ -16,7 +16,7 @@ final class SoftwareOutput extends AbstractOutput #[Groups(['software:read'])] public ?string $description = ''; - #[Groups(['software:read'])] + #[Groups(['software:read', 'software-profile:read'])] public ?string $type = ''; #[Groups(['software:read'])] diff --git a/src/Dto/Output/SoftwareProfileOutput.php b/src/Dto/Output/SoftwareProfileOutput.php index 5dc21e0..e306127 100644 --- a/src/Dto/Output/SoftwareProfileOutput.php +++ b/src/Dto/Output/SoftwareProfileOutput.php @@ -20,6 +20,9 @@ final class SoftwareProfileOutput extends AbstractOutput #[Groups(['software-profile:read'])] public ?OrganizationalUnitOutput $organizationalUnit = null; + #[Groups(['software-profile:read'])] + public ?OperativeSystemOutput $operativeSystem = null; + #[Groups(['software-profile:read'])] public ?array $softwareCollection = []; @@ -35,10 +38,15 @@ final class SoftwareProfileOutput extends AbstractOutput $this->description = $softwareProfile->getDescription(); $this->comments = $softwareProfile->getComments(); + if($softwareProfile->getOrganizationalUnit()) { $this->organizationalUnit = new OrganizationalUnitOutput($softwareProfile->getOrganizationalUnit()); } + if ($softwareProfile->getOperativeSystem()) { + $this->operativeSystem = new OperativeSystemOutput($softwareProfile->getOperativeSystem()); + } + $this->softwareCollection = $softwareProfile->getSoftwareCollection()->map( fn(Software $hardware) => new SoftwareOutput($hardware) )->toArray(); diff --git a/src/OpenApi/OpenApiFactory.php b/src/OpenApi/OpenApiFactory.php index eb23de8..2f4935e 100644 --- a/src/OpenApi/OpenApiFactory.php +++ b/src/OpenApi/OpenApiFactory.php @@ -316,7 +316,40 @@ final readonly class OpenApiFactory implements OpenApiFactoryInterface 'description' => 'Success', 'content' => [ 'application/json' => [ - 'schema' => ['$ref' => '#/components/schemas/InclusionClienteRes'], + 'schema' => [ + 'type' => 'object', + 'properties' => [ + 'res' => [ + 'type' => 'integer', + 'example' => 1, + ], + 'ido' => [ + 'type' => 'integer', + 'example' => 1, + ], + 'npc' => [ + 'type' => 'string', + 'example' => 'Nombre del cliente', + ], + 'che' => [ + 'type' => 'integer', + 'example' => 1, + ], + 'exe' => [ + 'type' => 'integer', + 'example' => 42, + ], + 'ida' => [ + 'type' => 'integer', + 'example' => 1, + ], + 'idc' => [ + 'type' => 'integer', + 'example' => 1, + ], + ], + 'required' => ['res', 'ido', 'npc', 'che', 'exe', 'ida', 'idc'], + ], ], ], ], diff --git a/src/State/Processor/OrganizationalUnitProcessor.php b/src/State/Processor/OrganizationalUnitProcessor.php index 468e410..e4d2244 100644 --- a/src/State/Processor/OrganizationalUnitProcessor.php +++ b/src/State/Processor/OrganizationalUnitProcessor.php @@ -11,11 +11,7 @@ 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; -use App\Dto\Input\OrganizationalUnitClientGroupInput; use App\Dto\Input\OrganizationalUnitInput; -use App\Dto\Input\OrganizationalUnitRootInput; use App\Dto\Output\OrganizationalUnitOutput; use App\Repository\OrganizationalUnitRepository; use App\Service\ChangeClientNetworkSettingsService; diff --git a/src/State/Provider/SoftwareProfileProvider.php b/src/State/Provider/SoftwareProfileProvider.php index 94f9aed..8d34140 100644 --- a/src/State/Provider/SoftwareProfileProvider.php +++ b/src/State/Provider/SoftwareProfileProvider.php @@ -41,7 +41,7 @@ readonly class SoftwareProfileProvider implements ProviderInterface $items = new \ArrayObject(); foreach ($paginator->getIterator() as $item){ - $items[] = new SoftwareProfileInput($item); + $items[] = new SoftwareProfileOutput($item); } return new TraversablePaginator($items, $paginator->getCurrentPage(), $paginator->getItemsPerPage(), $paginator->getTotalItems());