refs #726. Added new fields OU ddbb integration UDS
testing/ogcore-api/pipeline/head This commit looks good Details

develop-jenkins
Manuel Aranda Rosales 2024-10-01 16:19:40 +02:00
parent d135c74f8a
commit feb239f3de
6 changed files with 48 additions and 2 deletions

View File

@ -54,6 +54,9 @@ class OrganizationalUnitInput
#[Groups(['organizational-unit:write'])]
public ?RemoteCalendarOutput $remoteCalendar = null;
#[Groups(['organizational-unit:write'])]
public ?bool $remotePc = null;
public function __construct(?OrganizationalUnit $organizationalUnit = null)
{
if (!$organizationalUnit) {
@ -71,6 +74,7 @@ class OrganizationalUnitInput
$this->capacity = $organizationalUnit->getCapacity();
$this->comments = $organizationalUnit->getComments();
$this->type = $organizationalUnit->getType();
$this->remotePc = $organizationalUnit->isRemotePc();
if ($organizationalUnit->getNetworkSettings()){
$this->networkSettings = new NetworkSettingsInput($organizationalUnit->getNetworkSettings());
}
@ -97,6 +101,7 @@ class OrganizationalUnitInput
$organizationalUnit->setCapacity($this->capacity);
$organizationalUnit->setComments($this->comments);
$organizationalUnit->setType($this->type);
$organizationalUnit->setRemotePc($this->remotePc);
if ($this->networkSettings){
$organizationalUnit->setNetworkSettings($this->networkSettings->createOrUpdateEntity($organizationalUnit->getNetworkSettings()));

View File

@ -55,6 +55,12 @@ final class OrganizationalUnitOutput extends AbstractOutput
#[ApiProperty(readableLink: true)]
public ?RemoteCalendarOutput $remoteCalendar = null;
#[Groups(['organizational-unit:read'])]
public ?bool $remotePc = null;
#[Groups(['organizational-unit:read'])]
public ?bool $reserved = null;
#[Groups(['organizational-unit:read'])]
public \DateTime $createdAt;
@ -73,6 +79,8 @@ final class OrganizationalUnitOutput extends AbstractOutput
$this->board = $organizationalUnit->isBoard();
$this->capacity = $organizationalUnit->getCapacity();
$this->type = $organizationalUnit->getType();
$this->remotePc = $organizationalUnit->isRemotePc();
$this->reserved = $organizationalUnit->isReserved();
$this->networkSettings = $organizationalUnit->getNetworkSettings() ? new NetworkSettingsOutput($organizationalUnit->getNetworkSettings()) : null;
$this->remoteCalendar = $organizationalUnit->getRemoteCalendar() ? new RemoteCalendarOutput($organizationalUnit->getRemoteCalendar()) : null;
if ($organizationalUnit->getParent()) {

View File

@ -87,10 +87,16 @@ class OrganizationalUnit extends AbstractEntity
#[ORM\ManyToOne(inversedBy: 'organizationalUnits')]
private ?Subnet $subnet = null;
#[ORM\ManyToOne(targetEntity: RemoteCalendar::class, inversedBy: 'organizationalUnits', cascade: ['persist'])]
#[ORM\ManyToOne(targetEntity: RemoteCalendar::class, cascade: ['persist'], inversedBy: 'organizationalUnits')]
#[ORM\JoinColumn(nullable: true)]
private ?RemoteCalendar $remoteCalendar = null;
#[ORM\Column]
private ?bool $remotePc = false;
#[ORM\Column]
private ?bool $reserved = false;
public function __construct()
{
parent::__construct();
@ -399,4 +405,28 @@ class OrganizationalUnit extends AbstractEntity
return $this;
}
public function isRemotePc(): ?bool
{
return $this->remotePc;
}
public function setRemotePc(bool $remotePc): static
{
$this->remotePc = $remotePc;
return $this;
}
public function isReserved(): ?bool
{
return $this->reserved;
}
public function setReserved(bool $reserved): static
{
$this->reserved = $reserved;
return $this;
}
}

View File

@ -34,6 +34,7 @@ final class OrganizationalUnitFactory extends ModelFactory
'createdAt' => self::faker()->dateTime(),
'name' => self::faker()->text(255),
'updatedAt' => self::faker()->dateTime(),
'remotePc' => self::faker()->boolean(),
];
}

View File

@ -49,7 +49,7 @@ class UDSClient
$classroom = $servicePoolInfo['ou'];
$maxAvailableSeats = $this->getMaxAvailableSeats($classroom);
$servicePool['max_srvs'] = 10;
$servicePool['max_srvs'] = $maxAvailableSeats;
$servicePool['osmanager_id'] = null;
$response = $this->httpClient->request('PUT', $this->udsAPIurl . 'servicespools/' . $servicePool['id'], [

View File

@ -63,6 +63,7 @@ class OrganizationalUnitTest extends AbstractTest
$this->createClientWithCredentials()->request('POST', '/organizational-units',['json' => [
'name' => self::ORGANIZATIONAL_UNIT_CREATE,
'type' => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT,
'remotePc' => true,
]]);
$this->assertResponseStatusCodeSame(201);
@ -72,6 +73,7 @@ class OrganizationalUnitTest extends AbstractTest
'@type' => 'OrganizationalUnit',
'name' => self::ORGANIZATIONAL_UNIT_CREATE,
'type' => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT,
'remotePc' => true,
]);
}