<?php

namespace App\Entity;

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

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_pc_matrixes:read"}, "enable_max_depth"="true", "swagger_definition_name"="Read"},
 *    denormalizationContext={"groups"={"t_pc_matrixes:write"}, "swagger_definition_name"="Write"}
 * )
 * @ApiFilter(SearchFilter::class, properties={ "id": "exact", "pc": "exact", "kpa": "exact" })
 * @ApiFilter(PropertyFilter::class)
 * @ORM\Entity(repositoryClass=TPcMatrixesRepository::class)
 */

class TPcMatrixes
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * @Groups({ "t_pc_matrixes:read", "t_pc_matrixes:write", "t_pc_matrixes_milestones:read", "t_pc_matrixes_milestones_cascades:read" })
     */
    private $id;

    /**
     * @ORM\ManyToOne(targetEntity=TMainTargetsPlannings::class, inversedBy="tPcMatrixes")
     * @Groups({ "t_pc_matrixes:read", "t_pc_matrixes:write" })
     */
    private $pc;

    /**
     * @ORM\ManyToOne(targetEntity=TKpas::class, inversedBy="tPcMatrixes")
     * @Groups({ "t_pc_matrixes:read", "t_pc_matrixes:write" })
     */
    private $kpa;

    /**
     * @ORM\Column(type="text", nullable=true)
     * @Groups({ "t_pc_matrixes:read", "t_pc_matrixes:write", "t_pc_matrixes_milestones:read", "t_pc_matrixes_milestones_cascades:read" })
     */
    private $planningStatement;

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

    /**
     * @ORM\Column(type="decimal", precision=60, scale=2, nullable=true)
     * @Groups({ "t_pc_matrixes:read", "t_pc_matrixes:write" })
     */
    private $weight;

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

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

    /**
     * @ORM\Column(type="text", nullable=true)
     * @Groups({ "t_pc_matrixes:read", "t_pc_matrixes:write", "t_pc_matrixes_milestones:read", "t_pc_matrixes_milestones_cascades:read" })
     */
    private $indicatorDescription;

    /**
     * @ORM\OneToMany(targetEntity=TPcMatrixesCascades::class, mappedBy="majorCascade")
     * @Groups({ "t_pc_matrixes:read", "t_pc_matrixes:write" })
     */
    private $tPcMatrixesCascades;

    /**
     * @ORM\OneToMany(targetEntity=TPcMatrixesMilestones::class, mappedBy="pcMatrix")
     */
    private $tPcMatrixesMilestones;

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

    public function __construct()
    {
        $this->tPcMatrixesCascades = new ArrayCollection();
        $this->tPcMatrixesMilestones = new ArrayCollection();
    }

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

    public function getPc(): ?TMainTargetsPlannings
    {
        return $this->pc;
    }

    public function setPc(?TMainTargetsPlannings $pc): self
    {
        $this->pc = $pc;

        return $this;
    }

    public function getKpa(): ?TKpas
    {
        return $this->kpa;
    }

    public function setKpa(?TKpas $kpa): self
    {
        $this->kpa = $kpa;

        return $this;
    }

    public function getPlanningStatement(): ?string
    {
        return $this->planningStatement;
    }

    public function setPlanningStatement(?string $planningStatement): self
    {
        $this->planningStatement = $planningStatement;

        return $this;
    }

    public function getUnitOfMeasure(): ?string
    {
        return $this->unitOfMeasure;
    }

    public function setUnitOfMeasure(?string $unitOfMeasure): self
    {
        $this->unitOfMeasure = $unitOfMeasure;

        return $this;
    }

    public function getWeight(): ?string
    {
        return $this->weight;
    }

    public function setWeight(?string $weight): self
    {
        $this->weight = $weight;

        return $this;
    }

    public function getBaseline(): ?string
    {
        return $this->baseline;
    }

    public function setBaseline(?string $baseline): self
    {
        $this->baseline = $baseline;

        return $this;
    }

    public function getAnnualTarget(): ?string
    {
        return $this->annualTarget;
    }

    public function setAnnualTarget(?string $annualTarget): self
    {
        $this->annualTarget = $annualTarget;

        return $this;
    }

    public function getIndicatorDescription(): ?string
    {
        return $this->indicatorDescription;
    }

    public function setIndicatorDescription(?string $indicatorDescription): self
    {
        $this->indicatorDescription = $indicatorDescription;

        return $this;
    }

    /**
     * @return Collection|TPcMatrixesCascades[]
     */
    public function getTPcMatrixesCascades(): Collection
    {
        return $this->tPcMatrixesCascades;
    }

    public function addTPcMatrixesCascade(TPcMatrixesCascades $tPcMatrixesCascade): self
    {
        if (!$this->tPcMatrixesCascades->contains($tPcMatrixesCascade)) {
            $this->tPcMatrixesCascades[] = $tPcMatrixesCascade;
            $tPcMatrixesCascade->setMajorCascade($this);
        }

        return $this;
    }

    public function removeTPcMatrixesCascade(TPcMatrixesCascades $tPcMatrixesCascade): self
    {
        if ($this->tPcMatrixesCascades->removeElement($tPcMatrixesCascade)) {
            // set the owning side to null (unless already changed)
            if ($tPcMatrixesCascade->getMajorCascade() === $this) {
                $tPcMatrixesCascade->setMajorCascade(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection|TPcMatrixesMilestones[]
     */
    public function getTPcMatrixesMilestones(): Collection
    {
        return $this->tPcMatrixesMilestones;
    }

    public function addTPcMatrixesMilestone(TPcMatrixesMilestones $tPcMatrixesMilestone): self
    {
        if (!$this->tPcMatrixesMilestones->contains($tPcMatrixesMilestone)) {
            $this->tPcMatrixesMilestones[] = $tPcMatrixesMilestone;
            $tPcMatrixesMilestone->setPcMatrix($this);
        }

        return $this;
    }

    public function removeTPcMatrixesMilestone(TPcMatrixesMilestones $tPcMatrixesMilestone): self
    {
        if ($this->tPcMatrixesMilestones->removeElement($tPcMatrixesMilestone)) {
            // set the owning side to null (unless already changed)
            if ($tPcMatrixesMilestone->getPcMatrix() === $this) {
                $tPcMatrixesMilestone->setPcMatrix(null);
            }
        }

        return $this;
    }

    public function getMatrixCode(): ?string
    {
        return $this->matrixCode;
    }

    public function setMatrixCode(?string $matrixCode): self
    {
        $this->matrixCode = $matrixCode;

        return $this;
    }
}
