<?php

namespace AppBundle\Entity\Network;

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

/**
 * Fait le lien entre une Organization et un Network
 *
 * @Iri("http://schema.org/NetworkOrganization")
 */
#[ORM\Entity(repositoryClass: 'AppBundle\Entity\Network\Repository\NetworkOrganizationRepository')]
#[ORM\Table(name: 'NetworkOrganization')]
#[ORM\Index(name: 'viewIndex', columns: ['endDate'])]
class NetworkOrganization
{
    use TimestampableEntity;
    use CreatorUpdaterEntity;
    use ActivityPeriodTrait;
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'AUTO')]
    #[Groups(['networkorganization', 'network_list', 'organization_create', 'organization_details', 'organization_params_list'])]
    private $id;
    /**
     * @var Network
     */
    #[ORM\ManyToOne(targetEntity: 'Network', inversedBy: 'organizations')]
    #[ORM\JoinColumn(name: 'network_id', referencedColumnName: 'id', nullable: false)]
    #[Assert\NotNull]
    #[Groups(['networkorganization', 'organization_create_network', 'organization_details_network', 'organization_params_list_network'])]
    private $network;
    /**
     * @var Organization
     */
    #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Organization\Organization', inversedBy: 'network')]
    #[ORM\JoinColumn(name: 'organization_id', referencedColumnName: 'id', nullable: false)]
    #[Assert\NotNull]
    #[Groups(['networkorganization'])]
    private $organization;
    /**
     * @var Organization
     */
    #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Organization\Organization', inversedBy: 'networkChild')]
    #[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'id', nullable: true)]
    #[Assert\NotNull]
    #[Groups(['networkorganization', 'organization_params_list_network'])]
    private $parent;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string', nullable: true)]
    #[ORM\JoinColumn(nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Assert\Choice(callback: ['\AppBundle\Enum\Network\LeadingCauseEnum', 'toArray'])]
    #[Groups(['networkorganization', 'organization_params_list_network'])]
    private $leadingCause;
    /**
     * 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 network.
     *
     * @param Network $network
     *
     * @return $this
     */
    public function setNetwork(Network $network)
    {
        $this->network = $network;

        return $this;
    }
    /**
     * Gets network.
     *
     * @return Network
     */
    public function getNetwork()
    {
        return $this->network;
    }
    /**
     * 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 parent.
     *
     * @param Organization $parent
     *
     * @return $this
     */
    public function setParent(Organization $parent)
    {
        $this->parent = $parent;

        return $this;
    }
    /**
     * Gets parent.
     *
     * @return Organization
     */
    public function getParent()
    {
        return $this->parent;
    }
    /**
     * Sets leadingCause.
     *
     * @param string $leadingCause
     *
     * @return $this
     */
    public function setLeadingCause($leadingCause)
    {
        $this->leadingCause = $leadingCause;

        return $this;
    }
    /**
     * Gets leadingCause.
     *
     * @return string
     */
    public function getLeadingCause()
    {
        return $this->leadingCause;
    }
}
