Merging Corridor and Room in Place

This commit is contained in:
Kouril42 2023-02-02 17:09:16 +01:00
parent ce2c643cc6
commit 250e186017
11 changed files with 142 additions and 323 deletions

4
.gitignore vendored
View File

@ -17,3 +17,7 @@
# Secret keys # Secret keys
config/secrets/prod/prod.decrypt.private.php config/secrets/prod/prod.decrypt.private.php
config/secrets/dev/ config/secrets/dev/
# Test
src/trash/

View File

@ -1,51 +0,0 @@
<?php
namespace App\Entity;
use App\Repository\CorridorRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CorridorRepository::class)]
class Corridor extends Place
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: "integer")]
private $id;
#[ORM\Type]
#[ORM\Column(type: "string")]
private $type;
#[ORM\ManyToOne(targetEntity: Floor::class, inversedBy: "corridors")]
#[ORM\JoinColumn(nullable: false)]
private $floor;
public function getId(): ?int
{
return $this->id;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getFloor(): ?Floor
{
return $this->floor;
}
public function setFloor(?Floor $floor): self
{
$this->floor = $floor;
return $this;
}
}

View File

@ -20,8 +20,8 @@ class Cylinder
#[ORM\JoinColumn(nullable: false)] #[ORM\JoinColumn(nullable: false)]
private $cylinderbase; private $cylinderbase;
#[ORM\ManyToOne(targetEntity: Room::class, inversedBy: "CylinderRepresentation")] #[ORM\ManyToOne(targetEntity: Place::class, inversedBy: "CylinderRepresentation")]
private $room; private $place;
public function getId(): ?int public function getId(): ?int
{ {
@ -52,14 +52,14 @@ class Cylinder
return $this; return $this;
} }
public function getRoom(): ?Room public function getPlace(): ?Place
{ {
return $this->room; return $this->place;
} }
public function setRoom(?Room $room): self public function setPlace(?Place $place): self
{ {
$this->room = $room; $this->place = $place;
return $this; return $this;
} }

View File

@ -19,12 +19,12 @@ class Floor
#[ORM\JoinColumn(nullable: false)] #[ORM\JoinColumn(nullable: false)]
private $building; private $building;
#[ORM\OneToMany(targetEntity: Corridor::class, mappedBy: "floor")] #[ORM\ManyToMany(targetEntity: Place::class, mappedBy: "floors")]
private $corridors; private $places;
public function __construct() public function __construct()
{ {
$this->corridors = new ArrayCollection(); $this->places = new ArrayCollection();
} }
public function getId(): ?int public function getId(): ?int
@ -40,34 +40,32 @@ class Floor
public function setBuilding(?Building $building): self public function setBuilding(?Building $building): self
{ {
$this->building = $building; $this->building = $building;
return $this; return $this;
} }
/** /**
* @return Collection<int, Corridor> * @return Collection<int, Place>
*/ */
public function getCorridors(): Collection public function getPlaces(): Collection
{ {
return $this->corridors; return $this->places;
} }
public function addCorridor(Corridor $corridor): self public function addPlace(Place $place): self
{ {
if (!$this->corridors->contains($corridor)) { if (!$this->places->contains($place)) {
$this->corridors[] = $corridor; $this->places[] = $place;
$corridor->setFloor($this); $place->setFloor($this);
} }
return $this; return $this;
} }
public function removeCorridor(Corridor $corridor): self public function removePlace(Place $place): self
{ {
if ($this->corridors->removeElement($corridor)) { if ($this->places->removeElement($place)) {
// set the owning side to null (unless already changed) // set the owning side to null (unless already changed)
if ($corridor->getFloor() === $this) { if ($place->getFloor() === $this) {
$corridor->setFloor(null); $place->setFloor(null);
} }
} }

View File

@ -8,10 +8,10 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: PlaceRepository::class)] #[ORM\Entity(repositoryClass: PlaceRepository::class)]
#[ORM\MappedSuperclass] // #[ORM\MappedSuperclass]
#[ORM\InheritanceType("JOINED")] // #[ORM\InheritanceType("JOINED")]
#[ORM\DiscriminatorColumn(name: "type", type: "string")] // #[ORM\DiscriminatorColumn(name: "type", type: "string")]
#[ORM\DiscriminatorMap(["room" => Room::class, "corridor" => Corridor::class])] // #[ORM\DiscriminatorMap(["room" => Room::class, "corridor" => Corridor::class])]
class Place class Place
{ {
#[ORM\Id] #[ORM\Id]
@ -19,19 +19,33 @@ class Place
#[ORM\Column(type: "integer")] #[ORM\Column(type: "integer")]
private $id; private $id;
#[ORM\Type]
#[ORM\Column(type: "string")]
// Either 'C'orridor , 'S'tairs , 'E'levator or 'R'oom
private $type;
#[ORM\OneToMany(targetEntity: PlaceName::class, mappedBy: "place")]
private $names;
#[ORM\OneToMany(targetEntity: RoomUserName::class, mappedBy: "place")]
private $users;
#[ORM\ManyToMany(targetEntity: Floor::class, inversedBy: "places")]
private $floors;
#[ORM\ManyToMany(targetEntity: Place::class, inversedBy: "connectedPlaces")] #[ORM\ManyToMany(targetEntity: Place::class, inversedBy: "connectedPlaces")]
private $connection; private $connection;
#[ORM\ManyToMany(targetEntity: Place::class, mappedBy: "connection")] #[ORM\ManyToMany(targetEntity: Place::class, mappedBy: "connection")]
private $connectedPlaces; private $connectedPlaces;
#[ORM\OneToMany(targetEntity: PlaceName::class, mappedBy: "place")]
private $names;
public function __construct() public function __construct()
{ {
$this->connection = new ArrayCollection(); $this->connection = new ArrayCollection();
$this->connectedPlaces = new ArrayCollection(); $this->connectedPlaces = new ArrayCollection();
$this->names = new ArrayCollection();
$this->users = new ArrayCollection();
$this->floors = new ArrayCollection();
} }
public function getId(): ?int public function getId(): ?int
@ -39,10 +53,23 @@ class Place
return $this->id; return $this->id;
} }
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): bool
{
if ($type == 'C' or $type == 'S' or $type == 'E' or $type == 'R') {
$this->type = $type;
return true;
}
return false;
}
/** /**
* @return Collection<int, self> * @return Collection<int, self>
*/ */
public function getName(): Collection public function getNames(): Collection
{ {
return $this->names; return $this->names;
} }
@ -52,14 +79,57 @@ class Place
if (!$this->names->contains($name)) { if (!$this->names->contains($name)) {
$this->names[] = $name; $this->names[] = $name;
} }
return $this; return $this;
} }
public function removeName(self $name): self public function removeName(self $name): self
{ {
$this->names->removeElement($name); $this->names->removeElement($name);
return $this;
}
/**
* @return Collection<int, self>
*/
public function getRoomUsers(): Collection
{
return $this->users;
}
public function addRoomUser(self $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
}
return $this;
}
public function removeRoomUser(self $user): self
{
$this->users->removeElement($user);
return $this;
}
/**
* @return Collection<int, ThreeDObjectFile>
*/
public function getFloors(): Collection
{
return $this->floors;
}
public function addFloor(self $floor): self
{
if (!$this->floors->contains($floor)) {
$this->floors[] = $floor;
}
return $this;
}
public function removeFloor(self $floor): self
{
$this->floors->removeElement($floor);
return $this; return $this;
} }
/** /**
@ -75,14 +145,12 @@ class Place
if (!$this->connection->contains($connection)) { if (!$this->connection->contains($connection)) {
$this->connection[] = $connection; $this->connection[] = $connection;
} }
return $this; return $this;
} }
public function removeConnection(self $connection): self public function removeConnection(self $connection): self
{ {
$this->connection->removeElement($connection); $this->connection->removeElement($connection);
return $this; return $this;
} }
@ -100,7 +168,6 @@ class Place
$this->connectedPlaces[] = $connectedPlace; $this->connectedPlaces[] = $connectedPlace;
$connectedPlace->addConnection($this); $connectedPlace->addConnection($this);
} }
return $this; return $this;
} }
@ -109,7 +176,6 @@ class Place
if ($this->connectedPlaces->removeElement($connectedPlace)) { if ($this->connectedPlaces->removeElement($connectedPlace)) {
$connectedPlace->removeConnection($this); $connectedPlace->removeConnection($this);
} }
return $this; return $this;
} }
} }

View File

@ -7,7 +7,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: PlaceNamenRepository::class)] #[ORM\Entity(repositoryClass: PlaceNameRepository::class)]
class PlaceName class PlaceName
{ {
#[ORM\Id] #[ORM\Id]
@ -18,58 +18,23 @@ class PlaceName
#[ORM\Column(type: "string")] #[ORM\Column(type: "string")]
private $name; private $name;
#[ORM\ManyToOne(targetEntity: Place::class, inversedBy: "names")] #[ORM\ManyToOne(targetEntity: Place::class, inversedBy: "id")]
private $room; private $place;
public function __construct()
{
$this->polyhedronface = new ArrayCollection();
}
public function getId(): ?int public function getId(): ?int
{ {
return $this->id; return $this->id;
} }
/** public function getPlace(): ?Place
* @return Collection<int, PlaneSurface>
*/
public function getPolyhedronface(): Collection
{ {
return $this->polyhedronface; return $this->place;
} }
public function setPlace(?Place $place): self
public function addPolyhedronface(PlaneSurface $polyhedronface): self
{ {
if (!$this->polyhedronface->contains($polyhedronface)) { $this->place = $place;
$this->polyhedronface[] = $polyhedronface;
$polyhedronface->setPolyhedron($this);
}
return $this;
}
public function removePolyhedronface(PlaneSurface $polyhedronface): self
{
if ($this->polyhedronface->removeElement($polyhedronface)) {
// set the owning side to null (unless already changed)
if ($polyhedronface->getPolyhedron() === $this) {
$polyhedronface->setPolyhedron(null);
}
}
return $this;
}
public function getRoom(): ?Room
{
return $this->room;
}
public function setRoom(?Room $room): self
{
$this->room = $room;
return $this; return $this;
} }
@ -77,11 +42,9 @@ class PlaceName
{ {
return $this->name; return $this->name;
} }
public function setName(?string $name): self public function setName(?string $name): self
{ {
$this->name = $name; $this->name = $name;
return $this; return $this;
} }
} }

View File

@ -18,8 +18,8 @@ class PolySurface
#[ORM\OneToMany(targetEntity: PlaneSurface::class, mappedBy: "polySurface")] #[ORM\OneToMany(targetEntity: PlaneSurface::class, mappedBy: "polySurface")]
private $polysurfaceComponent; private $polysurfaceComponent;
#[ORM\ManyToOne(targetEntity: Corridor::class)] #[ORM\ManyToOne(targetEntity: Place::class)]
private $SurfaceRepresentation; private $place;
public function __construct() public function __construct()
{ {
@ -61,14 +61,14 @@ class PolySurface
return $this; return $this;
} }
public function getSurfaceRepresentation(): ?Corridor public function getPlace(): ?Place
{ {
return $this->SurfaceRepresentation; return $this->place;
} }
public function setSurfaceRepresentation(?Corridor $SurfaceRepresentation): self public function setPlace(?Place $place): self
{ {
$this->SurfaceRepresentation = $SurfaceRepresentation; $this->place = $place;
return $this; return $this;
} }

View File

@ -18,8 +18,8 @@ class Polyhedron
#[ORM\OneToMany(targetEntity: PlaneSurface::class, mappedBy: "polyhedron")] #[ORM\OneToMany(targetEntity: PlaneSurface::class, mappedBy: "polyhedron")]
private $polyhedronface; private $polyhedronface;
#[ORM\ManyToOne(targetEntity: Room::class, inversedBy: "PolyhedronRepresentation")] #[ORM\ManyToOne(targetEntity: Place::class, inversedBy: "PolyhedronRepresentation")]
private $room; private $place;
public function __construct() public function __construct()
{ {
@ -61,14 +61,14 @@ class Polyhedron
return $this; return $this;
} }
public function getRoom(): ?Room public function getPlace(): ?Place
{ {
return $this->room; return $this->place;
} }
public function setRoom(?Room $room): self public function setPlace(?Place $place): self
{ {
$this->room = $room; $this->place = $place;
return $this; return $this;
} }

View File

@ -1,157 +0,0 @@
<?php
namespace App\Entity;
use App\Repository\RoomRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: RoomRepository::class)]
class Room extends Place
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: "integer")]
private $id;
#[ORM\OneToMany(targetEntity: RoomUsersName::class, mappedBy: "room")]
private $users;
#[ORM\OneToMany(targetEntity: ThreeDObjectFile::class, mappedBy: "room")]
private $ComplexRepresentation;
#[ORM\OneToMany(targetEntity: Polyhedron::class, mappedBy: "room")]
private $PolyhedronRepresentation;
#[ORM\OneToMany(targetEntity: Cylinder::class, mappedBy: "room")]
private $CylinderRepresentation;
public function __construct()
{
parent::__construct();
$this->ComplexRepresentation = new ArrayCollection();
$this->PolyhedronRepresentation = new ArrayCollection();
$this->CylinderRepresentation = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection<int, self>
*/
public function getUser(): Collection
{
return $this->users;
}
public function addUser(self $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
}
return $this;
}
public function removeUser(self $user): self
{
$this->users->removeElement($user);
return $this;
}
/**
* @return Collection<int, ThreeDObjectFile>
*/
public function getComplexRepresentation(): Collection
{
return $this->ComplexRepresentation;
}
public function addComplexRepresentation(ThreeDObjectFile $complexRepresentation): self
{
if (!$this->ComplexRepresentation->contains($complexRepresentation)) {
$this->ComplexRepresentation[] = $complexRepresentation;
$complexRepresentation->setRoom($this);
}
return $this;
}
public function removeComplexRepresentation(ThreeDObjectFile $complexRepresentation): self
{
if ($this->ComplexRepresentation->removeElement($complexRepresentation)) {
// set the owning side to null (unless already changed)
if ($complexRepresentation->getRoom() === $this) {
$complexRepresentation->setRoom(null);
}
}
return $this;
}
/**
* @return Collection<int, Polyhedron>
*/
public function getPolyhedronRepresentation(): Collection
{
return $this->PolyhedronRepresentation;
}
public function addPolyhedronRepresentation(Polyhedron $polyhedronRepresentation): self
{
if (!$this->PolyhedronRepresentation->contains($polyhedronRepresentation)) {
$this->PolyhedronRepresentation[] = $polyhedronRepresentation;
$polyhedronRepresentation->setRoom($this);
}
return $this;
}
public function removePolyhedronRepresentation(Polyhedron $polyhedronRepresentation): self
{
if ($this->PolyhedronRepresentation->removeElement($polyhedronRepresentation)) {
// set the owning side to null (unless already changed)
if ($polyhedronRepresentation->getRoom() === $this) {
$polyhedronRepresentation->setRoom(null);
}
}
return $this;
}
/**
* @return Collection<int, Cylinder>
*/
public function getCylinderRepresentation(): Collection
{
return $this->CylinderRepresentation;
}
public function addCylinderRepresentation(Cylinder $cylinderRepresentation): self
{
if (!$this->CylinderRepresentation->contains($cylinderRepresentation)) {
$this->CylinderRepresentation[] = $cylinderRepresentation;
$cylinderRepresentation->setRoom($this);
}
return $this;
}
public function removeCylinderRepresentation(Cylinder $cylinderRepresentation): self
{
if ($this->CylinderRepresentation->removeElement($cylinderRepresentation)) {
// set the owning side to null (unless already changed)
if ($cylinderRepresentation->getRoom() === $this) {
$cylinderRepresentation->setRoom(null);
}
}
return $this;
}
}

View File

@ -2,13 +2,12 @@
namespace App\Entity; namespace App\Entity;
use App\Repository\PolyhedronRepository;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: RoomRepository::class)] #[ORM\Entity(repositoryClass: RoomUserRepository::class)]
class RoomUsersName class RoomUserName
{ {
#[ORM\Id] #[ORM\Id]
#[ORM\GeneratedValue] #[ORM\GeneratedValue]
@ -16,38 +15,35 @@ class RoomUsersName
private $id; private $id;
#[ORM\Column(type: "string")] #[ORM\Column(type: "string")]
private $usersName; private $userName;
#[ORM\ManyToOne(targetEntity: Room::class, inversedBy: "id")] #[ORM\ManyToOne(targetEntity: Place::class, inversedBy: "id")]
private $room; private $place;
public function getId(): ?int public function getId(): ?int
{ {
return $this->id; return $this->id;
} }
public function getPlace(): ?Place
public function getRoom(): ?Room
{ {
return $this->room; return $this->place;
} }
public function setRoom(?Room $room): self public function setPlace(?Place $place): self
{ {
$this->room = $room; $this->place = $place;
return $this; return $this;
} }
public function getUsersName(): ?string public function getUserName(): ?string
{ {
return $this->usersName; return $this->userName;
} }
public function setUsersName(?string $name): self public function setUserName(?string $name): self
{ {
$this->usersName = $name; $this->userName = $name;
return $this; return $this;
} }
} }

View File

@ -16,8 +16,8 @@ class ThreeDObjectFile
#[ORM\Column(type: "string", length: 255)] #[ORM\Column(type: "string", length: 255)]
private $filename; private $filename;
#[ORM\ManyToOne(targetEntity: Room::class, inversedBy: "ComplexRepresentation")] #[ORM\ManyToOne(targetEntity: Place::class, inversedBy: "ComplexRepresentation")]
private $room; private $place;
public function getId(): ?int public function getId(): ?int
{ {
@ -36,14 +36,14 @@ class ThreeDObjectFile
return $this; return $this;
} }
public function getRoom(): ?Room public function getPlace(): ?Place
{ {
return $this->room; return $this->place;
} }
public function setRoom(?Room $room): self public function setPlace(?Place $place): self
{ {
$this->room = $room; $this->place = $place;
return $this; return $this;
} }