develop-jenkins
parent
179f36ebef
commit
c14002e220
|
@ -32,7 +32,7 @@ services:
|
|||
|
||||
api_platform.filter.command.search:
|
||||
parent: 'api_platform.doctrine.orm.search_filter'
|
||||
arguments: [ { 'id': 'exact', 'name': 'exact'} ]
|
||||
arguments: [ { 'id': 'exact', 'name': 'partial'} ]
|
||||
tags: [ 'api_platform.filter' ]
|
||||
|
||||
api_platform.filter.command.boolean:
|
||||
|
@ -139,6 +139,18 @@ services:
|
|||
arguments: [ { 'id': 'exact', 'name': 'partial', } ]
|
||||
tags: [ 'api_platform.filter' ]
|
||||
|
||||
api_platform.filter.trace.search:
|
||||
parent: 'api_platform.doctrine.orm.search_filter'
|
||||
arguments: [ { 'id': 'exact', 'command.id': 'exact', 'client.id': 'exact' } ]
|
||||
tags: [ 'api_platform.filter' ]
|
||||
|
||||
api_platform.filter.trace.order:
|
||||
parent: 'api_platform.doctrine.orm.order_filter'
|
||||
arguments:
|
||||
$properties: { 'id': ~, 'command': ~ }
|
||||
$orderParameterName: 'order'
|
||||
tags: [ 'api_platform.filter' ]
|
||||
|
||||
api_platform.filter.user.order:
|
||||
parent: 'api_platform.doctrine.orm.order_filter'
|
||||
arguments:
|
||||
|
|
|
@ -59,7 +59,7 @@ final class OrganizationalUnitOutput extends AbstractOutput
|
|||
public ?bool $remotePc = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
public ?bool $reserved = null;
|
||||
public ?bool $available = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
public \DateTime $createdAt;
|
||||
|
@ -80,7 +80,7 @@ final class OrganizationalUnitOutput extends AbstractOutput
|
|||
$this->capacity = $organizationalUnit->getCapacity();
|
||||
$this->type = $organizationalUnit->getType();
|
||||
$this->remotePc = $organizationalUnit->isRemotePc();
|
||||
$this->reserved = $organizationalUnit->isReserved();
|
||||
$this->available = $organizationalUnit->getRemoteCalendar() && $organizationalUnit->getRemoteCalendar()->isAvailable();
|
||||
$this->networkSettings = $organizationalUnit->getNetworkSettings() ? new NetworkSettingsOutput($organizationalUnit->getNetworkSettings()) : null;
|
||||
$this->remoteCalendar = $organizationalUnit->getRemoteCalendar() ? new RemoteCalendarOutput($organizationalUnit->getRemoteCalendar()) : null;
|
||||
if ($organizationalUnit->getParent()) {
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\CommandTask;
|
||||
use App\Entity\Trace;
|
||||
use App\Model\TraceStatus;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
readonly class CreateTraceService
|
||||
{
|
||||
public function __construct(
|
||||
private EntityManagerInterface $entityManager
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
public function __invoke(CommandTask $commandTask): void
|
||||
{
|
||||
foreach ($commandTask->getCommands() as $command) {
|
||||
foreach ($commandTask->getClients() as $client) {
|
||||
$trace = new Trace();
|
||||
$trace->setClient($client);
|
||||
$trace->setCommand($command);
|
||||
$trace->setStatus(TraceStatus::PENDING);
|
||||
$trace->setExecutedAt($commandTask->getDatetime());
|
||||
$this->entityManager->persist($trace);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($commandTask->getCommandGroups() as $commandGroup) {
|
||||
foreach ($commandTask->getCommands() as $command) {
|
||||
foreach ($commandTask->getClients() as $client) {
|
||||
$trace = new Trace();
|
||||
$trace->setClient($client);
|
||||
$trace->setCommand($command);
|
||||
$trace->setStatus(TraceStatus::PENDING);
|
||||
$trace->setExecutedAt($commandTask->getDatetime());
|
||||
$this->entityManager->persist($trace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
}
|
|
@ -149,8 +149,7 @@ class UDSClient
|
|||
}
|
||||
|
||||
$remoteCalendar = $organizationalUnit->getRemoteCalendar();
|
||||
$aux = $remoteCalendar->isAvailable();
|
||||
if (!$remoteCalendar || !$aux) {
|
||||
if (!$remoteCalendar || !$remoteCalendar->isAvailable()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,12 +12,14 @@ use ApiPlatform\Validator\ValidatorInterface;
|
|||
use App\Dto\Input\CommandTaskInput;
|
||||
use App\Dto\Output\CommandTaskOutput;
|
||||
use App\Repository\CommandTaskRepository;
|
||||
use App\Service\CreateTraceService;
|
||||
|
||||
readonly class CommandTaskProcessor implements ProcessorInterface
|
||||
{
|
||||
public function __construct(
|
||||
private CommandTaskRepository $commandTaskRepository,
|
||||
private ValidatorInterface $validator
|
||||
private ValidatorInterface $validator,
|
||||
private CreateTraceService $createTraceService
|
||||
)
|
||||
{
|
||||
}
|
||||
|
@ -51,11 +53,12 @@ readonly class CommandTaskProcessor implements ProcessorInterface
|
|||
$entity = $this->commandTaskRepository->findOneByUuid($uriVariables['uuid']);
|
||||
}
|
||||
|
||||
$command = $data->createOrUpdateEntity($entity);
|
||||
$this->validator->validate($command);
|
||||
$this->commandTaskRepository->save($command);
|
||||
$task = $data->createOrUpdateEntity($entity);
|
||||
$this->validator->validate($task);
|
||||
$this->commandTaskRepository->save($task);
|
||||
$this->createTraceService->__invoke($task);
|
||||
|
||||
return new CommandTaskOutput($command);
|
||||
return new CommandTaskOutput($task);
|
||||
}
|
||||
|
||||
private function processDelete($data, Operation $operation, array $uriVariables = [], array $context = []): null
|
||||
|
|
Loading…
Reference in New Issue