From 58cb34f39bec8af194b38e2bbf08af7fce33f5c5 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Mon, 26 Apr 2021 17:09:54 +0200 Subject: [PATCH] Creation of entities : SocialIssue / Social Action / Result / Goal --- .../Entity/SocialWork/Goal.php | 121 ++++++++++ .../Entity/SocialWork/Result.php | 125 ++++++++++ .../Entity/SocialWork/SocialAction.php | 214 ++++++++++++++++++ .../Entity/SocialWork/SocialIssue.php | 154 +++++++++++++ .../Repository/SocialWork/GoalRepository.php | 50 ++++ .../SocialWork/ResultRepository.php | 50 ++++ .../SocialWork/SocialActionRepository.php | 50 ++++ .../SocialWork/SocialIssueRepository.php | 50 ++++ .../migrations/Version20210426145930.php | 80 +++++++ 9 files changed, 894 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Entity/SocialWork/Goal.php create mode 100644 src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php create mode 100644 src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php create mode 100644 src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php create mode 100644 src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php create mode 100644 src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php create mode 100644 src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php create mode 100644 src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20210426145930.php diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Goal.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Goal.php new file mode 100644 index 000000000..c86c0fd7f --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Goal.php @@ -0,0 +1,121 @@ +socialActions = new ArrayCollection(); + $this->results = new ArrayCollection(); + } + + public function getTitle(): ?array + { + return $this->title; + } + + public function setTitle(array $title): self + { + $this->title = $title; + + return $this; + } + + public function getDesactivationDate(): ?\DateTimeInterface + { + return $this->desactivationDate; + } + + public function setDesactivationDate(?\DateTimeInterface $desactivationDate): self + { + $this->desactivationDate = $desactivationDate; + + return $this; + } + + /** + * @return Collection|SocialAction[] + */ + public function getSocialActions(): Collection + { + return $this->socialActions; + } + + public function addSocialAction(SocialAction $socialAction): self + { + if (!$this->socialActions->contains($socialAction)) { + $this->socialActions[] = $socialAction; + } + + return $this; + } + + public function removeSocialAction(SocialAction $socialAction): self + { + $this->socialActions->removeElement($socialAction); + + return $this; + } + + /** + * @return Collection|Result[] + */ + public function getResults(): Collection + { + return $this->results; + } + + public function addResult(Result $result): self + { + if (!$this->results->contains($result)) { + $this->results[] = $result; + } + + return $this; + } + + public function removeResult(Result $result): self + { + $this->results->removeElement($result); + + return $this; + } +} diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php new file mode 100644 index 000000000..04009a9f6 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php @@ -0,0 +1,125 @@ +socialActions = new ArrayCollection(); + $this->goals = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getTitle(): ?array + { + return $this->title; + } + + public function setTitle(array $title): self + { + $this->title = $title; + + return $this; + } + + public function getDesactivationDate(): ?\DateTimeInterface + { + return $this->desactivationDate; + } + + public function setDesactivationDate(?\DateTimeInterface $desactivationDate): self + { + $this->desactivationDate = $desactivationDate; + + return $this; + } + + /** + * @return Collection|SocialAction[] + */ + public function getSocialActions(): Collection + { + return $this->socialActions; + } + + public function addSocialAction(SocialAction $socialAction): self + { + if (!$this->socialActions->contains($socialAction)) { + $this->socialActions[] = $socialAction; + } + + return $this; + } + + public function removeSocialAction(SocialAction $socialAction): self + { + $this->socialActions->removeElement($socialAction); + + return $this; + } + + /** + * @return Collection|Goal[] + */ + public function getGoals(): Collection + { + return $this->goals; + } + + public function addGoal(Goal $goal): self + { + if (!$this->goals->contains($goal)) { + $this->goals[] = $goal; + } + + return $this; + } + + public function removeGoal(Goal $goal): self + { + $this->goals->removeElement($goal); + + return $this; + } +} diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php new file mode 100644 index 000000000..e514d7295 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php @@ -0,0 +1,214 @@ +children = new ArrayCollection(); + $this->goals = new ArrayCollection(); + $this->results = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getDesactivationDate(): ?\DateTimeInterface + { + return $this->desactivationDate; + } + + public function setDesactivationDate(?\DateTimeInterface $desactivationDate): self + { + $this->desactivationDate = $desactivationDate; + + return $this; + } + + public function getIssue(): ?SocialIssue + { + return $this->issue; + } + + public function setIssue(?SocialIssue $issue): self + { + $this->issue = $issue; + + return $this; + } + + public function getParent(): ?self + { + return $this->parent; + } + + public function setParent(?self $parent): self + { + $this->parent = $parent; + + return $this; + } + + /** + * @return Collection|self[] + */ + public function getChildren(): Collection + { + return $this->children; + } + + public function addChild(self $child): self + { + if (!$this->children->contains($child)) { + $this->children[] = $child; + $child->setParent($this); + } + + return $this; + } + + public function removeChild(self $child): self + { + if ($this->children->removeElement($child)) { + // set the owning side to null (unless already changed) + if ($child->getParent() === $this) { + $child->setParent(null); + } + } + + return $this; + } + + public function getDefaultNotificationDelay(): ?\DateInterval + { + return $this->defaultNotificationDelay; + } + + public function setDefaultNotificationDelay(\DateInterval $defaultNotificationDelay): self + { + $this->defaultNotificationDelay = $defaultNotificationDelay; + + return $this; + } + + public function getTitle(): ?array + { + return $this->title; + } + + public function setTitle(array $title): self + { + $this->title = $title; + + return $this; + } + + /** + * @return Collection|Goal[] + */ + public function getGoals(): Collection + { + return $this->goals; + } + + public function addGoal(Goal $goal): self + { + if (!$this->goals->contains($goal)) { + $this->goals[] = $goal; + } + + return $this; + } + + public function removeGoal(Goal $goal): self + { + $this->goals->removeElement($goal); + + return $this; + } + + /** + * @return Collection|Result[] + */ + public function getResults(): Collection + { + return $this->results; + } + + public function addResult(Result $result): self + { + if (!$this->results->contains($result)) { + $this->results[] = $result; + } + + return $this; + } + + public function removeResult(Result $result): self + { + $this->results->removeElement($result); + + return $this; + } +} diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php new file mode 100644 index 000000000..78cf6896b --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php @@ -0,0 +1,154 @@ +children = new ArrayCollection(); + $this->socialActions = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getParent(): ?self + { + return $this->parent; + } + + public function setParent(?self $parent): self + { + $this->parent = $parent; + + return $this; + } + + /** + * @return Collection|self[] + */ + public function getChildren(): Collection + { + return $this->children; + } + + public function addChild(self $child): self + { + if (!$this->children->contains($child)) { + $this->children[] = $child; + $child->setParent($this); + } + + return $this; + } + + public function removeChild(self $child): self + { + if ($this->children->removeElement($child)) { + // set the owning side to null (unless already changed) + if ($child->getParent() === $this) { + $child->setParent(null); + } + } + + return $this; + } + + public function getDesactivationDate(): ?\DateTimeInterface + { + return $this->desactivationDate; + } + + public function setDesactivationDate(?\DateTimeInterface $desactivationDate): self + { + $this->desactivationDate = $desactivationDate; + + return $this; + } + + public function getTitle(): ?array + { + return $this->title; + } + + public function setTitle(array $title): self + { + $this->title = $title; + + return $this; + } + + /** + * @return Collection|SocialAction[] + */ + public function getSocialActions(): Collection + { + return $this->socialActions; + } + + public function addSocialAction(SocialAction $socialAction): self + { + if (!$this->socialActions->contains($socialAction)) { + $this->socialActions[] = $socialAction; + $socialAction->setSocialIssue($this); + } + + return $this; + } + + public function removeSocialAction(SocialAction $socialAction): self + { + if ($this->socialActions->removeElement($socialAction)) { + // set the owning side to null (unless already changed) + if ($socialAction->getSocialIssue() === $this) { + $socialAction->setSocialIssue(null); + } + } + + return $this; + } +} diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php new file mode 100644 index 000000000..5dedacd09 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('g') + ->andWhere('g.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('g.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Goal + { + return $this->createQueryBuilder('g') + ->andWhere('g.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php new file mode 100644 index 000000000..72368d665 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('r') + ->andWhere('r.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('r.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Result + { + return $this->createQueryBuilder('r') + ->andWhere('r.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php new file mode 100644 index 000000000..d3c1ae00f --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('s') + ->andWhere('s.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('s.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?SocialAction + { + return $this->createQueryBuilder('s') + ->andWhere('s.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php new file mode 100644 index 000000000..5736d9d5c --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('s') + ->andWhere('s.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('s.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?SocialIssue + { + return $this->createQueryBuilder('s') + ->andWhere('s.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20210426145930.php b/src/Bundle/ChillPersonBundle/migrations/Version20210426145930.php new file mode 100644 index 000000000..892f19b31 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20210426145930.php @@ -0,0 +1,80 @@ +addSql('CREATE SEQUENCE chill_person_social_action_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_person_social_issue_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_person_social_work_goal_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_person_social_work_result_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE chill_person_social_action (id INT NOT NULL, issue_id INT DEFAULT NULL, parent_id INT DEFAULT NULL, desactivationDate TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, defaultNotificationDelay INTERVAL NOT NULL, title JSONB NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_B7ABFAB85E7AA58C ON chill_person_social_action (issue_id)'); + $this->addSql('CREATE INDEX IDX_B7ABFAB8727ACA70 ON chill_person_social_action (parent_id)'); + $this->addSql('COMMENT ON COLUMN chill_person_social_action.defaultNotificationDelay IS \'(DC2Type:dateinterval)\''); + $this->addSql('CREATE TABLE chill_person_social_action_goal (socialaction_id INT NOT NULL, goal_id INT NOT NULL, PRIMARY KEY(socialaction_id, goal_id))'); + $this->addSql('CREATE INDEX IDX_163CA4DD3DC32179 ON chill_person_social_action_goal (socialaction_id)'); + $this->addSql('CREATE INDEX IDX_163CA4DD667D1AFE ON chill_person_social_action_goal (goal_id)'); + $this->addSql('CREATE TABLE chill_person_social_action_result (socialaction_id INT NOT NULL, result_id INT NOT NULL, PRIMARY KEY(socialaction_id, result_id))'); + $this->addSql('CREATE INDEX IDX_CA98C58C3DC32179 ON chill_person_social_action_result (socialaction_id)'); + $this->addSql('CREATE INDEX IDX_CA98C58C7A7B643 ON chill_person_social_action_result (result_id)'); + $this->addSql('CREATE TABLE chill_person_social_issue (id INT NOT NULL, parent_id INT DEFAULT NULL, desactivationDate TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, title JSONB NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_7A484DAE727ACA70 ON chill_person_social_issue (parent_id)'); + $this->addSql('CREATE TABLE chill_person_social_work_goal (id INT NOT NULL, title JSONB NOT NULL, desactivationDate TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE chill_person_social_work_goal_result (goal_id INT NOT NULL, result_id INT NOT NULL, PRIMARY KEY(goal_id, result_id))'); + $this->addSql('CREATE INDEX IDX_F3BAEEA9667D1AFE ON chill_person_social_work_goal_result (goal_id)'); + $this->addSql('CREATE INDEX IDX_F3BAEEA97A7B643 ON chill_person_social_work_goal_result (result_id)'); + $this->addSql('CREATE TABLE chill_person_social_work_result (id INT NOT NULL, title JSONB NOT NULL, desactivationDate TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('ALTER TABLE chill_person_social_action ADD CONSTRAINT FK_B7ABFAB85E7AA58C FOREIGN KEY (issue_id) REFERENCES chill_person_social_issue (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_social_action ADD CONSTRAINT FK_B7ABFAB8727ACA70 FOREIGN KEY (parent_id) REFERENCES chill_person_social_action (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_social_action_goal ADD CONSTRAINT FK_163CA4DD3DC32179 FOREIGN KEY (socialaction_id) REFERENCES chill_person_social_action (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_social_action_goal ADD CONSTRAINT FK_163CA4DD667D1AFE FOREIGN KEY (goal_id) REFERENCES chill_person_social_work_goal (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_social_action_result ADD CONSTRAINT FK_CA98C58C3DC32179 FOREIGN KEY (socialaction_id) REFERENCES chill_person_social_action (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_social_action_result ADD CONSTRAINT FK_CA98C58C7A7B643 FOREIGN KEY (result_id) REFERENCES chill_person_social_work_result (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_social_issue ADD CONSTRAINT FK_7A484DAE727ACA70 FOREIGN KEY (parent_id) REFERENCES chill_person_social_issue (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_social_work_goal_result ADD CONSTRAINT FK_F3BAEEA9667D1AFE FOREIGN KEY (goal_id) REFERENCES chill_person_social_work_goal (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_social_work_goal_result ADD CONSTRAINT FK_F3BAEEA97A7B643 FOREIGN KEY (result_id) REFERENCES chill_person_social_work_result (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE chill_person_social_action DROP CONSTRAINT FK_B7ABFAB8727ACA70'); + $this->addSql('ALTER TABLE chill_person_social_action_goal DROP CONSTRAINT FK_163CA4DD3DC32179'); + $this->addSql('ALTER TABLE chill_person_social_action_result DROP CONSTRAINT FK_CA98C58C3DC32179'); + $this->addSql('ALTER TABLE chill_person_social_action DROP CONSTRAINT FK_B7ABFAB85E7AA58C'); + $this->addSql('ALTER TABLE chill_person_social_issue DROP CONSTRAINT FK_7A484DAE727ACA70'); + $this->addSql('ALTER TABLE chill_person_social_action_goal DROP CONSTRAINT FK_163CA4DD667D1AFE'); + $this->addSql('ALTER TABLE chill_person_social_work_goal_result DROP CONSTRAINT FK_F3BAEEA9667D1AFE'); + $this->addSql('ALTER TABLE chill_person_social_action_result DROP CONSTRAINT FK_CA98C58C7A7B643'); + $this->addSql('ALTER TABLE chill_person_social_work_goal_result DROP CONSTRAINT FK_F3BAEEA97A7B643'); + $this->addSql('DROP SEQUENCE chill_person_social_action_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_person_social_issue_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_person_social_work_goal_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_person_social_work_result_id_seq CASCADE'); + $this->addSql('DROP TABLE chill_person_social_action'); + $this->addSql('DROP TABLE chill_person_social_action_goal'); + $this->addSql('DROP TABLE chill_person_social_action_result'); + $this->addSql('DROP TABLE chill_person_social_issue'); + $this->addSql('DROP TABLE chill_person_social_work_goal'); + $this->addSql('DROP TABLE chill_person_social_work_goal_result'); + $this->addSql('DROP TABLE chill_person_social_work_result'); + } +}