<?php
namespace App\Entity;
use App\Repository\JobRepository;
use DateTime;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid;
/**
* @ORM\Entity(repositoryClass=JobRepository::class)
*/
class Job
{
public const STATUS_TO_TREAT = 0;
public const STATUS_TREATMENT_IN_PROGRESS = 1;
public const STATUS_TREATED = 2;
public const STATUS_CANCELED = 8;
public const STATUS_ERROR = 99;
public const STATUS_LABEL = [
self::STATUS_TO_TREAT => 'To treat',
self::STATUS_TREATMENT_IN_PROGRESS => 'Treatment in progress',
self::STATUS_TREATED => 'Treated',
self::STATUS_CANCELED => 'Canceled',
self::STATUS_ERROR => 'Error',
];
public const STEP_CREATE_JOB = 0;
public const STEP_DOWNLOAD = 1;
public const STEP_DECRYPT = 2;
public const STEP_GET_AXONAUT_CUSTOMER = 3;
public const STEP_VERIFY_CREDIT = 4;
public const STEP_ANALYSIS = 5;
public const STEP_UPLOAD = 6;
public const STEP_SEND_CONFIRMATION = 7;
public const STEP_PDF_DOWNLOAD = 8;
public const STEP_SPECIAL_TREATMENT = 9;
public const STEP_JOB_DONE = 10;
public const STEP_LABEL = [
self::STEP_CREATE_JOB => 'Creation job',
self::STEP_DOWNLOAD => 'Download attachment',
self::STEP_DECRYPT => 'Decrypt bin file',
self::STEP_GET_AXONAUT_CUSTOMER => 'Get axonaut customer info',
self::STEP_VERIFY_CREDIT => 'Verify credit',
self::STEP_ANALYSIS => 'Analysis json file',
self::STEP_UPLOAD => 'Upload file to customer interface',
self::STEP_SEND_CONFIRMATION => 'Send confirmation mail',
self::STEP_PDF_DOWNLOAD => 'Download pdf from filegetter',
self::STEP_SPECIAL_TREATMENT => 'Special treatment',
self::STEP_JOB_DONE => 'Treatment done',
];
public const STEP_STATUS_TO_TREAT = 0;
public const STEP_STATUS_TREATMENT_IN_PROGRESS = 1;
public const STEP_STATUS_TREATED = 2;
public const STEP_STATUS_CANCELED = 8;
public const STEP_STATUS_ERROR = 99;
public const STEP_STATUS_LABEL = [
self::STEP_STATUS_TO_TREAT => 'To treat',
self::STEP_STATUS_TREATMENT_IN_PROGRESS => 'Treatment in progress',
self::STEP_STATUS_TREATED => 'Treated',
self::STEP_STATUS_CANCELED => 'Canceled',
self::STEP_STATUS_ERROR => 'Error',
];
public const TYPE_MP_ONLINE = 'online';
public const TYPE_MP_OFFLINE = 'offline';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="integer")
*/
private $status;
/**
* @ORM\Column(type="integer")
*/
private $step;
/**
* @ORM\Column(type="integer")
*/
private $stepStatus;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $stepMessage;
/**
* @ORM\Column(type="string", length=255)
*/
private $uuid;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $fromAddress;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $binPath;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $jsonPath;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $pdfPath;
/**
* @ORM\Column(type="json")
*/
private $context = [];
/**
* @ORM\Column(type="string", length=64, nullable=true)
*/
private $treatmentVersion;
/**
* @ORM\ManyToOne(targetEntity=MindpulseAnalyser::class)
*/
private $technicalVersion;
/**
* @ORM\ManyToOne(targetEntity=Contact::class, inversedBy="jobs")
*/
private $contact;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $failedMessageId;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\OneToMany(targetEntity=JobEvents::class, mappedBy="job", cascade={"persist"})
*/
private $jobEvents;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $testCreatedAt;
/**
* @ORM\OneToMany(targetEntity=Notification::class, mappedBy="job", cascade={"persist"})
*/
private $notifications;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $keySearchAxonaut;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $filegetterDocumentId;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $errorMessage;
/**
* @ORM\Column(type="integer", nullable=false)
*/
private $filegetterDownloadCounter = 0;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $delay = 0;
/**
* @ORM\Column(type="string", length=8, nullable=true)
*/
private $codePatient;
/**
* @ORM\Column(type="string", length=64, nullable=true)
*/
private $mode;
/**
* @ORM\Column(type="string", length=128, nullable=true)
*/
private $mindpulseVersion;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $filegetterDocumentUrl;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $attachmentFilename;
/**
* @ORM\Column(type="string", length=32, nullable=true)
*/
private $type;
public function __construct()
{
$this->jobEvents = new ArrayCollection();
$this->createdAt = new DateTime();
$this->uuid = Uuid::uuid4();
$this->notifications = new ArrayCollection();
}
/**
* @ORM\PreUpdate()
*/
public function preUpdateAt()
{
$this->updatedAt = new DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}
public function getStep(): ?int
{
return $this->step;
}
public function setStep(int $step): self
{
$this->step = $step;
return $this;
}
public function getStepStatus(): ?int
{
return $this->stepStatus;
}
public function setStepStatus(int $stepStatus): self
{
$this->stepStatus = $stepStatus;
return $this;
}
public function getStepMessage(): ?string
{
return $this->stepMessage;
}
public function setStepMessage(?string $stepMessage): self
{
$this->stepMessage = $stepMessage;
return $this;
}
public function getUuid(): ?string
{
return $this->uuid;
}
public function setUuid(string $uuid): self
{
$this->uuid = $uuid;
return $this;
}
public function getFromAddress(): ?string
{
return $this->fromAddress;
}
public function setFromAddress(string $fromAddress): self
{
$this->fromAddress = $fromAddress;
return $this;
}
public function getBinPath(): ?string
{
return $this->binPath;
}
public function setBinPath(string $binPath): self
{
$this->binPath = $binPath;
return $this;
}
public function getJsonPath(): ?string
{
return $this->jsonPath;
}
public function setJsonPath(?string $jsonPath): self
{
$this->jsonPath = $jsonPath;
return $this;
}
public function getPdfPath(): ?string
{
return $this->pdfPath;
}
public function setPdfPath(?string $pdfPath): self
{
$this->pdfPath = $pdfPath;
return $this;
}
public function getContext(): ?array
{
return $this->context;
}
public function setContext(array $context): self
{
$this->context = $context;
return $this;
}
public function getTreatmentVersion(): ?string
{
return $this->treatmentVersion;
}
public function setTreatmentVersion(string $treatmentVersion): self
{
$this->treatmentVersion = $treatmentVersion;
return $this;
}
public function getTechnicalVersion(): ?MindpulseAnalyser
{
return $this->technicalVersion;
}
public function setTechnicalVersion(?MindpulseAnalyser $technicalVersion): self
{
$this->technicalVersion = $technicalVersion;
return $this;
}
public function getContact(): ?Contact
{
return $this->contact;
}
public function setContact(?Contact $contact): self
{
$this->contact = $contact;
return $this;
}
public function getFailedMessageId(): ?int
{
return $this->failedMessageId;
}
public function setFailedMessageId(?int $failedMessageId): self
{
$this->failedMessageId = $failedMessageId;
return $this;
}
public function getCreatedAt(): ?DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @return Collection|JobEvents[]
*/
public function getJobEvents(): Collection
{
return $this->jobEvents;
}
public function getLastJobEvent(): ?JobEvents
{
return (false == $this->jobEvents->last() ? null : $this->jobEvents->last());
}
public function getLastErrorJobEvent(): ?JobEvents
{
$count = $this->jobEvents->count() - 1;
if ($count > 0) {
do {
$jobEvent = $this->jobEvents->get($count);
if (!is_null($jobEvent) && $jobEvent->getStatus() == JobEvents::STATUS_ERROR) {
return $jobEvent;
}
$count--;
} while (!is_null($this->jobEvents->get($count)));
}
return null;
}
public function addJobEvent(JobEvents $jobEvent): self
{
if (!$this->jobEvents->contains($jobEvent)) {
$this->jobEvents[] = $jobEvent;
$jobEvent->setJob($this);
}
return $this;
}
public function removeJobEvent(JobEvents $jobEvent): self
{
if ($this->jobEvents->removeElement($jobEvent)) {
// set the owning side to null (unless already changed)
if ($jobEvent->getJob() === $this) {
$jobEvent->setJob(null);
}
}
return $this;
}
public function getTestCreatedAt(): ?DateTimeInterface
{
return $this->testCreatedAt;
}
public function setTestCreatedAt(?DateTimeInterface $testCreatedAt): self
{
$this->testCreatedAt = $testCreatedAt;
return $this;
}
/**
* @return Collection|Notification[]
*/
public function getNotifications(): Collection
{
return $this->notifications;
}
public function addNotification(Notification $notification): self
{
if (!$this->notifications->contains($notification)) {
$this->notifications[] = $notification;
$notification->setJob($this);
}
return $this;
}
public function removeNotification(Notification $notification): self
{
if ($this->notifications->removeElement($notification)) {
// set the owning side to null (unless already changed)
if ($notification->getJob() === $this) {
$notification->setJob(null);
}
}
return $this;
}
public function getKeySearchAxonaut(): ?string
{
return $this->keySearchAxonaut;
}
public function setKeySearchAxonaut(?string $keySearchAxonaut): self
{
$this->keySearchAxonaut = $keySearchAxonaut;
return $this;
}
public function getFilegetterDocumentId(): ?int
{
return $this->filegetterDocumentId;
}
public function setFilegetterDocumentId(?int $filegetterDocumentId): self
{
$this->filegetterDocumentId = $filegetterDocumentId;
return $this;
}
public function getErrorMessage(): ?string
{
return $this->errorMessage;
}
public function setErrorMessage(?string $errorMessage): self
{
$this->errorMessage = $errorMessage;
return $this;
}
public function getFilegetterDownloadCounter(): ?int
{
return $this->filegetterDownloadCounter;
}
public function setFilegetterDownloadCounter(?int $filegetterDownloadCounter): self
{
$this->filegetterDownloadCounter = $filegetterDownloadCounter;
return $this;
}
public function getDelay(): ?int
{
return $this->delay;
}
public function setDelay(?int $delay): self
{
$this->delay = $delay;
return $this;
}
public function getCodePatient(): ?string
{
return $this->codePatient;
}
public function setCodePatient(?string $codePatient): self
{
$this->codePatient = $codePatient;
return $this;
}
public function getMode(): ?string
{
return $this->mode;
}
public function setMode(?string $mode): self
{
$this->mode = $mode;
return $this;
}
public function getMindpulseVersion(): ?string
{
return $this->mindpulseVersion;
}
public function setMindpulseVersion(?string $mindpulseVersion): self
{
$this->mindpulseVersion = $mindpulseVersion;
return $this;
}
public function getFilegetterDocumentUrl(): ?string
{
return $this->filegetterDocumentUrl;
}
public function setFilegetterDocumentUrl(?string $filegetterDocumentUrl): self
{
$this->filegetterDocumentUrl = $filegetterDocumentUrl;
return $this;
}
public function getAttachmentFilename(): ?string
{
return $this->attachmentFilename;
}
public function setAttachmentFilename(?string $attachmentFilename): self
{
$this->attachmentFilename = $attachmentFilename;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
}