<?php

namespace AppBundle\Entity\Education;

use AppBundle\Entity\AccessAndFunction\Access;
use AppBundle\Entity\Organization\Organization;
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\Annotation\DefaultField;

/**
 * Configuration des grilles d'évaluation
 */
#[ORM\Entity(repositoryClass: 'AppBundle\Entity\Education\Repository\EducationNotationConfigRepository')]
class EducationNotationConfig
{
    use TimestampableEntity;
    use CreatorUpdaterEntity;
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'AUTO')]
    #[Groups(['educationnotationconfig', 'educationnotationconfig_reference'])]
    private $id;
    /**
     * @var Organization
     *
     * @DefaultField
     */
    #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Organization\Organization', inversedBy: 'critereNotations')]
    #[ORM\JoinColumn(nullable: false)]
    #[Assert\NotNull]
    #[Groups(['educationnotationconfig'])]
    private $organization;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string')]
    #[Assert\Type(type: 'string')]
    #[Assert\NotNull]
    #[Groups(['educationnotationconfig', 'educationnotationconfig_reference'])]
    private $label;
    /**
     * @var bool
     */
    #[ORM\Column(type: 'boolean', options: ['default' => true])]
    #[Assert\Type(type: 'boolean')]
    #[Assert\NotNull]
    #[Groups(['educationnotationconfig'])]
    private $isActive = true;
    /**
     * @var string
     */
    #[ORM\Column(type: 'text', nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Groups(['educationnotationconfig'])]
    private $description;
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer', options: ['default' => 1])]
    #[Assert\Type(type: 'integer', message: 'invalid-integer')]
    #[Assert\Range(min: 1, max: 10)]
    #[Groups(['educationnotationconfig', 'report_card_educationstudent'])]
    private $coefficient = 1;
    /**
     * @var Access
     */
    #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access', mappedBy: 'educationNotationConfig')]
    #[Groups(['educationnotationconfig'])]
    private $teachers;
    /**
     * @var Education education
     */
    #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Education\EducationCurriculum', mappedBy: 'educationNotationConfig')]
    #[Groups(['educationnotationconfig'])]
    private $educationCurriculums;
    /**
     * @var ArrayCollection<EducationNotation>
     */
    #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Education\EducationNotationCriteriaConfig', mappedBy: 'educationNotationConfig', orphanRemoval: true, cascade: ['persist', 'remove'])]
    #[Groups(['educationnotationconfig', 'educationnotationcriteriaconfig'])]
    private $educationNotationCriteriaConfigs;
    public function __construct() {
        $this->teachers = new ArrayCollection();
        $this->educationCurriculums = new ArrayCollection();
        $this->educationNotationCriteriaConfigs = 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 label.
     *
     * @param string $label
     *
     * @return $this
     */
    public function setLabel($label)
    {
        $this->label = $label;

        return $this;
    }
    /**
     * Gets label.
     *
     * @return string
     */
    public function getLabel()
    {
        return $this->label;
    }
    /**
     * Set isActive
     *
     * @param boolean $isActive
     *
     * @return CriteriaNotation
     */
    public function setIsActive($isActive)
    {
        $this->isActive = $isActive;

        return $this;
    }
    /**
     * Get isActive
     *
     * @return boolean
     */
    public function getIsActive()
    {
        return $this->isActive;
    }
    /**
     * 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 coefficient.
     *
     * @param int $coefficient
     *
     * @return $this
     */
    public function setCoefficient($coefficient)
    {
        if($coefficient === null) $coefficient = 1;
        $this->coefficient = $coefficient;

        return $this;
    }
    /**
     * Gets coefficient.
     *
     * @return int
     */
    public function getCoefficient()
    {
        return $this->coefficient;
    }
    /**
     * Add teacher
     *
     * @param \AppBundle\Entity\AccessAndFunction\Access $teacher
     *
     * @return EducationNotationConfig
     */
    public function addTeacher(\AppBundle\Entity\AccessAndFunction\Access $teacher)
    {
        $teacher->setEducationNotationConfig($this);
        $this->teachers[] = $teacher;

        return $this;
    }
    /**
     * Remove teacher
     *
     * @param \AppBundle\Entity\AccessAndFunction\Access $teacher
     */
    public function removeTeacher(\AppBundle\Entity\AccessAndFunction\Access $teacher)
    {
        $teacher->setEducationNotationConfig(null);
        $this->teachers->removeElement($teacher);
    }
    /**
     * Get teachers
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getTeachers()
    {
        return $this->teachers;
    }
    /**
     * Add educationCurriculums
     *
     * @param Education $education
     *
     * @return EducationNotationConfig
     */
    public function addEducationCurriculum(EducationCurriculum $educationCurriculums)
    {
        $educationCurriculums->setEducationNotationConfig($this);
        $this->educationCurriculums[] = $educationCurriculums;

        return $this;
    }
    /**
     * Remove educationCurriculums
     *
     * @param Education $education
     */
    public function removeEducationCurriculum(EducationCurriculum $educationCurriculums)
    {
        $educationCurriculums->setEducationNotationConfig(null);
        $this->educationCurriculums->removeElement($educationCurriculums);
    }
    /**
     * Get educationCurriculums
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getEducationCurriculums()
    {
        return $this->educationCurriculums;
    }
    /**
     * Add educationNotationCriteriaConfigs
     *
     * @param EducationNotationCriteriaConfig $educationNotationCriteriaConfigs
     *
     * @return EducationNotationConfig
     */
    public function addEducationNotationCriteriaConfig(EducationNotationCriteriaConfig $educationNotationCriteriaConfig)
    {
        $educationNotationCriteriaConfig->setEducationNotationConfig($this);
        $this->educationNotationCriteriaConfigs[] = $educationNotationCriteriaConfig;

        return $this;
    }
    /**
     * Remove educationNotationCriteriaConfigs
     *
     * @param EducationNotationCriteriaConfig $education
     */
    public function removeEducationNotationCriteriaConfig(EducationNotationCriteriaConfig $educationNotationCriteriaConfig)
    {
        $educationNotationCriteriaConfig->setEducationNotationConfig(null);
        $this->educationNotationCriteriaConfigs->removeElement($educationNotationCriteriaConfig);
    }
    /**
     * Get educationNotationCriteriaConfigs
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getEducationNotationCriteriaConfigs()
    {
        return $this->educationNotationCriteriaConfigs;
    }
}
