Compare commits

...

32 Commits

Author SHA1 Message Date
2fc6977362 Images and documents for Underwater 2025-09-02 14:28:12 +02:00
386653b6bf Add images in Finding index 2025-09-02 09:59:35 +02:00
f35be9c845 Bibliography for Reuse 2025-08-08 16:28:56 +02:00
f91d88e04c Add missing endpoint for Reuse... 2025-08-08 12:05:52 +02:00
eabb619d90 Fix table name for Reuse coordinates 2025-08-08 11:27:37 +02:00
875ca03568 Add Reuse endpoint 2025-08-08 11:13:13 +02:00
660d409093 Merge branch 'master' of https://git.electricmandarine.cloud/nicolo/caprigis-api 2025-07-10 16:05:32 +02:00
b446c66fd6 Add Reuse (WIP) 2025-07-10 16:05:15 +02:00
42e32952d6 Add 'Reconstruction' image type 2025-07-08 12:06:02 +02:00
72af052651 Add GeoImage endpoints 2025-06-19 16:21:16 +02:00
e98cbc585b Merge branch 'master' of https://git.electricmandarine.cloud/nicolo/caprigis-api 2025-06-16 17:33:34 +02:00
726772ed75 WIP: Add GeoImage (georeferenced image) 2025-06-16 17:33:19 +02:00
c0d5b38a89 Add label for Underwater 2025-06-06 14:06:31 +02:00
321a6a4bea Retrieve ordered results 2025-06-06 13:53:42 +02:00
7ab75a30fb Use manual hydration for many-to-many to avoid problems with caching 2025-06-05 15:32:51 +02:00
660de08377 Add properties to Finding and Prehistoric 2025-06-03 15:34:45 +02:00
e402dbe97f Add properties to NotConserved 2025-06-03 14:11:59 +02:00
e5810d94c6 Add images to prehistoric 2025-05-07 16:41:23 +02:00
696ef51508 Add records property for underwater json (useless...) 2025-04-29 12:02:26 +02:00
2fa1d2d99e Add underwater sites 2025-04-29 10:50:10 +02:00
b84d4589fe Documents for not conserved 2025-04-28 15:55:07 +02:00
68854f875b Images for NotConserved 2025-04-28 12:36:42 +02:00
f573b4deca Add label to Site 2025-03-26 16:24:59 +01:00
6dc99531c7 Get site with id 2025-03-26 15:00:51 +01:00
95d78be851 Add flags to Site 2025-03-26 11:46:52 +01:00
851808021a Add sites endpoint 2025-03-24 21:53:51 +01:00
dc06764e36 Add Prehistoric stuff... 2025-01-10 11:33:03 +01:00
faee735af8 Update Site... again 2024-12-02 11:22:09 +01:00
691a78579e Update Site 2024-12-02 11:16:49 +01:00
b55f968201 Update Site 2024-12-01 15:43:42 +01:00
042b94f1af Merge branch 'master' of https://git.electricmandarine.cloud/nicolo/caprigis-api 2024-11-30 15:01:30 +01:00
16a73972cc Add video for ImageType 2024-11-30 15:00:59 +01:00
24 changed files with 1879 additions and 157 deletions

90
composer.lock generated
View File

@@ -347,16 +347,16 @@
}, },
{ {
"name": "doctrine/doctrine-bundle", "name": "doctrine/doctrine-bundle",
"version": "2.13.0", "version": "2.13.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/DoctrineBundle.git", "url": "https://github.com/doctrine/DoctrineBundle.git",
"reference": "ca59d84b8e63143ce1aed90cdb333ba329d71563" "reference": "2740ad8b8739b39ab37d409c972b092f632b025a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/ca59d84b8e63143ce1aed90cdb333ba329d71563", "url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/2740ad8b8739b39ab37d409c972b092f632b025a",
"reference": "ca59d84b8e63143ce1aed90cdb333ba329d71563", "reference": "2740ad8b8739b39ab37d409c972b092f632b025a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -370,7 +370,7 @@
"symfony/console": "^5.4 || ^6.0 || ^7.0", "symfony/console": "^5.4 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0", "symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
"symfony/deprecation-contracts": "^2.1 || ^3", "symfony/deprecation-contracts": "^2.1 || ^3",
"symfony/doctrine-bridge": "^5.4.19 || ^6.0.7 || ^7.0", "symfony/doctrine-bridge": "^5.4.46 || ^6.4.3 || ^7.0.3",
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0", "symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0",
"symfony/polyfill-php80": "^1.15", "symfony/polyfill-php80": "^1.15",
"symfony/service-contracts": "^1.1.1 || ^2.0 || ^3" "symfony/service-contracts": "^1.1.1 || ^2.0 || ^3"
@@ -447,7 +447,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/doctrine/DoctrineBundle/issues", "issues": "https://github.com/doctrine/DoctrineBundle/issues",
"source": "https://github.com/doctrine/DoctrineBundle/tree/2.13.0" "source": "https://github.com/doctrine/DoctrineBundle/tree/2.13.1"
}, },
"funding": [ "funding": [
{ {
@@ -463,7 +463,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-09-01T09:46:40+00:00" "time": "2024-11-08T23:27:54+00:00"
}, },
{ {
"name": "doctrine/doctrine-migrations-bundle", "name": "doctrine/doctrine-migrations-bundle",
@@ -1746,16 +1746,16 @@
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
"version": "v7.1.7", "version": "v7.1.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/console.git", "url": "https://github.com/symfony/console.git",
"reference": "3284aafcac338b6e86fd955ee4d794cbe434151a" "reference": "ff04e5b5ba043d2badfb308197b9e6b42883fcd5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/3284aafcac338b6e86fd955ee4d794cbe434151a", "url": "https://api.github.com/repos/symfony/console/zipball/ff04e5b5ba043d2badfb308197b9e6b42883fcd5",
"reference": "3284aafcac338b6e86fd955ee4d794cbe434151a", "reference": "ff04e5b5ba043d2badfb308197b9e6b42883fcd5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1819,7 +1819,7 @@
"terminal" "terminal"
], ],
"support": { "support": {
"source": "https://github.com/symfony/console/tree/v7.1.7" "source": "https://github.com/symfony/console/tree/v7.1.8"
}, },
"funding": [ "funding": [
{ {
@@ -1835,20 +1835,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-11-05T15:34:55+00:00" "time": "2024-11-06T14:23:19+00:00"
}, },
{ {
"name": "symfony/dependency-injection", "name": "symfony/dependency-injection",
"version": "v7.1.6", "version": "v7.1.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/dependency-injection.git", "url": "https://github.com/symfony/dependency-injection.git",
"reference": "1f12f9d580ef8dd09e3b756aa111cc2d5f311bfd" "reference": "e4d13f0f394f4d02a041ff76acd31c5a20a5f70b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/1f12f9d580ef8dd09e3b756aa111cc2d5f311bfd", "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/e4d13f0f394f4d02a041ff76acd31c5a20a5f70b",
"reference": "1f12f9d580ef8dd09e3b756aa111cc2d5f311bfd", "reference": "e4d13f0f394f4d02a041ff76acd31c5a20a5f70b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1899,7 +1899,7 @@
"description": "Allows you to standardize and centralize the way objects are constructed in your application", "description": "Allows you to standardize and centralize the way objects are constructed in your application",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": { "support": {
"source": "https://github.com/symfony/dependency-injection/tree/v7.1.6" "source": "https://github.com/symfony/dependency-injection/tree/v7.1.8"
}, },
"funding": [ "funding": [
{ {
@@ -1915,7 +1915,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-10-25T15:11:02+00:00" "time": "2024-11-09T09:16:45+00:00"
}, },
{ {
"name": "symfony/deprecation-contracts", "name": "symfony/deprecation-contracts",
@@ -2745,16 +2745,16 @@
}, },
{ {
"name": "symfony/http-foundation", "name": "symfony/http-foundation",
"version": "v7.1.7", "version": "v7.1.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/http-foundation.git", "url": "https://github.com/symfony/http-foundation.git",
"reference": "5183b61657807099d98f3367bcccb850238b17a9" "reference": "f4419ec69ccfc3f725a4de7c20e4e57626d10112"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/5183b61657807099d98f3367bcccb850238b17a9", "url": "https://api.github.com/repos/symfony/http-foundation/zipball/f4419ec69ccfc3f725a4de7c20e4e57626d10112",
"reference": "5183b61657807099d98f3367bcccb850238b17a9", "reference": "f4419ec69ccfc3f725a4de7c20e4e57626d10112",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -2764,12 +2764,12 @@
}, },
"conflict": { "conflict": {
"doctrine/dbal": "<3.6", "doctrine/dbal": "<3.6",
"symfony/cache": "<6.4" "symfony/cache": "<6.4.12|>=7.0,<7.1.5"
}, },
"require-dev": { "require-dev": {
"doctrine/dbal": "^3.6|^4", "doctrine/dbal": "^3.6|^4",
"predis/predis": "^1.1|^2.0", "predis/predis": "^1.1|^2.0",
"symfony/cache": "^6.4|^7.0", "symfony/cache": "^6.4.12|^7.1.5",
"symfony/dependency-injection": "^6.4|^7.0", "symfony/dependency-injection": "^6.4|^7.0",
"symfony/expression-language": "^6.4|^7.0", "symfony/expression-language": "^6.4|^7.0",
"symfony/http-kernel": "^6.4|^7.0", "symfony/http-kernel": "^6.4|^7.0",
@@ -2802,7 +2802,7 @@
"description": "Defines an object-oriented layer for the HTTP specification", "description": "Defines an object-oriented layer for the HTTP specification",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": { "support": {
"source": "https://github.com/symfony/http-foundation/tree/v7.1.7" "source": "https://github.com/symfony/http-foundation/tree/v7.1.8"
}, },
"funding": [ "funding": [
{ {
@@ -2818,20 +2818,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-11-06T09:02:46+00:00" "time": "2024-11-09T09:16:45+00:00"
}, },
{ {
"name": "symfony/http-kernel", "name": "symfony/http-kernel",
"version": "v7.1.7", "version": "v7.1.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/http-kernel.git", "url": "https://github.com/symfony/http-kernel.git",
"reference": "7f137cda31fd41e422edcdc01915f2c095b84399" "reference": "33fef24e3dc79d6d30bf4936531f2f4bd2ca189e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/7f137cda31fd41e422edcdc01915f2c095b84399", "url": "https://api.github.com/repos/symfony/http-kernel/zipball/33fef24e3dc79d6d30bf4936531f2f4bd2ca189e",
"reference": "7f137cda31fd41e422edcdc01915f2c095b84399", "reference": "33fef24e3dc79d6d30bf4936531f2f4bd2ca189e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -2916,7 +2916,7 @@
"description": "Provides a structured process for converting a Request into a Response", "description": "Provides a structured process for converting a Request into a Response",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": { "support": {
"source": "https://github.com/symfony/http-kernel/tree/v7.1.7" "source": "https://github.com/symfony/http-kernel/tree/v7.1.8"
}, },
"funding": [ "funding": [
{ {
@@ -2932,7 +2932,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-11-06T09:54:34+00:00" "time": "2024-11-13T14:25:32+00:00"
}, },
{ {
"name": "symfony/polyfill-intl-grapheme", "name": "symfony/polyfill-intl-grapheme",
@@ -3556,16 +3556,16 @@
}, },
{ {
"name": "symfony/string", "name": "symfony/string",
"version": "v7.1.6", "version": "v7.1.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/string.git", "url": "https://github.com/symfony/string.git",
"reference": "61b72d66bf96c360a727ae6232df5ac83c71f626" "reference": "591ebd41565f356fcd8b090fe64dbb5878f50281"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/61b72d66bf96c360a727ae6232df5ac83c71f626", "url": "https://api.github.com/repos/symfony/string/zipball/591ebd41565f356fcd8b090fe64dbb5878f50281",
"reference": "61b72d66bf96c360a727ae6232df5ac83c71f626", "reference": "591ebd41565f356fcd8b090fe64dbb5878f50281",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -3623,7 +3623,7 @@
"utf8" "utf8"
], ],
"support": { "support": {
"source": "https://github.com/symfony/string/tree/v7.1.6" "source": "https://github.com/symfony/string/tree/v7.1.8"
}, },
"funding": [ "funding": [
{ {
@@ -3639,20 +3639,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-09-25T14:20:29+00:00" "time": "2024-11-13T13:31:21+00:00"
}, },
{ {
"name": "symfony/var-dumper", "name": "symfony/var-dumper",
"version": "v7.1.7", "version": "v7.1.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/var-dumper.git", "url": "https://github.com/symfony/var-dumper.git",
"reference": "f6ea51f669760cacd7464bf7eaa0be87b8072db1" "reference": "7bb01a47b1b00428d32b5e7b4d3b2d1aa58d3db8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/f6ea51f669760cacd7464bf7eaa0be87b8072db1", "url": "https://api.github.com/repos/symfony/var-dumper/zipball/7bb01a47b1b00428d32b5e7b4d3b2d1aa58d3db8",
"reference": "f6ea51f669760cacd7464bf7eaa0be87b8072db1", "reference": "7bb01a47b1b00428d32b5e7b4d3b2d1aa58d3db8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -3706,7 +3706,7 @@
"dump" "dump"
], ],
"support": { "support": {
"source": "https://github.com/symfony/var-dumper/tree/v7.1.7" "source": "https://github.com/symfony/var-dumper/tree/v7.1.8"
}, },
"funding": [ "funding": [
{ {
@@ -3722,7 +3722,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-11-05T15:34:55+00:00" "time": "2024-11-08T15:46:42+00:00"
}, },
{ {
"name": "symfony/var-exporter", "name": "symfony/var-exporter",

View File

@@ -16,13 +16,20 @@ class FindingController extends AbstractController
public function index(EntityManagerInterface $em): JsonResponse public function index(EntityManagerInterface $em): JsonResponse
{ {
$repo = $em->getRepository(Finding::class); $repo = $em->getRepository(Finding::class);
$imgRepo = $em->getRepository(Image::class);
$findings = $repo->findAll(); $findings = $repo->findBy([], ['label' => 'ASC']);
foreach($findings as $key => $finding) { foreach($findings as $key => $finding) {
$coords = $repo->coordinates($finding->getId()); $coords = $repo->coordinates($finding->getId());
$finding->setLat($coords['lat']); $finding->setLat($coords['lat']);
$finding->setLng($coords['lng']); $finding->setLng($coords['lng']);
// TODO N + 1!!
$images = $imgRepo->findBy(
['finding' => $finding->getId()],
['sequence' => 'ASC']
);
$finding->setImages($images);
$findings[$key] = $finding; $findings[$key] = $finding;
} }

View File

@@ -0,0 +1,36 @@
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use App\Entity\GeoImage;
use Doctrine\ORM\EntityManagerInterface;
class GeoImageController extends AbstractController
{
#[Route('/geoimages', name: 'app_geo_images')]
public function index(EntityManagerInterface $em): JsonResponse
{
$repo = $em->getRepository(GeoImage::class);
$geoImages = $repo->findAllWithGeometry();
return $this->json($geoImages);
}
#[Route('/geoimages/menu', name: 'app_geo_image_menu')]
public function menu(EntityManagerInterface $em): JsonResponse
{
$repo = $em->getRepository(GeoImage::class);
$geoImages = $repo->findLabelsAndIds();
return $this->json($geoImages);
}
#[Route('/geoimages/{id}', name: 'app_geo_image_record')]
public function record(GeoImage $geoImage): JsonResponse
{
return $this->json($geoImage);
}
}

View File

@@ -4,6 +4,8 @@ namespace App\Controller;
use App\Entity\NotConserved; use App\Entity\NotConserved;
use App\Entity\Bibliography; use App\Entity\Bibliography;
use App\Entity\Document;
use App\Entity\Image;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
@@ -16,8 +18,9 @@ class NotConservedController extends AbstractController
{ {
$repo = $em->getRepository(NotConserved::class); $repo = $em->getRepository(NotConserved::class);
//$repoBib = $em->getRepository(Bibliography::class); //$repoBib = $em->getRepository(Bibliography::class);
$repoImg = $em->getRepository(Image::class);
$records = $repo->findBy([], ['id' => 'ASC']); $records = $repo->findBy([], ['label' => 'ASC']);
// Terrible? N+1.. // Terrible? N+1..
foreach ($records as $key => $record) { foreach ($records as $key => $record) {
@@ -26,6 +29,12 @@ class NotConservedController extends AbstractController
$record->setLng($repo->coordinates($id)['lng']); $record->setLng($repo->coordinates($id)['lng']);
//$biblio = $repoBib->findAllByNotConserved($id); //$biblio = $repoBib->findAllByNotConserved($id);
//$record->setBibliographies($biblio); //$record->setBibliographies($biblio);
$images = $repoImg->findBy(
['notConserved' => $record->getId()],
['sequence' => 'ASC']
);
$record->setImages($images);
$records[$key] = $record; $records[$key] = $record;
} }
@@ -44,14 +53,21 @@ class NotConservedController extends AbstractController
$repo = $em->getRepository(Bibliography::class); $repo = $em->getRepository(Bibliography::class);
$biblio = $repo->findAllByNotConserved($notConserved->getId()); $biblio = $repo->findAllByNotConserved($notConserved->getId());
$repo = $em->getRepository(Document::class);
$documents = $repo->findByNotConserved($notConserved->getId());
$notConserved->setBibliographies($biblio); $notConserved->setBibliographies($biblio);
$notConserved->setDocuments($documents);
$notConserved->setLat($coordinates['lat']); $notConserved->setLat($coordinates['lat']);
$notConserved->setLng($coordinates['lng']); $notConserved->setLng($coordinates['lng']);
$repo = $em->getRepository(Image::class);
return $this->json( $images = $repo->findBy(
$notConserved, ['notConserved' => $notConserved->getId()],
['sequence' => 'ASC']
); );
$notConserved->setImages($images);
return $this->json($notConserved);
} }
} }

View File

@@ -0,0 +1,70 @@
<?php
namespace App\Controller;
use App\Entity\Image;
use App\Entity\Prehistoric;
//use App\Entity\Bibliography;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
class PrehistoricController extends AbstractController
{
#[Route('/prehistoric', name: 'app_prehistoric')]
public function index(EntityManagerInterface $em): JsonResponse
{
$repo = $em->getRepository(Prehistoric::class);
//$repoBib = $em->getRepository(Bibliography::class);
$records = $repo->findBy([], ['label' => 'ASC']);
// Terrible? N+1..
foreach ($records as $key => $record) {
$id = $record->getId();
$record->setLat($repo->coordinates($id)['lat']);
$record->setLng($repo->coordinates($id)['lng']);
$repoImg = $em->getRepository(Image::class);
$images = $repoImg->findBy(
['prehistoric' => $record->getId()],
['sequence' => 'ASC']
);
$record->setImages($images);
$records[$key] = $record;
}
return $this->json([
'message' => 'All records for prehistoric assets',
'records' => $records
],
);
}
#[Route('/prehistoric/{id<\d+>}', name: 'app_prehistoric_record')]
public function record(Prehistoric $prehistoric, EntityManagerInterface $em): JsonResponse
{
$repo = $em->getRepository(Prehistoric::class);
$coordinates = $repo->coordinates($prehistoric->getId());
//$repo = $em->getRepository(Bibliography::class);
//$biblio = $repo->findAllByNotConserved($prehistoric->getId());
//$notConserved->setBibliographies($biblio);
$prehistoric->setLat($coordinates['lat']);
$prehistoric->setLng($coordinates['lng']);
$repo = $em->getRepository(Image::class);
$images = $repo->findBy(
['prehistoric' => $prehistoric->getId()],
['sequence' => 'ASC']
);
$prehistoric->setImages($images);
return $this->json($prehistoric);
}
}

View File

@@ -0,0 +1,66 @@
<?php
namespace App\Controller;
use App\Entity\Reuse;
use App\Entity\Bibliography;
use App\Entity\Image;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
class ReuseController extends AbstractController
{
#[Route('/reuse', name: 'app_reuse')]
public function index(EntityManagerInterface $em): JsonResponse
{
$repo = $em->getRepository(Reuse::class);
$repoImg = $em->getRepository(Image::class);
$records = $repo->findBy([], ['label' => 'ASC']);
// Terrible? N+1..
foreach ($records as $key => $record) {
$id = $record->getId();
$record->setLat($repo->coordinates($id)['lat']);
$record->setLng($repo->coordinates($id)['lng']);
$images = $repoImg->findBy(
['reuse' => $record->getId()],
['sequence' => 'ASC']
);
$record->setImages($images);
$records[$key] = $record;
}
return $this->json([
'message' => 'All records for reused assets',
'records' => $records
],
);
}
#[Route('/reuse/{id<\d+>}', name: 'app_reuse_record')]
public function record(Reuse $reuse, EntityManagerInterface $em): JsonResponse
{
$repo = $em->getRepository(Reuse::class);
$coordinates = $repo->coordinates($reuse->getId());
$repo = $em->getRepository(Bibliography::class);
$biblio = $repo->findAllByReuse($reuse->getId());
$reuse->setBibliography($biblio);
$reuse->setLat($coordinates['lat']);
$reuse->setLng($coordinates['lng']);
$repo = $em->getRepository(Image::class);
$images = $repo->findBy(
['reuse' => $reuse->getId()],
['sequence' => 'ASC']
);
$reuse->setImages($images);
return $this->json($reuse);
}
}

View File

@@ -15,12 +15,43 @@ use Symfony\Bridge\Doctrine\Attribute\MapEntity;
class SiteController extends AbstractController class SiteController extends AbstractController
{ {
#[Route('/site/{gisId<\w+>}', name: 'app_site')] #[Route('/sites', name: 'app_site')]
public function index( public function index(EntityManagerInterface $em): JsonResponse
#[MapEntity(mapping: ['gisId' => 'gisId'])] {
Site $site, $repo = $em->getRepository(Site::class);
EntityManagerInterface $em
): JsonResponse $sites = $repo->findBy([], ['label' => 'ASC']);
// TODO N+1...
foreach($sites as $key => $site) {
$coords = $repo->coordinates($site->getId());
$site->setLat($coords['lat']);
$site->setLng($coords['lng']);
$repoImg = $em->getRepository(Image::class);
$images = new ArrayCollection(
$repoImg->findBy(
['site' => $site->getId()],
['sequence' => 'ASC']
)
);
$repoDocs = $em->getRepository(Document::class);
$documents = $repoDocs->findBySite($site->getId());
$repoBib = $em->getRepository(Bibliography::class);
$bibliography = $repoBib->findAllBySite($site->getId());
$site->setImages($images);
$site->setDocuments($documents);
$site->setBibliography($bibliography);
$sites[$key] = $site;
}
return $this->json($sites);
}
#[Route('/sites/{id<\w+>}', name: 'app_site_record')]
//#[MapEntity(mapping: ['gisId' => 'gisId'])]
public function record(Site $site, EntityManagerInterface $em): JsonResponse
{ {
$repo = $em->getRepository(Site::class); $repo = $em->getRepository(Site::class);
$coords = $repo->coordinates($site->getId()); $coords = $repo->coordinates($site->getId());

View File

@@ -0,0 +1,63 @@
<?php
namespace App\Controller;
use App\Entity\Document;
use App\Entity\Image;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use App\Entity\Underwater;
use Doctrine\ORM\EntityManagerInterface;
class UnderwaterController extends AbstractController
{
#[Route('/underwater', name: 'app_underwater')]
public function index(EntityManagerInterface $em): JsonResponse
{
$repo = $em->getRepository(Underwater::class);
$imgRepo = $em->getRepository(Image::class);
$underwater = $repo->findAll();
/**
* @var Underwater $record
*/
foreach ($underwater as $key => $record) {
$coords = $repo->coordinates($record->getId());
$record->setLat($coords['lat']);
$record->setLng($coords['lng']);
// TODO N + 1!!
$images = $imgRepo->findBy(
['underwater' => $record->getId()],
['sequence' => 'ASC']
);
$record->setImages($images);
$underwater[$key] = $record;
}
return $this->json(['records' => $underwater]);
}
#[Route('/underwater/{id<\d+>}', name: 'app_underwater_record')]
public function record(Underwater $record, EntityManagerInterface $em)
{
$repo = $em->getRepository(Underwater::class);
$docRepo = $em->getRepository(Document::class);
$documents = $docRepo->findByUnderwater($record->getId());
$imgRepo = $em->getRepository(Image::class);
$images = $imgRepo->findBy(
['underwater' => $record->getId()],
['sequence' => 'ASC']
);
$coords = $repo->coordinates($record->getId());
$record->setLat($coords['lat']);
$record->setLng($coords['lng']);
$record->setImages($images);
$record->setDocuments($documents);
return $this->json($record);
}
}

View File

@@ -49,6 +49,12 @@ class Finding implements \JsonSerializable
#[ORM\Column(length: 40, nullable: true, name: 'misure')] #[ORM\Column(length: 40, nullable: true, name: 'misure')]
private ?string $measurements = null; private ?string $measurements = null;
#[ORM\Column(name: 'comune', length: 10, nullable: false)]
private ?string $municipality = null;
#[ORM\Column(name: 'etichetta', length: 150, nullable: false)]
private ?string $label = null;
private ?float $lat = null; private ?float $lat = null;
private ?float $lng = null; private ?float $lng = null;
@@ -59,7 +65,7 @@ class Finding implements \JsonSerializable
private ?array $bibliography = null; private ?array $bibliography = null;
/** /**
* @var Bibliography[] $images * @var Image[] $images
*/ */
private ?array $images = null; private ?array $images = null;
@@ -207,6 +213,30 @@ class Finding implements \JsonSerializable
return $this; return $this;
} }
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(?string $label): static
{
$this->label = $label;
return $this;
}
public function getMunicipality(): ?string
{
return $this->municipality;
}
public function setMunicipality(?string $municipality): static
{
$this->municipality = $municipality;
return $this;
}
public function getLat(): ?float public function getLat(): ?float
{ {
return $this->lat; return $this->lat;
@@ -269,6 +299,8 @@ class Finding implements \JsonSerializable
'conservationPlace' => $this->conservationPlace, 'conservationPlace' => $this->conservationPlace,
'description' => $this->description, 'description' => $this->description,
'author' => $this->author, 'author' => $this->author,
'label' => $this->label,
'municipality' => $this->municipality,
'coordinates' => [$this->lat, $this->lng], 'coordinates' => [$this->lat, $this->lng],
'bibliography' => $this->bibliography, 'bibliography' => $this->bibliography,
'images' => $this->images, 'images' => $this->images,

85
src/Entity/GeoImage.php Normal file
View File

@@ -0,0 +1,85 @@
<?php
namespace App\Entity;
use App\Repository\GeoImageRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
#[ORM\Entity(repositoryClass: GeoImageRepository::class)]
#[ORM\Table(name: 'geo_immagine_catasto')]
class GeoImage implements JsonSerializable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $filename = null;
#[ORM\Column(type: Types::JSON, name: 'poligono')]
private ?string $polygon = null;
#[ORM\Column(length: 60, name: 'etichetta')]
private ?string $label = null;
public function getId(): ?int
{
return $this->id;
}
public function setId(string $id): static
{
$this->id = $id;
return $this;
}
public function getFilename(): ?string
{
return $this->filename;
}
public function setFilename(string $filename): static
{
$this->filename = $filename;
return $this;
}
public function getPolygon(): ?string
{
return $this->polygon;
}
public function setPolygon(string $polygon): static
{
$this->polygon = $polygon;
return $this;
}
public function getLabel(): ?string
{
return $this->polygon;
}
public function setLabel(string $label): static
{
$this->label = $label;
return $this;
}
public function jsonSerialize(): mixed
{
return [
'id' => $this->id,
'filename' => $this->filename,
'polygon' => $this->polygon,
'label' => $this->label,
];
}
}

View File

@@ -31,6 +31,18 @@ class Image implements \JsonSerializable
#[ORM\Column(name: 'rinvenimento', type: Types::BIGINT, nullable: true)] #[ORM\Column(name: 'rinvenimento', type: Types::BIGINT, nullable: true)]
private ?string $finding = null; private ?string $finding = null;
#[ORM\Column(name: 'non_conserv', type: Types::BIGINT, nullable: true)]
private ?string $notConserved = null;
#[ORM\Column(name: 'affioramento', type: Types::BIGINT, nullable: true)]
private ?string $prehistoric = null;
#[ORM\Column(name: 'reimpiego', type: Types::BIGINT, nullable: true)]
private ?string $reuse = null;
#[ORM\Column(name: 'giacimento', type: Types::BIGINT, nullable: true)]
private ?string $underwater = null;
#[ORM\Column(name: 'ordine', type: Types::SMALLINT)] #[ORM\Column(name: 'ordine', type: Types::SMALLINT)]
private ?int $sequence = null; private ?int $sequence = null;
@@ -109,6 +121,54 @@ class Image implements \JsonSerializable
return $this; return $this;
} }
public function getNotConserved(): ?string
{
return $this->notConserved;
}
public function setNotConserved(?string $notConserved): static
{
$this->notConserved = $notConserved;
return $this;
}
public function getPrehistoric(): ?string
{
return $this->prehistoric;
}
public function setPrehistoric(?string $prehistoric): static
{
$this->prehistoric = $prehistoric;
return $this;
}
public function getReuse(): ?string
{
return $this->reuse;
}
public function setReuse(?string $reuse): static
{
$this->reuse = $reuse;
return $this;
}
public function getUnderwater(): ?string
{
return $this->underwater;
}
public function setUnderwater(?string $underwater): static
{
$this->underwater = $underwater;
return $this;
}
public function getSequence(): ?int public function getSequence(): ?int
{ {
return $this->sequence; return $this->sequence;

View File

@@ -28,6 +28,11 @@ class NotConserved implements \JsonSerializable
*/ */
private ?array $bibliographies = null; private ?array $bibliographies = null;
/**
* @var Document[] $documents
*/
private ?array $documents = null;
#[ORM\Column(length: 255, nullable: true, name: 'periodo')] #[ORM\Column(length: 255, nullable: true, name: 'periodo')]
private ?string $period = null; private ?string $period = null;
@@ -40,6 +45,17 @@ class NotConserved implements \JsonSerializable
#[ORM\Column(name: 'autore_scheda', length: 100, nullable: true)] #[ORM\Column(name: 'autore_scheda', length: 100, nullable: true)]
private ?string $author = null; private ?string $author = null;
#[ORM\Column(name: 'comune', length: 10, nullable: false)]
private ?string $municipality = null;
#[ORM\Column(name: 'etichetta', length: 100, nullable: false)]
private ?string $label = null;
/**
* @var Image[] $images
*/
private ?array $images = null;
public function getId(): ?int public function getId(): ?int
{ {
return $this->id; return $this->id;
@@ -100,6 +116,18 @@ class NotConserved implements \JsonSerializable
return $this; return $this;
} }
public function getDocuments(): ?array
{
return $this->documents;
}
public function setDocuments(array $documents): static
{
$this->documents = $documents;
return $this;
}
public function getPeriod(): ?string public function getPeriod(): ?string
{ {
return $this->period; return $this->period;
@@ -148,6 +176,48 @@ class NotConserved implements \JsonSerializable
return $this; return $this;
} }
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(?string $label): static
{
$this->label = $label;
return $this;
}
public function getMunicipality(): ?string
{
return $this->municipality;
}
public function setMunicipality(?string $municipality): static
{
$this->municipality = $municipality;
return $this;
}
/**
* @return Image[]
*/
public function getImages(): array
{
return $this->images;
}
/**
* @param Image[] $images
*/
public function setImages(array $images): static
{
$this->images = $images;
return $this;
}
public function jsonSerialize(): array public function jsonSerialize(): array
{ {
return [ return [
@@ -158,7 +228,11 @@ class NotConserved implements \JsonSerializable
'period' => $this->period, 'period' => $this->period,
'shortDescription' => $this->shortDescription, 'shortDescription' => $this->shortDescription,
'author' => $this->author, 'author' => $this->author,
'municipality' => $this->municipality,
'label' => $this->label,
'bibliography' => $this->bibliographies, 'bibliography' => $this->bibliographies,
'documents' => $this->documents,
'images' => $this->images,
]; ];
} }
} }

217
src/Entity/Prehistoric.php Normal file
View File

@@ -0,0 +1,217 @@
<?php
namespace App\Entity;
use App\Repository\PrehistoricRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: PrehistoricRepository::class)]
#[ORM\Table(name: 'preistoria')]
class Prehistoric implements \JsonSerializable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, name: 'denominazione')]
private ?string $denomination = null;
#[ORM\Column(length: 255, nullable: true, name: 'loc_generica')]
private ?string $genericPlace = null;
#[ORM\Column(length: 120, nullable: true, name: 'periodo')]
private ?string $period = null;
#[ORM\Column(type: Types::TEXT, nullable: true, name: 'descrizione')]
private ?string $description = null;
#[ORM\Column(length: 255, nullable: true, name: 'conservazione')]
private ?string $conservation = null;
#[ORM\Column(length: 255, nullable: true, name: 'autore_scheda')]
private ?string $author = null;
#[ORM\Column(name: 'comune', length: 10, nullable: false)]
private ?string $municipality = null;
#[ORM\Column(name: 'etichetta', length: 150, nullable: false)]
private ?string $label = null;
private ?float $lat;
private ?float $lng;
/**
* @var Image[] $images
*/
private ?array $images = null;
public function getId(): ?int
{
return $this->id;
}
public function setId(string $id): static
{
$this->id = $id;
return $this;
}
public function getDenomination(): ?string
{
return $this->denomination;
}
public function setDenomination(string $denomination): static
{
$this->denomination = $denomination;
return $this;
}
public function getGenericPlace(): ?string
{
return $this->genericPlace;
}
public function setGenericPlace(?string $genericPlace): static
{
$this->genericPlace = $genericPlace;
return $this;
}
public function getPeriod(): ?string
{
return $this->period;
}
public function setPeriod(?string $period): static
{
$this->period = $period;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): static
{
$this->description = $description;
return $this;
}
public function getConservation(): ?string
{
return $this->conservation;
}
public function setConservation(?string $conservation): static
{
$this->conservation = $conservation;
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;
}
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;
}
/**
* @return Image[]
*/
public function getImages(): array
{
return $this->images;
}
/**
* @param Image[] $images
*/
public function setImages(array $images): static
{
$this->images = $images;
return $this;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(?string $label): static
{
$this->label = $label;
return $this;
}
public function getMunicipality(): ?string
{
return $this->municipality;
}
public function setMunicipality(?string $municipality): static
{
$this->municipality = $municipality;
return $this;
}
public function jsonSerialize(): array
{
return [
'id' => $this->id,
'denomination' => $this->denomination,
'genericPlace' => $this->genericPlace,
'period' => $this->period,
'conservation' => $this->conservation,
'author' => $this->author,
'description' => $this->description,
'label' => $this->label,
'municipality' => $this->municipality,
'coordinates' => [$this->lat, $this->lng],
'images' => $this->images,
];
}
}

277
src/Entity/Reuse.php Normal file
View File

@@ -0,0 +1,277 @@
<?php
namespace App\Entity;
use App\Repository\ReuseRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ReuseRepository::class)]
#[ORM\Table(name: 'reimpiego')]
class Reuse implements \JsonSerializable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 200, name: 'denominazione')]
private ?string $denomination = null;
#[ORM\Column(length: 200, nullable: true, name: 'materia')]
private ?string $material = null;
#[ORM\Column(length: 100, nullable: true, name: 'rinvenimento')]
private ?string $finding = null;
#[ORM\Column(length: 100, nullable: true, name: 'misure')]
private ?string $measurements = null;
#[ORM\Column(length: 200, nullable: true, name: 'datazione')]
private ?string $dating = null;
#[ORM\Column(length: 255, nullable: true, name: 'stato_conservazione')]
private ?string $conservationState = null;
#[ORM\Column(length: 255, nullable: true, name: 'luogo_conservazione')]
private ?string $conservationPlace = null;
#[ORM\Column(type: Types::TEXT, nullable: true, name: 'descrizione')]
private ?string $description = null;
#[ORM\Column(length: 255, nullable: true, name: 'autore_scheda')]
private ?string $author = null;
#[ORM\Column(name: 'comune', length: 10, nullable: false)]
private ?string $municipality = null;
#[ORM\Column(name: 'etichetta', length: 150, nullable: false)]
private ?string $label = null;
private ?float $lat = null;
private ?float $lng = null;
/**
* @var Bibliography[] $bibliography
*/
private ?array $bibliography = null;
/**
* @var Image[] $images
*/
private ?array $images = null;
public function getId(): ?int
{
return $this->id;
}
public function setId(string $id): static
{
$this->id = $id;
return $this;
}
public function getDenomination(): ?string
{
return $this->denomination;
}
public function setDenomination(string $denomination): static
{
$this->denomination = $denomination;
return $this;
}
public function getMaterial(): ?string
{
return $this->material;
}
public function setMaterial(?string $material): static
{
$this->material = $material;
return $this;
}
public function getFinding(): ?string
{
return $this->finding;
}
public function setFinding(?string $finding): static
{
$this->finding = $finding;
return $this;
}
public function getDating(): ?string
{
return $this->dating;
}
public function setDating(?string $dating): static
{
$this->dating = $dating;
return $this;
}
public function getConservationState(): ?string
{
return $this->conservationState;
}
public function setConservationState(?string $conservationState): static
{
$this->conservationState = $conservationState;
return $this;
}
public function getConservationPlace(): ?string
{
return $this->conservationPlace;
}
public function setConservationPlace(?string $conservationPlace): static
{
$this->conservationPlace = $conservationPlace;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): static
{
$this->description = $description;
return $this;
}
public function getAuthor(): ?string
{
return $this->author;
}
public function setAuthor(string $author): static
{
$this->author = $author;
return $this;
}
public function getMeasurements(): ?string
{
return $this->measurements;
}
public function setMeasurements(?string $measurements): static
{
$this->measurements = $measurements;
return $this;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(?string $label): static
{
$this->label = $label;
return $this;
}
public function getMunicipality(): ?string
{
return $this->municipality;
}
public function setMunicipality(?string $municipality): static
{
$this->municipality = $municipality;
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;
}
public function getBibliography(): ?array
{
return $this->bibliography;
}
public function setBibliography(array $bibliography): static
{
$this->bibliography = $bibliography;
return $this;
}
public function getImages(): ?array
{
return $this->images;
}
public function setImages(array $images): static
{
$this->images = $images;
return $this;
}
public function jsonSerialize(): array
{
return [
'id' => $this->id,
'denomination' => $this->denomination,
'material' => $this->material,
'measurements' => $this->measurements,
'finding' => $this->finding,
'dating' => $this->dating,
'conservationState' => $this->conservationState,
'conservationPlace' => $this->conservationPlace,
'description' => $this->description,
'author' => $this->author,
'label' => $this->label,
'municipality' => $this->municipality,
'coordinates' => [$this->lat, $this->lng],
'bibliography' => $this->bibliography,
'images' => $this->images,
];
}
}

View File

@@ -59,8 +59,14 @@ class Site implements JsonSerializable
#[ORM\Column(name: 'luogo_custodia_mat', type: Types::TEXT, nullable: true)] #[ORM\Column(name: 'luogo_custodia_mat', type: Types::TEXT, nullable: true)]
private ?string $conservationPlace = null; private ?string $conservationPlace = null;
#[ORM\Column(name: 'documenti', type: Types::TEXT, nullable: true)]
private ?string $documentation = null;
#[ORM\Column(name: 'rilievi', length: 255, nullable: true)]
private ?string $surveys = null;
#[ORM\Column(name: 'proprietà', length: 255, nullable: true)] #[ORM\Column(name: 'proprietà', length: 255, nullable: true)]
private ?string $ownedBy = null; private ?string $ownership = null;
#[ORM\Column(name: 'gis_id', length: 20)] #[ORM\Column(name: 'gis_id', length: 20)]
private ?string $gisId = null; private ?string $gisId = null;
@@ -80,6 +86,15 @@ class Site implements JsonSerializable
#[ORM\Column(name: 'autore_scheda', nullable: true)] #[ORM\Column(name: 'autore_scheda', nullable: true)]
private ?string $author = null; private ?string $author = null;
#[ORM\Column(name: 'geojson', nullable: false, type: Types::BOOLEAN)]
private ?bool $geojson = null;
#[ORM\Column(name: 'area', nullable: false, type: Types::BOOLEAN)]
private ?bool $area = null;
#[ORM\Column(name: 'etichetta', nullable: false, length: 100)]
private ?string $label = null;
private ?float $lat; private ?float $lat;
private ?float $lng; private ?float $lng;
@@ -276,14 +291,26 @@ class Site implements JsonSerializable
return $this; return $this;
} }
public function getOwnedBy(): ?string public function getSurveys(): ?string
{ {
return $this->ownedBy; return $this->surveys;
} }
public function setOwnedBy(?string $ownedBy): static public function setSurveys(?string $surveys): static
{ {
$this->ownedBy = $ownedBy; $this->surveys = $surveys;
return $this;
}
public function getOwnership(): ?string
{
return $this->ownership;
}
public function setOwnership(?string $ownership): static
{
$this->ownership = $ownership;
return $this; return $this;
} }
@@ -336,6 +363,18 @@ class Site implements JsonSerializable
return $this; return $this;
} }
public function getDocumentation(): ?string
{
return $this->documentation;
}
public function setDocumentation(string $documentation): static
{
$this->documentation = $documentation;
return $this;
}
public function getTechniques(): ?string public function getTechniques(): ?string
{ {
return $this->techniques; return $this->techniques;
@@ -436,17 +475,22 @@ class Site implements JsonSerializable
'chronology' => $this->chronology, 'chronology' => $this->chronology,
'motivation' => $this->chronologyMotivation, 'motivation' => $this->chronologyMotivation,
'finding' => $this->finding, 'finding' => $this->finding,
'surveys' => $this->surveys,
'materials' => $this->materials, 'materials' => $this->materials,
'conservationState' => $this->conservationState, 'conservationState' => $this->conservationState,
'conservationPlace' => $this->conservationPlace, 'conservationPlace' => $this->conservationPlace,
'documentation' => $this->documentation,
'description' => $this->description, 'description' => $this->description,
'shortDescription' => $this->shortDescription, 'shortDescription' => $this->shortDescription,
'ownedBy' => $this->ownedBy, 'ownership' => $this->ownership,
'images' => $this->images->toArray(), 'images' => $this->images->toArray(),
'documents' => $this->documents, 'documents' => $this->documents,
'bibliography' => $this->bibliography, 'bibliography' => $this->bibliography,
'techniques' => $this->techniques, 'techniques' => $this->techniques,
'author' => $this->author, 'author' => $this->author,
'geojson' => $this->geojson,
'area' => $this->area,
'label' => $this->label,
]; ];
} }
} }

214
src/Entity/Underwater.php Normal file
View File

@@ -0,0 +1,214 @@
<?php
namespace App\Entity;
use App\Repository\UnderwaterRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
#[ORM\Entity(repositoryClass: UnderwaterRepository::class)]
#[ORM\Table(name: 'giacimento')]
class Underwater implements JsonSerializable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, name: 'denominazione')]
private ?string $denomination = null;
#[ORM\Column(length: 255, nullable: true, name: 'loc_generica')]
private ?string $genericPlace = null;
#[ORM\Column(length: 100, nullable: true, name: 'periodo')]
private ?string $period = null;
#[ORM\Column(type: Types::TEXT, nullable: true, name: 'descrizione_breve')]
private ?string $shortDescription = null;
#[ORM\Column(length: 100, nullable: true, name: 'conservazione')]
private ?string $conservationState = null;
#[ORM\Column(length: 80, nullable: true, name: 'autore_scheda')]
private ?string $author = null;
#[ORM\Column(length: 80, nullable: false, name: 'etichetta')]
private ?string $label = null;
private ?float $lat = null;
private ?float $lng = null;
/**
* @var Image[] $images
*/
private ?array $images = null;
/**
* @var Document[] $documents
*/
private ?array $documents = null;
public function getId(): ?int
{
return $this->id;
}
public function setId(string $id): static
{
$this->id = $id;
return $this;
}
public function getDenomination(): ?string
{
return $this->denomination;
}
public function setDenomination(string $denomination): static
{
$this->denomination = $denomination;
return $this;
}
public function getGenericPlace(): ?string
{
return $this->genericPlace;
}
public function setGenericPlace(?string $genericPlace): static
{
$this->genericPlace = $genericPlace;
return $this;
}
public function getPeriod(): ?string
{
return $this->period;
}
public function setPeriod(?string $period): static
{
$this->period = $period;
return $this;
}
public function getShortDescription(): ?string
{
return $this->shortDescription;
}
public function setShortDescription(?string $shortDescription): static
{
$this->shortDescription = $shortDescription;
return $this;
}
public function getConservationState(): ?string
{
return $this->conservationState;
}
public function setConservationState(?string $conservationState): static
{
$this->conservationState = $conservationState;
return $this;
}
public function getAuthor(): ?string
{
return $this->author;
}
public function setAuthor(?string $author): static
{
$this->author = $author;
return $this;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(?string $label): static
{
$this->label = $label;
return $this;
}
public function getLat(): ?float
{
return $this->lat;
}
public function setLat(?float $latitude): static
{
$this->lat = $latitude;
return $this;
}
public function getLng(): ?float
{
return $this->lng;
}
public function setLng(?float $longitude): static
{
$this->lng = $longitude;
return $this;
}
public function getImages(): ?array
{
return $this->images;
}
public function setImages(?array $images): static
{
$this->images = $images;
return $this;
}
public function getDocuments(): ?array
{
return $this->documents;
}
public function setDocuments(?array $documents): static
{
$this->documents = $documents;
return $this;
}
public function jsonSerialize(): array
{
return [
'id' => $this->id,
'genericPlace' => $this->genericPlace,
'coordinates' => [$this->lat, $this->lng],
'denomination' => $this->denomination,
'period' => $this->period,
'conservationState' => $this->conservationState,
'shortDescription' => $this->shortDescription,
'author' => $this->author,
'label' => $this->label,
'images' => $this->images,
'documents' => $this->documents,
];
}
}

View File

@@ -6,4 +6,6 @@ enum ImageType: string
{ {
case Photo = 'foto'; case Photo = 'foto';
case Survey = 'rilievo'; case Survey = 'rilievo';
case Video = 'video';
case Reconstruction = '3d';
} }

View File

@@ -22,74 +22,139 @@ class BibliographyRepository extends ServiceEntityRepository
*/ */
public function findAllBySite(int $siteId): array public function findAllBySite(int $siteId): array
{ {
$rsm = new ResultSetMappingBuilder($this->getEntityManager()); $conn = $this->getEntityManager()->getConnection();
$rsm->addRootEntityFromClassMetadata('App\Entity\Bibliography', 'b');
$query = $this->getEntityManager()->createNativeQuery( $sql = '
'SELECT SELECT
id, b.id,
citazione, b.citazione,
riferimento, b.riferimento,
pagine bs.pagine
FROM bibliografia b FROM bibliografia b
JOIN bibliografia_sito INNER JOIN bibliografia_sito bs ON bs.id_bibliografia = b.id
ON id_bibliografia = b.id WHERE bs.id_sito = :siteId
WHERE id_sito = :id ORDER BY bs.ordine ASC
ORDER BY ordine ASC', ';
$rsm
);
$query->setParameter('id', $siteId); $stmt = $conn->prepare($sql);
$results = $stmt->executeQuery(['siteId' => $siteId])->fetchAllAssociative();
return $query->getResult(); $entities = [];
foreach ($results as $row) {
$biblio = new Bibliography();
$biblio->setId($row['id']);
$biblio->setCitation($row['citazione']);
$biblio->setReference($row['riferimento']);
$biblio->setPages($row['pagine']);
$entities[] = $biblio;
}
return $entities;
} }
/** /**
* @return Bibliography[] * @return Bibliography[]
*/ */
public function findAllByNotConserved(int $notConserId): array public function findAllByNotConserved(int $notConservedId): array
{ {
$rsm = new ResultSetMappingBuilder($this->getEntityManager()); $conn = $this->getEntityManager()->getConnection();
$rsm->addRootEntityFromClassMetadata('App\Entity\Bibliography', 'b');
$query = $this->getEntityManager()->createNativeQuery( $sql = '
'SELECT SELECT
id, b.id,
citazione, b.citazione,
riferimento, b.riferimento,
pagine bs.pagine
FROM bibliografia b FROM bibliografia b
JOIN bibliografia_non_conser INNER JOIN bibliografia_non_conser bs ON bs.id_bibliografia = b.id
ON id_bibliografia = b.id WHERE bs.id_non_conser = :notConservedId
WHERE id_non_conser = :id ORDER BY bs.ordine ASC
ORDER BY ordine ASC', ';
$rsm
);
$query->setParameter('id', $notConserId); $stmt = $conn->prepare($sql);
$results = $stmt->executeQuery(['notConservedId' => $notConservedId])->fetchAllAssociative();
return $query->getResult(); $entities = [];
foreach ($results as $row) {
$biblio = new Bibliography();
$biblio->setId($row['id']);
$biblio->setCitation($row['citazione']);
$biblio->setReference($row['riferimento']);
$biblio->setPages($row['pagine']);
$entities[] = $biblio;
}
return $entities;
} }
/** /**
* @return Bibliography[] * @return Bibliography[]
*/ */
public function findAllByFinding(int $findingId): array public function findAllByFinding(int $findingId): array
{ {
$rsm = new ResultSetMappingBuilder($this->getEntityManager()); $conn = $this->getEntityManager()->getConnection();
$rsm->addRootEntityFromClassMetadata('App\Entity\Bibliography', 'b');
$query = $this->getEntityManager()->createNativeQuery( $sql = '
'SELECT SELECT
id, b.id,
citazione, b.citazione,
riferimento, b.riferimento,
pagine bs.pagine
FROM bibliografia b FROM bibliografia b
JOIN bibliografia_rinvenim INNER JOIN bibliografia_rinvenim bs ON bs.id_bibliografia = b.id
ON id_bibliografia = b.id WHERE bs.id_rinvenimento = :findingId
WHERE id_rinvenimento = :id ORDER BY bs.ordine ASC
ORDER BY ordine ASC', ';
$rsm
);
$query->setParameter('id', $findingId); $stmt = $conn->prepare($sql);
$results = $stmt->executeQuery(['findingId' => $findingId])->fetchAllAssociative();
return $query->getResult(); $entities = [];
foreach ($results as $row) {
$biblio = new Bibliography();
$biblio->setId($row['id']);
$biblio->setCitation($row['citazione']);
$biblio->setReference($row['riferimento']);
$biblio->setPages($row['pagine']);
$entities[] = $biblio;
}
return $entities;
}
/**
* @return Bibliography[]
*/
public function findAllByReuse(int $reuseId): array
{
$conn = $this->getEntityManager()->getConnection();
$sql = '
SELECT
b.id,
b.citazione,
b.riferimento,
br.pagine
FROM bibliografia b
INNER JOIN bibliografia_reimpiego br ON br.id_bibliografia = b.id
WHERE br.id_reimpiego = :reuseId
ORDER BY br.ordine ASC
';
$stmt = $conn->prepare($sql);
$results = $stmt->executeQuery(['reuseId' => $reuseId])->fetchAllAssociative();
$entities = [];
foreach ($results as $row) {
$biblio = new Bibliography();
$biblio->setId($row['id']);
$biblio->setCitation($row['citazione']);
$biblio->setReference($row['riferimento']);
$biblio->setPages($row['pagine']);
$entities[] = $biblio;
}
return $entities;
} }
} }

View File

@@ -22,30 +22,126 @@ class DocumentRepository extends ServiceEntityRepository
*/ */
public function findBySite(int $siteId): array public function findBySite(int $siteId): array
{ {
$rsm = new ResultSetMappingBuilder($this->getEntityManager()); $conn = $this->getEntityManager()->getConnection();
$rsm->addRootEntityFromClassMetadata('App\Entity\Document', 'd');
$query = $this->getEntityManager()->createNativeQuery(
'SELECT
id,
titolo,
filename,
descrizione,
autori,
luogo,
tipo
FROM documento d
JOIN sito_documento
ON id_documento = d.id
WHERE id_sito = :id
',
$rsm
);
$query->setParameter('id', $siteId); $sql = '
SELECT
d.id,
d.titolo,
d.filename,
d.descrizione,
d.autori,
d.tipo,
d.luogo
FROM documento d
INNER JOIN sito_documento sd ON sd.id_documento = d.id
WHERE sd.id_sito = :siteId
ORDER BY d.titolo ASC
';
return $query->getResult(); $stmt = $conn->prepare($sql);
$results = $stmt->executeQuery(['siteId' => $siteId])->fetchAllAssociative();
$entities = [];
foreach ($results as $row) {
$document = new Document();
$document->setId($row['id']);
$document->setTitle($row['titolo']);
$document->setFilename($row['filename']);
$document->setDescription($row['descrizione']);
$document->setConservationPlace($row['luogo']);
$document->setType($row['tipo']);
$document->setAuthors($row['autori']);
$entities[] = $document;
}
return $entities;
} }
/**
* @return Document[] Returns an array of Document objects
*/
public function findByNotConserved(int $notConservedId): array
{
$conn = $this->getEntityManager()->getConnection();
$sql = '
SELECT
d.id,
d.titolo,
d.filename,
d.descrizione,
d.autori,
d.tipo,
d.luogo
FROM documento d
INNER JOIN non_conserv_documento sd ON sd.id_documento = d.id
WHERE sd.id_non_conserv = :notConservedId
ORDER BY d.titolo ASC
';
$stmt = $conn->prepare($sql);
$results = $stmt->executeQuery(['notConservedId' => $notConservedId])->fetchAllAssociative();
$entities = [];
foreach ($results as $row) {
$document = new Document();
$document->setId($row['id']);
$document->setTitle($row['titolo']);
$document->setFilename($row['filename']);
$document->setDescription($row['descrizione']);
$document->setConservationPlace($row['luogo']);
$document->setType($row['tipo']);
$document->setAuthors($row['autori']);
$entities[] = $document;
}
return $entities;
}
/**
* @return Document[] Returns an array of Document objects
*/
public function findByUnderwater(int $underwaterId): array
{
$conn = $this->getEntityManager()->getConnection();
$sql = '
SELECT
d.id,
d.titolo,
d.filename,
d.descrizione,
d.autori,
d.tipo,
d.luogo
FROM documento d
INNER JOIN giacimento_documento gd ON gd.id_documento = d.id
WHERE gd.id_giacimento = :underwaterId
ORDER BY d.titolo ASC
';
$stmt = $conn->prepare($sql);
$results = $stmt->executeQuery(['underwaterId' => $underwaterId])->fetchAllAssociative();
$entities = [];
foreach ($results as $row) {
$document = new Document();
$document->setId($row['id']);
$document->setTitle($row['titolo']);
$document->setFilename($row['filename']);
$document->setDescription($row['descrizione']);
$document->setConservationPlace($row['luogo']);
$document->setType($row['tipo']);
$document->setAuthors($row['autori']);
$entities[] = $document;
}
return $entities;
}
// /** // /**
// * @return Document[] Returns an array of Document objects // * @return Document[] Returns an array of Document objects
// */ // */

View File

@@ -0,0 +1,135 @@
<?php
namespace App\Repository;
use App\Entity\GeoImage;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\DBAL\LockMode;
use Doctrine\Persistence\ManagerRegistry;
use Override;
/**
* @extends ServiceEntityRepository<GeoImage>
*/
class GeoImageRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, GeoImage::class);
}
#[Override]
public function find(mixed $id, LockMode|int|null $lockMode = null, ?int $lockVersion = null): ?object
{
$conn = $this->getEntityManager()->getConnection();
$sql = "SELECT
id,
filename,
etichetta as label,
ST_AsGeoJSON(poligono) as polygon
FROM geo_immagine_catasto
WHERE id = :id
";
$result = $conn->executeQuery($sql, ['id' => $id])
->fetchAssociative();
if (! $result) return null;
$geoImage = new GeoImage();
$geoImage->setId($result['id']);
$geoImage->setFilename($result['filename']);
$geoImage->setPolygon($result['polygon']);
$geoImage->setLabel($result['label']);
return $geoImage;
}
/**
* Returns all geoimages with associated geometry (polygon)
* as GeoJSON
* @return GeoImage[]
*/
public function findAllWithGeometry()
{
$conn = $this->getEntityManager()->getConnection();
$sql = "SELECT
id,
filename,
etichetta as label,
ST_AsGeoJSON(poligono) as polygon
FROM geo_immagine_catasto
ORDER BY etichetta ASC
";
$results = $conn->executeQuery($sql)
->fetchAllAssociative();
$entities = [];
foreach ($results as $result) {
$geoimage = new GeoImage();
$geoimage->setId($result['id']);
$geoimage->setFilename($result['filename']);
$geoimage->setPolygon($result['polygon']);
$geoimage->setLabel($result['label']);
$entities[] = $geoimage;
}
return $entities;
}
/**
* Returns all labels and ids for menu
* @return GeoImage[]
*/
public function findLabelsAndIds()
{
$conn = $this->getEntityManager()->getConnection();
$sql = "SELECT
id,
etichetta as label
FROM geo_immagine_catasto
ORDER BY etichetta ASC
";
$results = $conn->executeQuery($sql)
->fetchAllAssociative();
$entities = [];
foreach ($results as $result) {
$geoimage = new GeoImage();
$geoimage->setId($result['id']);
$geoimage->setLabel($result['label']);
$entities[] = $geoimage;
}
return $entities;
}
// /**
// * @return GeoImage[] Returns an array of GeoImage objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('g')
// ->andWhere('g.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('g.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?GeoImage
// {
// return $this->createQueryBuilder('g')
// ->andWhere('g.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@@ -32,28 +32,4 @@ class NotConservedRepository extends ServiceEntityRepository
return $conn->executeQuery($sql, ['id' => $id]) return $conn->executeQuery($sql, ['id' => $id])
->fetchAssociative(); ->fetchAssociative();
} }
// /**
// * @return NotConserved[] Returns an array of NotConserved objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('n')
// ->andWhere('n.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('n.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?NotConserved
// {
// return $this->createQueryBuilder('n')
// ->andWhere('n.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
} }

View File

@@ -0,0 +1,59 @@
<?php
namespace App\Repository;
use App\Entity\Prehistoric;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Prehistoric>
*/
class PrehistoricRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Prehistoric::class);
}
public function coordinates(int $id): array|bool
{
$conn = $this->getEntityManager()->getConnection();
$sql = '
SELECT
ST_X(ST_AsText(coordinate)) as lng,
ST_Y(ST_AsText(coordinate)) as lat
FROM
preistoria
WHERE id = :id
';
return $conn->executeQuery($sql, ['id' => $id])
->fetchAssociative();
}
// /**
// * @return Prehistoric[] Returns an array of Prehistoric objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('p')
// ->andWhere('p.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('p.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Prehistoric
// {
// return $this->createQueryBuilder('p')
// ->andWhere('p.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@@ -0,0 +1,36 @@
<?php
namespace App\Repository;
use App\Entity\Reuse;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Finding>
*/
class ReuseRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Reuse::class);
}
public function coordinates(int $id)
{
$conn = $this->getEntityManager()->getConnection();
$sql = '
SELECT
ST_X(ST_AsText(coordinate)) as lng,
ST_Y(ST_AsText(coordinate)) as lat
FROM
reimpiego
WHERE id = :id
';
return $conn->executeQuery($sql, ['id' => $id])
->fetchAssociative();
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace App\Repository;
use App\Entity\Underwater;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Underwater>
*/
class UnderwaterRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Underwater::class);
}
public function coordinates(int $id)
{
$conn = $this->getEntityManager()->getConnection();
$sql = '
SELECT
ST_X(ST_AsText(coordinate)) as lng,
ST_Y(ST_AsText(coordinate)) as lat
FROM
giacimento
WHERE id = :id
';
return $conn
->executeQuery($sql, ['id' => $id])
->fetchAssociative();
}
// /**
// * @return Underwater[] Returns an array of Underwater objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('u')
// ->andWhere('u.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('u.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Underwater
// {
// return $this->createQueryBuilder('u')
// ->andWhere('u.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}