create entity and schema

This commit is contained in:
Julien Fastré 2021-07-30 13:15:09 +02:00 committed by Marc Ducobu
parent 72a1ac02eb
commit 2f699d32b0
5 changed files with 533 additions and 0 deletions

View File

@ -160,12 +160,22 @@ use Symfony\Component\Validator\Constraints as Assert;
*/
private Collection $persons;
/**
* @var Collection
* @ORM\OneToMany(
* targetEntity=AccompanyingPeriodWorkEvaluation::class,
* mappedBy="accompanyingPeriodWork"
* )
*/
private Collection $accompanyingPeriodWorkEvaluations;
public function __construct()
{
$this->goals = new ArrayCollection();
$this->results = new ArrayCollection();
$this->thirdParties = new ArrayCollection();
$this->persons = new ArrayCollection();
$this->accompanyingPeriodWorkEvaluations = new ArrayCollection();
}
public function getId(): ?int

View File

@ -0,0 +1,309 @@
<?php
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
use DateInterval;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table("chill_person_accompanying_period_work_evaluation")
*/
class AccompanyingPeriodWorkEvaluation implements TrackUpdateInterface, TrackCreationInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id;
/**
* @ORM\ManyToOne(
* targetEntity=AccompanyingPeriodWork::class,
* mappedBy="accompanyingPeriodWorkEvaluations"
* )
*/
private ?AccompanyingPeriodWork $accompanyingPeriodWork;
/**
* @ORM\ManyToOne(
* targetEntity=Evaluation::class
* )
*/
private ?Evaluation $evaluation;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*/
private ?DateTimeImmutable $startDate;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*/
private ?DateTimeImmutable $endDate;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*/
private ?DateTimeImmutable $maxDate;
/**
* @ORM\Column(type="dateinterval", nullable=true, options={"default": null})
*/
private ?DateInterval $warningInterval;
private string $comment = '';
/**
* @ORM\ManyToOne(
* targetEntity=User::class
* )
*/
private ?User $createdBy;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*/
private ?DateTimeImmutable $createdAt;
/**
* @ORM\ManyToOne(
* targetEntity=User::class
* )
*/
private ?User $updatedBy;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*/
private ?DateTimeImmutable $updatedAt;
/**
* @var Collection
* @ORM\OneToMany(
* targetEntity=AccompanyingPeriodWorkEvaluationDocument::class,
* mappedBy="accompanyingPeriodWorkEvaluation"
* )
*/
private Collection $documents;
public function __construct()
{
$this->documents = new ArrayCollection();
}
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return AccompanyingPeriodWork|null
*/
public function getAccompanyingPeriodWork(): ?AccompanyingPeriodWork
{
return $this->accompanyingPeriodWork;
}
/**
* @param AccompanyingPeriodWork|null $accompanyingPeriodWork
* @return AccompanyingPeriodWorkEvaluation
*/
public function setAccompanyingPeriodWork(?AccompanyingPeriodWork $accompanyingPeriodWork): AccompanyingPeriodWorkEvaluation
{
$this->accompanyingPeriodWork = $accompanyingPeriodWork;
return $this;
}
/**
* @return Evaluation|null
*/
public function getEvaluation(): ?Evaluation
{
return $this->evaluation;
}
/**
* @param Evaluation|null $evaluation
* @return AccompanyingPeriodWorkEvaluation
*/
public function setEvaluation(?Evaluation $evaluation): AccompanyingPeriodWorkEvaluation
{
$this->evaluation = $evaluation;
return $this;
}
/**
* @return DateTimeImmutable|null
*/
public function getStartDate(): ?DateTimeImmutable
{
return $this->startDate;
}
/**
* @param DateTimeImmutable|null $startDate
* @return AccompanyingPeriodWorkEvaluation
*/
public function setStartDate(?DateTimeImmutable $startDate): AccompanyingPeriodWorkEvaluation
{
$this->startDate = $startDate;
return $this;
}
/**
* @return DateTimeImmutable|null
*/
public function getEndDate(): ?DateTimeImmutable
{
return $this->endDate;
}
/**
* @param DateTimeImmutable|null $endDate
* @return AccompanyingPeriodWorkEvaluation
*/
public function setEndDate(?DateTimeImmutable $endDate): AccompanyingPeriodWorkEvaluation
{
$this->endDate = $endDate;
return $this;
}
/**
* @return DateTimeImmutable|null
*/
public function getMaxDate(): ?DateTimeImmutable
{
return $this->maxDate;
}
/**
* @param DateTimeImmutable|null $maxDate
* @return AccompanyingPeriodWorkEvaluation
*/
public function setMaxDate(?DateTimeImmutable $maxDate): AccompanyingPeriodWorkEvaluation
{
$this->maxDate = $maxDate;
return $this;
}
/**
* @return DateInterval|null
*/
public function getWarningInterval(): ?DateInterval
{
return $this->warningInterval;
}
/**
* @param DateInterval|null $warningInterval
* @return AccompanyingPeriodWorkEvaluation
*/
public function setWarningInterval(?DateInterval $warningInterval): AccompanyingPeriodWorkEvaluation
{
$this->warningInterval = $warningInterval;
return $this;
}
/**
* @return string
*/
public function getComment(): string
{
return $this->comment;
}
/**
* @param string $comment
* @return AccompanyingPeriodWorkEvaluation
*/
public function setComment(string $comment): AccompanyingPeriodWorkEvaluation
{
$this->comment = $comment;
return $this;
}
/**
* @return User|null
*/
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
/**
* @param User|null $createdBy
* @return AccompanyingPeriodWorkEvaluation
*/
public function setCreatedBy(?User $createdBy): AccompanyingPeriodWorkEvaluation
{
$this->createdBy = $createdBy;
return $this;
}
/**
* @return DateTimeImmutable|null
*/
public function getCreatedAt(): ?DateTimeImmutable
{
return $this->createdAt;
}
/**
* @param DateTimeImmutable|null $createdAt
* @return AccompanyingPeriodWorkEvaluation
*/
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
/**
* @return User|null
*/
public function getUpdatedBy(): ?User
{
return $this->updatedBy;
}
/**
* @param User|null $updatedBy
* @return AccompanyingPeriodWorkEvaluation
*/
public function setUpdatedBy(?User $updatedBy): AccompanyingPeriodWorkEvaluation
{
$this->updatedBy = $updatedBy;
return $this;
}
/**
* @return DateTimeImmutable|null
*/
public function getUpdatedAt(): ?DateTimeImmutable
{
return $this->updatedAt;
}
/**
* @param DateTimeImmutable|null $updatedAt
* @return AccompanyingPeriodWorkEvaluation
*/
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
}

View File

@ -0,0 +1,122 @@
<?php
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Entity\User;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table("chill_person_accompanying_period_work_evaluation_document")
*/
class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doctrine\Model\TrackCreationInterface, \Chill\MainBundle\Doctrine\Model\TrackUpdateInterface
{
/**
* @var int|null
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id;
/**
* @var AccompanyingPeriodWorkEvaluation|null
* @ORM\ManyToOne(
* targetEntity=AccompanyingPeriodWorkEvaluation::class,
* inversedBy="documents"
* )
*/
private ?AccompanyingPeriodWorkEvaluation $accompanyingPeriodWorkEvaluation;
/**
* @ORM\ManyToOne(
* targetEntity=User::class
* )
*/
private ?User $createdBy;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*/
private ?\DateTimeImmutable $createdAt;
/**
* @ORM\ManyToOne(
* targetEntity=User::class
* )
*/
private ?User $updatedBy;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*/
private ?DateTimeImmutable $updatedAt;
private ?StoredObject $storedObject;
// TODO: ajouter gabarit
/**
* @return AccompanyingPeriodWorkEvaluation|null
*/
public function getAccompanyingPeriodWorkEvaluation(): ?AccompanyingPeriodWorkEvaluation
{
return $this->accompanyingPeriodWorkEvaluation;
}
/**
* @param AccompanyingPeriodWorkEvaluation|null $accompanyingPeriodWorkEvaluation
* @return AccompanyingPeriodWorkEvaluationDocument
*/
public function setAccompanyingPeriodWorkEvaluation(?AccompanyingPeriodWorkEvaluation $accompanyingPeriodWorkEvaluation): AccompanyingPeriodWorkEvaluationDocument
{
$this->accompanyingPeriodWorkEvaluation = $accompanyingPeriodWorkEvaluation;
return $this;
}
/**
* @return StoredObject|null
*/
public function getStoredObject(): ?StoredObject
{
return $this->storedObject;
}
/**
* @param StoredObject|null $storedObject
* @return AccompanyingPeriodWorkEvaluationDocument
*/
public function setStoredObject(?StoredObject $storedObject): AccompanyingPeriodWorkEvaluationDocument
{
$this->storedObject = $storedObject;
return $this;
}
public function setCreatedBy(User $user): \Chill\MainBundle\Doctrine\Model\TrackCreationInterface
{
$this->createdBy = $user;
return $this;
}
public function setCreatedAt(\DateTimeInterface $datetime): \Chill\MainBundle\Doctrine\Model\TrackCreationInterface
{
$this->createdAt = $datetime;
return $this;
}
public function setUpdatedBy(User $user): \Chill\MainBundle\Doctrine\Model\TrackUpdateInterface
{
$this->updatedBy = $user;
return $this;
}
public function setUpdatedAt(\DateTimeInterface $datetime): \Chill\MainBundle\Doctrine\Model\TrackUpdateInterface
{
$this->updatedAt = $datetime;
return $this;
}
}

View File

@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Create class AccompanyingPeriodWorkEvaluation
*/
final class Version20210729163023 extends AbstractMigration
{
public function getDescription(): string
{
return 'create class and tables for AccompanyingPeriodWorkEvaluation';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE SEQUENCE chill_person_accompanying_period_work_evaluation_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_person_accompanying_period_work_evaluation (id INT NOT NULL, evaluation_id INT DEFAULT NULL, startDate DATE DEFAULT NULL, endDate DATE DEFAULT NULL, maxDate DATE DEFAULT NULL, warningInterval INTERVAL DEFAULT NULL, createdAt DATE DEFAULT NULL, updatedAt DATE DEFAULT NULL, accompanyingPeriodWork_id INT DEFAULT NULL, createdBy_id INT DEFAULT NULL, updatedBy_id INT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_741A3A0BC55C1209 ON chill_person_accompanying_period_work_evaluation (accompanyingPeriodWork_id)');
$this->addSql('CREATE INDEX IDX_741A3A0B456C5646 ON chill_person_accompanying_period_work_evaluation (evaluation_id)');
$this->addSql('CREATE INDEX IDX_741A3A0B3174800F ON chill_person_accompanying_period_work_evaluation (createdBy_id)');
$this->addSql('CREATE INDEX IDX_741A3A0B65FF1AEC ON chill_person_accompanying_period_work_evaluation (updatedBy_id)');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation.startDate IS \'(DC2Type:date_immutable)\'');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation.endDate IS \'(DC2Type:date_immutable)\'');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation.maxDate IS \'(DC2Type:date_immutable)\'');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation.warningInterval IS \'(DC2Type:dateinterval)\'');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation.createdAt IS \'(DC2Type:date_immutable)\'');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation.updatedAt IS \'(DC2Type:date_immutable)\'');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation ADD CONSTRAINT FK_741A3A0BC55C1209 FOREIGN KEY (accompanyingPeriodWork_id) REFERENCES chill_person_accompanying_period_work (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation ADD CONSTRAINT FK_741A3A0B456C5646 FOREIGN KEY (evaluation_id) REFERENCES chill_person_social_work_evaluation (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation ADD CONSTRAINT FK_741A3A0B3174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation ADD CONSTRAINT FK_741A3A0B65FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema): void
{
$this->addSql('DROP SEQUENCE chill_person_accompanying_period_work_evaluation_id_seq CASCADE');
$this->addSql('DROP TABLE chill_person_accompanying_period_work_evaluation');
}
}

View File

@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Add document to AccompanyingPeriodWorkEvaluation
*/
final class Version20210730094514 extends AbstractMigration
{
public function getDescription(): string
{
return 'add documents to AccompanyingPeriodWorkEvaluation';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE SEQUENCE chill_person_accompanying_period_work_evaluation_document_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_person_accompanying_period_work_evaluation_document (id INT NOT NULL, createdAt DATE DEFAULT NULL, updatedAt DATE DEFAULT NULL, accompanyingPeriodWorkEvaluation_id INT DEFAULT NULL, createdBy_id INT DEFAULT NULL, updatedBy_id INT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_33EC9229836F75B8 ON chill_person_accompanying_period_work_evaluation_document (accompanyingPeriodWorkEvaluation_id)');
$this->addSql('CREATE INDEX IDX_33EC92293174800F ON chill_person_accompanying_period_work_evaluation_document (createdBy_id)');
$this->addSql('CREATE INDEX IDX_33EC922965FF1AEC ON chill_person_accompanying_period_work_evaluation_document (updatedBy_id)');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation_document.createdAt IS \'(DC2Type:date_immutable)\'');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation_document.updatedAt IS \'(DC2Type:date_immutable)\'');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ADD CONSTRAINT FK_33EC9229836F75B8 FOREIGN KEY (accompanyingPeriodWorkEvaluation_id) REFERENCES chill_person_accompanying_period_work_evaluation (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ADD CONSTRAINT FK_33EC92293174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ADD CONSTRAINT FK_33EC922965FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work.startDate IS \'(DC2Type:date_immutable)\'');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work.endDate IS \'(DC2Type:date_immutable)\'');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work ADD CONSTRAINT FK_B694FB365FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_B694FB365FF1AEC ON chill_person_accompanying_period_work (updatedBy_id)');
}
public function down(Schema $schema): void
{
$this->addSql('COMMENT ON COLUMN chill_calendar.calendar_range.startdate IS \'(DC2Type:datetimetz_immutable)\'');
$this->addSql('COMMENT ON COLUMN chill_calendar.calendar_range.enddate IS \'(DC2Type:datetimetz_immutable)\'');
$this->addSql('DROP TABLE chill_person_accompanying_period_work_evaluation_document');
$this->addSql('DROP SEQUENCE chill_person_accompanying_period_work_evaluation_document_id_seq');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work DROP CONSTRAINT FK_B694FB365FF1AEC');
$this->addSql('DROP INDEX IDX_B694FB365FF1AEC');
}
}