Commit f1649e79 authored by Thibaut Vallee's avatar Thibaut Vallee
Browse files

suppression des anciennes entités

parent 6747bfde
Loading
Loading
Loading
Loading

src/Entity/AbstractEtat.php

deleted100644 → 0
+0 −76
Changes for src/Entity/AbstractEtat.php: 0 added lines, 76 removed lines.
Original line number Diff line number Diff line
<?php

namespace Unicaen\Evenement\Entity;

use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Unicaen\Evenement\Model\EtatInterface;

#[ORM\MappedSuperclass]
#[ApiFilter(SearchFilter::class, properties: ['code' => 'exact', 'libelle' => 'istart'])]
abstract class AbstractEtat implements EtatInterface
{
    public function __construct()
    {
    }

    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    #[Groups(['evenement-etat:read'])]
    private ?int $id = null;
    public function getId(): int
    {
        return $this->id;
    }

    #[Assert\NotBlank(message: 'Le code ne peut être vide.')]
    #[Groups(['evenement-etat:read','evenement-etat:create', 'evenement-etat:update'])]
    #[ORM\Column(length: 255)]
    protected string $code;
    public function getCode(): string
    {
        return $this->code;
    }

    public function setCode(string $code): static
    {
        $this->code = $code;
        return $this;
    }

    #[Assert\NotBlank(message: 'Le libellé ne peut être vide.')]
    #[Groups(['evenement-etat:read','evenement-etat:create', 'evenement-etat:update'])]
    #[ORM\Column(length: 255)]
    protected ?string $libelle;

    public function getLibelle(): string
    {
        return $this->libelle;
    }

    public function setLibelle(string $libelle): static
    {
        $this->libelle = $libelle;
        return $this;
    }

    #[Groups(['evenement-etat:read','evenement-etat:create', 'evenement-etat:update'])]
    #[ORM\Column(length: 1024)]
    protected ?string $description;

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

    public function setDescription(?string $description): static
    {
        if($description == "") {$description = null;}
        $this->description = $description;
        return $this;
    }
}

src/Entity/AbstractJournal.php

deleted100644 → 0
+0 −92
Changes for src/Entity/AbstractJournal.php: 0 added lines, 92 removed lines.
Original line number Diff line number Diff line
<?php

namespace Unicaen\Evenement\Entity;

use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use DateInterval;
use DateTimeInterface;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\SerializedName;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Serializer\Annotation\Context;
use Unicaen\Evenement\Model\EtatInterface;
use Unicaen\Evenement\Model\EvenementLogsTrait;
use Unicaen\Evenement\Model\JournalInterface;

//TODO : un filtre sur le journal pour avoir le dernier, de la pagination, de la recherche dans les logs ...
#[ORM\MappedSuperclass]
//#[ApiFilter(SearchFilter::class, properties: ['nom' => 'istart',  'type.code' => 'exact', 'etat.code' => 'exact',
//    'parametres' => 'ipartial', 'log' =>  'iword_start', 'motsClefs' =>  'iword_start'
//])]
class AbstractJournal implements JournalInterface {

    public function __construct()
    {
        $this->dateExecution = new \DateTime();
    }

    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    #[Groups(['journal:read'])]
    private ?int $id = null;
    public function getId(): int
    {
        return $this->id;
    }

    #[ORM\Column(type: Types::DATETIME_MUTABLE)]
    #[Groups(['journal:read'])]
    #[Context([DateTimeNormalizer::FORMAT_KEY => 'd/m/Y H:i'])]
    protected ?DateTimeInterface $dateExecution = null;
    public function getDateExecution(): ?DateTimeInterface
    {
        return $this->dateExecution;
    }

    public function setDateExecution(?DateTimeInterface $dateExecution): static
    {
        $this->dateExecution = $dateExecution;
        return $this;
    }

    #[Groups(['journal:read'])]
    #[ORM\Column(type: Types::TEXT)]
    protected ?string $log = null;

    #[Groups(['journal:read'])]
    public function getLastLog(): ?string
    {
        if(!isset($this->log) || $this->log == ""){return null;}
        if (json_validate($this->log)) {
            $data = json_decode($this->log, false);
            $last = end($data);
            return json_encode($last);
        }
        //Si ce n'est pas un Json, on retourne toute la chaine
        return $this->log;
    }
    use EvenementLogsTrait;

    #[ORM\ManyToOne(targetEntity: EtatInterface::class)]
    #[ORM\JoinColumn(name: 'etat_id', nullable: false)]
    #[Groups(['journal:read', 'journal:update'])]
    protected ?EtatInterface $etat = null;

    public function getEtat(): EtatInterface
    {
        return $this->etat;
    }

    public function setEtat(EtatInterface $etat): static
    {
        $this->etat = $etat;
        return $this;
    }

}

src/Entity/Etat.php

deleted100644 → 0
+0 −59
Changes for src/Entity/Etat.php: 0 added lines, 59 removed lines.
Original line number Diff line number Diff line
<?php

namespace Unicaen\Evenement\Entity;

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use ApiPlatform\OpenApi\Model\Operation;
use Doctrine\ORM\Mapping as ORM;

#[ApiResource(
    shortName: "EvenementEtat",
    operations: [
        new Get(
            name:"evenement-etat-afficher",
            uriTemplate: '/evenement/etat/{id}',
        ),
        new GetCollection(
            name:"evenement-etat-lister",
            uriTemplate: '/evenements/etats',
        ),
        new Post(
            name:"evenement-etat-ajouter",
            uriTemplate: '/evenement/etat',
            denormalizationContext: [
                'groups' => ['evenement-etat:create'],
            ],
        ),
        new Patch(
            name:"evenement-etat-modifier",
            uriTemplate: '/evenement/etat/{id}',
            denormalizationContext: [
                'groups' => ['evenement-etat:update'],
            ],
        ),
        new Delete(
            name:"evenement-etat-supprimer",
            uriTemplate: '/evenement/etat/{id}',
            denormalizationContext: [
                'groups' => ['evenement-etat:delete'],
            ],
        ),
    ],
    normalizationContext: ['groups' => ['evenement-etat:read']],
    denormalizationContext: ['groups' => ['evenement-etat:read']],
    openapi: new Operation(
        tags: ['Unicaen Evenement Etat'],
    ),
    security: "is_granted('UNICAEN_PRIVILEGE', object)",
)]
#[ORM\Entity]
#[ORM\Table(name: 'unicaen_evenement_etat')]
class Etat extends AbstractEtat
{

}

src/Entity/Journal.php

deleted100644 → 0
+0 −87
Changes for src/Entity/Journal.php: 0 added lines, 87 removed lines.
Original line number Diff line number Diff line
<?php

namespace Unicaen\Evenement\Entity;

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use ApiPlatform\OpenApi\Model\Operation;
use Doctrine\ORM\Mapping as ORM;

#[ApiResource(
    shortName: "EvenementJournal",
    operations: [
        new Get(
            name:"evenement-journal-afficher",
            openapi: new Operation(
                description: "Affichage d'un journal",
                summary: "Affichage d'un journal",
                tags: ['Unicaen Evenement Journal'],
            ),
            uriTemplate: '/journal/{id}',
        ),
        new GetCollection(
            name:"evenement-journal-lister",
            openapi: new Operation(
                description: "Liste les journaux",
                summary: "Liste les journux",
                tags: ['Unicaen Evenement Journal'],
            ),
            uriTemplate: '/journaux',
            order: ['datePlanification' => 'DESC', 'dateTraitement' => 'DESC', 'dateCreation' => 'DESC', 'id' => 'ASC'],
            paginationEnabled: true,
            paginationItemsPerPage: 100,
            paginationClientEnabled: false
        ),
        new Post(
            name:"evenement-journal-ajouter",
            openapi: new Operation(
                description: "Création d'un journal",
                summary: "Création d'un journal",
                tags: ['Unicaen Evenement Journal'],
            ),
            uriTemplate: '/journal',
            denormalizationContext: [
                'groups' => ['journal:create'],
            ],
        ),
        new Patch(
            name:"evenement-journal-modifier",
            openapi: new Operation(
                description: "Modification d'un journal",
                summary: "Modification d'un journal",
                tags: ['Unicaen Evenement Journal'],
            ),
            uriTemplate: '/journal/{id}',
            denormalizationContext: [
                'groups' => ['journal:update'],
            ],
        ),
        new Delete(
            name:"evenement-journal-supprimer",
            openapi: new Operation(
                description: "Suppression d'un journal",
                summary: "Suppression d'un journal",
                tags: ['Unicaen Evenement Journal'],
            ),
            uriTemplate: '/journal/{id}',
            denormalizationContext: [
                'groups' => ['journal:delete'],
            ],
        ),
    ],
    normalizationContext: ['groups' => ['journal:read']],
    denormalizationContext: ['groups' => ['journal:read']],
    openapi: new Operation(
        tags: ['Unicaen Evenement Journal'],
    ),
    security: "is_granted('UNICAEN_PRIVILEGE', object)",
)]
#[ORM\Entity]
#[ORM\Table(name: 'unicaen_evenement_journal')]
class Journal extends AbstractJournal {

}

src/Entity/Type.php

deleted100644 → 0
+0 −59
Changes for src/Entity/Type.php: 0 added lines, 59 removed lines.
Original line number Diff line number Diff line
<?php

namespace Unicaen\Evenement\Entity;

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use ApiPlatform\OpenApi\Model\Operation;
use Doctrine\ORM\Mapping as ORM;

#[ApiResource(
    shortName: "EvenementType",
    operations: [
        new Get(
            name:"evenement-type-afficher",
            uriTemplate: '/evenement/type/{id}',
        ),
        new GetCollection(
            name:"evenement-type-lister",
            uriTemplate: '/evenements/types',
        ),
        new Post(
            name:"evenement-type-ajouter",
            uriTemplate: '/evenement/type',
            denormalizationContext: [
                'groups' => ['evenement-type:create'],
            ],
        ),
        new Patch(
            name:"evenement-type-modifier",
            uriTemplate: '/evenement/type/{id}',
            denormalizationContext: [
                'groups' => ['evenement-type:update'],
            ],
        ),
        new Delete(
            name:"evenement-type-supprimer",
            uriTemplate: '/evenement/type/{id}',
            denormalizationContext: [
                'groups' => ['evenement-type:delete'],
            ],
        ),
    ],
    normalizationContext: ['groups' => ['evenement-type:read']],
    denormalizationContext: ['groups' => ['evenement-type:read']],
    openapi: new Operation(
        tags: ['Unicaen Evenement Type'],
    ),
    security: "is_granted('UNICAEN_PRIVILEGE', object)",
)]
#[ORM\Entity]
#[ORM\Table(name: 'unicaen_evenement_type')]
class Type extends AbstractEvenementType
{

}
Loading