From 6798fe4c3850d05ecfc171100dbab675d44424b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P?= Date: Tue, 26 Nov 2024 12:47:33 +0100 Subject: [PATCH 1/6] Update Finding --- src/Entity/Finding.php | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/Entity/Finding.php b/src/Entity/Finding.php index 724d167..c2f8213 100644 --- a/src/Entity/Finding.php +++ b/src/Entity/Finding.php @@ -21,9 +21,6 @@ class Finding implements \JsonSerializable #[ORM\Column(length: 200, nullable: true, name: 'materia')] 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')] private ?string $place = null; @@ -102,18 +99,6 @@ class Finding implements \JsonSerializable return $this; } - public function getInventory(): ?string - { - return $this->inventory; - } - - public function setInventory(?string $inventory): static - { - $this->inventory = $inventory; - - return $this; - } - public function getPlace(): ?string { return $this->place; @@ -277,7 +262,6 @@ class Finding implements \JsonSerializable 'object' => $this->object, 'material' => $this->material, 'measurements' => $this->measurements, - 'inventory' => $this->inventory, 'place' => $this->place, 'year' => $this->year, 'dating' => $this->dating, From 83bd1bb9261b534b8bc8e5420651492dc407d1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P?= Date: Tue, 26 Nov 2024 14:33:09 +0100 Subject: [PATCH 2/6] Change year type --- src/Entity/Finding.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Entity/Finding.php b/src/Entity/Finding.php index c2f8213..1cb2674 100644 --- a/src/Entity/Finding.php +++ b/src/Entity/Finding.php @@ -24,8 +24,8 @@ class Finding implements \JsonSerializable #[ORM\Column(length: 100, nullable: true, name: 'luogo_rinv')] private ?string $place = null; - #[ORM\Column(nullable: true, name: 'anno_rinv')] - private ?int $year = null; + #[ORM\Column(nullable: true, name: 'anno_rinv', length: 40)] + private ?string $year = null; #[ORM\Column(length: 200, nullable: true, name: 'datazione')] private ?string $dating = null; @@ -111,12 +111,12 @@ class Finding implements \JsonSerializable return $this; } - public function getYear(): ?int + public function getYear(): ?string { return $this->year; } - public function setYear(?int $year): static + public function setYear(?string $year): static { $this->year = $year; From 3bcdb1bf2de411b8cb0e69900c3fe17535235fee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P?= Date: Tue, 26 Nov 2024 15:27:05 +0100 Subject: [PATCH 3/6] Add columns to Site --- src/Entity/Site.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/Entity/Site.php b/src/Entity/Site.php index 765908b..726e037 100644 --- a/src/Entity/Site.php +++ b/src/Entity/Site.php @@ -74,6 +74,12 @@ class Site implements JsonSerializable #[ORM\Column(name: 'loc_generica', length: 200, nullable: true)] 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 $lng; @@ -322,6 +328,30 @@ class Site implements JsonSerializable 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 { return $this->lat; @@ -394,6 +424,8 @@ class Site implements JsonSerializable 'ownedBy' => $this->ownedBy, 'images' => $this->images->toArray(), 'documents' => $this->documents, + 'techniques' => $this->techniques, + 'author' => $this->author, ]; } } From 0f8f975e3d086d574385ab7bfd4c2348547cba4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P?= Date: Tue, 26 Nov 2024 15:49:36 +0100 Subject: [PATCH 4/6] Add column to Document --- src/Entity/Document.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Entity/Document.php b/src/Entity/Document.php index bb21c84..4ce4f89 100644 --- a/src/Entity/Document.php +++ b/src/Entity/Document.php @@ -26,6 +26,9 @@ class Document implements \JsonSerializable #[ORM\Column(length: 400, nullable: true, name: 'autori')] private ?string $authors = null; + #[ORM\Column(nullable: true, name: 'luogo')] + private ?string $conservationPlace = null; + #[ORM\Column(length: 20, nullable: true, name: 'tipo')] private ?string $type = null; @@ -101,6 +104,18 @@ class Document implements \JsonSerializable return $this; } + public function getConservationPlace(): ?string + { + return $this->conservationPlace; + } + + public function setConservationPlace(?string $conservationPlace): static + { + $this->conservationPlace = $conservationPlace; + + return $this; + } + public function jsonSerialize(): mixed { return [ @@ -109,6 +124,7 @@ class Document implements \JsonSerializable 'filename' => $this->filename, 'description' => $this->description, 'authors' => $this->authors, + 'conservationPlace' => $this->conservationPlace, 'type' => $this->type, ]; } From 78bd3ab85f6c714ed644a07e8cf4c1dc833f6bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P?= Date: Tue, 26 Nov 2024 15:51:52 +0100 Subject: [PATCH 5/6] Update Document repo --- src/Repository/DocumentRepository.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Repository/DocumentRepository.php b/src/Repository/DocumentRepository.php index ba6ea7e..e4c83bf 100644 --- a/src/Repository/DocumentRepository.php +++ b/src/Repository/DocumentRepository.php @@ -31,6 +31,7 @@ class DocumentRepository extends ServiceEntityRepository filename, descrizione, autori, + luogo, tipo FROM documento d JOIN sito_documento From 5706cab5518801c2638a8d7842f7fd97e23f9527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P?= Date: Thu, 28 Nov 2024 09:40:50 +0100 Subject: [PATCH 6/6] Add site-biblio relation --- src/Controller/SiteController.php | 4 ++++ src/Entity/Site.php | 21 +++++++++++++++++++ src/Repository/BibliographyRepository.php | 25 +++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/src/Controller/SiteController.php b/src/Controller/SiteController.php index a7e7a63..0e3ae55 100644 --- a/src/Controller/SiteController.php +++ b/src/Controller/SiteController.php @@ -5,6 +5,7 @@ namespace App\Controller; use App\Entity\Site; use App\Entity\Image; use App\Entity\Document; +use App\Entity\Bibliography; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -32,9 +33,12 @@ class SiteController extends AbstractController ); $repo = $em->getRepository(Document::class); $documents = $repo->findBySite($site->getId()); + $repo = $em->getRepository(Bibliography::class); + $bibliography = $repo->findAllBySite($site->getId()); $site->setImages($images); $site->setDocuments($documents); + $site->setBibliography($bibliography); $site->setLat((float) $coords['lat']); $site->setLng((float) $coords['lng']); diff --git a/src/Entity/Site.php b/src/Entity/Site.php index 726e037..559e1c0 100644 --- a/src/Entity/Site.php +++ b/src/Entity/Site.php @@ -86,8 +86,16 @@ class Site implements JsonSerializable private ?ArrayCollection $images; + /** + * @var Document[] $documents + */ private ?array $documents; + /** + * @var Bibliography[] $bibliography + */ + private ?array $bibliography; + public function getId(): ?int { return $this->id; @@ -398,6 +406,18 @@ class Site implements JsonSerializable return $this; } + public function getBibliography(): ?array + { + return $this->bibliography; + } + + public function setBibliography(array $bibliography): static + { + $this->bibliography = $bibliography; + + return $this; + } + public function jsonSerialize(): array { return [ @@ -424,6 +444,7 @@ class Site implements JsonSerializable 'ownedBy' => $this->ownedBy, 'images' => $this->images->toArray(), 'documents' => $this->documents, + 'bibliography' => $this->bibliography, 'techniques' => $this->techniques, 'author' => $this->author, ]; diff --git a/src/Repository/BibliographyRepository.php b/src/Repository/BibliographyRepository.php index f085bbb..9d75107 100644 --- a/src/Repository/BibliographyRepository.php +++ b/src/Repository/BibliographyRepository.php @@ -17,6 +17,31 @@ class BibliographyRepository extends ServiceEntityRepository 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[] */