src/Entity/Job.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\JobRepository;
  4. use DateTime;
  5. use DateTimeInterface;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Ramsey\Uuid\Uuid;
  10. /**
  11.  * @ORM\Entity(repositoryClass=JobRepository::class)
  12.  */
  13. class Job
  14. {
  15.     public const STATUS_TO_TREAT                    0;
  16.     public const STATUS_TREATMENT_IN_PROGRESS       1;
  17.     public const STATUS_TREATED                     2;
  18.     public const STATUS_CANCELED                    8;
  19.     public const STATUS_ERROR                       99;
  20.     public const STATUS_LABEL = [
  21.         self::STATUS_TO_TREAT                       => 'To treat',
  22.         self::STATUS_TREATMENT_IN_PROGRESS          => 'Treatment in progress',
  23.         self::STATUS_TREATED                        => 'Treated',
  24.         self::STATUS_CANCELED                       => 'Canceled',
  25.         self::STATUS_ERROR                          => 'Error',
  26.     ];
  27.     public const STEP_CREATE_JOB                    0;
  28.     public const STEP_DOWNLOAD                      1;
  29.     public const STEP_DECRYPT                       2;
  30.     public const STEP_GET_AXONAUT_CUSTOMER          3;
  31.     public const STEP_VERIFY_CREDIT                 4;
  32.     public const STEP_ANALYSIS                      5;
  33.     public const STEP_UPLOAD                        6;
  34.     public const STEP_SEND_CONFIRMATION             7;
  35.     public const STEP_PDF_DOWNLOAD                  8;
  36.     public const STEP_SPECIAL_TREATMENT             9;
  37.     public const STEP_JOB_DONE                      10;
  38.     public const STEP_LABEL = [
  39.         self::STEP_CREATE_JOB                       => 'Creation job',
  40.         self::STEP_DOWNLOAD                         => 'Download attachment',
  41.         self::STEP_DECRYPT                          => 'Decrypt bin file',
  42.         self::STEP_GET_AXONAUT_CUSTOMER             => 'Get axonaut customer info',
  43.         self::STEP_VERIFY_CREDIT                    => 'Verify credit',
  44.         self::STEP_ANALYSIS                         => 'Analysis json file',
  45.         self::STEP_UPLOAD                           => 'Upload file to customer interface',
  46.         self::STEP_SEND_CONFIRMATION                => 'Send confirmation mail',
  47.         self::STEP_PDF_DOWNLOAD                     => 'Download pdf from filegetter',
  48.         self::STEP_SPECIAL_TREATMENT                => 'Special treatment',
  49.         self::STEP_JOB_DONE                         => 'Treatment done',
  50.     ];
  51.     public const STEP_STATUS_TO_TREAT                0;
  52.     public const STEP_STATUS_TREATMENT_IN_PROGRESS   1;
  53.     public const STEP_STATUS_TREATED                 2;
  54.     public const STEP_STATUS_CANCELED                8;
  55.     public const STEP_STATUS_ERROR                   99;
  56.     public const STEP_STATUS_LABEL = [
  57.         self::STEP_STATUS_TO_TREAT                   => 'To treat',
  58.         self::STEP_STATUS_TREATMENT_IN_PROGRESS      => 'Treatment in progress',
  59.         self::STEP_STATUS_TREATED                    => 'Treated',
  60.         self::STEP_STATUS_CANCELED                   => 'Canceled',
  61.         self::STEP_STATUS_ERROR                      => 'Error',
  62.     ];
  63.     public const TYPE_MP_ONLINE 'online';
  64.     public const TYPE_MP_OFFLINE 'offline';
  65.     /**
  66.      * @ORM\Id
  67.      * @ORM\GeneratedValue
  68.      * @ORM\Column(type="integer")
  69.      */
  70.     private $id;
  71.     /**
  72.      * @ORM\Column(type="integer")
  73.      */
  74.     private $status;
  75.     /**
  76.      * @ORM\Column(type="integer")
  77.      */
  78.     private $step;
  79.     /**
  80.      * @ORM\Column(type="integer")
  81.      */
  82.     private $stepStatus;
  83.     /**
  84.      * @ORM\Column(type="text", nullable=true)
  85.      */
  86.     private $stepMessage;
  87.     /**
  88.      * @ORM\Column(type="string", length=255)
  89.      */
  90.     private $uuid;
  91.     /**
  92.      * @ORM\Column(type="string", length=255, nullable=true)
  93.      */
  94.     private $fromAddress;
  95.     /**
  96.      * @ORM\Column(type="string", length=255, nullable=true)
  97.      */
  98.     private $binPath;
  99.     /**
  100.      * @ORM\Column(type="string", length=255, nullable=true)
  101.      */
  102.     private $jsonPath;
  103.     /**
  104.      * @ORM\Column(type="string", length=255, nullable=true)
  105.      */
  106.     private $pdfPath;
  107.     /**
  108.      * @ORM\Column(type="json")
  109.      */
  110.     private $context = [];
  111.     /**
  112.      * @ORM\Column(type="string", length=64, nullable=true)
  113.      */
  114.     private $treatmentVersion;
  115.     /**
  116.      * @ORM\ManyToOne(targetEntity=MindpulseAnalyser::class)
  117.      */
  118.     private $technicalVersion;
  119.     /**
  120.      * @ORM\ManyToOne(targetEntity=Contact::class, inversedBy="jobs")
  121.      */
  122.     private $contact;
  123.     /**
  124.      * @ORM\Column(type="integer", nullable=true)
  125.      */
  126.     private $failedMessageId;
  127.     /**
  128.      * @ORM\Column(type="datetime")
  129.      */
  130.     private $createdAt;
  131.     /**
  132.      * @ORM\Column(type="datetime", nullable=true)
  133.      */
  134.     private $updatedAt;
  135.     /**
  136.      * @ORM\OneToMany(targetEntity=JobEvents::class, mappedBy="job", cascade={"persist"})
  137.      */
  138.     private $jobEvents;
  139.     /**
  140.      * @ORM\Column(type="datetime", nullable=true)
  141.      */
  142.     private $testCreatedAt;
  143.     /**
  144.      * @ORM\OneToMany(targetEntity=Notification::class, mappedBy="job", cascade={"persist"})
  145.      */
  146.     private $notifications;
  147.     /**
  148.      * @ORM\Column(type="string", length=255, nullable=true)
  149.      */
  150.     private $keySearchAxonaut;
  151.     /**
  152.      * @ORM\Column(type="integer", nullable=true)
  153.      */
  154.     private $filegetterDocumentId;
  155.     /**
  156.      * @ORM\Column(type="text", nullable=true)
  157.      */
  158.     private $errorMessage;
  159.     /**
  160.      * @ORM\Column(type="integer", nullable=false)
  161.      */
  162.     private $filegetterDownloadCounter 0;
  163.     /**
  164.      * @ORM\Column(type="integer", nullable=true)
  165.      */
  166.     private $delay 0;
  167.     /**
  168.      * @ORM\Column(type="string", length=8, nullable=true)
  169.      */
  170.     private $codePatient;
  171.     /**
  172.      * @ORM\Column(type="string", length=64, nullable=true)
  173.      */
  174.     private $mode;
  175.     /**
  176.      * @ORM\Column(type="string", length=128, nullable=true)
  177.      */
  178.     private $mindpulseVersion;
  179.     /**
  180.      * @ORM\Column(type="text", nullable=true)
  181.      */
  182.     private $filegetterDocumentUrl;
  183.     /**
  184.      * @ORM\Column(type="string", length=255, nullable=true)
  185.      */
  186.     private $attachmentFilename;
  187.     /**
  188.      * @ORM\Column(type="string", length=32, nullable=true)
  189.      */
  190.     private $type;
  191.     public function __construct()
  192.     {
  193.         $this->jobEvents = new ArrayCollection();
  194.         $this->createdAt = new DateTime();
  195.         $this->uuid Uuid::uuid4();
  196.         $this->notifications = new ArrayCollection();
  197.     }
  198.     /**
  199.      * @ORM\PreUpdate()
  200.      */
  201.     public function preUpdateAt()
  202.     {
  203.         $this->updatedAt = new DateTime();
  204.     }
  205.     public function getId(): ?int
  206.     {
  207.         return $this->id;
  208.     }
  209.     public function getStatus(): ?int
  210.     {
  211.         return $this->status;
  212.     }
  213.     public function setStatus(int $status): self
  214.     {
  215.         $this->status $status;
  216.         return $this;
  217.     }
  218.     public function getStep(): ?int
  219.     {
  220.         return $this->step;
  221.     }
  222.     public function setStep(int $step): self
  223.     {
  224.         $this->step $step;
  225.         return $this;
  226.     }
  227.     public function getStepStatus(): ?int
  228.     {
  229.         return $this->stepStatus;
  230.     }
  231.     public function setStepStatus(int $stepStatus): self
  232.     {
  233.         $this->stepStatus $stepStatus;
  234.         return $this;
  235.     }
  236.     public function getStepMessage(): ?string
  237.     {
  238.         return $this->stepMessage;
  239.     }
  240.     public function setStepMessage(?string $stepMessage): self
  241.     {
  242.         $this->stepMessage $stepMessage;
  243.         return $this;
  244.     }
  245.     public function getUuid(): ?string
  246.     {
  247.         return $this->uuid;
  248.     }
  249.     public function setUuid(string $uuid): self
  250.     {
  251.         $this->uuid $uuid;
  252.         return $this;
  253.     }
  254.     public function getFromAddress(): ?string
  255.     {
  256.         return $this->fromAddress;
  257.     }
  258.     public function setFromAddress(string $fromAddress): self
  259.     {
  260.         $this->fromAddress $fromAddress;
  261.         return $this;
  262.     }
  263.     public function getBinPath(): ?string
  264.     {
  265.         return $this->binPath;
  266.     }
  267.     public function setBinPath(string $binPath): self
  268.     {
  269.         $this->binPath $binPath;
  270.         return $this;
  271.     }
  272.     public function getJsonPath(): ?string
  273.     {
  274.         return $this->jsonPath;
  275.     }
  276.     public function setJsonPath(?string $jsonPath): self
  277.     {
  278.         $this->jsonPath $jsonPath;
  279.         return $this;
  280.     }
  281.     public function getPdfPath(): ?string
  282.     {
  283.         return $this->pdfPath;
  284.     }
  285.     public function setPdfPath(?string $pdfPath): self
  286.     {
  287.         $this->pdfPath $pdfPath;
  288.         return $this;
  289.     }
  290.     public function getContext(): ?array
  291.     {
  292.         return $this->context;
  293.     }
  294.     public function setContext(array $context): self
  295.     {
  296.         $this->context $context;
  297.         return $this;
  298.     }
  299.     public function getTreatmentVersion(): ?string
  300.     {
  301.         return $this->treatmentVersion;
  302.     }
  303.     public function setTreatmentVersion(string $treatmentVersion): self
  304.     {
  305.         $this->treatmentVersion $treatmentVersion;
  306.         return $this;
  307.     }
  308.     public function getTechnicalVersion(): ?MindpulseAnalyser
  309.     {
  310.         return $this->technicalVersion;
  311.     }
  312.     public function setTechnicalVersion(?MindpulseAnalyser $technicalVersion): self
  313.     {
  314.         $this->technicalVersion $technicalVersion;
  315.         return $this;
  316.     }
  317.     public function getContact(): ?Contact
  318.     {
  319.         return $this->contact;
  320.     }
  321.     public function setContact(?Contact $contact): self
  322.     {
  323.         $this->contact $contact;
  324.         return $this;
  325.     }
  326.     public function getFailedMessageId(): ?int
  327.     {
  328.         return $this->failedMessageId;
  329.     }
  330.     public function setFailedMessageId(?int $failedMessageId): self
  331.     {
  332.         $this->failedMessageId $failedMessageId;
  333.         return $this;
  334.     }
  335.     public function getCreatedAt(): ?DateTimeInterface
  336.     {
  337.         return $this->createdAt;
  338.     }
  339.     public function setCreatedAt(DateTimeInterface $createdAt): self
  340.     {
  341.         $this->createdAt $createdAt;
  342.         return $this;
  343.     }
  344.     public function getUpdatedAt(): ?DateTimeInterface
  345.     {
  346.         return $this->updatedAt;
  347.     }
  348.     public function setUpdatedAt(?DateTimeInterface $updatedAt): self
  349.     {
  350.         $this->updatedAt $updatedAt;
  351.         return $this;
  352.     }
  353.     /**
  354.      * @return Collection|JobEvents[]
  355.      */
  356.     public function getJobEvents(): Collection
  357.     {
  358.         return $this->jobEvents;
  359.     }
  360.     public function getLastJobEvent(): ?JobEvents
  361.     {
  362.         return (false == $this->jobEvents->last() ? null $this->jobEvents->last());
  363.     }
  364.     public function getLastErrorJobEvent(): ?JobEvents
  365.     {
  366.         $count $this->jobEvents->count() - 1;
  367.         if ($count 0) {
  368.             do {
  369.                 $jobEvent $this->jobEvents->get($count);
  370.                 if (!is_null($jobEvent) && $jobEvent->getStatus() == JobEvents::STATUS_ERROR) {
  371.                     return $jobEvent;
  372.                 }
  373.                 $count--;
  374.             } while (!is_null($this->jobEvents->get($count)));
  375.         }
  376.         return null;
  377.     }
  378.     public function addJobEvent(JobEvents $jobEvent): self
  379.     {
  380.         if (!$this->jobEvents->contains($jobEvent)) {
  381.             $this->jobEvents[] = $jobEvent;
  382.             $jobEvent->setJob($this);
  383.         }
  384.         return $this;
  385.     }
  386.     public function removeJobEvent(JobEvents $jobEvent): self
  387.     {
  388.         if ($this->jobEvents->removeElement($jobEvent)) {
  389.             // set the owning side to null (unless already changed)
  390.             if ($jobEvent->getJob() === $this) {
  391.                 $jobEvent->setJob(null);
  392.             }
  393.         }
  394.         return $this;
  395.     }
  396.     public function getTestCreatedAt(): ?DateTimeInterface
  397.     {
  398.         return $this->testCreatedAt;
  399.     }
  400.     public function setTestCreatedAt(?DateTimeInterface $testCreatedAt): self
  401.     {
  402.         $this->testCreatedAt $testCreatedAt;
  403.         return $this;
  404.     }
  405.     /**
  406.      * @return Collection|Notification[]
  407.      */
  408.     public function getNotifications(): Collection
  409.     {
  410.         return $this->notifications;
  411.     }
  412.     public function addNotification(Notification $notification): self
  413.     {
  414.         if (!$this->notifications->contains($notification)) {
  415.             $this->notifications[] = $notification;
  416.             $notification->setJob($this);
  417.         }
  418.         return $this;
  419.     }
  420.     public function removeNotification(Notification $notification): self
  421.     {
  422.         if ($this->notifications->removeElement($notification)) {
  423.             // set the owning side to null (unless already changed)
  424.             if ($notification->getJob() === $this) {
  425.                 $notification->setJob(null);
  426.             }
  427.         }
  428.         return $this;
  429.     }
  430.     public function getKeySearchAxonaut(): ?string
  431.     {
  432.         return $this->keySearchAxonaut;
  433.     }
  434.     public function setKeySearchAxonaut(?string $keySearchAxonaut): self
  435.     {
  436.         $this->keySearchAxonaut $keySearchAxonaut;
  437.         return $this;
  438.     }
  439.     public function getFilegetterDocumentId(): ?int
  440.     {
  441.         return $this->filegetterDocumentId;
  442.     }
  443.     public function setFilegetterDocumentId(?int $filegetterDocumentId): self
  444.     {
  445.         $this->filegetterDocumentId $filegetterDocumentId;
  446.         return $this;
  447.     }
  448.     public function getErrorMessage(): ?string
  449.     {
  450.         return $this->errorMessage;
  451.     }
  452.     public function setErrorMessage(?string $errorMessage): self
  453.     {
  454.         $this->errorMessage $errorMessage;
  455.         return $this;
  456.     }
  457.     public function getFilegetterDownloadCounter(): ?int
  458.     {
  459.         return $this->filegetterDownloadCounter;
  460.     }
  461.     public function setFilegetterDownloadCounter(?int $filegetterDownloadCounter): self
  462.     {
  463.         $this->filegetterDownloadCounter $filegetterDownloadCounter;
  464.         return $this;
  465.     }
  466.     public function getDelay(): ?int
  467.     {
  468.         return $this->delay;
  469.     }
  470.     public function setDelay(?int $delay): self
  471.     {
  472.         $this->delay $delay;
  473.         return $this;
  474.     }
  475.     public function getCodePatient(): ?string
  476.     {
  477.         return $this->codePatient;
  478.     }
  479.     public function setCodePatient(?string $codePatient): self
  480.     {
  481.         $this->codePatient $codePatient;
  482.         return $this;
  483.     }
  484.     public function getMode(): ?string
  485.     {
  486.         return $this->mode;
  487.     }
  488.     public function setMode(?string $mode): self
  489.     {
  490.         $this->mode $mode;
  491.         return $this;
  492.     }
  493.     public function getMindpulseVersion(): ?string
  494.     {
  495.         return $this->mindpulseVersion;
  496.     }
  497.     public function setMindpulseVersion(?string $mindpulseVersion): self
  498.     {
  499.         $this->mindpulseVersion $mindpulseVersion;
  500.         return $this;
  501.     }
  502.     public function getFilegetterDocumentUrl(): ?string
  503.     {
  504.         return $this->filegetterDocumentUrl;
  505.     }
  506.     public function setFilegetterDocumentUrl(?string $filegetterDocumentUrl): self
  507.     {
  508.         $this->filegetterDocumentUrl $filegetterDocumentUrl;
  509.         return $this;
  510.     }
  511.     public function getAttachmentFilename(): ?string
  512.     {
  513.         return $this->attachmentFilename;
  514.     }
  515.     public function setAttachmentFilename(?string $attachmentFilename): self
  516.     {
  517.         $this->attachmentFilename $attachmentFilename;
  518.         return $this;
  519.     }
  520.     public function getType(): ?string
  521.     {
  522.         return $this->type;
  523.     }
  524.     public function setType(?string $type): self
  525.     {
  526.         $this->type $type;
  527.         return $this;
  528.     }
  529. }