src/Entity/ReadingCard.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\BaseDateAtTrait;
  4. use App\Repository\ReadingCardRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Doctrine\ORM\Mapping\JoinColumn;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. #[ORM\Entity(repositoryClassReadingCardRepository::class)]
  11. #[ORM\HasLifecycleCallbacks]
  12. class ReadingCard
  13. {
  14.     use BaseDateAtTrait;
  15.     public const REFERENCE_TYPE_BOOK 0;
  16.     public const REFERENCE_TYPE_ARTICLE 1;
  17.     public const REFERENCE_TYPE_AUTRE 2;
  18.     public static $allReferencesType = [
  19.         self::REFERENCE_TYPE_BOOK => 'reading_card.referencesType.book',
  20.         self::REFERENCE_TYPE_ARTICLE => 'reading_card.referencesType.article',
  21.         self::REFERENCE_TYPE_AUTRE => 'reading_card.referencesType.autre',
  22.     ];
  23.     public const REQUIRED_BOOK_FIELDS = ['referencePlace''referenceEditor''referencePublishDate'];
  24.     public const REQUIRED_ARTICLE_FIELDS = ['referenceVolume''referenceDate''referencePage'];
  25.     #[ORM\Id]
  26.     #[ORM\GeneratedValue]
  27.     #[ORM\Column(type'integer')]
  28.     private $id;
  29.     #[Assert\NotBlank]
  30.     #[ORM\Column(type'integer')]
  31.     private $referenceType;
  32.     #[Assert\NotBlank]
  33.     #[ORM\Column(type'string'length255)]
  34.     private $referenceAuthorLastName;
  35.     #[Assert\NotBlank]
  36.     #[ORM\Column(type'string'length255)]
  37.     private $referenceAuthorFirstName;
  38.     #[Assert\NotBlank]
  39.     #[ORM\Column(type'string'length255)]
  40.     private $referenceTitle;
  41.     #[ORM\Column(type'string'length255nullabletrue)]
  42.     private $referenceMagazine;
  43.     #[ORM\Column(type'string'length255nullabletrue)]
  44.     private $referenceVolume;
  45.     #[ORM\Column(type'string'length255nullabletrue)]
  46.     private $referenceDate;
  47.     #[ORM\Column(type'string'length255nullabletrue)]
  48.     private $referencePage;
  49.     #[ORM\Column(type'string'length255nullabletrue)]
  50.     private $referencePlace;
  51.     #[ORM\Column(type'string'length255nullabletrue)]
  52.     private $referenceEditor;
  53.     #[ORM\Column(type'string'length255nullabletrue)]
  54.     private $referencePublishDate;
  55.     #[ORM\Column(type'string'length255nullabletrue)]
  56.     private $referenceTranslation;
  57.     #[ORM\Column(type'string'length255nullabletrue)]
  58.     private $doi;
  59.     #[Assert\NotBlank]
  60.     #[ORM\Column(type'text'nullabletrue)]
  61.     private $relevanceProject;
  62.     #[ORM\Column(type'text'nullabletrue)]
  63.     private $resume;
  64.     #[ORM\Column(type'json'nullabletrue)]
  65.     private $keywords = [];
  66.     #[ORM\Column(type'text'nullabletrue)]
  67.     private $arguments;
  68.     #[ORM\Column(type'text'nullabletrue)]
  69.     private $quotes;
  70.     #[ORM\Column(type'text'nullabletrue)]
  71.     private $reviews;
  72.     #[ORM\Column(type'text'nullabletrue)]
  73.     private $referencesText;
  74.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'readingCards')]
  75.     private $user;
  76.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'lastUserReadingCards')]
  77.     private $lastUser;
  78.     #[ORM\OneToOne(targetEntityWorkroomResource::class, mappedBy'readingCard'cascade: ['persist''remove'])]
  79.     #[JoinColumn(onDelete'CASCADE')]
  80.     private $workroomResource;
  81.     #[ORM\OneToOne(targetEntityPersonalResource::class, mappedBy'readingCard'cascade: ['persist''remove'])]
  82.     #[JoinColumn(onDelete'CASCADE')]
  83.     private $personalResource;
  84.     #[ORM\ManyToMany(targetEntitySemanticTag::class, inversedBy'readingCards')]
  85.     private $semanticTag;
  86.     public const AI_STATUS_PENDING 'pending';
  87.     public const AI_STATUS_RUNNING 'running';
  88.     public const AI_STATUS_DONE    'done';
  89.     public const AI_STATUS_FAILED  'failed';
  90.     #[ORM\Column(type'string'length16nullabletrue)]
  91.     private ?string $aiStatus null;
  92.     #[ORM\Column(type'text'nullabletrue)]
  93.     private ?string $aiError null;
  94.     #[ORM\Column(type'datetime'nullabletrue)]
  95.     private ?\DateTimeInterface $aiStartedAt null;
  96.     #[ORM\Column(type'datetime'nullabletrue)]
  97.     private ?\DateTimeInterface $aiFinishedAt null;
  98.     public function __construct()
  99.     {
  100.         $this->semanticTag = new ArrayCollection();
  101.     }
  102.     public function getAiStatus(): ?string
  103.     {
  104.         return $this->aiStatus;
  105.     }
  106.     public function setAiStatus(?string $aiStatus): self
  107.     {
  108.         $this->aiStatus $aiStatus;
  109.         return $this;
  110.     }
  111.     public function getAiError(): ?string
  112.     {
  113.         return $this->aiError;
  114.     }
  115.     public function setAiError(?string $aiError): self
  116.     {
  117.         $this->aiError $aiError;
  118.         return $this;
  119.     }
  120.     public function getAiStartedAt(): ?\DateTimeInterface
  121.     {
  122.         return $this->aiStartedAt;
  123.     }
  124.     public function setAiStartedAt(?\DateTimeInterface $aiStartedAt): self
  125.     {
  126.         $this->aiStartedAt $aiStartedAt;
  127.         return $this;
  128.     }
  129.     public function getAiFinishedAt(): ?\DateTimeInterface
  130.     {
  131.         return $this->aiFinishedAt;
  132.     }
  133.     public function setAiFinishedAt(?\DateTimeInterface $aiFinishedAt): self
  134.     {
  135.         $this->aiFinishedAt $aiFinishedAt;
  136.         return $this;
  137.     }
  138.     public function getId(): ?int
  139.     {
  140.         return $this->id;
  141.     }
  142.     public function getReferenceType(): ?string
  143.     {
  144.         return $this->referenceType;
  145.     }
  146.     public function getReferenceFromCode(int $referenceType): ?string
  147.     {
  148.         return self::$allReferencesType[$referenceType];
  149.     }
  150.     public function setReferenceType(?string $referenceType): self
  151.     {
  152.         $this->referenceType $referenceType;
  153.         return $this;
  154.     }
  155.     public function getReferenceAuthorLastName(): ?string
  156.     {
  157.         return $this->referenceAuthorLastName;
  158.     }
  159.     public function setReferenceAuthorLastName(?string $referenceAuthorLastName): self
  160.     {
  161.         $this->referenceAuthorLastName $referenceAuthorLastName;
  162.         return $this;
  163.     }
  164.     public function getReferenceAuthorFirstName(): ?string
  165.     {
  166.         return $this->referenceAuthorFirstName;
  167.     }
  168.     public function setReferenceAuthorFirstName(?string $referenceAuthorFirstName): self
  169.     {
  170.         $this->referenceAuthorFirstName $referenceAuthorFirstName;
  171.         return $this;
  172.     }
  173.     public function getReferenceTitle(): ?string
  174.     {
  175.         return $this->referenceTitle;
  176.     }
  177.     public function setReferenceTitle(?string $referenceTitle): self
  178.     {
  179.         $this->referenceTitle $referenceTitle;
  180.         return $this;
  181.     }
  182.     public function getReferenceMagazine(): ?string
  183.     {
  184.         return $this->referenceMagazine;
  185.     }
  186.     public function setReferenceMagazine(?string $referenceMagazine): self
  187.     {
  188.         $this->referenceMagazine $referenceMagazine;
  189.         return $this;
  190.     }
  191.     public function getReferenceVolume(): ?string
  192.     {
  193.         return $this->referenceVolume;
  194.     }
  195.     public function setReferenceVolume(?string $referenceVolume): self
  196.     {
  197.         $this->referenceVolume $referenceVolume;
  198.         return $this;
  199.     }
  200.     public function getReferencePage(): ?string
  201.     {
  202.         return $this->referencePage;
  203.     }
  204.     public function setReferencePage(?string $referencePage): self
  205.     {
  206.         $this->referencePage $referencePage;
  207.         return $this;
  208.     }
  209.     public function getReferenceDate(): ?string
  210.     {
  211.         return $this->referenceDate;
  212.     }
  213.     public function setReferenceDate(?string $referenceDate): self
  214.     {
  215.         $this->referenceDate $referenceDate;
  216.         return $this;
  217.     }
  218.     public function getReferencePlace(): ?string
  219.     {
  220.         return $this->referencePlace;
  221.     }
  222.     public function setReferencePlace(?string $referencePlace): self
  223.     {
  224.         $this->referencePlace $referencePlace;
  225.         return $this;
  226.     }
  227.     public function getReferenceEditor(): ?string
  228.     {
  229.         return $this->referenceEditor;
  230.     }
  231.     public function setReferenceEditor(?string $referenceEditor): self
  232.     {
  233.         $this->referenceEditor $referenceEditor;
  234.         return $this;
  235.     }
  236.     public function getReferencePublishDate(): ?string
  237.     {
  238.         return $this->referencePublishDate;
  239.     }
  240.     public function setReferencePublishDate(?string $referencePublishDate): self
  241.     {
  242.         $this->referencePublishDate $referencePublishDate;
  243.         return $this;
  244.     }
  245.     public function getReferenceTranslation(): ?string
  246.     {
  247.         return $this->referenceTranslation;
  248.     }
  249.     public function setReferenceTranslation(?string $referenceTranslation): self
  250.     {
  251.         $this->referenceTranslation $referenceTranslation;
  252.         return $this;
  253.     }
  254.     public function getDoi(): ?string
  255.     {
  256.         return $this->doi;
  257.     }
  258.     public function setDoi(?string $doi): self
  259.     {
  260.         $this->doi $doi;
  261.         return $this;
  262.     }
  263.     public function getRelevanceProject(): ?string
  264.     {
  265.         return $this->relevanceProject;
  266.     }
  267.     public function setRelevanceProject(?string $relevanceProject): self
  268.     {
  269.         $this->relevanceProject $relevanceProject;
  270.         return $this;
  271.     }
  272.     public function getResume(): ?string
  273.     {
  274.         return $this->resume;
  275.     }
  276.     public function setResume(?string $resume): self
  277.     {
  278.         $this->resume $resume;
  279.         return $this;
  280.     }
  281.     public function getKeywords(): ?array
  282.     {
  283.         return $this->keywords;
  284.     }
  285.     public function setKeywords(?array $keywords): self
  286.     {
  287.         $this->keywords $keywords;
  288.         return $this;
  289.     }
  290.     public function getArguments(): ?string
  291.     {
  292.         return $this->arguments;
  293.     }
  294.     public function setArguments(?string $arguments): self
  295.     {
  296.         $this->arguments $arguments;
  297.         return $this;
  298.     }
  299.     public function getQuotes(): ?string
  300.     {
  301.         return $this->quotes;
  302.     }
  303.     public function setQuotes(?string $quotes): self
  304.     {
  305.         $this->quotes $quotes;
  306.         return $this;
  307.     }
  308.     public function getReviews(): ?string
  309.     {
  310.         return $this->reviews;
  311.     }
  312.     public function setReviews(?string $reviews): self
  313.     {
  314.         $this->reviews $reviews;
  315.         return $this;
  316.     }
  317.     public function getReferencesText(): ?string
  318.     {
  319.         return $this->referencesText;
  320.     }
  321.     public function setReferencesText(?string $referencesText): self
  322.     {
  323.         $this->referencesText $referencesText;
  324.         return $this;
  325.     }
  326.     public function getUser(): ?User
  327.     {
  328.         return $this->user;
  329.     }
  330.     public function setUser(?User $user): self
  331.     {
  332.         $this->user $user;
  333.         return $this;
  334.     }
  335.     public function getLastUser(): ?User
  336.     {
  337.         return $this->lastUser;
  338.     }
  339.     public function setLastUser(?User $lastUser): self
  340.     {
  341.         $this->lastUser $lastUser;
  342.         return $this;
  343.     }
  344.     public function getWorkroomResource(): ?WorkroomResource
  345.     {
  346.         return $this->workroomResource;
  347.     }
  348.     public function setWorkroomResource(?WorkroomResource $workroomResource): self
  349.     {
  350.         $this->workroomResource $workroomResource;
  351.         return $this;
  352.     }
  353.     public function getPersonalResource(): ?PersonalResource
  354.     {
  355.         return $this->personalResource;
  356.     }
  357.     public function setPersonalResource(?PersonalResource $personalResource): self
  358.     {
  359.         $this->personalResource $personalResource;
  360.         return $this;
  361.     }
  362.     public function setKeywordsString($str)
  363.     {
  364.         $keywords explode(','str_replace(' '''$str));
  365.         $this->setKeywords($keywords);
  366.         return $this;
  367.     }
  368.     public function getKeywordsString()
  369.     {
  370.         $keywordsString '';
  371.         foreach ($this->keywords as $keyword) {
  372.             $keywordsString .= $keyword.',';
  373.         }
  374.         return substr($keywordsString0, -1);
  375.     }
  376.     /**
  377.      * @return Collection|SemanticTag[]
  378.      */
  379.     public function getSemanticTag(): Collection
  380.     {
  381.         return $this->semanticTag;
  382.     }
  383.     public function getSementicTagAsString(): ?string
  384.     {
  385.         $semanticAsString '';
  386.         foreach ($this->semanticTag as $semanticTag) {
  387.             $semanticAsString .= $semanticTag->getName().',';
  388.         }
  389.         return substr($semanticAsString0, -1);
  390.     }
  391.     public function addSemanticTag(SemanticTag $semanticTag): self
  392.     {
  393.         if (!$this->semanticTag->contains($semanticTag)) {
  394.             $this->semanticTag[] = $semanticTag;
  395.         }
  396.         return $this;
  397.     }
  398.     public function removeSemanticTag(SemanticTag $semanticTag): self
  399.     {
  400.         $this->semanticTag->removeElement($semanticTag);
  401.         return $this;
  402.     }
  403. }