src/Entity/WorksPlanJob.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\WorksPlanJobRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Context;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. /**
  10.  * WorksPlanJob — task altındaki iş birimi (Order'daki ProjectOrderTaskJobs aynası).
  11.  * Planlama otoritesi burada: start_at + should_end_at cascade kaynağı.
  12.  * is_end_at Order'dan listener ile geri akar; cascade tetiklemez (informational).
  13.  *
  14.  * Dependency edge'i child sahibinde — bu job için "ben başlamadan önce şunlar bitsin":
  15.  *  - $parent_dependencies: bu job'a gelen kenarlar (child=$this)
  16.  *  - $child_dependencies:  bu job'tan giden kenarlar (parent=$this)
  17.  *
  18.  * @ORM\Entity(repositoryClass=WorksPlanJobRepository::class)
  19.  * @ORM\Table(name="works_plan_jobs")
  20.  */
  21. class WorksPlanJob
  22. {
  23.     /**
  24.      * @ORM\Id
  25.      * @ORM\GeneratedValue
  26.      * @ORM\Column(type="integer")
  27.      * @Groups({
  28.      *     "works_plan_job@base",
  29.      *     "works_plan_job@core"
  30.      * })
  31.      */
  32.     private $id;
  33.     /**
  34.      * @ORM\ManyToOne(targetEntity=WorksPlanTask::class, inversedBy="jobs")
  35.      * @ORM\JoinColumn(name="works_plan_task_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  36.      */
  37.     private $works_plan_task;
  38.     /**
  39.      * @ORM\Column(type="integer")
  40.      * @Groups({
  41.      *     "works_plan_job@base",
  42.      *     "works_plan_job@core"
  43.      * })
  44.      */
  45.     private $job_index;
  46.     /**
  47.      * @ORM\Column(type="text", nullable=true)
  48.      * @Groups({
  49.      *     "works_plan_job@core"
  50.      * })
  51.      */
  52.     private $job_description;
  53.     /**
  54.      * Serbest açıklama/not (başlık=job_description'dan ayrı). Drawer'da düzenlenir.
  55.      *
  56.      * @ORM\Column(type="text", nullable=true)
  57.      * @Groups({
  58.      *     "works_plan_job@core"
  59.      * })
  60.      */
  61.     private $description;
  62.     /**
  63.      * @ORM\Column(type="float")
  64.      * @Groups({
  65.      *     "works_plan_job@core"
  66.      * })
  67.      */
  68.     private $job_weight;
  69.     /**
  70.      * Ağırlık pin: kullanıcı bu job'un yüzdesini bilerek sabitlediyse true.
  71.      * Rebalance pinli job'lara dokunmaz; pinsiz kardeşler kalanı orantılı paylaşır.
  72.      *
  73.      * @ORM\Column(type="boolean", options={"default": false})
  74.      * @Groups({
  75.      *     "works_plan_job@core"
  76.      * })
  77.      */
  78.     private $weight_locked false;
  79.     /**
  80.      * Tamamlama kilidi (weight_locked'tan FARKLI). Order job tamamlanınca true olur
  81.      * (back-sync). Kilitliyken order job'u değiştiremez; sadece plan yöneticisi unlock eder.
  82.      * Plan = lock otoritesi; materialize ile order'a (project_order_task_jobs.locked) yansır.
  83.      *
  84.      * @ORM\Column(type="boolean", options={"default": false})
  85.      * @Groups({
  86.      *     "works_plan_job@core"
  87.      * })
  88.      */
  89.     private $locked false;
  90.     /**
  91.      * @ORM\Column(type="date_immutable", nullable=true)
  92.      * @Groups({
  93.      *     "works_plan_job@core"
  94.      * })
  95.      * @Context({"datetime_format"="Y-m-d"})
  96.      */
  97.     private $start_at;
  98.     /**
  99.      * @ORM\Column(type="date_immutable", nullable=true)
  100.      * @Groups({
  101.      *     "works_plan_job@core"
  102.      * })
  103.      * @Context({"datetime_format"="Y-m-d"})
  104.      */
  105.     private $should_end_at;
  106.     /**
  107.      * @ORM\Column(type="date_immutable", nullable=true)
  108.      * @Groups({
  109.      *     "works_plan_job@core"
  110.      * })
  111.      * @Context({"datetime_format"="Y-m-d"})
  112.      */
  113.     private $is_end_at;
  114.     /**
  115.      * Bitiş geri bildirimi / sebep (elle is_end_at girilince). Yalnızca Plan tarafında;
  116.      * Order'a yansımaz (orada gerekmez).
  117.      *
  118.      * @ORM\Column(type="text", nullable=true)
  119.      * @Groups({
  120.      *     "works_plan_job@core"
  121.      * })
  122.      */
  123.     private $is_end_note;
  124.     /**
  125.      * @ORM\Column(type="float")
  126.      * @Groups({
  127.      *     "works_plan_job@core"
  128.      * })
  129.      */
  130.     private $duration_days;
  131.     /**
  132.      * Bu job'a gelen kenarlar (child=$this). UI'da "Bekle: [parent chip] +Ng" listesi.
  133.      *
  134.      * @ORM\OneToMany(targetEntity=WorksPlanJobDependency::class, mappedBy="child_job", cascade={"persist", "remove"}, orphanRemoval=true)
  135.      * @ORM\OrderBy({"dependency_index" = "ASC"})
  136.      * @Groups({
  137.      *     "works_plan_job@dependencies"
  138.      * })
  139.      */
  140.     private $parent_dependencies;
  141.     /**
  142.      * Bu job'tan giden kenarlar (parent=$this). Yalnızca cascade hesabı / cycle detection için.
  143.      * Serialization gerekmez (back-reference).
  144.      *
  145.      * @ORM\OneToMany(targetEntity=WorksPlanJobDependency::class, mappedBy="parent_job", cascade={"persist", "remove"}, orphanRemoval=true)
  146.      */
  147.     private $child_dependencies;
  148.     /**
  149.      * @ORM\OneToMany(targetEntity=WorksPlanJobHistory::class, mappedBy="job", cascade={"persist", "remove"}, orphanRemoval=true)
  150.      * @ORM\OrderBy({"changed_at" = "DESC"})
  151.      * @Groups({
  152.      *     "works_plan_job@history"
  153.      * })
  154.      */
  155.     private $history;
  156.     public function __construct()
  157.     {
  158.         $this->parent_dependencies = new ArrayCollection();
  159.         $this->child_dependencies = new ArrayCollection();
  160.         $this->history = new ArrayCollection();
  161.     }
  162.     public function getId(): ?int
  163.     {
  164.         return $this->id;
  165.     }
  166.     public function getWorksPlanTask(): ?WorksPlanTask
  167.     {
  168.         return $this->works_plan_task;
  169.     }
  170.     public function setWorksPlanTask(?WorksPlanTask $works_plan_task): self
  171.     {
  172.         $this->works_plan_task $works_plan_task;
  173.         return $this;
  174.     }
  175.     public function getJobIndex(): ?int
  176.     {
  177.         return $this->job_index;
  178.     }
  179.     public function setJobIndex(int $job_index): self
  180.     {
  181.         $this->job_index $job_index;
  182.         return $this;
  183.     }
  184.     public function getJobDescription(): ?string
  185.     {
  186.         return $this->job_description;
  187.     }
  188.     public function setJobDescription(?string $job_description): self
  189.     {
  190.         $this->job_description $job_description;
  191.         return $this;
  192.     }
  193.     public function getDescription(): ?string
  194.     {
  195.         return $this->description;
  196.     }
  197.     public function setDescription(?string $description): self
  198.     {
  199.         $this->description $description;
  200.         return $this;
  201.     }
  202.     public function getJobWeight(): ?float
  203.     {
  204.         return $this->job_weight;
  205.     }
  206.     public function setJobWeight(float $job_weight): self
  207.     {
  208.         $this->job_weight $job_weight;
  209.         return $this;
  210.     }
  211.     public function getWeightLocked(): bool
  212.     {
  213.         return (bool) $this->weight_locked;
  214.     }
  215.     public function getLocked(): bool
  216.     {
  217.         return (bool) $this->locked;
  218.     }
  219.     public function setLocked(bool $locked): self
  220.     {
  221.         $this->locked $locked;
  222.         return $this;
  223.     }
  224.     public function setWeightLocked(bool $weight_locked): self
  225.     {
  226.         $this->weight_locked $weight_locked;
  227.         return $this;
  228.     }
  229.     public function getStartAt(): ?\DateTimeImmutable
  230.     {
  231.         return $this->start_at;
  232.     }
  233.     public function setStartAt(?\DateTimeImmutable $start_at): self
  234.     {
  235.         $this->start_at $start_at;
  236.         return $this;
  237.     }
  238.     public function getShouldEndAt(): ?\DateTimeImmutable
  239.     {
  240.         return $this->should_end_at;
  241.     }
  242.     public function setShouldEndAt(?\DateTimeImmutable $should_end_at): self
  243.     {
  244.         $this->should_end_at $should_end_at;
  245.         return $this;
  246.     }
  247.     public function getIsEndAt(): ?\DateTimeImmutable
  248.     {
  249.         return $this->is_end_at;
  250.     }
  251.     public function setIsEndAt(?\DateTimeImmutable $is_end_at): self
  252.     {
  253.         $this->is_end_at $is_end_at;
  254.         return $this;
  255.     }
  256.     public function getIsEndNote(): ?string
  257.     {
  258.         return $this->is_end_note;
  259.     }
  260.     public function setIsEndNote(?string $is_end_note): self
  261.     {
  262.         $this->is_end_note $is_end_note;
  263.         return $this;
  264.     }
  265.     public function getDurationDays(): ?float
  266.     {
  267.         return $this->duration_days;
  268.     }
  269.     public function setDurationDays(float $duration_days): self
  270.     {
  271.         $this->duration_days $duration_days;
  272.         return $this;
  273.     }
  274.     /**
  275.      * @return Collection<int, WorksPlanJobDependency>
  276.      */
  277.     public function getParentDependencies(): Collection
  278.     {
  279.         return new ArrayCollection(array_values($this->parent_dependencies->toArray()));
  280.     }
  281.     public function addParentDependency(WorksPlanJobDependency $dependency): self
  282.     {
  283.         if (!$this->parent_dependencies->contains($dependency)) {
  284.             $this->parent_dependencies[] = $dependency;
  285.             $dependency->setChildJob($this);
  286.         }
  287.         return $this;
  288.     }
  289.     public function removeParentDependency(WorksPlanJobDependency $dependency): self
  290.     {
  291.         if ($this->parent_dependencies->removeElement($dependency)) {
  292.             if ($dependency->getChildJob() === $this) {
  293.                 $dependency->setChildJob(null);
  294.             }
  295.         }
  296.         return $this;
  297.     }
  298.     /**
  299.      * @return Collection<int, WorksPlanJobDependency>
  300.      */
  301.     public function getChildDependencies(): Collection
  302.     {
  303.         return new ArrayCollection(array_values($this->child_dependencies->toArray()));
  304.     }
  305.     /**
  306.      * @return Collection<int, WorksPlanJobHistory>
  307.      */
  308.     public function getHistory(): Collection
  309.     {
  310.         return new ArrayCollection(array_values($this->history->toArray()));
  311.     }
  312.     public function addHistory(WorksPlanJobHistory $entry): self
  313.     {
  314.         if (!$this->history->contains($entry)) {
  315.             $this->history[] = $entry;
  316.             $entry->setJob($this);
  317.         }
  318.         return $this;
  319.     }
  320. }