<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Mask\MarkingCodesMask;
//
/**
* DnsitCriterion
*
* @ORM\Table(name="dnsit_criterion", indexes={@ORM\Index(name="criterion_criterion_code_idx", columns={"criterion_code"}), @ORM\Index(name="criterion_criterion_text_key_idx", columns={"criterion_text_key"}), @ORM\Index(name="criterion_criterion_tag_key_idx", columns={"criterion_tag_key"})})
* @ORM\Entity(repositoryClass="App\Repository\DnsitCriterionRepository")
*/
class DnsitCriterion
{
/**
* @var int|null
*
* @ORM\Column(name="criterion_code", type="float", nullable=true, unique=true)
*/
private $criterionCode;
/**
* @var string|null
*
* @ORM\Column(name="criterion_text_key", type="string", length=255, nullable=true, unique=true)
*/
private $criterionTextKey;
/**
* @var string|null
*
* @ORM\Column(name="criterion_tag_key", type="string", length=255, nullable=true, unique=true)
*/
private $criterionTagKey;
/**
* @var string|null
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* @var int|null
*
* @ORM\Column(name="qualitative", type="integer", nullable=true)
*/
private $qualitative;
/**
* @var int|null
*
* @ORM\Column(name="class", type="integer", nullable=true)
*/
private $class;
/**
* @var int|null
*
* @ORM\Column(name="value_type", type="integer", nullable=true)
*/
private $valueType;
/**
* @var int|null
*
* @ORM\Column(name="entity", type="bigint", nullable=true)
*/
private $entity;
/**
* @var int|null
*
* @ORM\Column(name="marking", type="smallint", nullable=true)
*/
private $marking;
/**
* @var string|null
*
* @ORM\Column(name="params", type="text", nullable=true)
*/
private $params;
/**
* @var \DateTime|null
*
* @ORM\Column(name="created_at", type="datetime", nullable=true)
*/
private $createdAt;
/**
* @var int|null
*
* @ORM\Column(name="created_by", type="bigint", nullable=true)
*/
private $createdBy;
/**
* @var \DateTime|null
*
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @var int|null
*
* @ORM\Column(name="updated_by", type="bigint", nullable=true)
*/
private $updatedBy;
/**
* @var int
*
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \App\Entity\DnsitTranslateCriterion
*
* @ORM\ManyToOne(targetEntity="App\Entity\DnsitTranslateCriterion")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="translate_id", referencedColumnName="id")
* })
*/
private $translate;
/**
* @var \App\Entity\DnsitCriterionCategory
*
* @ORM\ManyToOne(targetEntity="App\Entity\DnsitCriterionCategory", inversedBy="criterions")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="criterion_category_id", referencedColumnName="id")
* })
*/
private $criterionCategory;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\OneToMany(targetEntity="App\Entity\WebSort", mappedBy="criterion", cascade={"persist","remove"})
*/
private $sorts;
/**
* @ORM\OneToMany(targetEntity="App\Entity\DnsitModality", mappedBy="criterion", cascade={"remove"})
*/
private $modalities;
/**
* @ORM\Column(type="json", nullable=true)
*/
private $extraData = [];
/**
* @ORM\ManyToMany(targetEntity="App\Entity\WebFilterItem", mappedBy="criterions")
*/
private $filterItems;
public function __construct() {
// Champ qualitatif mis à 0 par défaut
$this->setQualitative(0);
$this->sorts = new ArrayCollection();
$this->modalities = new ArrayCollection();
$this->filterItems = new ArrayCollection();
}
public function __toString(){
return $this->id . '-' . $this->name;
}
public function getCriterionCode(): ?float
{
return $this->criterionCode;
}
public function setCriterionCode(?float $criterionCode): self
{
$this->criterionCode = $criterionCode;
return $this;
}
public function getCriterionTextKey(): ?string
{
return $this->criterionTextKey;
}
public function setCriterionTextKey(?string $criterionTextKey): self
{
$this->criterionTextKey = $criterionTextKey;
return $this;
}
public function getCriterionTagKey(): ?string
{
return $this->criterionTagKey;
}
public function setCriterionTagKey(?string $criterionTagKey): self
{
$this->criterionTagKey = $criterionTagKey;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getQualitative(): ?int
{
return $this->qualitative;
}
public function setQualitative(?int $qualitative): self
{
$this->qualitative = $qualitative;
return $this;
}
public function getClass(): ?int
{
return $this->class;
}
public function setClass(?int $class): self
{
$this->class = $class;
return $this;
}
public function getValueType(): ?int
{
return $this->valueType;
}
public function setValueType(?int $valueType): self
{
$this->valueType = $valueType;
return $this;
}
public function getEntity(): ?string
{
return $this->entity;
}
public function setEntity(?string $entity): self
{
$this->entity = $entity;
return $this;
}
public function getMarking(): ?int
{
return $this->marking;
}
public function setMarking(?int $marking): self
{
$this->marking = $marking;
return $this;
}
public function getParams(): ?string
{
return $this->params;
}
public function setParams(?string $params): self
{
$this->params = $params;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getCreatedBy(): ?int
{
return $this->createdBy;
}
public function setCreatedBy(?int $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getUpdatedBy(): ?int
{
return $this->updatedBy;
}
public function setUpdatedBy(?int $updatedBy): self
{
$this->updatedBy = $updatedBy;
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function getTranslate(): ?DnsitTranslateCriterion
{
return $this->translate;
}
public function setTranslate(?DnsitTranslateCriterion $translate): self
{
$this->translate = $translate;
return $this;
}
public function getCriterionCategory(): ?DnsitCriterionCategory
{
return $this->criterionCategory;
}
public function setCriterionCategory(?DnsitCriterionCategory $criterionCategory): self
{
$this->criterionCategory = $criterionCategory;
return $this;
}
public function bindLeiData($xmlCriterion, $language) {
$this->setCriterionCode((int) $xmlCriterion->CRITERE);
$this->setQualitative((int) $xmlCriterion->CRITERE_QUALITATIF);
$this->setValueType((int) $xmlCriterion->CRITERE_TYPEVAL);
$this->setName((string) $xmlCriterion->CRITERE_NOM);
$this->setMarking(MarkingCodesMask::LEI);
}
public function bindTourinsoftData($jsonCriterion, $language, $suffixe = "") {
$this->setCriterionTextKey(strtoupper($jsonCriterion->SyndicFieldID));
// $this->setCriterionCode($jsonCriterion->CRITERE);
switch ($jsonCriterion->ViewType) {
case 5:
case 6:
$this->setQualitative(-1);
break;
case 7:
case 8:
$this->setQualitative(1);
break;
// On ne met pas 0 dans qualitatif par défaut car les flux renvoient plusieurs fois les critères avec parfois un viewtype de type texte
///default:
// $this->setQualitative(0);
}
$this->setValueType($jsonCriterion->ViewType);
$name = $jsonCriterion->SyndicFieldName;
if ($suffixe != "")
$name .= " (" . $suffixe . ")";
$this->setName($name);
$this->setMarking(MarkingCodesMask::TOURINSOFT);
}
/**
* @return Collection|WebSort[]
*/
public function getSorts(): Collection
{
return $this->sorts;
}
public function addSort(WebSort $sort): self
{
if (!$this->sorts->contains($sort)) {
$this->sorts[] = $sort;
$sort->setCriterion($this);
}
return $this;
}
public function removeSort(WebSort $sort): self
{
if ($this->sorts->contains($sort)) {
$this->sorts->removeElement($sort);
// set the owning side to null (unless already changed)
if ($sort->getCriterion() === $this) {
$sort->setCriterion(null);
}
}
return $this;
}
/**
* @return Collection|DnsitModality[]
*/
public function getModalities(): Collection
{
return $this->modalities;
}
public function addModality(DnsitModality $modality): self
{
if (!$this->modalities->contains($modality)) {
$this->modalities[] = $modality;
$modality->setDnsitCriterion($this);
}
return $this;
}
public function removeModality(DnsitModality $modality): self
{
if ($this->modalities->contains($modality)) {
$this->modalities->removeElement($modality);
// set the owning side to null (unless already changed)
if ($modality->getCriterion() === $this) {
$modality->setCriterion(null);
}
}
return $this;
}
public function getExtraData(): ?array
{
return $this->extraData;
}
public function setExtraData(?array $extraData): self
{
$this->extraData = $extraData;
return $this;
}
/**
* @return Collection|WebFilterItem[]
*/
public function getFilterItems() : Collection
{
return $this->filterItems;
}
public function addFilterItem(WebFilterItem $item) : self
{
if (!$this->filterItems->contains($item)) {
$this->filterItems[] = $item;
$item->addCriterion($this);
}
return $this;
}
public function removeFilterItem(WebFilterItem $item) : self
{
if ($this->filterItems->contains($item)) {
$this->filterItems->removeElement($item);
$item->removeCriterion($this);
}
return $this;
}
}