<?php

namespace AppBundle\Entity\Place;

use AppBundle\Annotation\ExportSplitFields;
use AppBundle\Entity\Booking\Course;
use AppBundle\Entity\Booking\EducationalProject;
use AppBundle\Entity\Booking\Event;
use AppBundle\Entity\Booking\Examen;
use AppBundle\Entity\Core\File;
use AppBundle\Entity\Core\ContactPoint;
use AppBundle\Entity\Product\Equipment;
use AppBundle\Entity\Traits\ContactPointType;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use AppBundle\Entity\Traits\TimestampableEntity;
use AppBundle\Entity\Traits\CreatorUpdaterEntity;
use AppBundle\Entity\Core\ContactInterface;

/**
 * Salle d'une Place
 */
#[ORM\Entity]
class Room implements ContactInterface
{
    use TimestampableEntity;
    use CreatorUpdaterEntity;
    use ContactPointType;
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'AUTO')]
    #[Groups(['room', 'equipment_list', 'equipmentrepair_list_equipment', 'equipmentaccounting_list', 'equipmentmediatheque_list', 'equipmentcostume_list', 'place_list', 'examenconvocation_list_examen', 'planning_list', 'examen_details', 'course_details', 'educationalproject_details', 'planning_detail', 'event_details'])]
    private $id;
    /**
     * @var Place
     */
    #[Assert\NotNull]
    #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Place\Place', inversedBy: 'rooms')]
    private $place;
    /**
     * @var string
     */
    #[Assert\Type(type: 'string')]
    #[ORM\Column(type: 'string', nullable: true)]
    #[Groups(['room', 'room_reference', 'equipment_list_roomstorage', 'equipment_list_roomwhereisused', 'equipmentrent_list_equipment', 'equipmentloan_list_equipment', 'equipmentcontrol_list_equipment', 'equipmentrepair_list_equipment', 'equipmentaccounting_list_roomwhereisused', 'equipmentmediatheque_list_roomwhereisused', 'equipmentcostume_list_roomwhereisused', 'equipmentaccounting_list_roomstorage', 'equipmentmediatheque_list_roomstorage', 'equipmentcostume_list_roomstorage', 'place_list_rooms', 'examenconvocation_list_examen', 'planning_list', 'examen_details_room', 'course_details_room', 'educationalproject_details_room', 'reportmessage', 'planning_detail_room', 'student_list_courses', 'event_details_room'])]
    private $name;
    /**
     * @var string A short description of the item.
     */
    #[Assert\Type(type: 'string')]
    #[ORM\Column(type: 'text', nullable: true)]
    #[Groups(['room', 'place_list_rooms'])]
    private $description;
    /**
     * @var string
     */
    #[Assert\Type(type: 'string')]
    #[ORM\Column(type: 'string', nullable: true)]
    #[Groups(['room', 'place_list_rooms'])]
    private $localisation;
    /**
     * @var int
     */
    #[Assert\Type(type: 'integer', message: 'invalid-integer')]
    #[ORM\Column(type: 'integer', nullable: true)]
    #[Groups(['room', 'place_list_rooms', 'room_reference'])]
    private $capacity;
    /**
     * @var int
     */
    #[Assert\Type(type: 'integer', message: 'invalid-integer')]
    #[ORM\Column(type: 'integer', nullable: true)]
    #[Groups(['room', 'place_list_rooms', 'room_reference'])]
    private $floorSize;
    /**
     * @var ArrayCollection<OpeningHoursSpecification>
     */
    #[Assert\Valid]
    #[ORM\ManyToMany(targetEntity: 'OpeningHoursSpecification', cascade: ['persist'], orphanRemoval: true)]
    #[ORM\JoinTable(joinColumns: [], inverseJoinColumns: [])]
    #[ORM\JoinColumn(name: 'room_id', referencedColumnName: 'id')]
    #[ORM\JoinColumn(name: 'openinghoursspecification_id', referencedColumnName: 'id', unique: true)]
    #[Groups(['room_openinghoursspecification'])]
    private $openingHoursSpecification;
    /**
     * @var ArrayCollection<ContactPoint>
     */
    #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\ContactPoint')]
    #[Groups(['room_contactpoint'])]
    private $contactpoint;
    /**
     * @var ArrayCollection<Equipment>
     */
    #[Assert\Valid]
    #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Product\Equipment', cascade: ['persist'])]
    #[ORM\JoinTable(joinColumns: [], inverseJoinColumns: [])]
    #[ORM\JoinColumn(name: 'room_id', referencedColumnName: 'id')]
    #[ORM\JoinColumn(name: 'equipment_id', referencedColumnName: 'id', unique: true)]
    #[Groups(['room_equipment'])]
    private $equipments;
    /**
     * @var ArrayCollection<RoomControl>
     */
    #[Assert\Valid]
    #[ORM\OneToMany(targetEntity: 'RoomControl', mappedBy: 'room', cascade: ['persist'], orphanRemoval: true)]
    #[ORM\JoinColumn(nullable: false)]
    #[Groups(['room_control'])]
    private $controls;
    /**
     * @var ArrayCollection<AppBundle\Entity\Place\RoomRepair>
     */
    #[Assert\Valid]
    #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Place\RoomRepair', mappedBy: 'room', cascade: ['persist'], orphanRemoval: true)]
    #[ORM\JoinColumn(nullable: false)]
    #[Groups(['room_repair'])]
    private $repairs;
    /**
     * @var ArrayCollection<Course>
     */
    #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Booking\Course', mappedBy: 'room')]
    #[Groups(['room_booking'])]
    private $courses;
    /**
     * @var ArrayCollection<EducationalProject>
     */
    #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Booking\EducationalProject', mappedBy: 'room')]
    #[Groups(['room_booking'])]
    private $educationalProjects;
    /**
     * @var ArrayCollection<Event>
     */
    #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Booking\Event', mappedBy: 'room')]
    #[Groups(['room_booking'])]
    private $events;
    /**
     * @var ArrayCollection<Examen>
     */
    #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Booking\Examen', mappedBy: 'room')]
    #[Groups(['room_booking'])]
    private $examens;
    /**
     * @var ArrayCollection<Equipment>
     */
    #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Product\Equipment', mappedBy: 'roomStorage')]
    #[Groups(['room_equipment'])]
    private $equipmentStorages;
    /**
     * @var ArrayCollection<Equipment>
     */
    #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Product\Equipment', mappedBy: 'roomWhereIsUsed')]
    #[Groups(['room_equipment'])]
    private $equipmentUseds;
    /**
     * @var array
     * @ExportSplitFields({"name","description","localisation","floorSize","capacity"})
     *
     */
    #[Groups(['template'])]
    private $fullLabelTemplate;
    public function __construct()
    {
        $this->openingHoursSpecification = new ArrayCollection();
        $this->contactpoint = new ArrayCollection();
        $this->equipments = new ArrayCollection();
        $this->repairs = new ArrayCollection();
        $this->controls = new ArrayCollection();
        $this->courses = new ArrayCollection();
        $this->educationalProjects = new ArrayCollection();
        $this->events = new ArrayCollection();
        $this->examens = new ArrayCollection();
        $this->equipmentStorages = new ArrayCollection();
        $this->equipmentUseds = new ArrayCollection();
    }
    /**
     * Sets id.
     *
     * @param int $id
     *
     * @return $this
     */
    public function setId($id)
    {
        $this->id = $id;

        return $this;
    }
    /**
     * Gets id.
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }
    /**
     * Sets place.
     *
     * @param Place $place
     *
     * @return $this
     */
    public function setPlace(Place $place)
    {
        $this->place = $place;

        return $this;
    }
    /**
     * Gets place.
     *
     * @return Place
     */
    public function getPlace()
    {
        return $this->place;
    }
    /**
     * Sets name.
     *
     * @param string $name
     *
     * @return $this
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }
    /**
     * Gets name.
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }
    /**
     * Sets floorSize.
     *
     * @param int $floorSize
     *
     * @return $this
     */
    public function setFloorSize($floorSize)
    {
        $this->floorSize = $floorSize;

        return $this;
    }
    /**
     * Gets floorSize.
     *
     * @return int
     */
    public function getFloorSize()
    {
        return $this->floorSize;
    }
    /**
     * Sets description.
     *
     * @param string $description
     *
     * @return $this
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }
    /**
     * Gets description.
     *
     * @return string
     */
    public function getDescription()
    {
        return $this->description;
    }
    /**
     * Sets localisation.
     *
     * @param string $localisation
     *
     * @return $this
     */
    public function setLocalisation($localisation)
    {
        $this->localisation = $localisation;

        return $this;
    }
    /**
     * Gets localisation.
     *
     * @return string
     */
    public function getLocalisation()
    {
        return $this->localisation;
    }
    /**
     * Sets capacity.
     *
     * @param int $capacity
     *
     * @return $this
     */
    public function setCapacity($capacity)
    {
        $this->capacity = $capacity;

        return $this;
    }
    /**
     * Gets capacity.
     *
     * @return int
     */
    public function getCapacity()
    {
        return $this->capacity;
    }
    /**
     * Adds openingHoursSpecification.
     *
     * @param OpeningHoursSpecification $openingHoursSpecification
     *
     * @return $this
     */
    public function addOpeningHoursSpecification(OpeningHoursSpecification $openingHoursSpecification)
    {
        $this->openingHoursSpecification[] = $openingHoursSpecification;

        return $this;
    }
    /**
     * Removes openingHoursSpecification.
     *
     * @param OpeningHoursSpecification $openingHoursSpecification
     *
     * @return $this
     */
    public function removeOpeningHoursSpecification(OpeningHoursSpecification $openingHoursSpecification)
    {
        $this->openingHoursSpecification->removeElement($openingHoursSpecification);
        return $this;
    }
    /**
     * Gets openingHoursSpecification.
     *
     * @return ArrayCollection<OpeningHoursSpecification>
     */
    public function getOpeningHoursSpecification()
    {
        return $this->openingHoursSpecification;
    }
    /**
     * Adds contactpoint.
     *
     * @param ContactPoint $contactpoint
     *
     * @return $this
     */
    public function addContactpoint(ContactPoint $contactpoint)
    {
        $this->contactpoint[] = $contactpoint;

        return $this;
    }
    /**
     * Removes contactpoint.
     *
     * @param ContactPoint $contactpoint
     *
     * @return $this
     */
    public function removeContactpoint(ContactPoint $contactpoint)
    {
        $this->contactpoint->removeElement($contactpoint);
        return $this;
    }
    /**
     * Gets contactpoint.
     *
     * @return ArrayCollection<ContactPoint>
     */
    public function getContactpoint()
    {
        return $this->contactpoint;
    }
    /**
     * Adds control.
     *
     * @param RoomControl $control
     *
     * @return $this
     */
    public function addControl(RoomControl $control)
    {
        $control->setRoom($this);
        $this->controls[] = $control;

        return $this;
    }
    /**
     * Removes control.
     *
     * @param RoomControl $control
     *
     * @return $this
     */
    public function removeControl(RoomControl $control)
    {
        $this->controls->removeElement($control);
        return $this;
    }
    /**
     * Gets control.
     *
     * @return ArrayCollection<RoomControl>
     */
    public function getControls()
    {
        return $this->controls;
    }
    /**
     * Adds repair.
     *
     * @param RoomRepair $repair
     *
     * @return $this
     */
    public function addRepair(RoomRepair $repair)
    {
        $repair->setRoom($this);
        $this->repairs[] = $repair;

        return $this;
    }
    /**
     * Removes repair.
     *
     * @param RoomRepair $repair
     *
     * @return $this
     */
    public function removeRepair(RoomRepair $repair)
    {
        $this->repairs->removeElement($repair);
        return $this;
    }
    /**
     * Gets repairs.
     *
     * @return ArrayCollection<RoomRepair>
     */
    public function getRepairs()
    {
        return $this->repairs;
    }
    /**
     * Add equipment
     *
     * @param \AppBundle\Entity\Product\Equipment $equipment
     *
     * @return Room
     */
    public function addEquipment(\AppBundle\Entity\Product\Equipment $equipment)
    {
        $this->equipments[] = $equipment;

        return $this;
    }
    /**
     * Remove equipment
     *
     * @param \AppBundle\Entity\Product\Equipment $equipment
     */
    public function removeEquipment(\AppBundle\Entity\Product\Equipment $equipment)
    {
        $this->equipments->removeElement($equipment);
    }
    /**
     * Get equipments
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getEquipments()
    {
        return $this->equipments;
    }
    /**
     * Add course
     *
     * @param \AppBundle\Entity\Booking\Course $course
     *
     * @return Room
     */
    public function addCourse(\AppBundle\Entity\Booking\Course $course)
    {
        $this->courses[] = $course;

        return $this;
    }
    /**
     * Remove course
     *
     * @param \AppBundle\Entity\Booking\Course $course
     */
    public function removeCourse(\AppBundle\Entity\Booking\Course $course)
    {
        $this->courses->removeElement($course);
    }
    /**
     * Get courses
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getCourses()
    {
        return $this->courses;
    }
    /**
     * Add educationalProject
     *
     * @param \AppBundle\Entity\Booking\EducationalProject $educationalProject
     *
     * @return Room
     */
    public function addEducationalProject(\AppBundle\Entity\Booking\EducationalProject $educationalProject)
    {
        $this->educationalProjects[] = $educationalProject;

        return $this;
    }
    /**
     * Remove educationalProject
     *
     * @param \AppBundle\Entity\Booking\EducationalProject $educationalProject
     */
    public function removeEducationalProject(\AppBundle\Entity\Booking\EducationalProject $educationalProject)
    {
        $this->educationalProjects->removeElement($educationalProject);
    }
    /**
     * Get educationalProjects
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getEducationalProjects()
    {
        return $this->educationalProjects;
    }
    /**
     * Add event
     *
     * @param \AppBundle\Entity\Booking\Event $event
     *
     * @return Room
     */
    public function addEvent(\AppBundle\Entity\Booking\Event $event)
    {
        $this->events[] = $event;

        return $this;
    }
    /**
     * Remove event
     *
     * @param \AppBundle\Entity\Booking\Event $event
     */
    public function removeEvent(\AppBundle\Entity\Booking\Event $event)
    {
        $this->events->removeElement($event);
    }
    /**
     * Get events
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getEvents()
    {
        return $this->events;
    }
    /**
     * Add examen
     *
     * @param \AppBundle\Entity\Booking\Examen $examen
     *
     * @return Room
     */
    public function addExamen(\AppBundle\Entity\Booking\Examen $examen)
    {
        $this->examens[] = $examen;

        return $this;
    }
    /**
     * Remove examen
     *
     * @param \AppBundle\Entity\Booking\Examen $examen
     */
    public function removeExamen(\AppBundle\Entity\Booking\Examen $examen)
    {
        $this->examens->removeElement($examen);
    }
    /**
     * Get examens
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getExamens()
    {
        return $this->examens;
    }
    /**
     * Add equipmentStorage
     *
     * @param \AppBundle\Entity\Product\Equipment $equipmentStorage
     *
     * @return Room
     */
    public function addEquipmentStorage(\AppBundle\Entity\Product\Equipment $equipmentStorage)
    {
        $this->equipmentStorages[] = $equipmentStorage;

        return $this;
    }
    /**
     * Remove equipmentStorage
     *
     * @param \AppBundle\Entity\Product\Equipment $equipmentStorage
     */
    public function removeEquipmentStorage(\AppBundle\Entity\Product\Equipment $equipmentStorage)
    {
        $this->equipmentStorages->removeElement($equipmentStorage);
    }
    /**
     * Get equipmentStorages
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getEquipmentStorages()
    {
        return $this->equipmentStorages;
    }
    /**
     * Add equipmentUsed
     *
     * @param \AppBundle\Entity\Product\Equipment $equipmentUsed
     *
     * @return Room
     */
    public function addEquipmentUsed(\AppBundle\Entity\Product\Equipment $equipmentUsed)
    {
        $equipmentUsed->setRoomWhereIsUsed($this);
        $this->equipmentUseds[] = $equipmentUsed;

        return $this;
    }
    /**
     * Remove equipmentUsed
     *
     * @param \AppBundle\Entity\Product\Equipment $equipmentUsed
     */
    public function removeEquipmentUsed(\AppBundle\Entity\Product\Equipment $equipmentUsed)
    {
        $equipmentUsed->setRoomWhereIsUsed(null);
        $this->equipmentUseds->removeElement($equipmentUsed);
    }
    /**
     * Get equipmentUseds
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getEquipmentUseds()
    {
        return $this->equipmentUseds;
    }
    /**
     *
     * {@inheritdoc}
     */
    public function getContact() {
        return $this;
    }
    /**
     *
     * {@inheritdoc}
     */
    public function getContactAddress() {
        return $this->getPlace()->getContactAddress();
    }
    /**
     *
     * {@inheritdoc}
     */
    public function getContactName() {
        return $this->getName();
    }
    /**
     *
     * {@inheritdoc}
     */
    public function getContactContactPoint() {
        return $this->getContactPointPrincipal();
    }
    /**
     * Gets full label.
     *
     * @return array
     */
    public function getFullLabelTemplate()
    {
        return [
          $this->getName(),
          $this->getDescription(),
          $this->getLocalisation(),
          $this->getFloorSize(),
          $this->getCapacity()
        ];
    }
}
