From 5bc7bdab2dbccaeb7de5a63ea4f41cd5a4d5c3f6 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Wed, 1 Jul 2015 09:53:36 +0200 Subject: [PATCH] Initialisation of the bundle --- Entity/Activity.php | 311 ++++++++++++++++++ Entity/ActivityReason.php | 133 ++++++++ Entity/ActivityReasonCategory.php | 102 ++++++ Entity/ActivityType.php | 73 ++++ Resources/config/doctrine/Activity.orm.yml | 30 ++ .../config/doctrine/ActivityReason.orm.yml | 19 ++ .../doctrine/ActivityReasonCategory.orm.yml | 16 + .../config/doctrine/ActivityType.orm.yml | 14 + .../migrations/Version20150701091248.php | 63 ++++ 9 files changed, 761 insertions(+) create mode 100644 Entity/Activity.php create mode 100644 Entity/ActivityReason.php create mode 100644 Entity/ActivityReasonCategory.php create mode 100644 Entity/ActivityType.php create mode 100644 Resources/config/doctrine/Activity.orm.yml create mode 100644 Resources/config/doctrine/ActivityReason.orm.yml create mode 100644 Resources/config/doctrine/ActivityReasonCategory.orm.yml create mode 100644 Resources/config/doctrine/ActivityType.orm.yml create mode 100644 Resources/migrations/Version20150701091248.php diff --git a/Entity/Activity.php b/Entity/Activity.php new file mode 100644 index 000000000..e4662983d --- /dev/null +++ b/Entity/Activity.php @@ -0,0 +1,311 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\ActivityBundle\Entity; + +use Chill\MainBundle\Entity\Scope; +use Chill\MainBundle\Entity\User; +use Chill\ActivityBundle\Entity\ActivityReason; +use Chill\ActivityBundle\Entity\ActivityType; +use Chill\PersonBundle\Entity\Person; + +/** + * Activity + */ +class Activity +{ + /** + * @var integer + */ + private $id; + + /** + * @var User + */ + private $user; + + /** + * @var \DateTime + */ + private $date; + + /** + * @var \DateTime + */ + private $durationTime; + + /** + * @var string + */ + private $remark; + + /** + * @var boolean + */ + private $attendee; + + /** + * @var ActivityReason + */ + private $reason; + + /** + * @var ActivityType + */ + private $type; + + /** + * @var Scope + */ + private $scope; + + /** + * @var Person + */ + private $person; + + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set user + * + * @param User $user + * + * @return Activity + */ + public function setUserr(User $user) + { + $this->user = $user; + + return $this; + } + + /** + * Get user + * + * @return User + */ + public function getUser() + { + return $this->user; + } + + /** + * Set date + * + * @param \DateTime $date + * + * @return Activity + */ + public function setDate($date) + { + $this->date = $date; + + return $this; + } + + /** + * Get date + * + * @return \DateTime + */ + public function getDate() + { + return $this->date; + } + + /** + * Set durationTime + * + * @param \DateTime $durationTime + * + * @return Activity + */ + public function setDurationTime($durationTime) + { + $this->durationTime = $durationTime; + + return $this; + } + + /** + * Get durationTime + * + * @return \DateTime + */ + public function getDurationTime() + { + return $this->durationTime; + } + + /** + * Set remark + * + * @param string $remark + * + * @return Activity + */ + public function setRemark($remark) + { + $this->remark = $remark; + + return $this; + } + + /** + * Get remark + * + * @return string + */ + public function getRemark() + { + return $this->remark; + } + + /** + * Set attendee + * + * @param boolean $attendee + * + * @return Activity + */ + public function setAttendee($attendee) + { + $this->attendee = $attendee; + + return $this; + } + + /** + * Get attendee + * + * @return boolean + */ + public function getAttendee() + { + return $this->attendee; + } + + /** + * Set reason + * + * @param ActivityReason $reason + * + * @return Activity + */ + public function setReason(ActivityReason $reason) + { + $this->reason = $reason; + + return $this; + } + + /** + * Get reason + * + * @return ActivityReason + */ + public function getReason() + { + return $this->reason; + } + + /** + * Set type + * + * @param ActivityType $type + * + * @return Activity + */ + public function setType(ActivityType $type) + { + $this->type = $type; + + return $this; + } + + /** + * Get type + * + * @return ActivityType + */ + public function getType() + { + return $this->type; + } + + /** + * Set scope + * + * @param Scope $scope + * + * @return Activity + */ + public function setScope(Scope $scope) + { + $this->scope = $scope; + + return $this; + } + + /** + * Get scope + * + * @return Scope + */ + public function getScope() + { + return $this->scope; + } + + /** + * Set person + * + * @param Person $person + * + * @return Activity + */ + public function setPerson(Person $person) + { + $this->person = $person; + + return $this; + } + + /** + * Get person + * + * @return Person + */ + public function getPerson() + { + return $this->person; + } +} + diff --git a/Entity/ActivityReason.php b/Entity/ActivityReason.php new file mode 100644 index 000000000..10f9243a6 --- /dev/null +++ b/Entity/ActivityReason.php @@ -0,0 +1,133 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\ActivityBundle\Entity; + +use Chill\ActivityBundle\Entity\ActivityReasonCategory; + +/** + * ActivityReason + */ +class ActivityReason +{ + /** + * @var integer + */ + private $id; + + /** + * @var string + */ + private $label; + + /** + * @var ActivityReasonCategory + */ + private $category; + + /** + * @var boolean + */ + private $active; + + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set label + * + * @param string $label + * + * @return ActivityReason + */ + public function setLabel($label) + { + $this->label = $label; + + return $this; + } + + /** + * Get label + * + * @return string + */ + public function getLabel() + { + return $this->label; + } + + /** + * Set category + * + * @param ActivityReasonCategory $category + * + * @return ActivityReason + */ + public function setCategory(ActivityReasonCategory $category) + { + $this->category = $category; + + return $this; + } + + /** + * Get category + * + * @return ActivityReasonCategory + */ + public function getCategory() + { + return $this->category; + } + + /** + * Set active + * + * @param boolean $active + * + * @return ActivityReason + */ + public function setActive($active) + { + $this->active = $active; + + return $this; + } + + /** + * Get active + * + * @return boolean + */ + public function getActive() + { + return $this->active; + } +} + diff --git a/Entity/ActivityReasonCategory.php b/Entity/ActivityReasonCategory.php new file mode 100644 index 000000000..c7af694c5 --- /dev/null +++ b/Entity/ActivityReasonCategory.php @@ -0,0 +1,102 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\ActivityBundle\Entity; + +/** + * ActivityReasonCategory + */ +class ActivityReasonCategory +{ + /** + * @var integer + */ + private $id; + + /** + * @var string + */ + private $label; + + /** + * @var boolean + */ + private $active; + + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set label + * + * @param string $label + * + * @return ActivityReasonCategory + */ + public function setLabel($label) + { + $this->label = $label; + + return $this; + } + + /** + * Get label + * + * @return string + */ + public function getLabel() + { + return $this->label; + } + + /** + * Set active + * + * @param boolean $active + * + * @return ActivityReasonCategory + */ + public function setActive($active) + { + $this->active = $active; + + return $this; + } + + /** + * Get active + * + * @return boolean + */ + public function getActive() + { + return $this->active; + } +} + diff --git a/Entity/ActivityType.php b/Entity/ActivityType.php new file mode 100644 index 000000000..0fadc77a0 --- /dev/null +++ b/Entity/ActivityType.php @@ -0,0 +1,73 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\ActivityBundle\Entity; + +/** + * ActivityType + */ +class ActivityType +{ + /** + * @var integer + */ + private $id; + + /** + * @var string + */ + private $name; + + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set name + * + * @param string $name + * + * @return ActivityType + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } +} + diff --git a/Resources/config/doctrine/Activity.orm.yml b/Resources/config/doctrine/Activity.orm.yml new file mode 100644 index 000000000..22ebc3219 --- /dev/null +++ b/Resources/config/doctrine/Activity.orm.yml @@ -0,0 +1,30 @@ +Chill\ActivityBundle\Entity\Activity: + type: entity + table: null + id: + id: + type: integer + id: true + generator: + strategy: AUTO + fields: + date: + type: datetime + durationTime: + type: time + remark: + type: text + attendee: + type: boolean + manyToOne: + user: + targetEntity: Chill\MainBundle\Entity\User + scope: + targetEntity: Chill\MainBundle\Entity\Scope + reason: + targetEntity: Chill\ActivityBundle\Entity\ActivityReason + type: + targetEntity: Chill\ActivityBundle\Entity\ActivityType + person: + targetEntity: Chill\PersonBundle\Entity\Person + lifecycleCallbacks: { } diff --git a/Resources/config/doctrine/ActivityReason.orm.yml b/Resources/config/doctrine/ActivityReason.orm.yml new file mode 100644 index 000000000..00cfdb03f --- /dev/null +++ b/Resources/config/doctrine/ActivityReason.orm.yml @@ -0,0 +1,19 @@ +Chill\ActivityBundle\Entity\ActivityReason: + type: entity + table: null + id: + id: + type: integer + id: true + generator: + strategy: AUTO + fields: + label: + type: string + length: 255 + active: + type: boolean + manyToOne: + category: + targetEntity: Chill\ActivityBundle\Entity\ActivityReasonCategory + lifecycleCallbacks: { } \ No newline at end of file diff --git a/Resources/config/doctrine/ActivityReasonCategory.orm.yml b/Resources/config/doctrine/ActivityReasonCategory.orm.yml new file mode 100644 index 000000000..96e0b667d --- /dev/null +++ b/Resources/config/doctrine/ActivityReasonCategory.orm.yml @@ -0,0 +1,16 @@ +Chill\ActivityBundle\Entity\ActivityReasonCategory: + type: entity + table: null + id: + id: + type: integer + id: true + generator: + strategy: AUTO + fields: + label: + type: string + length: 255 + active: + type: boolean + lifecycleCallbacks: { } diff --git a/Resources/config/doctrine/ActivityType.orm.yml b/Resources/config/doctrine/ActivityType.orm.yml new file mode 100644 index 000000000..d6691e25b --- /dev/null +++ b/Resources/config/doctrine/ActivityType.orm.yml @@ -0,0 +1,14 @@ +Chill\ActivityBundle\Entity\ActivityType: + type: entity + table: null + id: + id: + type: integer + id: true + generator: + strategy: AUTO + fields: + name: + type: string + length: 255 + lifecycleCallbacks: { } diff --git a/Resources/migrations/Version20150701091248.php b/Resources/migrations/Version20150701091248.php new file mode 100644 index 000000000..6173fbdaa --- /dev/null +++ b/Resources/migrations/Version20150701091248.php @@ -0,0 +1,63 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('CREATE SEQUENCE Activity_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE ActivityReason_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE ActivityReasonCategory_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE ActivityType_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE Activity (id INT NOT NULL, user_id INT DEFAULT NULL, scope_id INT DEFAULT NULL, reason_id INT DEFAULT NULL, type_id INT DEFAULT NULL, person_id INT DEFAULT NULL, date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, durationTime TIME(0) WITHOUT TIME ZONE NOT NULL, remark TEXT NOT NULL, attendee BOOLEAN NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_55026B0CA76ED395 ON Activity (user_id)'); + $this->addSql('CREATE INDEX IDX_55026B0C682B5931 ON Activity (scope_id)'); + $this->addSql('CREATE INDEX IDX_55026B0C59BB1592 ON Activity (reason_id)'); + $this->addSql('CREATE INDEX IDX_55026B0CC54C8C93 ON Activity (type_id)'); + $this->addSql('CREATE INDEX IDX_55026B0C217BBB47 ON Activity (person_id)'); + $this->addSql('CREATE TABLE ActivityReason (id INT NOT NULL, category_id INT DEFAULT NULL, label VARCHAR(255) NOT NULL, active BOOLEAN NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_654A2FCD12469DE2 ON ActivityReason (category_id)'); + $this->addSql('CREATE TABLE ActivityReasonCategory (id INT NOT NULL, label VARCHAR(255) NOT NULL, active BOOLEAN NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE ActivityType (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('ALTER TABLE Activity ADD CONSTRAINT FK_55026B0CA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE Activity ADD CONSTRAINT FK_55026B0C682B5931 FOREIGN KEY (scope_id) REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE Activity ADD CONSTRAINT FK_55026B0C59BB1592 FOREIGN KEY (reason_id) REFERENCES ActivityReason (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE Activity ADD CONSTRAINT FK_55026B0CC54C8C93 FOREIGN KEY (type_id) REFERENCES ActivityType (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE Activity ADD CONSTRAINT FK_55026B0C217BBB47 FOREIGN KEY (person_id) REFERENCES Person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE ActivityReason ADD CONSTRAINT FK_654A2FCD12469DE2 FOREIGN KEY (category_id) REFERENCES ActivityReasonCategory (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE Activity DROP CONSTRAINT FK_55026B0C59BB1592'); + $this->addSql('ALTER TABLE ActivityReason DROP CONSTRAINT FK_654A2FCD12469DE2'); + $this->addSql('ALTER TABLE Activity DROP CONSTRAINT FK_55026B0CC54C8C93'); + $this->addSql('DROP SEQUENCE Activity_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE ActivityReason_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE ActivityReasonCategory_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE ActivityType_id_seq CASCADE'); + $this->addSql('DROP TABLE Activity'); + $this->addSql('DROP TABLE ActivityReason'); + $this->addSql('DROP TABLE ActivityReasonCategory'); + $this->addSql('DROP TABLE ActivityType'); + } +} \ No newline at end of file