Updated command script migration
testing/ogcore-api/pipeline/head This commit looks good Details

develop-jenkins
Manuel Aranda Rosales 2024-10-07 11:30:44 +02:00
parent cdfab436d8
commit ea35ddd1e4
7 changed files with 22 additions and 6 deletions

View File

@ -129,8 +129,12 @@ Una vez tengamos la base de datos cargada, podremos ejecutar las migraciones de
```sh
--- Migraciones de OpenGnsys. ---
Proximamente
```
docker exec ogcore-php php bin/console opengnsys:migration:organizational-unit #cargamos las unidades organizativas
docker exec ogcore-php php bin/console opengnsys:migration:hardware-profile #cargamos los perfiles de hardware
docker exec ogcore-php php bin/console opengnsys:migration:clients #cargamos los clientes
docker exec ogcore-php php bin/console opengnsys:migration:os #cargamos los sistemas operativos
docker exec ogcore-php php bin/console opengnsys:migration:partition #cargamos las particiones
```
## Objetos de interés

View File

@ -13,6 +13,7 @@ resources:
filters:
- 'api_platform.filter.organizational_unit.order'
- 'api_platform.filter.organizational_unit.search'
- 'api_platform.filter.organizational_unit.group_filter'
ApiPlatform\Metadata\Get:
security: 'is_granted("ORGANIZATIONAL_UNIT_VIEW", object)'

View File

@ -93,6 +93,11 @@ services:
arguments: [ { id: 'exact', name: 'partial', type: 'exact', parent.id: 'exact'} ]
tags: [ 'api_platform.filter' ]
api_platform.filter.organizational_unit.group_filter:
parent: 'api_platform.serializer.group_filter'
arguments: [ 'groups', true, ['organizational-unit:read:collection:short'] ]
tags: [ 'api_platform.filter' ]
api_platform.filter.partition.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:

View File

@ -79,6 +79,7 @@ class LoadDefaultCommandsCommand extends Command
foreach ($commands as $command) {
$entity = new \App\Entity\Command();
$entity->setName($command['name']);
$entity->setScript('');
$entity->setEnabled($command['enabled']);
$entity->setReadOnly($command['readOnly']);

View File

@ -6,6 +6,7 @@ use App\Entity\Hardware;
use App\Entity\HardwareProfile;
use App\Entity\HardwareType;
use App\Entity\OrganizationalUnit;
use App\Model\OrganizationalUnitTypes;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\Persistence\ManagerRegistry;
@ -118,7 +119,11 @@ class MigrateHardwareAndHardwareProfileCommand extends Command
$hardwareProfileEntity->setComments($hardwareProfile['perfilhard.comentarios']);
}
$migrationId = $hardwareProfile['perfilhard.grupoid'] === 0 ? $hardwareProfile['perfilhard.idcentro'] : $hardwareProfile['perfilhard.grupoid'];
$migrationId = match ($hardwareProfile['perfilhard.grupoid']) {
0 => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT . '-' . $hardwareProfile['perfilhard.idcentro'],
default => OrganizationalUnitTypes::CLASSROOMS_GROUP . '-' . $hardwareProfile['perfilhard.grupoid'],
};
$organizationalUnit = $organizationalUnitRepository->findOneBy(['migrationId' => $migrationId]);
if ($organizationalUnit){

View File

@ -14,7 +14,7 @@ abstract class AbstractOutput
public UuidInterface $uuid;
#[ApiProperty(identifier: false)]
#[Groups('default')]
#[Groups(groups: ['default', 'organizational-unit:read:collection:short'])]
public int $id;
public function __construct(private readonly AbstractEntity $entity)

View File

@ -11,7 +11,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
#[Get(shortName: 'OrganizationalUnit')]
final class OrganizationalUnitOutput extends AbstractOutput
{
#[Groups(['organizational-unit:read', "client:read", "user:read"])]
#[Groups(['organizational-unit:read', "client:read", "user:read", 'organizational-unit:read:collection:short'])]
public string $name;
#[Groups(['organizational-unit:read'])]
@ -38,7 +38,7 @@ final class OrganizationalUnitOutput extends AbstractOutput
#[Groups(['organizational-unit:read'])]
public ?self $parent = null;
#[Groups(['organizational-unit:read'])]
#[Groups(['organizational-unit:read', 'organizational-unit:read:collection:short'])]
public string $path;
#[Groups(['organizational-unit:read', "client:read"])]