<?php

namespace AppBundle\Entity\Person;

use AppBundle\Entity\Core\Tagg;
use AppBundle\Entity\Organization\Organization;
use AppBundle\Entity\Traits\ActivityPeriodTrait;
use Doctrine\Common\Collections\ArrayCollection;
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 AppBundle\Validator\Constraints\Delete as OpentalentDelete;
use AppBundle\Annotation\DefaultField;

/**
 * Commission à l'intérieur d'une Organization
 *
 * @Iri("http://schema.org/Commission")
 * @OpentalentDelete\EntityDelete()
 */
#[ORM\Entity]
class Commission
{
    use TimestampableEntity;
    use CreatorUpdaterEntity;
    use ActivityPeriodTrait;
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'AUTO')]
    #[Groups(['commission', 'commission_list'])]
    private $id;
    /**
     * @var Organization
     *
     * @DefaultField
     */
    #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Organization\Organization', inversedBy: 'commissions')]
    #[ORM\JoinColumn(nullable: false)]
    #[Assert\NotNull]
    #[Groups(['commission'])]
    private $organization;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string', length: 60)]
    #[Assert\Type(type: 'string')]
    #[Assert\NotNull]
    #[Groups(['commission', 'commission_list'])]
    private $name;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string', length: 50, nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Groups(['commission', 'commission_list'])]
    private $type;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string', length: 127, nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Groups(['commission', 'commission_list'])]
    private $description;
    /**
     * @var ArrayCollection<CommissionMember>
     */
    #[Groups(['commission_commissionmember', 'commission_list'])]
    #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Person\CommissionMember', cascade: ['persist'], mappedBy: 'commission', orphanRemoval: true)]
    private $commissionMembers;
    /**
     * @var ArrayCollection<Tagg>
     */
    #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\Tagg', cascade: ['persist'], inversedBy: 'commissions')]
    #[Assert\Valid]
    #[ORM\JoinTable(name: 'tag_commission', joinColumns: [], inverseJoinColumns: [])]
    #[ORM\JoinColumn(name: 'commission_id', referencedColumnName: 'id')]
    #[ORM\JoinColumn(name: 'tag_id', referencedColumnName: 'id')]
    #[Groups(['commission_tags', 'manage_tags', 'commission_list'])]
    private $tags;
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->commissionMembers = 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 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 type.
     * 
     * @param string $type
     * 
     * @return $this
     */
    public function setType($type)
    {
        $this->type = $type;

        return $this;
    }
    /**
     * Gets type.
     * 
     * @return string
     */
    public function getType()
    {
        return $this->type;
    }
    /**
     * 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;
    }
    /**
     * Add commissionMember
     *
     * @param \AppBundle\Entity\Person\CommissionMember $commissionMember
     *
     * @return Commission
     */
    public function addCommissionMember(\AppBundle\Entity\Person\CommissionMember $commissionMember)
    {
        $this->commissionMembers[] = $commissionMember;
        $commissionMember->setCommission($this);
        
        return $this;
    }
    /**
     * Remove commissionMember
     *
     * @param \AppBundle\Entity\Person\CommissionMember $commissionMember
     */
    public function removeCommissionMember(\AppBundle\Entity\Person\CommissionMember $commissionMember)
    {
        $this->commissionMembers->removeElement($commissionMember);
    }
    /**
     * Get commissionMembers
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getCommissionMembers()
    {
        return $this->commissionMembers;
    }
    /**
     * Set organization
     *
     * @param \AppBundle\Entity\Organization\Organization $organization
     *
     * @return Commission
     */
    public function setOrganization(\AppBundle\Entity\Organization\Organization $organization)
    {
        $this->organization = $organization;

        return $this;
    }
    /**
     * Get organization
     *
     * @return \AppBundle\Entity\Organization\Organization
     */
    public function getOrganization()
    {
        return $this->organization;
    }
    /**
     * Add tag
     *
     * @param \AppBundle\Entity\Core\Tagg $tag
     *
     * @return Commission
     */
    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;
    }
}
