Optimized database schema

This commit is contained in:
Kevin Frantz 2018-10-31 21:53:30 +01:00
parent 0a18123384
commit ad00c57143
6 changed files with 13 additions and 19 deletions

View File

@ -11,6 +11,8 @@ use App\DBAL\Types\RecieverType;
use App\Entity\Meta\RightInterface; use App\Entity\Meta\RightInterface;
use App\Entity\Meta\RecieverGroupInterface; use App\Entity\Meta\RecieverGroupInterface;
use App\Entity\Meta\RecieverGroup; use App\Entity\Meta\RecieverGroup;
use App\Entity\Meta\RecieverInterface;
use App\Entity\Meta\Reciever;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -22,7 +24,7 @@ abstract class LawModificator
foreach (LayerType::getChoices() as $layerKey => $layerValue) { foreach (LayerType::getChoices() as $layerKey => $layerValue) {
foreach (RightType::getChoices() as $rightKey => $rightValue) { foreach (RightType::getChoices() as $rightKey => $rightValue) {
$right = self::createRight($law, $node, $rightKey, $layerKey); $right = self::createRight($law, $node, $rightKey, $layerKey);
$right->setRecieverGroup(self::createRecieverGroup($node, RecieverType::NODE)); //$right->setRecieverGroup(self::createRecieverGroup($node, RecieverType::NODE));
$law->getRights()->add($right); $law->getRights()->add($right);
} }
} }
@ -39,9 +41,9 @@ abstract class LawModificator
return $right; return $right;
} }
public static function createRecieverGroup(RelationInterface $node, string $reciever): RecieverGroupInterface public static function createRecieverGroup(RelationInterface $node, string $reciever): RecieverInterface
{ {
$recieverGroup = new RecieverGroup(); $recieverGroup = new Reciever();
$recieverGroup->setNode($node); $recieverGroup->setNode($node);
$recieverGroup->setReciever($reciever); $recieverGroup->setReciever($reciever);

View File

@ -11,7 +11,7 @@ use App\Entity\Source\SourceInterface;
/** /**
* @author kevinfrantz * @author kevinfrantz
* @ORM\Table(name="meta_reciever_group") * @ORM\Table(name="meta_reciever")
* @ORM\Entity() * @ORM\Entity()
*/ */
class Reciever extends AbstractMeta implements RecieverInterface class Reciever extends AbstractMeta implements RecieverInterface
@ -29,7 +29,7 @@ class Reciever extends AbstractMeta implements RecieverInterface
protected $relation; protected $relation;
/** /**
* @ORM\ManyToMany(targetEntity="App\Entity\AbstractSource") * @ORM\ManyToMany(targetEntity="App\Entity\Source\AbstractSource")
* @ORM\JoinTable(name="meta_reciever_members", * @ORM\JoinTable(name="meta_reciever_members",
* joinColumns={@ORM\JoinColumn(name="reciever_id", referencedColumnName="id")}, * joinColumns={@ORM\JoinColumn(name="reciever_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="source_id", referencedColumnName="id")} * inverseJoinColumns={@ORM\JoinColumn(name="source_id", referencedColumnName="id")}

View File

@ -34,26 +34,17 @@ final class Relation extends AbstractMeta implements RelationInterface
/** /**
* Parents represent the creators of the relation. * Parents represent the creators of the relation.
* *
* @ORM\ManyToMany(targetEntity="Relation") * @ORM\ManyToMany(targetEntity="Relation",mappedBy="childs")
* @ORM\JoinTable(name="meta_relation_parents",
* joinColumns={@ORM\JoinColumn(name="relation_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="relation_id", referencedColumnName="id")}
* )
*
* @var Collection|RelationInterface[] * @var Collection|RelationInterface[]
*/ */
protected $parents; protected $parents;
/** /**
* Childs represent the by the object produced relations. * Childs represent the by the object produced relations.
*
* @todo Replace this by self referencing
*
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/association-mapping.html
* @ORM\ManyToMany(targetEntity="Relation") * @ORM\ManyToMany(targetEntity="Relation")
* @ORM\JoinTable(name="meta_relation_childs", * @ORM\JoinTable(name="meta_relation_childs",
* joinColumns={@ORM\JoinColumn(name="relation_id", referencedColumnName="id")}, * joinColumns={@ORM\JoinColumn(name="relation_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="relation_id", referencedColumnName="id")} * inverseJoinColumns={@ORM\JoinColumn(name="child_id", referencedColumnName="id")}
* ) * )
* *
* @var Collection|RelationInterface[] * @var Collection|RelationInterface[]

View File

@ -41,7 +41,7 @@ final class Right extends AbstractMeta implements RightInterface
protected $layer; protected $layer;
/** /**
* @ORM\OneToOne(targetEntity="RecieverGroup",cascade={"persist", "remove"}) * @ORM\OneToOne(targetEntity="Reciever",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="reciever_id", referencedColumnName="id") * @ORM\JoinColumn(name="reciever_id", referencedColumnName="id")
* *
* @var RecieverInterface * @var RecieverInterface

View File

@ -42,7 +42,7 @@ abstract class AbstractSource extends AbstractEntity implements SourceInterface
* @todo Rename table to use the right schema * @todo Rename table to use the right schema
* *
* @var Collection|GroupSource[] * @var Collection|GroupSource[]
* @ORM\ManyToMany(targetEntity="GroupSource") * @ORM\ManyToMany(targetEntity="GroupSource",mappedBy="members")
*/ */
protected $groups; protected $groups;

View File

@ -19,7 +19,8 @@ final class GroupSource extends AbstractSource implements MembersAttributInterfa
/** /**
* @var Collection * @var Collection
* @ORM\ManyToMany(targetEntity="AbstractSource") * @ORM\ManyToMany(targetEntity="AbstractSource",inversedBy="groups")
* @ORM\JoinTable(name="source_group_members")
*/ */
protected $members; protected $members;