From 39bb06b99134ef4dc3d66ad56b8202d531d5b1a7 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 30 Oct 2023 11:53:41 +0100 Subject: [PATCH 01/11] Adjust query to transfer relationship from one person to another depending on whether original person was in the to or from position --- .../Remove/Handler/PersonMoveRelationHandler.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php index d4e9be2a2..1ba1f6766 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php @@ -26,7 +26,15 @@ class PersonMoveRelationHandler implements PersonMoveSqlHandlerInterface { $insertSql = sprintf(<<<'SQL' INSERT INTO chill_person_relationships (id, relation_id, reverse, createdat, createdby_id, fromperson_id, toperson_id) - SELECT nextval('chill_person_relationships_id_seq'), relation_id, reverse, createdat, createdby_id, fromperson_id, toperson_id + SELECT nextval('chill_person_relationships_id_seq'), relation_id, reverse, createdat, createdby_id, + CASE + WHEN cpr.fromperson_id = %d THEN %d + ELSE cpr.fromperson_id + END as fromperson, + CASE + WHEN cpr.toperson_id = %d THEN %d + ELSE cpr.toperson_id + END as toperson FROM chill_person_relationships cpr WHERE fromperson_id = %d OR toperson_id = %d AND NOT EXISTS ( @@ -35,7 +43,7 @@ class PersonMoveRelationHandler implements PersonMoveSqlHandlerInterface cpr2.fromperson_id = %d AND cpr2.toperson_id = %d OR cpr2.fromperson_id = %d AND cpr2.toperson_id = %d ); - SQL, $from->getId(), $from->getId(), $to->getId(), $from->getId(), $from->getId(), $to->getId()); + SQL, $from->getId(), $to->getId(), $from->getId(), $to->getId(), $from->getId(), $from->getId(), $to->getId(), $from->getId(), $from->getId(), $to->getId()); $deleteSql = [ sprintf('DELETE FROM chill_person_relationships WHERE fromperson_id = %d', $from->getId()), From cac092c45add606d5e557ee7efc13c0a1b9dbe67 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 30 Oct 2023 12:00:25 +0100 Subject: [PATCH 02/11] add changie --- .changes/unreleased/Fixed-20231030-115441.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/unreleased/Fixed-20231030-115441.yaml diff --git a/.changes/unreleased/Fixed-20231030-115441.yaml b/.changes/unreleased/Fixed-20231030-115441.yaml new file mode 100644 index 000000000..144658fff --- /dev/null +++ b/.changes/unreleased/Fixed-20231030-115441.yaml @@ -0,0 +1,5 @@ +kind: Fixed +body: Fix merging of double person files. Adjustement relationship sql statement +time: 2023-10-30T11:54:41.028058144+01:00 +custom: + Issue: "182" From bfe0d9a137e4d7f24be4e5bdfe33a2002154b2d1 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 30 Oct 2023 13:52:50 +0100 Subject: [PATCH 03/11] Add a comment --- .../Actions/Remove/Handler/PersonMoveRelationHandler.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php index 1ba1f6766..ce6810429 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php @@ -24,6 +24,7 @@ class PersonMoveRelationHandler implements PersonMoveSqlHandlerInterface public function getSqls(string $className, string $field, Person $from, Person $to): array { + // Insert sql statement taking into account two cases. One where the person is the fromperson and another where the person is the toperson in the relationship. $insertSql = sprintf(<<<'SQL' INSERT INTO chill_person_relationships (id, relation_id, reverse, createdat, createdby_id, fromperson_id, toperson_id) SELECT nextval('chill_person_relationships_id_seq'), relation_id, reverse, createdat, createdby_id, From ec85f05e0bb16d7526cad71a2c1c1ebf632d5879 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 30 Oct 2023 14:09:03 +0100 Subject: [PATCH 04/11] Php cs fixer --- .../ChillActivityBundle/Controller/ActivityController.php | 4 ++-- src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 43c0b13bb..06489010c 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -673,8 +673,8 @@ final class ActivityController extends AbstractController throw $this->createNotFoundException('Accompanying Period not found'); } - // TODO Add permission - // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + // TODO Add permission + // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); } else { throw $this->createNotFoundException('Person or Accompanying Period not found'); } diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index 046d553e9..41e0140c8 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php @@ -100,7 +100,7 @@ class ThirdPartyType extends AbstractType 'label' => 'thirdparty.Contact data are confidential', ]); - // Institutional ThirdParty (parent) + // Institutional ThirdParty (parent) } else { $builder ->add('nameCompany', TextType::class, [ From f43bd2bc5828b8d284bc6255a7b08e49ec54b68c Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 1 Nov 2023 09:48:48 +0100 Subject: [PATCH 05/11] minor change to rerun pipeline --- .../Actions/Remove/Handler/PersonMoveRelationHandler.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php index ce6810429..45f655f4e 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php @@ -24,7 +24,8 @@ class PersonMoveRelationHandler implements PersonMoveSqlHandlerInterface public function getSqls(string $className, string $field, Person $from, Person $to): array { - // Insert sql statement taking into account two cases. One where the person is the fromperson and another where the person is the toperson in the relationship. +/* Insert sql statement taking into account two cases. + One where the person is the fromperson and another where the person is the toperson in the relationship.*/ $insertSql = sprintf(<<<'SQL' INSERT INTO chill_person_relationships (id, relation_id, reverse, createdat, createdby_id, fromperson_id, toperson_id) SELECT nextval('chill_person_relationships_id_seq'), relation_id, reverse, createdat, createdby_id, From 3ce78d0c16b1d5e7ae39f16a5942cdb14be25e90 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 1 Nov 2023 10:52:42 +0100 Subject: [PATCH 06/11] php cs fixer --- .../Actions/Remove/Handler/PersonMoveRelationHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php index 45f655f4e..3d64515d3 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php @@ -24,8 +24,8 @@ class PersonMoveRelationHandler implements PersonMoveSqlHandlerInterface public function getSqls(string $className, string $field, Person $from, Person $to): array { -/* Insert sql statement taking into account two cases. - One where the person is the fromperson and another where the person is the toperson in the relationship.*/ + /* Insert sql statement taking into account two cases. + One where the person is the fromperson and another where the person is the toperson in the relationship.*/ $insertSql = sprintf(<<<'SQL' INSERT INTO chill_person_relationships (id, relation_id, reverse, createdat, createdby_id, fromperson_id, toperson_id) SELECT nextval('chill_person_relationships_id_seq'), relation_id, reverse, createdat, createdby_id, From db70ce4a611d4a8fc83f58d4a3f301ee273548b3 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 30 Oct 2023 11:53:41 +0100 Subject: [PATCH 07/11] Adjust query to transfer relationship from one person to another depending on whether original person was in the to or from position --- .../Remove/Handler/PersonMoveRelationHandler.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php index d4e9be2a2..1ba1f6766 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php @@ -26,7 +26,15 @@ class PersonMoveRelationHandler implements PersonMoveSqlHandlerInterface { $insertSql = sprintf(<<<'SQL' INSERT INTO chill_person_relationships (id, relation_id, reverse, createdat, createdby_id, fromperson_id, toperson_id) - SELECT nextval('chill_person_relationships_id_seq'), relation_id, reverse, createdat, createdby_id, fromperson_id, toperson_id + SELECT nextval('chill_person_relationships_id_seq'), relation_id, reverse, createdat, createdby_id, + CASE + WHEN cpr.fromperson_id = %d THEN %d + ELSE cpr.fromperson_id + END as fromperson, + CASE + WHEN cpr.toperson_id = %d THEN %d + ELSE cpr.toperson_id + END as toperson FROM chill_person_relationships cpr WHERE fromperson_id = %d OR toperson_id = %d AND NOT EXISTS ( @@ -35,7 +43,7 @@ class PersonMoveRelationHandler implements PersonMoveSqlHandlerInterface cpr2.fromperson_id = %d AND cpr2.toperson_id = %d OR cpr2.fromperson_id = %d AND cpr2.toperson_id = %d ); - SQL, $from->getId(), $from->getId(), $to->getId(), $from->getId(), $from->getId(), $to->getId()); + SQL, $from->getId(), $to->getId(), $from->getId(), $to->getId(), $from->getId(), $from->getId(), $to->getId(), $from->getId(), $from->getId(), $to->getId()); $deleteSql = [ sprintf('DELETE FROM chill_person_relationships WHERE fromperson_id = %d', $from->getId()), From a1132cf82fe2df23d2b76283b9b12f5516f71538 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 30 Oct 2023 12:00:25 +0100 Subject: [PATCH 08/11] add changie --- .changes/unreleased/Fixed-20231030-115441.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/unreleased/Fixed-20231030-115441.yaml diff --git a/.changes/unreleased/Fixed-20231030-115441.yaml b/.changes/unreleased/Fixed-20231030-115441.yaml new file mode 100644 index 000000000..144658fff --- /dev/null +++ b/.changes/unreleased/Fixed-20231030-115441.yaml @@ -0,0 +1,5 @@ +kind: Fixed +body: Fix merging of double person files. Adjustement relationship sql statement +time: 2023-10-30T11:54:41.028058144+01:00 +custom: + Issue: "182" From 050a2955ca0f3dfa724e5cc3f707ce6875ee5ada Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 30 Oct 2023 13:52:50 +0100 Subject: [PATCH 09/11] Add a comment --- .../Actions/Remove/Handler/PersonMoveRelationHandler.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php index 1ba1f6766..ce6810429 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php @@ -24,6 +24,7 @@ class PersonMoveRelationHandler implements PersonMoveSqlHandlerInterface public function getSqls(string $className, string $field, Person $from, Person $to): array { + // Insert sql statement taking into account two cases. One where the person is the fromperson and another where the person is the toperson in the relationship. $insertSql = sprintf(<<<'SQL' INSERT INTO chill_person_relationships (id, relation_id, reverse, createdat, createdby_id, fromperson_id, toperson_id) SELECT nextval('chill_person_relationships_id_seq'), relation_id, reverse, createdat, createdby_id, From c29b356c021d87c6f4e0a9d384e52db67434101f Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 1 Nov 2023 09:48:48 +0100 Subject: [PATCH 10/11] minor change to rerun pipeline --- .../Actions/Remove/Handler/PersonMoveRelationHandler.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php index ce6810429..45f655f4e 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php @@ -24,7 +24,8 @@ class PersonMoveRelationHandler implements PersonMoveSqlHandlerInterface public function getSqls(string $className, string $field, Person $from, Person $to): array { - // Insert sql statement taking into account two cases. One where the person is the fromperson and another where the person is the toperson in the relationship. +/* Insert sql statement taking into account two cases. + One where the person is the fromperson and another where the person is the toperson in the relationship.*/ $insertSql = sprintf(<<<'SQL' INSERT INTO chill_person_relationships (id, relation_id, reverse, createdat, createdby_id, fromperson_id, toperson_id) SELECT nextval('chill_person_relationships_id_seq'), relation_id, reverse, createdat, createdby_id, From 1e43772b17ae2b06fec5f139aedaefed6c1af312 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 1 Nov 2023 10:52:42 +0100 Subject: [PATCH 11/11] php cs fixer --- .../Actions/Remove/Handler/PersonMoveRelationHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php index 45f655f4e..3d64515d3 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php @@ -24,8 +24,8 @@ class PersonMoveRelationHandler implements PersonMoveSqlHandlerInterface public function getSqls(string $className, string $field, Person $from, Person $to): array { -/* Insert sql statement taking into account two cases. - One where the person is the fromperson and another where the person is the toperson in the relationship.*/ + /* Insert sql statement taking into account two cases. + One where the person is the fromperson and another where the person is the toperson in the relationship.*/ $insertSql = sprintf(<<<'SQL' INSERT INTO chill_person_relationships (id, relation_id, reverse, createdat, createdby_id, fromperson_id, toperson_id) SELECT nextval('chill_person_relationships_id_seq'), relation_id, reverse, createdat, createdby_id,