buckets/src/Entity/Bucket.php

165 lines
3.5 KiB
PHP

<?php
namespace App\Entity;
use App\Enum\BucketAllocationType;
use App\Enum\BucketType;
use App\Repository\BucketRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\UuidV7;
#[ORM\Entity(repositoryClass: BucketRepository::class)]
#[ORM\Table(name: 'bucket')]
#[ORM\UniqueConstraint(name: 'unique_scenario_priority', columns: ['scenario_id', 'priority'])]
class Bucket
{
#[ORM\Id]
#[ORM\Column(type: 'uuid')]
private UuidV7 $id;
#[ORM\ManyToOne(targetEntity: Scenario::class)]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
private Scenario $scenario;
#[ORM\Column(length: 255)]
private string $name;
#[ORM\Column(enumType: BucketType::class)]
private BucketType $type = BucketType::NEED;
#[ORM\Column]
private int $priority;
#[ORM\Column(options: ['default' => 0])]
private int $sortOrder = 0;
#[ORM\Column(enumType: BucketAllocationType::class)]
private BucketAllocationType $allocationType;
#[ORM\Column(nullable: true)]
private ?int $allocationValue = null;
#[ORM\Column(options: ['default' => 0])]
private int $startingAmount = 0;
#[ORM\Column(type: 'decimal', precision: 5, scale: 2, options: ['default' => '0.00'])]
private string $bufferMultiplier = '0.00';
public function __construct()
{
$this->id = new UuidV7();
}
public function getId(): UuidV7
{
return $this->id;
}
public function getScenario(): Scenario
{
return $this->scenario;
}
public function getName(): string
{
return $this->name;
}
public function getType(): BucketType
{
return $this->type;
}
public function getPriority(): int
{
return $this->priority;
}
public function getSortOrder(): int
{
return $this->sortOrder;
}
public function getAllocationType(): BucketAllocationType
{
return $this->allocationType;
}
public function getAllocationValue(): ?int
{
return $this->allocationValue;
}
public function getStartingAmount(): int
{
return $this->startingAmount;
}
public function getBufferMultiplier(): string
{
return $this->bufferMultiplier;
}
public function setScenario(Scenario $scenario): static
{
$this->scenario = $scenario;
return $this;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function setType(BucketType $type): static
{
$this->type = $type;
return $this;
}
public function setPriority(int $priority): static
{
$this->priority = $priority;
return $this;
}
public function setSortOrder(int $sortOrder): static
{
$this->sortOrder = $sortOrder;
return $this;
}
public function setAllocationType(BucketAllocationType $allocationType): static
{
$this->allocationType = $allocationType;
return $this;
}
public function setAllocationValue(?int $allocationValue): static
{
$this->allocationValue = $allocationValue;
return $this;
}
public function setStartingAmount(int $startingAmount): static
{
$this->startingAmount = $startingAmount;
return $this;
}
public function setBufferMultiplier(string $bufferMultiplier): static
{
$this->bufferMultiplier = $bufferMultiplier;
return $this;
}
}