<?php

namespace App\Entity;

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use App\Repository\ElementRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Attribute\Groups;

#[ORM\Entity(repositoryClass: ElementRepository::class)]
#[ORM\Table(name: 'elemento')]
#[ApiResource(
    operations: [
        new Get(normalizationContext: ['groups' => 'element:item']),
        new GetCollection(normalizationContext: ['groups' => 'element:list'])
    ],
    order: ['label' => 'DESC'],
    paginationEnabled: false,
)]
class Element
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    #[Groups(['element:list', 'element:item'])]
    private ?int $id = null;

    #[ORM\Column(name: 'etichetta', length: 6)]
    #[Groups(['element:list', 'element:item'])]
    private ?string $label = null;

    #[ORM\Column(name: 'rango', length: 50, nullable: true)]
    #[Groups(['element:list', 'element:item'])]
    private ?string $rank = null;

    #[ORM\Column(name: 'tipo', type: Types::BIGINT, nullable: true)]
    #[Groups(['element:list', 'element:item'])]
    private ?string $type = null;

    #[ORM\Column(name: 'materiale', type: Types::BIGINT, nullable: true)]
    #[ORM\ManyToOne(targetEntity: Material::class)]
    #[ORM\JoinColumn(name: 'materiale', referencedColumnName: 'id')]
    #[Groups(['element:list', 'element:item'])]
    #[ApiProperty(uriTemplate: '/materials/{id}')]
    private ?string $material = null;

    #[ORM\Column(name: 'lavorazione', type: Types::BIGINT, nullable: true)]
    private ?string $production = null;

    #[ORM\Column(name: 'posa', type: Types::BIGINT, nullable: true)]
    private ?string $placement = null;

    #[ORM\Column(name: 'strutt_oriz', type: Types::BIGINT)]
    private ?string $horizontalStructure = null;

    #[ORM\Column(name: 'riconoscimento', type: Types::BIGINT, nullable: true)]
    private ?string $identification = null;

    #[ORM\Column(name: 'note', type: Types::TEXT, nullable: true)]
    #[Groups(['element:list', 'element:item'])]
    private ?string $notes = null;

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

    public function setId(string $id): static
    {
        $this->id = $id;

        return $this;
    }

    public function getLabel(): ?string
    {
        return $this->label;
    }

    public function setLabel(string $label): static
    {
        $this->label = $label;

        return $this;
    }

    public function getRank(): ?string
    {
        return $this->rank;
    }

    public function setRank(?string $rank): static
    {
        $this->rank = $rank;

        return $this;
    }

    public function getType(): ?string
    {
        return $this->type;
    }

    public function setType(?string $type): static
    {
        $this->type = $type;

        return $this;
    }

    public function getMaterial(): ?string
    {
        return $this->material;
    }

    public function setMaterial(?string $material): static
    {
        $this->material = $material;

        return $this;
    }

    public function getProduction(): ?string
    {
        return $this->production;
    }

    public function setProduction(?string $production): static
    {
        $this->production = $production;

        return $this;
    }

    public function getPlacement(): ?string
    {
        return $this->placement;
    }

    public function setPlacement(?string $placement): static
    {
        $this->placement = $placement;

        return $this;
    }

    public function getHorizontalStructure(): ?string
    {
        return $this->horizontalStructure;
    }

    public function setHorizontalStructure(string $horizontalStructure): static
    {
        $this->horizontalStructure = $horizontalStructure;

        return $this;
    }

    public function getIdentification(): ?string
    {
        return $this->identification;
    }

    public function setIdentification(?string $identification): static
    {
        $this->identification = $identification;

        return $this;
    }

    public function getNotes(): ?string
    {
        return $this->notes;
    }

    public function setNotes(?string $notes): static
    {
        $this->notes = $notes;

        return $this;
    }
}
