src/Entity/Slave/Operation.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Slave;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Table(name="eposm_s_operation")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Slave\OperationRepository")
  10.  */
  11. class Operation
  12. {
  13.     public function __toString(){
  14.         return $this->getSupplier().' - '.$this->getValue();
  15.     }
  16.     public function displayActive($type)
  17.     {
  18.         $html '';
  19.         switch($this->isActive()){
  20.             case '0'$color 'color_r'$title 'Disattivo'; break;
  21.             case '1'$color 'color_gr'$title 'Attivo'; break;
  22.             default: break;
  23.         }
  24.         switch($type){
  25.             case 'icon': return '<i class="icon-circle cursor_p '.$color.'" data-bs-toggle="tooltip" title="'.$title.'"></i>'; break;
  26.             case 'string': return '<i class="icon-circle cursor_p '.$color.'"></i> '.$title; break;
  27.         }
  28.     }
  29.     public function displayEmailParameters($parameter)
  30.     {
  31.         $result '';
  32.         if($this->getEmailParams() != null){
  33.             $params json_decode($this->getEmailParams(), true);
  34.             switch($parameter){
  35.                 case 'address'$result $params['emailAddress']; break;
  36.                 case 'host'$result $params['emailHost']; break;
  37.                 case 'port'$result $params['emailPort']; break;
  38.                 case 'encryption'$result $params['emailEncryption']; break;
  39.                 case 'user'$result $params['emailUser']; break;
  40.                 case 'password'$result $params['emailPassword']; break;
  41.                 case 'all'$result '<table class="table table-sm b_none m_b_none"><tr><th style="padding: 0.1rem 0.1rem !important">Indirizzo</th><td style="padding: 0.1rem 0.1rem !important">'.$params['emailAddress'].'</td></tr><tr><th style="padding: 0.1rem 0.1rem !important">Host</th><td style="padding: 0.1rem 0.1rem !important">'.$params['emailHost'].'</td></tr><tr><th style="padding: 0.1rem 0.1rem !important">Porta</th><td style="padding: 0.1rem 0.1rem !important">'.$params['emailPort'].'</td></tr><tr><th style="padding: 0.1rem 0.1rem !important">Metodo crittografico</th><td style="padding: 0.1rem 0.1rem !important">'.$params['emailEncryption'].'</td></tr><tr><th style="padding: 0.1rem 0.1rem !important">Utente</th><td style="padding: 0.1rem 0.1rem !important">'.$params['emailUser'].'</td></tr><tr><th style="padding: 0.1rem 0.1rem !important">Password</th><td style="padding: 0.1rem 0.1rem !important">'.$params['emailPassword'].'</td></tr></table>'; break;
  42.                 default: break;
  43.             }
  44.         }
  45.         return $result;
  46.     }
  47.     public function displaySupplierAndValue()
  48.     {
  49.         return $this->getSupplier().' - '.$this->getValue();
  50.     }
  51.     public function getKeyTicketNumber()
  52.     {
  53.         foreach($this->getKeyMappings() as $key){
  54.             if($key->isTicketNumber())
  55.                 return $key;
  56.         }
  57.         return false;
  58.     }
  59.     public function getKeyTermid()
  60.     {
  61.         foreach($this->getKeyMappings() as $key){
  62.             if($key->isTermid())
  63.                 return $key;
  64.         }
  65.         return false;
  66.     }
  67.     
  68.     public function getKeyValueByValue($value)
  69.     {
  70.         foreach($this->getKeyMappings() as $key){
  71.             if($key->getTicketColumn() == $value){
  72.                 return $key->getMappingValue();
  73.             }
  74.         }
  75.         return false;
  76.     }
  77.     
  78.     public function getKeyByValue($value)
  79.     {
  80.         foreach($this->getKeyMappings() as $key){
  81.             if($key->getTicketColumn() == $value){
  82.                 return $key;
  83.             }
  84.         }
  85.         return false;
  86.     }
  87.     
  88.     /**
  89.      * @ORM\Column(name="id", type="bigint")
  90.      * @ORM\Id
  91.      * @ORM\GeneratedValue(strategy="AUTO")
  92.      */
  93.     protected $id;
  94.     
  95.     /**
  96.      * @ORM\Column(name="value", type="string", length=191, nullable=true)
  97.      */
  98.     protected $value;
  99.     /**
  100.      * @ORM\Column(name="slug_master", type="string", length=191)
  101.      */
  102.     protected $slugMaster;
  103.     
  104.     /**
  105.      * @ORM\Column(name="code_client", type="string", length=191, nullable=true)
  106.      */
  107.     protected $codeClient;
  108.     
  109.     /**
  110.      * @ORM\Column(name="identifier_regex", type="text", nullable=true)
  111.      */
  112.     protected $identifierRegex;
  113.     
  114.     /**
  115.      * @ORM\Column(name="is_uav", type="boolean")
  116.      */
  117.     protected $uav false;
  118.     /**
  119.      * @ORM\Column(name="active", type="boolean")
  120.      */
  121.     protected $active false;
  122.     // ManyToOne
  123.         /**
  124.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\Supplier", inversedBy="operations")
  125.          * @ORM\JoinColumn(name="supplier_id", referencedColumnName="id")
  126.          */
  127.         private $supplier;
  128.         
  129.         /**
  130.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\OperationGroup", inversedBy="operations")
  131.          * @ORM\JoinColumn(name="group_id", referencedColumnName="id")
  132.          */
  133.         private $group;
  134.     //
  135.     // OneToMany
  136.         /**
  137.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\OperationTariff", mappedBy="operation")
  138.          */
  139.         private $tariffs;
  140.         /**
  141.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\Ticket", mappedBy="operation")
  142.          */
  143.         private $tickets;
  144.         
  145.         /**
  146.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\OperationKeyMapping", mappedBy="operation")
  147.          * @ORM\OrderBy({"priority" = "ASC"})
  148.          */
  149.         private $keyMappings;
  150.         
  151.         /**
  152.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\OperationSubjectMapping", mappedBy="operation")
  153.          */
  154.         private $subjectMappings;
  155.         
  156.         /**
  157.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\OperationAlgorithm", mappedBy="operation")
  158.          */
  159.         private $algorithms;
  160.         public function __construct()
  161.         {
  162.             $this->tariffs = new ArrayCollection();
  163.             $this->tickets = new ArrayCollection();
  164.             $this->keyMappings = new ArrayCollection();
  165.             $this->subjectMappings = new ArrayCollection();
  166.             $this->algorithms = new ArrayCollection();
  167.         }
  168.     //
  169.     public function getId(): ?string
  170.     {
  171.         return $this->id;
  172.     }
  173.     public function getValue(): ?string
  174.     {
  175.         return $this->value;
  176.     }
  177.     public function setValue(?string $value): self
  178.     {
  179.         $this->value $value;
  180.         return $this;
  181.     }
  182.     public function getSlugMaster(): ?string
  183.     {
  184.         return $this->slugMaster;
  185.     }
  186.     public function setSlugMaster(string $slugMaster): self
  187.     {
  188.         $this->slugMaster $slugMaster;
  189.         return $this;
  190.     }
  191.     public function getCodeClient(): ?string
  192.     {
  193.         return $this->codeClient;
  194.     }
  195.     public function setCodeClient(?string $codeClient): self
  196.     {
  197.         $this->codeClient $codeClient;
  198.         return $this;
  199.     }
  200.     public function getIdentifierRegex(): ?string
  201.     {
  202.         return $this->identifierRegex;
  203.     }
  204.     public function setIdentifierRegex(?string $identifierRegex): self
  205.     {
  206.         $this->identifierRegex $identifierRegex;
  207.         return $this;
  208.     }
  209.     public function isUav(): ?bool
  210.     {
  211.         return $this->uav;
  212.     }
  213.     public function setUav(bool $uav): self
  214.     {
  215.         $this->uav $uav;
  216.         return $this;
  217.     }
  218.     public function isActive(): ?bool
  219.     {
  220.         return $this->active;
  221.     }
  222.     public function setActive(bool $active): self
  223.     {
  224.         $this->active $active;
  225.         return $this;
  226.     }
  227.     public function getSupplier(): ?Supplier
  228.     {
  229.         return $this->supplier;
  230.     }
  231.     public function setSupplier(?Supplier $supplier): self
  232.     {
  233.         $this->supplier $supplier;
  234.         return $this;
  235.     }
  236.     public function getGroup(): ?OperationGroup
  237.     {
  238.         return $this->group;
  239.     }
  240.     public function setGroup(?OperationGroup $group): self
  241.     {
  242.         $this->group $group;
  243.         return $this;
  244.     }
  245.     /**
  246.      * @return Collection<int, OperationTariff>
  247.      */
  248.     public function getTariffs(): Collection
  249.     {
  250.         return $this->tariffs;
  251.     }
  252.     public function addTariff(OperationTariff $tariff): self
  253.     {
  254.         if (!$this->tariffs->contains($tariff)) {
  255.             $this->tariffs->add($tariff);
  256.             $tariff->setOperation($this);
  257.         }
  258.         return $this;
  259.     }
  260.     public function removeTariff(OperationTariff $tariff): self
  261.     {
  262.         if ($this->tariffs->removeElement($tariff)) {
  263.             // set the owning side to null (unless already changed)
  264.             if ($tariff->getOperation() === $this) {
  265.                 $tariff->setOperation(null);
  266.             }
  267.         }
  268.         return $this;
  269.     }
  270.     /**
  271.      * @return Collection<int, Ticket>
  272.      */
  273.     public function getTickets(): Collection
  274.     {
  275.         return $this->tickets;
  276.     }
  277.     public function addTicket(Ticket $ticket): self
  278.     {
  279.         if (!$this->tickets->contains($ticket)) {
  280.             $this->tickets->add($ticket);
  281.             $ticket->setOperation($this);
  282.         }
  283.         return $this;
  284.     }
  285.     public function removeTicket(Ticket $ticket): self
  286.     {
  287.         if ($this->tickets->removeElement($ticket)) {
  288.             // set the owning side to null (unless already changed)
  289.             if ($ticket->getOperation() === $this) {
  290.                 $ticket->setOperation(null);
  291.             }
  292.         }
  293.         return $this;
  294.     }
  295.     /**
  296.      * @return Collection<int, OperationKeyMapping>
  297.      */
  298.     public function getKeyMappings(): Collection
  299.     {
  300.         return $this->keyMappings;
  301.     }
  302.     public function addKeyMapping(OperationKeyMapping $keyMapping): self
  303.     {
  304.         if (!$this->keyMappings->contains($keyMapping)) {
  305.             $this->keyMappings->add($keyMapping);
  306.             $keyMapping->setOperation($this);
  307.         }
  308.         return $this;
  309.     }
  310.     public function removeKeyMapping(OperationKeyMapping $keyMapping): self
  311.     {
  312.         if ($this->keyMappings->removeElement($keyMapping)) {
  313.             // set the owning side to null (unless already changed)
  314.             if ($keyMapping->getOperation() === $this) {
  315.                 $keyMapping->setOperation(null);
  316.             }
  317.         }
  318.         return $this;
  319.     }
  320.     /**
  321.      * @return Collection<int, OperationSubjectMapping>
  322.      */
  323.     public function getSubjectMappings(): Collection
  324.     {
  325.         return $this->subjectMappings;
  326.     }
  327.     public function addSubjectMapping(OperationSubjectMapping $subjectMapping): self
  328.     {
  329.         if (!$this->subjectMappings->contains($subjectMapping)) {
  330.             $this->subjectMappings->add($subjectMapping);
  331.             $subjectMapping->setOperation($this);
  332.         }
  333.         return $this;
  334.     }
  335.     public function removeSubjectMapping(OperationSubjectMapping $subjectMapping): self
  336.     {
  337.         if ($this->subjectMappings->removeElement($subjectMapping)) {
  338.             // set the owning side to null (unless already changed)
  339.             if ($subjectMapping->getOperation() === $this) {
  340.                 $subjectMapping->setOperation(null);
  341.             }
  342.         }
  343.         return $this;
  344.     }
  345.     /**
  346.      * @return Collection<int, OperationAlgorithm>
  347.      */
  348.     public function getAlgorithms(): Collection
  349.     {
  350.         return $this->algorithms;
  351.     }
  352.     public function addAlgorithm(OperationAlgorithm $algorithm): self
  353.     {
  354.         if (!$this->algorithms->contains($algorithm)) {
  355.             $this->algorithms->add($algorithm);
  356.             $algorithm->setOperation($this);
  357.         }
  358.         return $this;
  359.     }
  360.     public function removeAlgorithm(OperationAlgorithm $algorithm): self
  361.     {
  362.         if ($this->algorithms->removeElement($algorithm)) {
  363.             // set the owning side to null (unless already changed)
  364.             if ($algorithm->getOperation() === $this) {
  365.                 $algorithm->setOperation(null);
  366.             }
  367.         }
  368.         return $this;
  369.     }
  370. }