<?php

namespace AppBundle\Entity\Organization;

use AppBundle\Annotation\DefaultField;
use AppBundle\Entity\Core\File;
use AppBundle\Entity\Core\Tagg;
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\ExportSplitFields;
/**
 * Types d'activités proposées par une structure
 *
 * @Iri("http://schema.org/Activity")
 */
#[ORM\Entity]
class Activity
{
    use TimestampableEntity;
    use CreatorUpdaterEntity;
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'AUTO')]
    #[Groups(['activity', 'activity_reference', 'access_details_organizationfunction', 'network_list', 'organization_cotisation_steps'])]
    private $id;
    /**
     * @var string A short description of the item.
     *
     * @Iri("https://schema.org/description")
     */
    #[ORM\Column(type: 'text', nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Groups(['activity'])]
    private $description;
    /**
     * @var File An image of the item. This can be a [URL](http://schema.org/URL) or a fully described [ImageObject](http://schema.org/ImageObject).
     * @Iri("https://schema.org/logo")
     */
    #[Assert\Valid]
    #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Core\File', cascade: ['persist'], inversedBy: 'activityLogos')]
    #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
    #[Groups(['activity'])]
    private $logo;
    /**
     * @var File An image of the item. This can be a [URL](http://schema.org/URL) or a fully described [ImageObject](http://schema.org/ImageObject).
     * @Iri("https://schema.org/logo")
     */
    #[Assert\Valid]
    #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Core\File', cascade: ['persist'], inversedBy: 'activityImages')]
    #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
    #[Groups(['activity'])]
    private $imageActivity;
    /**
     * @var string The name of the item.
     *
     * @Iri("https://schema.org/name")
     */
    #[ORM\Column(type: 'string', nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Groups(['activity', 'activity_reference', 'access_detail_personactivity', 'student_list_personactivity', 'adherent_list_personactivity', 'accesses_list_personactivity', 'rule_personactivityactive', 'accesses_rules_personactivityactive', 'othercontact_list_personactivity', 'access_details_personactivity', 'ca_list_personactivity', 'board_list_personactivity', 'presence_attendance_eventuser', 'adherent_contact_personactivity', 'network_list_activities', 'invitations_list_guest', 'organization_cotisation_steps_activities'])]
    private $name;
    /**
     *
     * @var ActivityType
     */
    #[ORM\ManyToOne(targetEntity: '\AppBundle\Entity\Organization\ActivityType')]
    #[Groups(['activity', 'access_detail_personactivity', 'network_list_activities', 'activity_reference', 'organization_cotisation_steps_activities'])]
    private $activityType;
    /**
     * @var Organization
     *
     * @DefaultField
     */
    #[ORM\ManyToOne(targetEntity: 'Organization', inversedBy: 'activities')]
    #[ORM\JoinColumn(nullable: false)]
    #[Assert\NotNull]
    #[Groups(['activity'])]
    private $organization;
    /**
     * @var ArrayCollection<Categories>
     */
    #[Assert\Valid]
    #[ORM\ManyToMany(targetEntity: '\AppBundle\Entity\Core\Categories', cascade: ['persist'])]
    #[Groups(['activity_categories'])]
    private $categories;
    /**
     * @var ArrayCollection<PersonActivity>
     */
    #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Person\PersonActivity', mappedBy: 'activity')]
    #[Groups(['organization_access'])]
    private $personActivities;
    /**
     * @var ArrayCollection<Tagg>
     */
    #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\Tagg', cascade: ['persist'], inversedBy: 'activities')]
    #[Assert\Valid]
    #[ORM\JoinTable(name: 'tag_activity', joinColumns: [], inverseJoinColumns: [])]
    #[ORM\JoinColumn(name: 'activity_id', referencedColumnName: 'id')]
    #[ORM\JoinColumn(name: 'tag_id', referencedColumnName: 'id')]
    #[Groups(['activity_tags', 'manage_tags'])]
    private $tags;
    /**
     * @var string
     * @ExportSplitFields({"name","activityType.subFamillyType"})
     */
    #[Groups(['network_list_activities'])]
    private $fullLabelTemplate;
    public function __construct() {
        $this->categories = new ArrayCollection();
        $this->personActivities = 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 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 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 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;
    }
    /**
     * Add category
     *
     * @param \AppBundle\Entity\Core\Categories $category
     *
     * @return Activity
     */
    public function addCategory(\AppBundle\Entity\Core\Categories $category)
    {
        $this->categories[] = $category;

        return $this;
    }
    /**
     * Remove category
     *
     * @param \AppBundle\Entity\Core\Categories $category
     */
    public function removeCategory(\AppBundle\Entity\Core\Categories $category)
    {
        $this->categories->removeElement($category);
    }
    /**
     * Get categories
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getCategories()
    {
        return $this->categories;
    }
    /**
     * Set logo
     *
     * @param \AppBundle\Entity\Core\File $logo
     *
     * @return Activity
     */
    public function setLogo(\AppBundle\Entity\Core\File $logo = null)
    {
        $this->logo = $logo;

        return $this;
    }
    /**
     * Get logo
     *
     * @return \AppBundle\Entity\Core\File
     */
    public function getLogo()
    {
        return $this->logo;
    }
    /**
     * Set imageActivity
     *
     * @param \AppBundle\Entity\Core\File $imageActivity
     *
     * @return Activity
     */
    public function setImageActivity(\AppBundle\Entity\Core\File $imageActivity = null)
    {
        $this->imageActivity = $imageActivity;

        return $this;
    }
    /**
     * Get imageActivity
     *
     * @return \AppBundle\Entity\Core\File
     */
    public function getImageActivity()
    {
        return $this->imageActivity;
    }
    /**
     * Set activityType
     *
     * @param \AppBundle\Entity\Organization\ActivityType $activityType
     *
     * @return Activity
     */
    public function setActivityType(\AppBundle\Entity\Organization\ActivityType $activityType = null)
    {
        $this->activityType = $activityType;

        return $this;
    }
    /**
     * Get activityType
     *
     * @return \AppBundle\Entity\Organization\ActivityType
     */
    public function getActivityType()
    {
        return $this->activityType;
    }
    /**
     * Add personActivity
     *
     * @param \AppBundle\Entity\Person\PersonActivity $personActivity
     *
     * @return Activity
     */
    public function addPersonActivity(\AppBundle\Entity\Person\PersonActivity $personActivity)
    {
        $this->personActivities[] = $personActivity;

        return $this;
    }
    /**
     * Remove personActivity
     *
     * @param \AppBundle\Entity\Person\PersonActivity $personActivity
     */
    public function removePersonActivity(\AppBundle\Entity\Person\PersonActivity $personActivity)
    {
        $this->personActivities->removeElement($personActivity);
    }
    /**
     * Get personActivities
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getPersonActivities()
    {
        return $this->personActivities;
    }
    /**
     * @return array
     */
    public function getFullLabelTemplate()
    {
        return array($this->getName(), array("value" => $this->getActivityType() ? $this->getActivityType()->getSubFamillyType() : null, "translate" => true));
    }
    /**
     * Add tag
     *
     * @param \AppBundle\Entity\Core\Tagg $tag
     *
     * @return Activity
     */
    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;
    }
}
