refs #724. Added RemoteCalendar and RemoteCalendarRule entities
parent
939a15ad2a
commit
bdd5093a6a
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20240924090429 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE TABLE remote_calendar (id INT AUTO_INCREMENT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_BD3BDE0AD17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE remote_calendar_rule (id INT AUTO_INCREMENT NOT NULL, remote_calendar_id INT DEFAULT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, busy_weekdays JSON NOT NULL COMMENT \'(DC2Type:json)\', busy_from_hour DATETIME NOT NULL, busy_to_hour DATETIME NOT NULL, is_remote_available TINYINT(1) NOT NULL, available_from_date DATE NOT NULL, available_to_date DATE NOT NULL, available_reason VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_EE93D058D17F50A6 (uuid), INDEX IDX_EE93D058C56641EE (remote_calendar_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('ALTER TABLE remote_calendar_rule ADD CONSTRAINT FK_EE93D058C56641EE FOREIGN KEY (remote_calendar_id) REFERENCES remote_calendar (id)');
|
||||
$this->addSql('ALTER TABLE organizational_unit ADD remote_calendar_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE organizational_unit ADD CONSTRAINT FK_749AEB2DC56641EE FOREIGN KEY (remote_calendar_id) REFERENCES remote_calendar (id)');
|
||||
$this->addSql('CREATE INDEX IDX_749AEB2DC56641EE ON organizational_unit (remote_calendar_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE organizational_unit DROP FOREIGN KEY FK_749AEB2DC56641EE');
|
||||
$this->addSql('ALTER TABLE remote_calendar_rule DROP FOREIGN KEY FK_EE93D058C56641EE');
|
||||
$this->addSql('DROP TABLE remote_calendar');
|
||||
$this->addSql('DROP TABLE remote_calendar_rule');
|
||||
$this->addSql('DROP INDEX IDX_749AEB2DC56641EE ON organizational_unit');
|
||||
$this->addSql('ALTER TABLE organizational_unit DROP remote_calendar_id');
|
||||
}
|
||||
}
|
|
@ -84,6 +84,10 @@ class OrganizationalUnit extends AbstractEntity
|
|||
#[ORM\OneToMany(mappedBy: 'organizationalUnit', targetEntity: SoftwareProfile::class)]
|
||||
private Collection $softwareProfiles;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: RemoteCalendar::class, inversedBy: 'organizationalUnits', cascade: ['persist'])]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?RemoteCalendar $remoteCalendar = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\RemoteCalendarRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: RemoteCalendarRepository::class)]
|
||||
class RemoteCalendar extends AbstractEntity
|
||||
{
|
||||
use NameableTrait;
|
||||
|
||||
/**
|
||||
* @var Collection<int, OrganizationalUnit>
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'remoteCalendar', targetEntity: OrganizationalUnit::class)]
|
||||
private Collection $organizationalUnits;
|
||||
|
||||
/**
|
||||
* @var Collection<int, RemoteCalendarRule>
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'remoteCalendar', targetEntity: RemoteCalendarRule::class)]
|
||||
private Collection $rules;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->rules = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getOrganizationalUnits(): Collection
|
||||
{
|
||||
return $this->organizationalUnits;
|
||||
}
|
||||
|
||||
public function setOrganizationalUnits(Collection $organizationalUnits): void
|
||||
{
|
||||
$this->organizationalUnits = $organizationalUnits;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, RemoteCalendarRule>
|
||||
*/
|
||||
public function getRules(): Collection
|
||||
{
|
||||
return $this->rules;
|
||||
}
|
||||
|
||||
public function addRule(RemoteCalendarRule $rule): static
|
||||
{
|
||||
if (!$this->rules->contains($rule)) {
|
||||
$this->rules->add($rule);
|
||||
$rule->setRemoteCalendar($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeRule(RemoteCalendarRule $rule): static
|
||||
{
|
||||
if ($this->rules->removeElement($rule)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($rule->getRemoteCalendar() === $this) {
|
||||
$rule->setRemoteCalendar(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\RemoteCalendarRuleRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: RemoteCalendarRuleRepository::class)]
|
||||
class RemoteCalendarRule extends AbstractEntity
|
||||
{
|
||||
#[ORM\ManyToOne(inversedBy: 'rules')]
|
||||
private ?RemoteCalendar $remoteCalendar = null;
|
||||
|
||||
#[ORM\Column(type: Types::JSON)]
|
||||
private array $busyWeekdays = [];
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
||||
private ?\DateTimeInterface $busyFromHour = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
||||
private ?\DateTimeInterface $busyToHour = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?bool $isRemoteAvailable = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_MUTABLE)]
|
||||
private ?\DateTimeInterface $availableFromDate = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_MUTABLE)]
|
||||
private ?\DateTimeInterface $availableToDate = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $availableReason = null;
|
||||
|
||||
public function getBusyWeekdays(): array
|
||||
{
|
||||
return $this->busyWeekdays;
|
||||
}
|
||||
|
||||
public function setBusyWeekdays(array $busyWeekdays): static
|
||||
{
|
||||
$this->busyWeekdays = $busyWeekdays;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBusyFromHour(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->busyFromHour;
|
||||
}
|
||||
|
||||
public function setBusyFromHour(\DateTimeInterface $busyFromHour): static
|
||||
{
|
||||
$this->busyFromHour = $busyFromHour;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBusyToHour(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->busyToHour;
|
||||
}
|
||||
|
||||
public function setBusyToHour(\DateTimeInterface $busyToHour): static
|
||||
{
|
||||
$this->busyToHour = $busyToHour;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isRemoteAvailable(): ?bool
|
||||
{
|
||||
return $this->isRemoteAvailable;
|
||||
}
|
||||
|
||||
public function setRemoteAvailable(bool $isRemoteAvailable): static
|
||||
{
|
||||
$this->isRemoteAvailable = $isRemoteAvailable;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAvailableFromDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->availableFromDate;
|
||||
}
|
||||
|
||||
public function setAvailableFromDate(\DateTimeInterface $availableFromDate): static
|
||||
{
|
||||
$this->availableFromDate = $availableFromDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAvailableToDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->availableToDate;
|
||||
}
|
||||
|
||||
public function setAvailableToDate(\DateTimeInterface $availableToDate): static
|
||||
{
|
||||
$this->availableToDate = $availableToDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAvailableReason(): ?string
|
||||
{
|
||||
return $this->availableReason;
|
||||
}
|
||||
|
||||
public function setAvailableReason(string $availableReason): static
|
||||
{
|
||||
$this->availableReason = $availableReason;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRemoteCalendar(): ?RemoteCalendar
|
||||
{
|
||||
return $this->remoteCalendar;
|
||||
}
|
||||
|
||||
public function setRemoteCalendar(?RemoteCalendar $remoteCalendar): static
|
||||
{
|
||||
$this->remoteCalendar = $remoteCalendar;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\RemoteCalendar;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<RemoteCalendar>
|
||||
*/
|
||||
class RemoteCalendarRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, RemoteCalendar::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return RemoteCalendar[] Returns an array of RemoteCalendar objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('r')
|
||||
// ->andWhere('r.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('r.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?RemoteCalendar
|
||||
// {
|
||||
// return $this->createQueryBuilder('r')
|
||||
// ->andWhere('r.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\RemoteCalendarRule;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<RemoteCalendarRule>
|
||||
*/
|
||||
class RemoteCalendarRuleRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, RemoteCalendarRule::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return RemoteCalendarRule[] Returns an array of RemoteCalendarRule objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('r')
|
||||
// ->andWhere('r.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('r.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?RemoteCalendarRule
|
||||
// {
|
||||
// return $this->createQueryBuilder('r')
|
||||
// ->andWhere('r.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
Loading…
Reference in New Issue