<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Trait\TimestampableEntity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
/**
* A Report generated by governmental or non-governmental organization.
*
* @see https://schema.org/Report
*
* @author Jordi Fernandes Alves <jfadev@gmail.com>
*/
#[ORM\Entity]
#[ApiResource(
iri: 'Report',
itemOperations: [
'get' => ['normalization_context' => ['groups' => 'report:item:get']],
'put' => [
'normalization_context' => ['groups' => 'report:item:put'],
'denormalization_context' => ['groups' => 'report:item:put'],
],
'delete' => [],
],
collectionOperations: [
'get' => [
'normalization_context' => ['groups' => 'report:collection:get'],
],
'post' => [
'normalization_context' => ['groups' => 'report:collection:post'],
'denormalization_context' => ['groups' => 'report:collection:post'],
],
],
)]
class Report
{
use TimestampableEntity;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'NONE')]
#[ORM\Column(type: 'uuid', unique: true)]
#[ApiProperty(iri: 'https://schema.org/identifier')]
#[Groups(['report:collection:get', 'report:item:get'])]
private ?UuidInterface $id = null;
#[ORM\Column(type: 'string', nullable: false)]
#[Assert\NotNull]
#[Assert\Type('string')]
#[ApiProperty(iri: 'https://schema.org/name')]
#[Groups(['report:collection:get', 'report:collection:post', 'report:item:get', 'report:item:put'])]
private ?string $reportName = null;
#[ORM\Column(type: 'string', nullable: false)]
#[Assert\NotNull]
#[Assert\Type('string')]
#[ApiProperty(iri: 'https://schema.org/Text')]
#[Groups(['report:collection:get', 'report:collection:post', 'report:item:get', 'report:item:put'])]
private ?string $reportType = null;
#[ORM\Column(type: 'json', nullable: false)]
#[Assert\NotNull]
#[ApiProperty(iri: 'https://schema.org/Text')]
#[Groups(['report:collection:get', 'report:collection:post', 'report:item:get', 'report:item:put'])]
private ?array $data = null;
#[ORM\Column(type: 'json', nullable: false)]
#[Assert\NotNull]
#[ApiProperty(iri: 'https://schema.org/Text')]
#[Groups(['report:collection:get', 'report:collection:post', 'report:item:get', 'report:item:put'])]
private ?array $filters = null;
#[ApiProperty(iri: 'https://schema.org/Person')]
#[Groups(['report:collection:get', 'report:collection:post', 'report:item:get', 'report:item:put'])]
private ?User $generatedBy = null;
public function __construct()
{
$this->id = Uuid::uuid4();
}
public function getId(): ?UuidInterface
{
return $this->id;
}
public function setReportName(?string $reportName): void
{
$this->reportName = $reportName;
}
public function getReportName(): ?string
{
return $this->reportName;
}
public function setReportType(?string $reportType): void
{
$this->reportType = $reportType;
}
public function getReportType(): ?string
{
return $this->reportType;
}
public function setData(?array $data): void
{
$this->data = $data;
}
public function getData(): ?array
{
return $this->data;
}
public function setFilters(?array $filters): void
{
$this->filters = $filters;
}
public function getFilters(): ?array
{
return $this->filters;
}
public function setGeneratedBy(?User $generatedBy): void
{
$this->generatedBy = $generatedBy;
}
public function getGeneratedBy(): ?User
{
return $this->generatedBy;
}
}