refs #955. New database fields
testing/ogcore-api/pipeline/head This commit looks good Details

develop-jenkins
Manuel Aranda Rosales 2024-10-17 09:04:34 +02:00
parent d5e36c6657
commit 5173dc81f0
10 changed files with 100 additions and 10 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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);
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace App\Dto\Input;
use ApiPlatform\Metadata\ApiProperty;
use App\Dto\Output\ClientOutput;
use App\Dto\Output\ImageOutput;
use App\Dto\Output\OperativeSystemOutput;
use App\Entity\Partition;
use Symfony\Component\Serializer\Annotation\Groups;
class PartitionArrayInput
{
/**
* @var PartitionInput[]
*/
#[Groups(['partition:write'])]
#[ApiProperty(description: 'The partitions of the client', example: "[{diskNumber: 1, partitionNumber: 1, partitionCode: 'code', size: 100, cacheContent: 'cache content', filesystem: 'filesystem', operativeSystem: {name: 'Ubuntu'}, client: {name: 'client'}, memoryUsage: 100, image: {name: 'image'}}]")]
public ?array $partitions = [];
}

View File

@ -9,13 +9,21 @@ use Symfony\Component\Serializer\Annotation\Groups;
#[Get(shortName: 'OperativeSystem')]
final class OperativeSystemOutput extends AbstractOutput
{
#[Groups(['operative-system:read', 'partition:read'])]
#[Groups(['operative-system:read', 'partition:read', 'software-profile:read'])]
public string $name;
#[Groups(['operative-system:read'])]
public \DateTime $createdAt;
#[Groups(['operative-system:read'])]
public ?string $createdBy = null;
public function __construct(OperativeSystem $operativeSystem)
{
parent::__construct($operativeSystem);
$this->name = $operativeSystem->getName();
$this->createdAt = $operativeSystem->getCreatedAt();
$this->createdBy = $operativeSystem->getCreatedBy();
}
}

View File

@ -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'])]

View File

@ -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();

View File

@ -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'],
],
],
],
],

View File

@ -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;

View File

@ -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());