<?php

namespace AppBundle\Entity\Organization;

use AppBundle\Annotation\DefaultField;
use AppBundle\Entity\Core\Tagg;
use Doctrine\ORM\Mapping as ORM;
use Dunglas\ApiBundle\Annotation\Iri;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use AppBundle\Entity\Traits\TimestampableEntity;
use AppBundle\Entity\Traits\CreatorUpdaterEntity;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * Jury composé d'Access pour unr Organization
 *
 * @Iri("http://schema.org/Jury")
 */
#[ORM\Entity]
class Jury
{
    use TimestampableEntity;
    use CreatorUpdaterEntity;
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'AUTO')]
    #[Groups(['jury', 'jury_access', 'examenconvocation_list_examen', 'examen_details', 'planning_detail', 'presence_attendance'])]
    private $id;
    /**
     * @var Organization
     *
     * @DefaultField
     */
    #[ORM\ManyToOne(targetEntity: 'Organization', inversedBy: 'juries')]
    #[ORM\JoinColumn(nullable: false)]
    #[Assert\NotNull]
    #[Groups(['jury'])]
    private $organization;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string', length: 35)]
    #[Assert\Type(type: 'string')]
    #[Assert\NotNull]
    #[Groups(['jury', 'jury_reference', 'examenconvocation_list_examen', 'examen_details_jury'])]
    private $name;
    /**
     * @var \DateTime
     */
    #[ORM\Column(type: 'date', nullable: true)]
    #[Assert\Date]
    #[Groups(['jury'])]
    private $date;
    /**
     * @var \DateTime
     */
    #[ORM\Column(type: 'date', nullable: true)]
    #[Assert\Date]
    #[Groups(['jury'])]
    private $endDate;
    /**
     * @var Access
     */
    #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access', inversedBy: 'juryMembers', cascade: ['persist'])]
    #[ORM\JoinTable(name: 'juries_members')]
    #[Groups(['jury_access', 'examen_details_jury', 'presence_attendance_jury', 'planning_detail_jury'])]
    private $members;
    /**
     * @var ArrayCollection<Examen>
     */
    #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Booking\Examen', mappedBy: 'jury')]
    #[Groups(['jury_examen'])]
    private $examens;
    /**
     * @var ArrayCollection<Tagg>
     */
    #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\Tagg', cascade: ['persist'], inversedBy: 'juries')]
    #[Assert\Valid]
    #[ORM\JoinTable(name: 'tag_jury', joinColumns: [], inverseJoinColumns: [])]
    #[ORM\JoinColumn(name: 'jury_id', referencedColumnName: 'id')]
    #[ORM\JoinColumn(name: 'tag_id', referencedColumnName: 'id')]
    #[Groups(['jury_tags', 'manage_tags'])]
    private $tags;
    public function __construct() {
        $this->members = new ArrayCollection();
        $this->examens = new ArrayCollection();
        $this->tags = 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 organization.
     * 
     * @param Organization $organization
     * 
     * @return $this
     */
    public function setOrganization(Organization $organization)
    {
        $this->organization = $organization;

        return $this;
    }
    /**
     * Gets organization.
     * 
     * @return Organization
     */
    public function getOrganization()
    {
        return $this->organization;
    }
    /**
     * 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 date.
     * 
     * @param \DateTime $date
     * 
     * @return $this
     */
    public function setDate(\DateTime $date = null)
    {
        $this->date = $date;

        return $this;
    }
    /**
     * Gets date.
     * 
     * @return \DateTime
     */
    public function getDate()
    {
        return $this->date;
    }
    /**
     * Gets members.
     *
     * @return ArrayCollection<JuryMember>
     */
    public function getMembers()
    {
        return ($this->members) ? array_values($this->members->toArray()) : new ArrayCollection();
    }
    /**
     * Add member
     *
     * @param \AppBundle\Entity\AccessAndFunction\Access $access
     *
     * @return Jury
     */
    public function addMember(\AppBundle\Entity\AccessAndFunction\Access $access)
    {
        $this->members[] = $access;
        return $this;
    }
    /**
     * Remove member
     *
     * @param \AppBundle\Entity\AccessAndFunction\Access $access
     */
    public function removeMember(\AppBundle\Entity\AccessAndFunction\Access $access)
    {
        $this->members->removeElement($access);
    }
    /**
     * Add examen
     *
     * @param \AppBundle\Entity\Booking\Examen $examen
     *
     * @return Jury
     */
    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;
    }
    /**
     * Set endDate
     *
     * @param \DateTime $endDate
     *
     * @return Jury
     */
    public function setEndDate($endDate)
    {
        $this->endDate = $endDate;

        return $this;
    }
    /**
     * Get endDate
     *
     * @return \DateTime
     */
    public function getEndDate()
    {
        return $this->endDate;
    }
    /**
     * Add tag
     *
     * @param \AppBundle\Entity\Core\Tagg $tag
     *
     * @return Jury
     */
    public function addTag(\AppBundle\Entity\Core\Tagg $tag)
    {
        $this->tags[] = $tag;

        return $this;
    }
    /**
     * Remove tag
     *
     * @param \AppBundle\Entity\Core\Tagg $tag
     */
    public function removeTag(\AppBundle\Entity\Core\Tagg $tag)
    {
        $this->tags->removeElement($tag);
    }
    /**
     * Get tags
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getTags()
    {
        return $this->tags;
    }
}
