From a146e47ce265bde41687dea7ad562ddfa1ec3359 Mon Sep 17 00:00:00 2001 From: Antony Le Courtes <antony.lecourtes@unicaen.fr> Date: Mon, 9 Dec 2024 11:25:29 +0100 Subject: [PATCH] =?UTF-8?q?Refactoring=20pour=20retirer=20d=C3=A9pendance?= =?UTF-8?q?=20SignatureFlowStep=20sur=20l'entit=C3=A9=20ProcessStep?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/config/database.md | 10 +++++----- doc/dev/database-install-sql.md | 5 ++--- src/Entity/Db/Process.php | 27 +++++++++++++++++++++----- src/Entity/Db/ProcessStep.php | 34 +++++++++++++++------------------ src/Service/ProcessService.php | 4 ++-- 5 files changed, 46 insertions(+), 34 deletions(-) diff --git a/doc/config/database.md b/doc/config/database.md index fdb5186..417ac55 100644 --- a/doc/config/database.md +++ b/doc/config/database.md @@ -85,7 +85,8 @@ CREATE TABLE public.unicaen_signature_process ( status int4 NULL, document_name varchar(255) NOT NULL, currentstep int4 NOT NULL, - CONSTRAINT unicaen_signature_process_pkey PRIMARY KEY (id), + label varchar(255) NULL DEFAULT NULL::character varying, + CONSTRAINT unicaen_signature_process_pkey PRIMARY KEY (id), CONSTRAINT fk_994855d2b4090c8a FOREIGN KEY (signatureflow_id) REFERENCES unicaen_signature_signatureflow(id) ); CREATE INDEX idx_994855d2b4090c8a ON public.unicaen_signature_process USING btree (signatureflow_id); @@ -131,13 +132,12 @@ CREATE TABLE public.unicaen_signature_process_step ( id int4 NOT NULL, process_id int4 NULL, signature_id int4 NULL, - signatureflowstep_id int4 NULL, - CONSTRAINT unicaen_signature_process_step_pkey PRIMARY KEY (id), + label varchar(255) NULL DEFAULT NULL::character varying, + + CONSTRAINT unicaen_signature_process_step_pkey PRIMARY KEY (id), CONSTRAINT fk_cf70b0a57ec2f574 FOREIGN KEY (process_id) REFERENCES unicaen_signature_process(id), - CONSTRAINT fk_cf70b0a5c352c4 FOREIGN KEY (signatureflowstep_id) REFERENCES unicaen_signature_signatureflowstep(id), CONSTRAINT fk_cf70b0a5ed61183a FOREIGN KEY (signature_id) REFERENCES unicaen_signature_signature(id) ); CREATE INDEX idx_cf70b0a57ec2f574 ON public.unicaen_signature_process_step USING btree (process_id); -CREATE INDEX idx_cf70b0a5c352c4 ON public.unicaen_signature_process_step USING btree (signatureflowstep_id); CREATE UNIQUE INDEX uniq_cf70b0a5ed61183a ON public.unicaen_signature_process_step USING btree (signature_id); ``` \ No newline at end of file diff --git a/doc/dev/database-install-sql.md b/doc/dev/database-install-sql.md index 82d5e66..66fc3fa 100644 --- a/doc/dev/database-install-sql.md +++ b/doc/dev/database-install-sql.md @@ -100,6 +100,7 @@ CREATE TABLE unicaen_signature_process status int4 NULL, currentstep int4 NOT NULL, document_name varchar(255) NOT NULL, + label varchar(255) NULL DEFAULT NULL::character varying, signatureflow_id int4 NULL, CONSTRAINT unicaen_signature_process_pkey PRIMARY KEY (id), CONSTRAINT fk_994855d2b4090c8a FOREIGN KEY (signatureflow_id) REFERENCES unicaen_signature_signatureflow (id) @@ -112,14 +113,12 @@ CREATE TABLE unicaen_signature_process_step id int4 NOT NULL, process_id int4 NULL, signature_id int4 NULL, - signatureflowstep_id int4 NULL, + label varchar(255) NULL DEFAULT NULL::character varying, CONSTRAINT unicaen_signature_process_step_pkey PRIMARY KEY (id), CONSTRAINT fk_cf70b0a57ec2f574 FOREIGN KEY (process_id) REFERENCES unicaen_signature_process (id), - CONSTRAINT fk_cf70b0a5c352c4 FOREIGN KEY (signatureflowstep_id) REFERENCES unicaen_signature_signatureflowstep (id), CONSTRAINT fk_cf70b0a5ed61183a FOREIGN KEY (signature_id) REFERENCES unicaen_signature_signature (id) ); CREATE INDEX idx_cf70b0a57ec2f574 ON unicaen_signature_process_step USING btree (process_id); -CREATE INDEX idx_cf70b0a5c352c4 ON unicaen_signature_process_step USING btree (signatureflowstep_id); CREATE UNIQUE INDEX uniq_cf70b0a5ed61183a ON unicaen_signature_process_step USING btree (signature_id); -- Sequences diff --git a/src/Entity/Db/Process.php b/src/Entity/Db/Process.php index 499d747..af0597b 100644 --- a/src/Entity/Db/Process.php +++ b/src/Entity/Db/Process.php @@ -54,6 +54,14 @@ class Process */ protected int $currentStep = 0; + /** + * Label du process issu du SignatureFlow + * + * @var ?string + * @ORM\Column (type="text", nullable=true) + */ + private ?string $label; + /** * @var SignatureFlow * @ORM\ManyToOne(targetEntity="SignatureFlow") @@ -181,6 +189,20 @@ class Process return $this; } + + public function getLabel(): ?string + { + return $this->label; + } + + public function setLabel(?string $label): ?string + { + $this->label = $label; + + return $this; + } + + /** * @return SignatureFlow */ @@ -232,11 +254,6 @@ class Process ); } - public function getLabel(): string - { - return $this->getSignatureFlow()->getLabel(); - } - public function isInProgress(): bool { return $this->getStatus() == Signature::STATUS_SIGNATURE_WAIT; diff --git a/src/Entity/Db/ProcessStep.php b/src/Entity/Db/ProcessStep.php index f71c3be..e2640a5 100644 --- a/src/Entity/Db/ProcessStep.php +++ b/src/Entity/Db/ProcessStep.php @@ -32,11 +32,15 @@ class ProcessStep */ private Signature $signature; + /** - * @var SignatureFlowStep - * @ORM\ManyToOne(targetEntity="SignatureFlowStep") + * Label de l'étape du process issu du SignatureFlowStep + * + * @var ?string + * @ORM\Column (type="text", nullable=true) */ - private SignatureFlowStep $signatureFlowStep; + private ?string $label; + /** * @return int @@ -89,23 +93,17 @@ class ProcessStep return $this; } - /** - * @return SignatureFlowStep - */ - public function getSignatureFlowStep(): SignatureFlowStep - { - return $this->signatureFlowStep; - } + public function setLabel($label) :ProcessStep { + $this->label = $label; - /** - * @param SignatureFlowStep $signatureFlowStep - */ - public function setSignatureFlowStep(SignatureFlowStep $signatureFlowStep): self - { - $this->signatureFlowStep = $signatureFlowStep; return $this; } + public function getLabel() :string { + return $this->label; + } + + /** * @return int */ @@ -114,9 +112,7 @@ class ProcessStep return $this->getSignature()->getOrder(); } - public function getLabel() :string { - return $this->getSignatureFlowStep()->getLabel(); - } + public function getLetterfileName() :string { return $this->getSignature()->getLetterfileKey(); diff --git a/src/Service/ProcessService.php b/src/Service/ProcessService.php index 54b7cb5..77067d0 100644 --- a/src/Service/ProcessService.php +++ b/src/Service/ProcessService.php @@ -24,6 +24,7 @@ class ProcessService SignatureConfigurationServiceAwareTrait, SignatureServiceAwareTrait; + /** * @return ProcessRepository */ @@ -188,8 +189,7 @@ class ProcessService // Création des étapes $processStep = new ProcessStep(); $this->getObjectManager()->persist($processStep); - - $processStep->setSignatureFlowStep($signatureFlowStep); + $processStep->setLabel($signatureFlowStep->getLabel()); $processStep->setProcess($process); $process->getSteps()->add($processStep); -- GitLab