<?php

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\TMainStructureOfficesRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * @ApiResource(
 *    normalizationContext={"groups"={"t_main_structure_offices:read"}, "enable_max_depth"="true", "swagger_definition_name"="Read"},
 *    denormalizationContext={"groups"={"t_main_structure_offices:write"}, "swagger_definition_name"="Write"}
 * )
 * @ApiFilter(SearchFilter::class, properties={ "id": "exact", "status": "exact", "mainStructureLevel": "exact" })
 * @ApiFilter(PropertyFilter::class)
 * @ORM\Entity(repositoryClass=TMainStructureOfficesRepository::class)
 */

class TMainStructureOffices
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * @Groups({ "t_main_structure_offices:read", "t_main_structure_offices:write", "t_staff_members:read", "t_supervisions_assignings:read", "t_projects:read" })
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     * @Groups({ "t_main_structure_offices:read", "t_main_structure_offices:write", "t_supervisions_assignings:read", "t_main_targets_plannings:read", "t_projects:read", "t_main_structure_offices_positions:read", "t_witnesses_assignings:read" })
     */
    private $name;

    /**
     * @ORM\Column(type="string", length=60, nullable=true)
     * @Groups({ "t_main_structure_offices:read", "t_main_structure_offices:write" })
     */
    private $status;

    /**
     * @ORM\ManyToOne(targetEntity=TMainStructureLevels::class, inversedBy="tMainStructureOffices")
     * @Groups({ "t_main_structure_offices:read", "t_main_structure_offices:write", "t_staff_members:read" })
     */
    private $mainStructureLevel;

    /**
     * @ORM\OneToMany(targetEntity=TMainTargetsPlannings::class, mappedBy="mainStructureOffice")
     * @Groups({ "t_main_structure_offices:read", "t_main_structure_offices:write" })
     */
    private $tMainTargetsPlannings;

    /**
     * @ORM\OneToMany(targetEntity=TMainStructureOfficesPositions::class, mappedBy="mainStructureOffice")
     * @Groups({ "t_main_structure_offices:read", "t_main_structure_offices:write" })
     */
    private $tMainStructureOfficesPositions;

    /**
     * @ORM\OneToMany(targetEntity=TProjects::class, mappedBy="mainStructureOffice")
     */
    private $tProjects;

    /**
     * @ORM\OneToMany(targetEntity=TProjectsLocationMaps::class, mappedBy="mainStructureOffice")
     */
    private $tProjectsLocationMaps;

    /**
     * @ORM\OneToMany(targetEntity=TProjects::class, mappedBy="subOffice")
     */
    private $tProjectsSubOffice;

    public function __construct()
    {
        $this->tMainTargetsPlannings = new ArrayCollection();
        $this->tMainStructureOfficesPositions = new ArrayCollection();
        $this->tProjects = new ArrayCollection();
        $this->tProjectsLocationMaps = new ArrayCollection();
        $this->tProjectsSubOffice = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName(?string $name): self
    {
        $this->name = $name;

        return $this;
    }

    public function getStatus(): ?string
    {
        return $this->status;
    }

    public function setStatus(?string $status): self
    {
        $this->status = $status;

        return $this;
    }

    public function getMainStructureLevel(): ?TMainStructureLevels
    {
        return $this->mainStructureLevel;
    }

    public function setMainStructureLevel(?TMainStructureLevels $mainStructureLevel): self
    {
        $this->mainStructureLevel = $mainStructureLevel;

        return $this;
    }

    /**
     * @return Collection|TMainTargetsPlannings[]
     */
    public function getTMainTargetsPlannings(): Collection
    {
        return $this->tMainTargetsPlannings;
    }

    public function addTMainTargetsPlanning(TMainTargetsPlannings $tMainTargetsPlanning): self
    {
        if (!$this->tMainTargetsPlannings->contains($tMainTargetsPlanning)) {
            $this->tMainTargetsPlannings[] = $tMainTargetsPlanning;
            $tMainTargetsPlanning->setMainStructureOffice($this);
        }

        return $this;
    }

    public function removeTMainTargetsPlanning(TMainTargetsPlannings $tMainTargetsPlanning): self
    {
        if ($this->tMainTargetsPlannings->removeElement($tMainTargetsPlanning)) {
            // set the owning side to null (unless already changed)
            if ($tMainTargetsPlanning->getMainStructureOffice() === $this) {
                $tMainTargetsPlanning->setMainStructureOffice(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection|TMainStructureOfficesPositions[]
     */
    public function getTMainStructureOfficesPositions(): Collection
    {
        return $this->tMainStructureOfficesPositions;
    }

    public function addTMainStructureOfficesPosition(TMainStructureOfficesPositions $tMainStructureOfficesPosition): self
    {
        if (!$this->tMainStructureOfficesPositions->contains($tMainStructureOfficesPosition)) {
            $this->tMainStructureOfficesPositions[] = $tMainStructureOfficesPosition;
            $tMainStructureOfficesPosition->setMainStructureOffice($this);
        }

        return $this;
    }

    public function removeTMainStructureOfficesPosition(TMainStructureOfficesPositions $tMainStructureOfficesPosition): self
    {
        if ($this->tMainStructureOfficesPositions->removeElement($tMainStructureOfficesPosition)) {
            // set the owning side to null (unless already changed)
            if ($tMainStructureOfficesPosition->getMainStructurePosition() === $this) {
                $tMainStructureOfficesPosition->setMainStructurePosition(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection|TProjects[]
     */
    public function getTProjects(): Collection
    {
        return $this->tProjects;
    }

    public function addTProject(TProjects $tProject): self
    {
        if (!$this->tProjects->contains($tProject)) {
            $this->tProjects[] = $tProject;
            $tProject->setMainStructureOffice($this);
        }

        return $this;
    }

    public function removeTProject(TProjects $tProject): self
    {
        if ($this->tProjects->removeElement($tProject)) {
            // set the owning side to null (unless already changed)
            if ($tProject->getMainStructureOffice() === $this) {
                $tProject->setMainStructureOffice(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection|TProjectsLocationMaps[]
     */
    public function getTProjectsLocationMaps(): Collection
    {
        return $this->tProjectsLocationMaps;
    }

    public function addTProjectsLocationMap(TProjectsLocationMaps $tProjectsLocationMap): self
    {
        if (!$this->tProjectsLocationMaps->contains($tProjectsLocationMap)) {
            $this->tProjectsLocationMaps[] = $tProjectsLocationMap;
            $tProjectsLocationMap->setMainStructureOffice($this);
        }

        return $this;
    }

    public function removeTProjectsLocationMap(TProjectsLocationMaps $tProjectsLocationMap): self
    {
        if ($this->tProjectsLocationMaps->removeElement($tProjectsLocationMap)) {
            // set the owning side to null (unless already changed)
            if ($tProjectsLocationMap->getMainStructureOffice() === $this) {
                $tProjectsLocationMap->setMainStructureOffice(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection|TProjects[]
     */
    public function getTProjectsSubOffice(): Collection
    {
        return $this->tProjectsSubOffice;
    }

    public function addTProjectsSubOffice(TProjects $tProjectsSubOffice): self
    {
        if (!$this->tProjectsSubOffice->contains($tProjectsSubOffice)) {
            $this->tProjectsSubOffice[] = $tProjectsSubOffice;
            $tProjectsSubOffice->setSubOffice($this);
        }

        return $this;
    }

    public function removeTProjectsSubOffice(TProjects $tProjectsSubOffice): self
    {
        if ($this->tProjectsSubOffice->removeElement($tProjectsSubOffice)) {
            // set the owning side to null (unless already changed)
            if ($tProjectsSubOffice->getSubOffice() === $this) {
                $tProjectsSubOffice->setSubOffice(null);
            }
        }

        return $this;
    }
}
