src/Entity/DnsitCriterion.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Mask\MarkingCodesMask;
  7. //
  8. /**
  9.  * DnsitCriterion
  10.  *
  11.  * @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"})})
  12.  * @ORM\Entity(repositoryClass="App\Repository\DnsitCriterionRepository")
  13.  */
  14. class DnsitCriterion
  15. {
  16.     /**
  17.      * @var int|null
  18.      *
  19.      * @ORM\Column(name="criterion_code", type="float", nullable=true, unique=true)
  20.      */
  21.     private $criterionCode;
  22.     /**
  23.      * @var string|null
  24.      *
  25.      * @ORM\Column(name="criterion_text_key", type="string", length=255, nullable=true, unique=true)
  26.      */
  27.     private $criterionTextKey;
  28.     /**
  29.      * @var string|null
  30.      *
  31.      * @ORM\Column(name="criterion_tag_key", type="string", length=255, nullable=true, unique=true)
  32.      */
  33.     private $criterionTagKey;
  34.     /**
  35.      * @var string|null
  36.      *
  37.      * @ORM\Column(name="name", type="string", length=255, nullable=true)
  38.      */
  39.     private $name;
  40.     /**
  41.      * @var int|null
  42.      *
  43.      * @ORM\Column(name="qualitative", type="integer", nullable=true)
  44.      */
  45.     private $qualitative;
  46.     /**
  47.      * @var int|null
  48.      *
  49.      * @ORM\Column(name="class", type="integer", nullable=true)
  50.      */
  51.     private $class;
  52.     /**
  53.      * @var int|null
  54.      *
  55.      * @ORM\Column(name="value_type", type="integer", nullable=true)
  56.      */
  57.     private $valueType;
  58.     /**
  59.      * @var int|null
  60.      *
  61.      * @ORM\Column(name="entity", type="bigint", nullable=true)
  62.      */
  63.     private $entity;
  64.     /**
  65.      * @var int|null
  66.      *
  67.      * @ORM\Column(name="marking", type="smallint", nullable=true)
  68.      */
  69.     private $marking;
  70.     /**
  71.      * @var string|null
  72.      *
  73.      * @ORM\Column(name="params", type="text", nullable=true)
  74.      */
  75.     private $params;
  76.     /**
  77.      * @var \DateTime|null
  78.      *
  79.      * @ORM\Column(name="created_at", type="datetime", nullable=true)
  80.      */
  81.     private $createdAt;
  82.     /**
  83.      * @var int|null
  84.      *
  85.      * @ORM\Column(name="created_by", type="bigint", nullable=true)
  86.      */
  87.     private $createdBy;
  88.     /**
  89.      * @var \DateTime|null
  90.      *
  91.      * @ORM\Column(name="updated_at", type="datetime", nullable=true)
  92.      */
  93.     private $updatedAt;
  94.     /**
  95.      * @var int|null
  96.      *
  97.      * @ORM\Column(name="updated_by", type="bigint", nullable=true)
  98.      */
  99.     private $updatedBy;
  100.     /**
  101.      * @var int
  102.      *
  103.      * @ORM\Column(name="id", type="bigint")
  104.      * @ORM\Id
  105.      * @ORM\GeneratedValue(strategy="IDENTITY")
  106.      */
  107.     private $id;
  108.     /**
  109.      * @var \App\Entity\DnsitTranslateCriterion
  110.      *
  111.      * @ORM\ManyToOne(targetEntity="App\Entity\DnsitTranslateCriterion")
  112.      * @ORM\JoinColumns({
  113.      *   @ORM\JoinColumn(name="translate_id", referencedColumnName="id")
  114.      * })
  115.      */
  116.     private $translate;
  117.     /**
  118.      * @var \App\Entity\DnsitCriterionCategory
  119.      *
  120.      * @ORM\ManyToOne(targetEntity="App\Entity\DnsitCriterionCategory", inversedBy="criterions")
  121.      * @ORM\JoinColumns({
  122.      *   @ORM\JoinColumn(name="criterion_category_id", referencedColumnName="id")
  123.      * })
  124.      */
  125.     private $criterionCategory;
  126.     /**
  127.      * @var \Doctrine\Common\Collections\Collection
  128.      *
  129.      * @ORM\OneToMany(targetEntity="App\Entity\WebSort", mappedBy="criterion", cascade={"persist","remove"})
  130.      */
  131.     private $sorts;
  132.     /**
  133.      * @ORM\OneToMany(targetEntity="App\Entity\DnsitModality", mappedBy="criterion", cascade={"remove"})
  134.      */
  135.     private $modalities;
  136.     /**
  137.      * @ORM\Column(type="json", nullable=true)
  138.      */
  139.     private $extraData = [];
  140.     /** 
  141.      * @ORM\ManyToMany(targetEntity="App\Entity\WebFilterItem", mappedBy="criterions")
  142.      */
  143.     private $filterItems;
  144.     public function __construct() {
  145.         // Champ qualitatif mis à 0 par défaut
  146.         $this->setQualitative(0);
  147.         $this->sorts = new ArrayCollection();
  148.         $this->modalities = new ArrayCollection();
  149.         $this->filterItems = new ArrayCollection();
  150.     }
  151.     public function __toString(){
  152.           return $this->id '-' $this->name;
  153.       }
  154.     public function getCriterionCode(): ?float
  155.     {
  156.         return $this->criterionCode;
  157.     }
  158.     public function setCriterionCode(?float $criterionCode): self
  159.     {
  160.         $this->criterionCode $criterionCode;
  161.         return $this;
  162.     }
  163.     public function getCriterionTextKey(): ?string
  164.     {
  165.         return $this->criterionTextKey;
  166.     }
  167.     public function setCriterionTextKey(?string $criterionTextKey): self
  168.     {
  169.         $this->criterionTextKey $criterionTextKey;
  170.         return $this;
  171.     }
  172.     public function getCriterionTagKey(): ?string
  173.     {
  174.         return $this->criterionTagKey;
  175.     }
  176.     public function setCriterionTagKey(?string $criterionTagKey): self
  177.     {
  178.         $this->criterionTagKey $criterionTagKey;
  179.         return $this;
  180.     }
  181.     public function getName(): ?string
  182.     {
  183.         return $this->name;
  184.     }
  185.     public function setName(?string $name): self
  186.     {
  187.         $this->name $name;
  188.         return $this;
  189.     }
  190.     public function getQualitative(): ?int
  191.     {
  192.         return $this->qualitative;
  193.     }
  194.     public function setQualitative(?int $qualitative): self
  195.     {
  196.         $this->qualitative $qualitative;
  197.         return $this;
  198.     }
  199.     public function getClass(): ?int
  200.     {
  201.         return $this->class;
  202.     }
  203.     public function setClass(?int $class): self
  204.     {
  205.         $this->class $class;
  206.         return $this;
  207.     }
  208.     public function getValueType(): ?int
  209.     {
  210.         return $this->valueType;
  211.     }
  212.     public function setValueType(?int $valueType): self
  213.     {
  214.         $this->valueType $valueType;
  215.         return $this;
  216.     }
  217.     public function getEntity(): ?string
  218.     {
  219.         return $this->entity;
  220.     }
  221.     public function setEntity(?string $entity): self
  222.     {
  223.         $this->entity $entity;
  224.         return $this;
  225.     }
  226.     public function getMarking(): ?int
  227.     {
  228.         return $this->marking;
  229.     }
  230.     public function setMarking(?int $marking): self
  231.     {
  232.         $this->marking $marking;
  233.         return $this;
  234.     }
  235.     public function getParams(): ?string
  236.     {
  237.         return $this->params;
  238.     }
  239.     public function setParams(?string $params): self
  240.     {
  241.         $this->params $params;
  242.         return $this;
  243.     }
  244.     public function getCreatedAt(): ?\DateTimeInterface
  245.     {
  246.         return $this->createdAt;
  247.     }
  248.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  249.     {
  250.         $this->createdAt $createdAt;
  251.         return $this;
  252.     }
  253.     public function getCreatedBy(): ?int
  254.     {
  255.         return $this->createdBy;
  256.     }
  257.     public function setCreatedBy(?int $createdBy): self
  258.     {
  259.         $this->createdBy $createdBy;
  260.         return $this;
  261.     }
  262.     public function getUpdatedAt(): ?\DateTimeInterface
  263.     {
  264.         return $this->updatedAt;
  265.     }
  266.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  267.     {
  268.         $this->updatedAt $updatedAt;
  269.         return $this;
  270.     }
  271.     public function getUpdatedBy(): ?int
  272.     {
  273.         return $this->updatedBy;
  274.     }
  275.     public function setUpdatedBy(?int $updatedBy): self
  276.     {
  277.         $this->updatedBy $updatedBy;
  278.         return $this;
  279.     }
  280.     public function getId(): ?int
  281.     {
  282.         return $this->id;
  283.     }
  284.     public function getTranslate(): ?DnsitTranslateCriterion
  285.     {
  286.         return $this->translate;
  287.     }
  288.     public function setTranslate(?DnsitTranslateCriterion $translate): self
  289.     {
  290.         $this->translate $translate;
  291.         return $this;
  292.     }
  293.     public function getCriterionCategory(): ?DnsitCriterionCategory
  294.     {
  295.         return $this->criterionCategory;
  296.     }
  297.     public function setCriterionCategory(?DnsitCriterionCategory $criterionCategory): self
  298.     {
  299.         $this->criterionCategory $criterionCategory;
  300.         return $this;
  301.     }
  302.     public function bindLeiData($xmlCriterion$language) {
  303.                           $this->setCriterionCode((int) $xmlCriterion->CRITERE);
  304.                           $this->setQualitative((int) $xmlCriterion->CRITERE_QUALITATIF);
  305.                           $this->setValueType((int) $xmlCriterion->CRITERE_TYPEVAL);
  306.                           $this->setName((string) $xmlCriterion->CRITERE_NOM);
  307.                           $this->setMarking(MarkingCodesMask::LEI);
  308.                       }
  309.     public function bindTourinsoftData($jsonCriterion$language$suffixe "") {
  310.                           $this->setCriterionTextKey(strtoupper($jsonCriterion->SyndicFieldID));
  311.                           // $this->setCriterionCode($jsonCriterion->CRITERE);
  312.                           switch ($jsonCriterion->ViewType) {
  313.                               case 5:
  314.                               case 6:
  315.                                   $this->setQualitative(-1);
  316.                                   break;
  317.                               case 7:
  318.                               case 8:
  319.                                   $this->setQualitative(1);
  320.                                   break;
  321.                               // 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
  322.                               ///default:
  323.                               //    $this->setQualitative(0);
  324.                           }
  325.                   
  326.                           $this->setValueType($jsonCriterion->ViewType);
  327.                           $name $jsonCriterion->SyndicFieldName;
  328.                           if ($suffixe != "")
  329.                               $name .= " (" $suffixe ")";
  330.                           $this->setName($name);
  331.                         $this->setMarking(MarkingCodesMask::TOURINSOFT);
  332.                       }
  333.     /**
  334.      * @return Collection|WebSort[]
  335.      */
  336.     public function getSorts(): Collection
  337.     {
  338.         return $this->sorts;
  339.     }
  340.     public function addSort(WebSort $sort): self
  341.     {
  342.         if (!$this->sorts->contains($sort)) {
  343.             $this->sorts[] = $sort;
  344.             $sort->setCriterion($this);
  345.         }
  346.         return $this;
  347.     }
  348.     public function removeSort(WebSort $sort): self
  349.     {
  350.         if ($this->sorts->contains($sort)) {
  351.             $this->sorts->removeElement($sort);
  352.             // set the owning side to null (unless already changed)
  353.             if ($sort->getCriterion() === $this) {
  354.                 $sort->setCriterion(null);
  355.             }
  356.         }
  357.         return $this;
  358.     }
  359.     /**
  360.      * @return Collection|DnsitModality[]
  361.      */
  362.     public function getModalities(): Collection
  363.     {
  364.         return $this->modalities;
  365.     }
  366.     public function addModality(DnsitModality $modality): self
  367.     {
  368.         if (!$this->modalities->contains($modality)) {
  369.             $this->modalities[] = $modality;
  370.             $modality->setDnsitCriterion($this);
  371.         }
  372.         return $this;
  373.     }
  374.     public function removeModality(DnsitModality $modality): self
  375.     {
  376.         if ($this->modalities->contains($modality)) {
  377.             $this->modalities->removeElement($modality);
  378.             // set the owning side to null (unless already changed)
  379.             if ($modality->getCriterion() === $this) {
  380.                 $modality->setCriterion(null);
  381.             }
  382.         }
  383.         return $this;
  384.     }
  385.     public function getExtraData(): ?array
  386.     {
  387.         return $this->extraData;
  388.     }
  389.     public function setExtraData(?array $extraData): self
  390.     {
  391.         $this->extraData $extraData;
  392.         return $this;
  393.     }
  394.     /**
  395.      * @return Collection|WebFilterItem[]
  396.      */
  397.     public function getFilterItems() : Collection
  398.     {
  399.         return $this->filterItems;
  400.     }
  401.     public function addFilterItem(WebFilterItem $item) : self
  402.     {
  403.         if (!$this->filterItems->contains($item)) {
  404.             $this->filterItems[] = $item;
  405.             $item->addCriterion($this);
  406.         }
  407.         return $this;
  408.     }
  409.     public function removeFilterItem(WebFilterItem $item) : self
  410.     {
  411.         if ($this->filterItems->contains($item)) {
  412.             $this->filterItems->removeElement($item);
  413.             $item->removeCriterion($this);
  414.         }
  415.         return $this;
  416.     }
  417. }