This commit is contained in:
Nicolò P 2024-11-30 15:01:30 +01:00
commit 042b94f1af
6 changed files with 103 additions and 20 deletions

View File

@ -5,6 +5,7 @@ namespace App\Controller;
use App\Entity\Site; use App\Entity\Site;
use App\Entity\Image; use App\Entity\Image;
use App\Entity\Document; use App\Entity\Document;
use App\Entity\Bibliography;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -32,9 +33,12 @@ class SiteController extends AbstractController
); );
$repo = $em->getRepository(Document::class); $repo = $em->getRepository(Document::class);
$documents = $repo->findBySite($site->getId()); $documents = $repo->findBySite($site->getId());
$repo = $em->getRepository(Bibliography::class);
$bibliography = $repo->findAllBySite($site->getId());
$site->setImages($images); $site->setImages($images);
$site->setDocuments($documents); $site->setDocuments($documents);
$site->setBibliography($bibliography);
$site->setLat((float) $coords['lat']); $site->setLat((float) $coords['lat']);
$site->setLng((float) $coords['lng']); $site->setLng((float) $coords['lng']);

View File

@ -26,6 +26,9 @@ class Document implements \JsonSerializable
#[ORM\Column(length: 400, nullable: true, name: 'autori')] #[ORM\Column(length: 400, nullable: true, name: 'autori')]
private ?string $authors = null; private ?string $authors = null;
#[ORM\Column(nullable: true, name: 'luogo')]
private ?string $conservationPlace = null;
#[ORM\Column(length: 20, nullable: true, name: 'tipo')] #[ORM\Column(length: 20, nullable: true, name: 'tipo')]
private ?string $type = null; private ?string $type = null;
@ -101,6 +104,18 @@ class Document implements \JsonSerializable
return $this; return $this;
} }
public function getConservationPlace(): ?string
{
return $this->conservationPlace;
}
public function setConservationPlace(?string $conservationPlace): static
{
$this->conservationPlace = $conservationPlace;
return $this;
}
public function jsonSerialize(): mixed public function jsonSerialize(): mixed
{ {
return [ return [
@ -109,6 +124,7 @@ class Document implements \JsonSerializable
'filename' => $this->filename, 'filename' => $this->filename,
'description' => $this->description, 'description' => $this->description,
'authors' => $this->authors, 'authors' => $this->authors,
'conservationPlace' => $this->conservationPlace,
'type' => $this->type, 'type' => $this->type,
]; ];
} }

View File

@ -21,14 +21,11 @@ class Finding implements \JsonSerializable
#[ORM\Column(length: 200, nullable: true, name: 'materia')] #[ORM\Column(length: 200, nullable: true, name: 'materia')]
private ?string $material = null; private ?string $material = null;
#[ORM\Column(length: 30, nullable: true, name: 'inventario')]
private ?string $inventory = null;
#[ORM\Column(length: 100, nullable: true, name: 'luogo_rinv')] #[ORM\Column(length: 100, nullable: true, name: 'luogo_rinv')]
private ?string $place = null; private ?string $place = null;
#[ORM\Column(nullable: true, name: 'anno_rinv')] #[ORM\Column(nullable: true, name: 'anno_rinv', length: 40)]
private ?int $year = null; private ?string $year = null;
#[ORM\Column(length: 200, nullable: true, name: 'datazione')] #[ORM\Column(length: 200, nullable: true, name: 'datazione')]
private ?string $dating = null; private ?string $dating = null;
@ -102,18 +99,6 @@ class Finding implements \JsonSerializable
return $this; return $this;
} }
public function getInventory(): ?string
{
return $this->inventory;
}
public function setInventory(?string $inventory): static
{
$this->inventory = $inventory;
return $this;
}
public function getPlace(): ?string public function getPlace(): ?string
{ {
return $this->place; return $this->place;
@ -126,12 +111,12 @@ class Finding implements \JsonSerializable
return $this; return $this;
} }
public function getYear(): ?int public function getYear(): ?string
{ {
return $this->year; return $this->year;
} }
public function setYear(?int $year): static public function setYear(?string $year): static
{ {
$this->year = $year; $this->year = $year;
@ -277,7 +262,6 @@ class Finding implements \JsonSerializable
'object' => $this->object, 'object' => $this->object,
'material' => $this->material, 'material' => $this->material,
'measurements' => $this->measurements, 'measurements' => $this->measurements,
'inventory' => $this->inventory,
'place' => $this->place, 'place' => $this->place,
'year' => $this->year, 'year' => $this->year,
'dating' => $this->dating, 'dating' => $this->dating,

View File

@ -74,14 +74,28 @@ class Site implements JsonSerializable
#[ORM\Column(name: 'loc_generica', length: 200, nullable: true)] #[ORM\Column(name: 'loc_generica', length: 200, nullable: true)]
private ?string $genericPlace = null; private ?string $genericPlace = null;
#[ORM\Column(name: 'tecniche_ed', nullable: true)]
private ?string $techniques = null;
#[ORM\Column(name: 'autore_scheda', nullable: true)]
private ?string $author = null;
private ?float $lat; private ?float $lat;
private ?float $lng; private ?float $lng;
private ?ArrayCollection $images; private ?ArrayCollection $images;
/**
* @var Document[] $documents
*/
private ?array $documents; private ?array $documents;
/**
* @var Bibliography[] $bibliography
*/
private ?array $bibliography;
public function getId(): ?int public function getId(): ?int
{ {
return $this->id; return $this->id;
@ -322,6 +336,30 @@ class Site implements JsonSerializable
return $this; return $this;
} }
public function getTechniques(): ?string
{
return $this->techniques;
}
public function setTechniques(string $techniques): static
{
$this->techniques = $techniques;
return $this;
}
public function getAuthor(): ?string
{
return $this->author;
}
public function setAuthor(string $author): static
{
$this->author = $author;
return $this;
}
public function getLat(): ?float public function getLat(): ?float
{ {
return $this->lat; return $this->lat;
@ -368,6 +406,18 @@ class Site implements JsonSerializable
return $this; return $this;
} }
public function getBibliography(): ?array
{
return $this->bibliography;
}
public function setBibliography(array $bibliography): static
{
$this->bibliography = $bibliography;
return $this;
}
public function jsonSerialize(): array public function jsonSerialize(): array
{ {
return [ return [
@ -394,6 +444,9 @@ class Site implements JsonSerializable
'ownedBy' => $this->ownedBy, 'ownedBy' => $this->ownedBy,
'images' => $this->images->toArray(), 'images' => $this->images->toArray(),
'documents' => $this->documents, 'documents' => $this->documents,
'bibliography' => $this->bibliography,
'techniques' => $this->techniques,
'author' => $this->author,
]; ];
} }
} }

View File

@ -17,6 +17,31 @@ class BibliographyRepository extends ServiceEntityRepository
parent::__construct($registry, Bibliography::class); parent::__construct($registry, Bibliography::class);
} }
/**
* @return Bibliography[]
*/
public function findAllBySite(int $siteId): array
{
$rsm = new ResultSetMappingBuilder($this->getEntityManager());
$rsm->addRootEntityFromClassMetadata('App\Entity\Bibliography', 'b');
$query = $this->getEntityManager()->createNativeQuery(
'SELECT
id,
citazione,
riferimento,
pagine
FROM bibliografia b
JOIN bibliografia_sito
ON id_bibliografia = b.id
WHERE id_sito = :id
ORDER BY ordine ASC',
$rsm
);
$query->setParameter('id', $siteId);
return $query->getResult();
}
/** /**
* @return Bibliography[] * @return Bibliography[]
*/ */

View File

@ -31,6 +31,7 @@ class DocumentRepository extends ServiceEntityRepository
filename, filename,
descrizione, descrizione,
autori, autori,
luogo,
tipo tipo
FROM documento d FROM documento d
JOIN sito_documento JOIN sito_documento