<?php

namespace App\Entity;

use App\RecordInterface;
use App\Repository\SiteRepository;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\DBAL\Types\Types;
use App\RecordStatus;
use Doctrine\Common\Collections\Collection as DoctrineCollection;

#[ORM\Entity(repositoryClass: SiteRepository::class)]
#[ORM\Table(name: 'site')]
class Site implements RecordInterface
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column(name: 'id')]
    private ?int $id = null;

    #[ORM\Column(name: 'stato')]
    private ?int $status = null;

    #[ORM\Column(name: 'modif')]
    private ?DateTimeImmutable $modifiedAt = null;

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

    #[ORM\Column(name: 'nome_ant_sito', type: Types::TEXT)]
    private ?string $ancientName = null;

    //#[ORM\Column(name: 'coord_sito', type: Types::TEXT)]
    private ?float $lat = null;

    private ?float $lng = null;

    #[ORM\Column(name: 'stato_mod_sito', length: 40)]
    private ?string $country = null;

    #[ORM\Column(name: 'desc_sito', type: Types::TEXT)]
    private ?string $description = null;

    #[ORM\Column(name: 'desc_br_sito', type: Types::TEXT)]
    private ?string $shortDescription = null;

    #[ORM\Column(name: 'id_est_sito', type: Types::TEXT)]
    private ?string $externalIdentifier = null;

    #[ORM\Column(name: 'link_sito', type: Types::TEXT)]
    private ?string $link = null;

    #[ORM\Column(name: 'sogg_sito', type: Types::TEXT)]
    private ?string $subjectHeadings = null;

    #[ORM\Column(name: 'uri_sito', type: Types::TEXT)]
    private ?string $uri = null;

    #[ORM\Column(name: 'resp', length: 100)]
    private ?string $owner = null;

    #[ORM\Column(name: 'note_sito', type: Types::TEXT)]
    private ?string $notes = null;

    #[ORM\Column(length: 100, name: 'editor')]
    private ?string $editor = null;

    #[ORM\Column(length: 100, name: 'creator')]
    private ?string $creator = null;

    // TODO: These are references to vocabs
    #[ORM\Column(name: 'dir_aut_sito')]
    private ?int $authorRights = null;

    #[ORM\Column(name: 'dir_acc_sito')]
    private ?int $accessRights = null;

    #[ORM\Column(name: 'lic_sito')]
    private ?int $license = null;

    #[ORM\JoinTable(name: 'rel_sito_collezione')]
    #[ORM\JoinColumn(name: 'Sito_id_sito', referencedColumnName: 'id')]
    #[ORM\InverseJoinColumn(name: 'Collezione_id_coll', referencedColumnName: 'id')]
    #[ORM\ManyToMany(targetEntity: Collection::class, inversedBy: 'conservation_place')]
    private DoctrineCollection $collections;

    private bool $isEditable = false;

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

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

    public function setStatus(int $status): static
    {
        $this->status = $status;

        return $this;
    }

    public function getModifiedAt(): ?DateTimeImmutable
    {
        return $this->modifiedAt;
    }

    public function setModifiedAt(DateTimeImmutable $modifiedAt): static
    {
        $this->modifiedAt = $modifiedAt;

        return $this;
    }

    public function getOwner(): ?string
    {
        return $this->owner;
    }

    public function setOwner(string $owner): static
    {
        $this->owner = $owner;

        return $this;
    }

    public function getEditor(): ?string
    {
        return $this->editor;
    }

    public function setEditor(string $editor): static
    {
        $this->editor = $editor;

        return $this;
    }

    public function getCreator(): ?string
    {
        return $this->creator;
    }

    public function setCreator(string $creator): static
    {
        $this->creator = $creator;

        return $this;
    }

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

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

        return $this;
    }

    public function getCountry(): ?string
    {
        return $this->country;
    }

    public function setCountry(string $country): static
    {
        $this->country = $country;

        return $this;
    }

    public function getAncientName(): ?string
    {
        return $this->ancientName;
    }

    public function setAncientName(string $ancientName): static
    {
        $this->ancientName = $ancientName;

        return $this;
    }

    public function getDescription(): ?string
    {
        return $this->description;
    }

    public function setDescription(string $description): static
    {
        $this->description = $description;

        return $this;
    }

    public function getShortDescription(): ?string
    {
        return $this->shortDescription;
    }

    public function setShortDescription(string $shortDescription): static
    {
        $this->shortDescription = $shortDescription;

        return $this;
    }

    public function getExternalIdentifier(): ?string
    {
        return $this->externalIdentifier;
    }

    public function setExternalIdentifier(string $externalIdentifier): static
    {
        $this->externalIdentifier = $externalIdentifier;

        return $this;
    }

    public function getLink(): ?string
    {
        return $this->link;
    }

    public function setLink(string $link): static
    {
        $this->link = $link;

        return $this;
    }

    public function getSubjectHeadings(): ?string
    {
        return $this->subjectHeadings;
    }

    public function setSubjectHeadings(string $subjectHeadings): static
    {
        $this->subjectHeadings = $subjectHeadings;

        return $this;
    }

    public function getUri(): ?string
    {
        return $this->uri;
    }

    public function setUri(string $uri): static
    {
        $this->uri = $uri;

        return $this;
    }

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

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

        return $this;
    }

    public function getCollections(): ?DoctrineCollection
    {
        return $this->collections;
    }

    public function setCollections(DoctrineCollection $collections): static
    {
        $this->collections = $collections;

        return $this;
    }

    public function getEditableStatus(): bool
    {
        return $this->isEditable;
    }

    public function setEditableStatus(bool $status): static
    {
        $this->isEditable = $status;
        
        return $this;
    }

    public function getLat(): float
    {
        return $this->lat;
    }

    public function setLat(float $lat): static
    {
        $this->lat = $lat;

        return $this;
    }

    public function getLng(): float
    {
        return $this->lng;
    }

    public function setLng(float $lng): static
    {
        $this->lng = $lng;

        return $this;
    }
}
