<?php

namespace AppBundle\Entity\Person;

use AppBundle\Entity\Traits\ActivityPeriodTrait;
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\Organization\Activity as Activity;
use AppBundle\Entity\Product\EquipmentList as EquipmentList;
use AppBundle\Entity\Traits\TimestampableEntity;
use AppBundle\Entity\Traits\CreatorUpdaterEntity;

/**
 * Lien entre une Person et une Activity
 *
 * @Iri("http://schema.org/PersonActivity")
 */
#[ORM\Entity(repositoryClass: 'AppBundle\Entity\Person\Repository\PersonActivityRepository')]
class PersonActivity
{
    use TimestampableEntity;
    use CreatorUpdaterEntity;
    use ActivityPeriodTrait;
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'AUTO')]
    #[Groups(['personactivity', 'access_details', 'student_list', 'adherent_list', 'accesses_list', 'rule', 'accesses_rules', 'othercontact_list', 'ca_list', 'board_list', 'licence_cmf', 'adherent_contact'])]
    private $id;
    /**
     * @var Access
     */
    #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access', inversedBy: 'personActivity')]
    #[ORM\JoinColumn(nullable: false)]
    #[Assert\NotNull]
    #[Groups(['personactivity'])]
    private $access;
    /**
     * @var Activity
     */
    #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Organization\Activity', inversedBy: 'personActivities')]
    #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
    #[Groups(['personactivity', 'access_detail_personactivity', 'student_list_personactivity', 'adherent_list_personactivity', 'accesses_list_personactivity', 'rule_personactivityactive', 'accesses_rules_personactivityactive', 'othercontact_list_personactivity', 'ca_list_personactivity', 'access_details_personactivity', 'board_list_personactivity', 'presence_attendance_eventuser', 'adherent_contact_personactivity', 'invitations_list_guest'])]
    private $activity;
    /**
     * @var EquipmentList
     */
    #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Product\EquipmentList')]
    #[Groups(['personactivity', 'access_detail_personactivity', 'rule_personactivityactive', 'student_list_personactivity', 'adherent_list_personactivity', 'accesses_list_personactivity', 'rule_personactivityactive', 'accesses_rules_personactivityactive', 'othercontact_list_personactivity', 'ca_list_personactivity', 'presence_attendance_eventuser', 'access_details_personactivity', 'board_list_personactivity', 'adherent_contact_personactivity', 'invitations_list_guest'])]
    private $speciality;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string', nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Groups(['personactivity', 'access_detail_personactivity', 'access_details_personactivity'])]
    private $complementSpeciality;
    /**
     * @var bool
     */
    #[ORM\Column(type: 'boolean', options: ['default' => false])]
    #[Assert\Type(type: 'boolean')]
    #[Assert\NotNull]
    #[Groups(['personactivity', 'access_detail_personactivity', 'adherent_list_personactivity'])]
    private $mainActivity = false;
    /**
     * @var string
     */
    #[Groups(['template', 'access_detail_personactivity', 'invitations_list_guest'])]
    private $fullLabelTemplate;
    /**
     * 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 activity.
     * 
     * @param Activity $activity
     * 
     * @return $this
     */
    public function setActivity(Activity $activity = null)
    {
        $this->activity = $activity;

        return $this;
    }
    /**
     * Gets activity.
     * 
     * @return Activity
     */
    public function getActivity()
    {
        return $this->activity;
    }
    /**
     * Sets speciality.
     * 
     * @param EquipmentList $speciality
     * 
     * @return $this
     */
    public function setSpeciality(EquipmentList $speciality = null)
    {
        $this->speciality = $speciality;

        return $this;
    }
    /**
     * Gets speciality.
     * 
     * @return EquipmentList
     */
    public function getSpeciality()
    {
        return $this->speciality;
    }
    /**
     * Sets complementSpeciality.
     * 
     * @param string $complementSpeciality
     * 
     * @return $this
     */
    public function setcomplementSpeciality($complementSpeciality)
    {
        $this->complementSpeciality = $complementSpeciality;

        return $this;
    }
    /**
     * Gets complementSpeciality.
     * 
     * @return string
     */
    public function getcomplementSpeciality()
    {
        return $this->complementSpeciality;
    }
    /**
     * Sets mainActivity.
     * 
     * @param bool $mainActivity
     * 
     * @return $this
     */
    public function setMainActivity($mainActivity)
    {
        $this->mainActivity = $mainActivity;

        return $this;
    }
    /**
     * Gets mainActivity.
     * 
     * @return bool
     */
    public function getMainActivity()
    {
        return $this->mainActivity;
    }
    /**
     * Set access
     *
     * @param \AppBundle\Entity\AccessAndFunction\Access $access
     *
     * @return PersonActivity
     */
    public function setAccess(\AppBundle\Entity\AccessAndFunction\Access $access)
    {
        $this->access = $access;

        return $this;
    }
    /**
     * Get access
     *
     * @return \AppBundle\Entity\AccessAndFunction\Access
     */
    public function getAccess()
    {
        return $this->access;
    }
    /**
     * Gets full label.
     *
     * @return array
     */
    public function getFullLabelTemplate()
    {
        return [
            ['value' => $this->getActivity() ? $this->getActivity()->getName() : '', 'separator' => ' - '],
            ['value' => $this->getSpeciality() ? $this->getSpeciality()->getDetail() : '', 'translate' => true]
        ];
    }
}
