Skip to content

Commit

Permalink
added Label entity & updated modelio
Browse files Browse the repository at this point in the history
  • Loading branch information
ginokok1996 committed May 18, 2020
1 parent 23c5f16 commit 3aa6a5b
Show file tree
Hide file tree
Showing 8 changed files with 2,454 additions and 835 deletions.
Binary file modified api/public/schema/Datamodel_Modelio.zip
Binary file not shown.
Binary file modified api/public/schema/datamodel.pdf
Binary file not shown.
2,970 changes: 2,140 additions & 830 deletions api/public/schema/openapi.yaml

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions api/public/schema/publiccode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ url: "https://github.com/ConductionNL/verzoekregistratiecomponent"
landingURL: "pc.zaakonline.nl"
isBasedOn: "https://github.com/ConductionNL/Proto-component-commonground.git"
softwareVersion: "V.0.1"
<<<<<<< HEAD
releaseDate: "2020-06-05"
=======
releaseDate: "2020-23-04"
>>>>>>> development
releaseDate: "2020-18-05"
logo: pc.zaakonline.nl
monochromeLogo: img/logo-mono.svg

Expand Down
219 changes: 219 additions & 0 deletions api/src/Entity/Label.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
<?php

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;

use Doctrine\Common\Collections\ArrayCollection;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Serializer\Annotation\MaxDepth;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;

/**
* @ApiResource(
* normalizationContext={"groups"={"read"}, "enable_max_depth"=true},
* denormalizationContext={"groups"={"write"}, "enable_max_depth"=true}
*
* )
*
* @ORM\Entity(repositoryClass="App\Repository\LabelRepository")
* @Gedmo\Loggable(logEntryClass="App\Entity\ChangeLog")
*
* @ApiFilter(BooleanFilter::class)
* @ApiFilter(OrderFilter::class)
* @ApiFilter(DateFilter::class, strategy=DateFilter::EXCLUDE_NULL)
* @ApiFilter(SearchFilter::class)
*/
class Label
{
/**
* @var UuidInterface The UUID identifier of this object
*
* @example e2984465-190a-4562-829e-a8cca81aa35d
*
* @Groups({"read"})
* @Assert\Uuid
* @ORM\Id
* @ORM\Column(type="uuid", unique=true)
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator")
*/
private $id;

/**
* @var string Name of the label
*
* @example Label
* @Groups({"read", "write"})
* @ORM\Column(type="string", length=2550)
* @Assert\Length(
* max = 255
* )
* @Assert\NotNull
*/
private $name;

/**
* @var string Description of the label
*
* @example label description
* @Groups({"read", "write"})
* @ORM\Column(type="string", length=255)
* @Assert\Length(
* max = 2550
* )
* @Assert\NotNull
*/
private $description;

/**
* @var string Color of the label
*
* @example red
* @Groups({"read", "write"})
* @ORM\Column(type="string", length=2550)
* @Assert\Length(
* max = 255
* )
* @Assert\NotNull
*/
private $color;

/**
* @var string icon of the label
*
* @example url of icon
* @Groups({"read", "write"})
* @ORM\Column(type="string", length=2550)
* @Assert\Length(
* max = 255
* )
* @Assert\NotNull
*/
private $icon;

/**
* @var request The request this submitter belongs to
*
* @Groups({"read","write"})
* @MaxDepth(1)
* @ORM\ManyToOne(targetEntity="App\Entity\Request", inversedBy="labels")
*/
private $request;

/**
* @var Datetime $dateCreated The moment this resource was created
*
* @Groups({"read"})
* @Gedmo\Timestampable(on="create")
* @ORM\Column(type="datetime", nullable=true)
*/
private $dateCreated;

/**
* @var Datetime $dateModified The moment this resource last Modified
*
* @Groups({"read"})
* @Gedmo\Timestampable(on="update")
* @ORM\Column(type="datetime", nullable=true)
*/
private $dateModified;

public function getId()
{
return $this->id;
}

public function getName(): ?string
{
return $this->name;
}

public function setName(string $name): self
{
$this->name = $name;

return $this;
}

public function getDescription(): ?string
{
return $this->description;
}

public function setDescription(string $description): self
{
$this->description = $description;

return $this;
}

public function getColor(): ?string
{
return $this->color;
}

public function setColor(string $color): self
{
$this->color = $color;

return $this;
}

public function getIcon(): ?string
{
return $this->icon;
}

public function setIcon(string $icon): self
{
$this->icon = $icon;

return $this;
}

public function getRequest(): ?Request
{
return $this->request;
}

public function setRequest(?Request $request): self
{
$this->request = $request;

return $this;
}

public function getDateCreated(): ?\DateTimeInterface
{
return $this->dateCreated;
}

public function setDateCreated(\DateTimeInterface $dateCreated): self
{
$this->dateCreated= $dateCreated;

return $this;
}

public function getDateModified(): ?\DateTimeInterface
{
return $this->dateModified;
}

public function setDateModified(\DateTimeInterface $dateModified): self
{
$this->dateModified = $dateModified;

return $this;
}
}
44 changes: 44 additions & 0 deletions api/src/Entity/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,18 @@ class Request
*/
private $submitters;

/**
* @var ArrayCollection $labels labels for this request
*
*
* @Assert\Valid
* @MaxDepth(1)
* @Groups({"read", "write"})
* @ORM\OneToMany(targetEntity="App\Entity\Label", mappedBy="request", cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=true)
*/
private $labels;

/**
* @var Datetime $dateSubmitted The moment this request was submitted by the submitter
*
Expand Down Expand Up @@ -308,6 +320,7 @@ public function __construct()
$this->children = new ArrayCollection();
$this->submitters = new ArrayCollection();
$this->roles = new ArrayCollection();
$this->labels = new ArrayCollection();
}

public function getId():?Uuid
Expand Down Expand Up @@ -589,4 +602,35 @@ public function removeRole(Role $role): self

return $this;
}

/**
* @return Collection|Label[]
*/
public function getLabels(): Collection
{
return $this->labels;
}

public function addLabel(Label $label): self
{
if (!$this->labels->contains($label)) {
$this->labels[] = $label;
$label->setRequest($this);
}

return $this;
}

public function removeLabel(Label $label): self
{
if ($this->labels->contains($label)) {
$this->labels->removeElement($label);
// set the owning side to null (unless already changed)
if ($label->getRequest() === $this) {
$label->setRequest(null);
}
}

return $this;
}
}
50 changes: 50 additions & 0 deletions api/src/Repository/LabelRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace App\Repository;

use App\Entity\Label;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
* @method Label|null find($id, $lockMode = null, $lockVersion = null)
* @method Label|null findOneBy(array $criteria, array $orderBy = null)
* @method Label[] findAll()
* @method Label[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class LabelRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Label::class);
}

// /**
// * @return Label[] Returns an array of Label objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('l')
->andWhere('l.exampleField = :val')
->setParameter('val', $value)
->orderBy('l.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?Label
{
return $this->createQueryBuilder('l')
->andWhere('l.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}
Empty file added request
Empty file.

0 comments on commit 3aa6a5b

Please sign in to comment.