From d245afb0094c26c3d66b06deb6c999259d2f54f3 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 6 Sep 2022 14:41:40 +0200 Subject: [PATCH 1/7] correct identification of from() --- .../PersonAggregators/HouseholdPositionAggregator.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php index ec4a270ac..0a7a6d387 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php @@ -15,6 +15,7 @@ use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Export\ExportElementValidatedInterface; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Templating\TranslatableStringHelper; +use Chill\PersonBundle\Entity\Household\HouseholdMember; use Chill\PersonBundle\Repository\Household\PositionRepository; use DateTime; use Doctrine\ORM\QueryBuilder; @@ -46,7 +47,7 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl public function alterQuery(QueryBuilder $qb, $data) { $qb->resetDQLPart('from'); - $qb->from('ChillPersonBundle:Household\HouseholdMember', 'hm'); + $qb->from(HouseholdMember::class, 'hm'); $qb->join('hm.person', 'person'); $qb->join('person.center', 'center'); @@ -70,7 +71,7 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl } else { $qb->groupBy('household_position_aggregator'); } - + } public function applyOn() From 29cc589bf2e414d913e1c7eef6af577d6cddf3f1 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 8 Aug 2022 15:24:22 +0200 Subject: [PATCH 2/7] exports: add a new GeographicalUnitStat aggregator --- .../GeographicalUnitStatAggregator.php | 96 +++++++++++++++++++ .../services/exports_accompanying_course.yaml | 7 ++ .../translations/messages.fr.yml | 2 + 3 files changed, 105 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php new file mode 100644 index 000000000..ed5d80ae8 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php @@ -0,0 +1,96 @@ +repository = $em->getRepository(...::class); + } + */ + + /** + * @inheritDoc + */ + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Geographical unit'; + } + + $g = $this->repository->find($value); + + return $g; //... + }; + } + + /** + * @inheritDoc + */ + public function getQueryKeys($data): array + { + return ['geographicalunitstat_aggregator']; + } + + /** + * @inheritDoc + */ + public function buildForm(FormBuilderInterface $builder) + { + // TODO: Implement buildForm() method. + } + + /** + * @inheritDoc + */ + public function getTitle(): string + { + return 'Group by geographical unit'; + } + + /** + * @inheritDoc + */ + public function addRole() + { + return null; + } + + /** + * @inheritDoc + */ + public function alterQuery(QueryBuilder $qb, $data) + { + + //$qb->addSelect('... AS geographicalunitstat_aggregator'); + + $groupby = $qb->getDQLPart('groupBy'); + + if (!empty($groupBy)) { + $qb->addGroupBy('geographicalunitstat_aggregator'); + } else { + $qb->groupBy('geographicalunitstat_aggregator'); + } + } + + /** + * @inheritDoc + */ + public function applyOn(): string + { + return Declarations::ACP_TYPE; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml index 1e313d59d..de10f5788 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml @@ -178,6 +178,13 @@ services: tags: - { name: chill.export_aggregator, alias: accompanyingcourse_step_aggregator } + chill.person.export.aggregator_geographicalunitstat: + class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\GeographicalUnitStatAggregator + autowire: true + autoconfigure: true + tags: + - { name: chill.export_aggregator, alias: accompanyingcourse_geographicalunitstat_aggregator } + chill.person.export.aggregator_socialaction: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\SocialActionAggregator autowire: true diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index dc32a2cae..e909f0ab7 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -449,6 +449,8 @@ Step: Statut Group by step: Grouper les parcours par statut du parcours Filter by geographical unit: Filtrer les parcours par zone géographique +Group by geographical unit: Grouper les parcours par zone géographique +Geographical unit: Zone géographique Filter by socialaction: Filtrer les parcours par action d'accompagnement Accepted socialactions: Actions d'accompagnement From d9e602247e7e80884277dea7dc15453c1a7ec876 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 7 Sep 2022 11:09:03 +0200 Subject: [PATCH 3/7] fix errors with Role type --- src/Bundle/ChillMainBundle/Export/ExportManager.php | 4 ++-- .../GeographicalUnitStatAggregator.php | 2 +- .../ChillPersonBundle/Export/Export/ListPersonDuplicate.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Export/ExportManager.php b/src/Bundle/ChillMainBundle/Export/ExportManager.php index 9ba9bc1a8..788fae719 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportManager.php +++ b/src/Bundle/ChillMainBundle/Export/ExportManager.php @@ -559,13 +559,13 @@ class ExportManager } foreach ($centers as $center) { - if ($this->authorizationChecker->isGranted($role->getRole(), $center) === false) { + if ($this->authorizationChecker->isGranted($role, $center) === false) { //debugging $this->logger->debug('user has no access to element', [ 'method' => __METHOD__, 'type' => get_class($element), 'center' => $center->getName(), - 'role' => $role->getRole(), + 'role' => $role, ]); ///// Bypasse les autorisations qui empêche d'afficher les nouveaux exports diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php index ed5d80ae8..18a1b3dea 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php @@ -64,7 +64,7 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface /** * @inheritDoc */ - public function addRole() + public function addRole(): ?string { return null; } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php index 7f8688493..75d757f9e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php @@ -142,9 +142,9 @@ class ListPersonDuplicate implements DirectExportInterface, ExportElementValidat return 'List duplicates'; } - public function requiredRole(): Role + public function requiredRole(): string { - return new Role(PersonVoter::DUPLICATE); + return PersonVoter::DUPLICATE; } public function validateForm($data, ExecutionContextInterface $context) From 482abd3980c04f4ce5b2dd96bd1ce7f35e55cc09 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 7 Sep 2022 12:23:38 +0200 Subject: [PATCH 4/7] remove dump --- .../Filter/AccompanyingCourseFilters/ConfidentialFilter.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php index 3ebf77182..4d1784cb3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php @@ -73,8 +73,6 @@ class ConfidentialFilter implements FilterInterface public function describeAction($data, $format = 'string'): array { - dump($data, self::CHOICES); - foreach (self::CHOICES as $k => $v) { if ($v === $data['accepted_confidentials']) { $choice = $k; From 3851e65777d157dd4c1317ef92624aeb553d6c66 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 7 Sep 2022 13:38:13 +0200 Subject: [PATCH 5/7] fix errors with Role type --- src/Bundle/ChillMainBundle/Export/ExportManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Export/ExportManager.php b/src/Bundle/ChillMainBundle/Export/ExportManager.php index 788fae719..e2d099ba8 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportManager.php +++ b/src/Bundle/ChillMainBundle/Export/ExportManager.php @@ -594,7 +594,7 @@ class ExportManager 'center' => $center, 'circles' => $this->authorizationHelper->getReachableScopes( $this->user, - $element->requiredRole()->getRole(), + $element->requiredRole(), $center ), ]; From 81359877c43db4ec80d094ea42a073938758648d Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 7 Sep 2022 19:35:07 +0200 Subject: [PATCH 6/7] exports: add condition with distinct alias on join clauses (wip) --- .../Aggregator/ActivityTypeAggregator.php | 4 +-- .../AdministrativeLocationAggregator.php | 4 ++- .../ClosingMotiveAggregator.php | 4 ++- .../EvaluationAggregator.php | 7 ++++-- .../JobAggregator.php | 4 ++- .../OriginAggregator.php | 4 ++- .../ReferrerAggregator.php | 6 +++-- .../RequestorAggregator.php | 6 ++--- .../ScopeAggregator.php | 6 +++-- .../SocialIssueAggregator.php | 7 ++++-- .../HouseholdPositionAggregator.php | 19 ++++++++------ .../Export/Export/CountEvaluation.php | 14 ++++++++--- .../Export/Export/CountHousehold.php | 25 ++++++++++++++----- .../CountPersonWithAccompanyingCourse.php | 14 ++++++++--- .../Export/Export/CountSocialWorkActions.php | 7 ++++-- .../ActivityTypeFilter.php | 6 ++--- .../CurrentUserScopeFilter.php | 6 +++-- .../EvaluationFilter.php | 17 +++++++++---- .../RequestorFilter.php | 17 ++++++++----- .../SocialActionFilter.php | 5 +++- .../SocialIssueFilter.php | 6 +++-- 21 files changed, 129 insertions(+), 59 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php index d318d969a..f31e2e73f 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php @@ -44,8 +44,8 @@ class ActivityTypeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('type', $qb->getAllAliases(), true)) { - $qb->join('activity.activityType', 'type'); + if (!in_array('aty', $qb->getAllAliases(), true)) { + $qb->join('activity.activityType', 'aty'); } $qb->addSelect(sprintf('IDENTITY(activity.activityType) AS %s', self::KEY)); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php index a1cf7160b..13185c2a2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php @@ -39,7 +39,9 @@ class AdministrativeLocationAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acp.administrativeLocation', 'al'); + if (!in_array('acploc', $qb->getAllAliases(), true)) { + $qb->join('acp.administrativeLocation', 'acploc'); + } $qb->addSelect('IDENTITY(acp.administrativeLocation) AS location_aggregator'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php index b0f8f98f0..033ba4365 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php @@ -40,7 +40,9 @@ class ClosingMotiveAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acp.closingMotive', 'cm'); + if (!in_array('acpmotive', $qb->getAllAliases(), true)) { + $qb->join('acp.closingMotive', 'acpmotive'); + } $qb->addSelect('IDENTITY(acp.closingMotive) AS closingmotive_aggregator'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php index 96c63b9cf..120506aae 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php @@ -43,9 +43,12 @@ final class EvaluationAggregator implements AggregatorInterface if (!in_array('acpw', $qb->getAllAliases(), true)) { $qb->join('acp.works', 'acpw'); } - $qb->join('acpw.accompanyingPeriodWorkEvaluations', 'we'); - $qb->addSelect('IDENTITY(we.evaluation) AS evaluation_aggregator'); + if (!in_array('workeval', $qb->getAllAliases(), true)) { + $qb->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval'); + } + + $qb->addSelect('IDENTITY(workeval.evaluation) AS evaluation_aggregator'); $groupby = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php index 6443cc02e..7634ea37f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php @@ -39,7 +39,9 @@ final class JobAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acp.job', 'j'); + if (!in_array('acpjob', $qb->getAllAliases(), true)) { + $qb->join('acp.job', 'acpjob'); + } $qb->addSelect('IDENTITY(acp.job) AS job_aggregator'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php index b98edae32..4c784e08d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php @@ -41,7 +41,9 @@ final class OriginAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acp.origin', 'o'); + if (!in_array('acporigin', $qb->getAllAliases(), true)) { + $qb->join('acp.origin', 'acporigin'); + } $qb->addSelect('o.id AS origin_aggregator'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php index a1df6b559..22eca6f76 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php @@ -39,9 +39,11 @@ final class ReferrerAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acp.user', 'u'); + if (!in_array('acpuser', $qb->getAllAliases(), true)) { + $qb->join('acp.user', 'acpuser'); + } - $qb->addSelect('u.id AS referrer_aggregator'); + $qb->addSelect('acpuser.id AS referrer_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php index 26d5fad53..80195bdcc 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php @@ -35,8 +35,8 @@ final class RequestorAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('part', $qb->getAllAliases(), true)) { - $qb->join('acp.participations', 'part'); + if (!in_array('acppart', $qb->getAllAliases(), true)) { + $qb->join('acp.participations', 'acppart'); } $qb->addSelect(" @@ -44,7 +44,7 @@ final class RequestorAggregator implements AggregatorInterface WHEN acp.requestorPerson IS NOT NULL THEN ( CASE - WHEN acp.requestorPerson = part.person + WHEN acp.requestorPerson = acppart.person THEN 'is person concerned' ELSE 'is other person' END ) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php index c7b3142f2..5b2901921 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php @@ -39,9 +39,11 @@ final class ScopeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acp.scopes', 's'); + if (!in_array('acpscope', $qb->getAllAliases(), true)) { + $qb->join('acp.scopes', 'acpscope'); + } - $qb->addSelect('s.id as scope_aggregator'); + $qb->addSelect('acpscope.id as scope_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php index 7cb726673..ac5ac94c0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php @@ -39,8 +39,11 @@ final class SocialIssueAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acp.socialIssues', 'si'); - $qb->addSelect('si.id as socialissue_aggregator'); + if (!in_array('acpsocialissue', $qb->getAllAliases(), true)) { + $qb->join('acp.socialIssues', 'acpsocialissue'); + } + + $qb->addSelect('acpsocialissue.id as socialissue_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php index ea94e891b..b63d3842f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php @@ -46,22 +46,27 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl public function alterQuery(QueryBuilder $qb, $data) { $qb->resetDQLPart('from'); - $qb->from(HouseholdMember::class, 'hm'); + $qb->from(HouseholdMember::class, 'member'); - $qb->join('hm.person', 'person'); - $qb->join('person.center', 'center'); + if (!in_array('person', $qb->getAllAliases(), true)) { + $qb->join('member.person', 'person'); + } + + if (!in_array('center', $qb->getAllAliases(), true)) { + $qb->join('person.center', 'center'); + } $qb->andWhere($qb->expr()->andX( - $qb->expr()->lte('hm.startDate', ':date'), + $qb->expr()->lte('member.startDate', ':date'), $qb->expr()->orX( - $qb->expr()->isNull('hm.endDate'), - $qb->expr()->gte('hm.endDate', ':date') + $qb->expr()->isNull('member.endDate'), + $qb->expr()->gte('member.endDate', ':date') ) )); $qb->setParameter('date', $data['date_position']); - $qb->addSelect('IDENTITY(hm.position) AS household_position_aggregator'); + $qb->addSelect('IDENTITY(member.position) AS household_position_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php index e931a1a42..5b2ab65eb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -88,11 +88,17 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $qb = $this->repository->createQueryBuilder('acp') - ->join('acp.works', 'acpw') - ->join('acpw.accompanyingPeriodWorkEvaluations', 'eval'); + $qb = $this->repository->createQueryBuilder('acp'); - $qb->select('COUNT(eval.id) AS export_result'); + if (!in_array('acpw', $qb->getAllAliases(), true)) { + $qb->join('acp.works', 'acpw'); + } + + if (!in_array('workeval', $qb->getAllAliases(), true)) { + $qb->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval'); + } + + $qb->select('COUNT(workeval.id) AS export_result'); return $qb; } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php index a79c1c00e..f60f66310 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php @@ -88,13 +88,26 @@ class CountHousehold implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $qb = $this->repository->createQueryBuilder('acp') - ->join('acp.participations', 'acppart') - ->join('acppart.person', 'person') - ->join('person.householdParticipations', 'householdmember') - ->join('householdmember.household', 'household'); + $qb = $this->repository->createQueryBuilder('acp'); - $qb->select('COUNT(DISTINCT householdmember.household) AS export_result'); + if (!in_array('acppart', $qb->getAllAliases(), true)) { + $qb->join('acp.participations', 'acppart'); + } + + if (!in_array('partperson', $qb->getAllAliases(), true)) { + $qb->join('acppart.person', 'partperson'); + } + + if (!in_array('member', $qb->getAllAliases(), true)) { + $qb->join('partperson.householdParticipations', 'member'); + } + + if (!in_array('household', $qb->getAllAliases(), true)) { + $qb->join('member.household', 'household'); + } + + + $qb->select('COUNT(DISTINCT member.household) AS export_result'); return $qb; } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php index 4de0eb191..800023fc5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php @@ -88,11 +88,17 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $qb = $this->repository->createQueryBuilder('acp') - ->join('acp.participations', 'acppart') - ->join('acppart.person', 'person'); + $qb = $this->repository->createQueryBuilder('acp'); - $qb->select('COUNT(DISTINCT person.id) AS export_result'); + if (!in_array('acppart', $qb->getAllAliases(), true)) { + $qb->join('acp.participations', 'acppart'); + } + + if (!in_array('partperson', $qb->getAllAliases(), true)) { + $qb->join('acppart.person', 'partperson'); + } + + $qb->select('COUNT(DISTINCT partperson.id) AS export_result'); return $qb; } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountSocialWorkActions.php b/src/Bundle/ChillPersonBundle/Export/Export/CountSocialWorkActions.php index 1a856e23d..17de7e5ae 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountSocialWorkActions.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountSocialWorkActions.php @@ -90,8 +90,11 @@ class CountSocialWorkActions implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $qb = $this->repository->createQueryBuilder('acp') - ->join('acp.works', 'acpw'); + $qb = $this->repository->createQueryBuilder('acp'); + + if (!in_array('acpw', $qb->getAllAliases(), true)) { + $qb->join('acp.works', 'acpw'); + } $qb->select('COUNT(acpw.id) as export_result'); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActivityTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActivityTypeFilter.php index 845b318b9..2659172a4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActivityTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActivityTypeFilter.php @@ -43,11 +43,11 @@ class ActivityTypeFilter implements FilterInterface // we replace indicator 'from' clause by 'act', and put 'acp' in a join $qb->resetDQLPart('from'); - $qb->from('ChillActivityBundle:Activity', 'act'); + $qb->from('ChillActivityBundle:Activity', 'activity'); $qb - ->join('act.accompanyingPeriod', 'acp') - ->join('act.activityType', 'aty'); + ->join('activity.accompanyingPeriod', 'acp') + ->join('activity.activityType', 'aty'); $where = $qb->getDQLPart('where'); $clause = $qb->expr()->in('aty.id', ':activitytypes'); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilter.php index cbbd9bef5..569146614 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilter.php @@ -42,10 +42,12 @@ class CurrentUserScopeFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acp.scopes', 's'); + if (!in_array('acpscope', $qb->getAllAliases(), true)) { + $qb->join('acp.scopes', 'acpscope'); + } $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->eq('s.id', ':userscope'); + $clause = $qb->expr()->eq('acpscope.id', ':userscope'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php index 7df43a06f..c04d5bcd0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php @@ -37,13 +37,20 @@ class EvaluationFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb - ->join('acp.works', 'acpw') - ->join('acpw.accompanyingPeriodWorkEvaluations', 'we') - ->join('we.evaluation', 'ev'); + if (!in_array('acpw', $qb->getAllAliases(), true)) { + $qb->join('acp.works', 'acpw'); + } + + if (!in_array('workeval', $qb->getAllAliases(), true)) { + $qb->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval'); + } + + if (!in_array('eval', $qb->getAllAliases(), true)) { + $qb->join('workeval.evaluation', 'eval'); + } $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('ev.id', ':evaluations'); + $clause = $qb->expr()->in('eval.id', ':evaluations'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php index 6bcf359ae..c0338b42e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php @@ -55,11 +55,14 @@ final class RequestorFilter implements FilterInterface switch ($data['accepted_choices']) { case 'participation': - $qb->join('acp.participations', 'part'); + + if (!in_array('acppart', $qb->getAllAliases(), true)) { + $qb->join('acp.participations', 'acppart'); + } $clause = $qb->expr()->andX( $qb->expr()->isNotNull('acp.requestorPerson'), - $qb->expr()->eq('acp.requestorPerson', 'part.person') + $qb->expr()->eq('acp.requestorPerson', 'acppart.person') ); break; @@ -67,7 +70,9 @@ final class RequestorFilter implements FilterInterface case 'other_person': $expr = $this->em->getExpressionBuilder(); - $qb->join('acp.participations', 'part'); + if (!in_array('acppart', $qb->getAllAliases(), true)) { + $qb->join('acp.participations', 'acppart'); + } $clause = $expr->andX( $expr->isNotNull('acp.requestorPerson'), @@ -76,10 +81,10 @@ final class RequestorFilter implements FilterInterface // subquery $this->em->createQueryBuilder() - ->select('identity(acp2.requestorPerson)') ->from('ChillPersonBundle:AccompanyingPeriod', 'acp2') - ->join('acp2.participations', 'part2') - ->where($expr->eq('acp2.requestorPerson', 'part2.person')) + ->join('acp2.participations', 'acppart2') + ->select('identity(acp2.requestorPerson)') + ->where($expr->eq('acp2.requestorPerson', 'acppart2.person')) ->getDQL() ) ); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php index 50889225c..c0eb98513 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php @@ -46,7 +46,10 @@ class SocialActionFilter implements FilterInterface if (!in_array('acpw', $qb->getAllAliases(), true)) { $qb->join('acp.works', 'acpw'); } - $qb->join('acpw.socialAction', 'sa'); + + if (!in_array('acpw', $qb->getAllAliases(), true)) { + $qb->join('acpw.socialAction', 'sa'); + } $where = $qb->getDQLPart('where'); $clause = $qb->expr()->in('sa.id', ':socialactions'); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php index fdcb15ee7..ad232d7c2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php @@ -50,10 +50,12 @@ class SocialIssueFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acp.socialIssues', 'si'); + if (!in_array('acpsocialissue', $qb->getAllAliases(), true)) { + $qb->join('acp.socialIssues', 'acpsocialissue'); + } $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('si.id', ':socialissues'); + $clause = $qb->expr()->in('acpsocialissue.id', ':socialissues'); if ($where instanceof Andx) { $where->add($clause); From 1dcff2f23cd4fe9124a18463c4ada67c976b8a2a Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 7 Sep 2022 19:58:38 +0200 Subject: [PATCH 7/7] exports: add condition with distinct alias on join clauses --- exports_alias_conventions.csv | 68 +++++++++++++++++ exports_alias_conventions.md | 76 +++++++++++++++++++ .../BySocialActionAggregator.php | 6 +- .../BySocialIssueAggregator.php | 6 +- .../ACPAggregators/ByThirdpartyAggregator.php | 6 +- .../ACPAggregators/ByUserAggregator.php | 6 +- .../ACPAggregators/LocationTypeAggregator.php | 6 +- .../ACPAggregators/UserScopeAggregator.php | 6 +- .../Aggregator/ActivityTypeAggregator.php | 23 +----- .../ActivityReasonAggregator.php | 41 +--------- .../LinkedToACP/AvgActivityDuration.php | 2 +- .../LinkedToACP/AvgActivityVisitDuration.php | 2 +- .../Export/LinkedToACP/CountActivity.php | 7 +- .../LinkedToACP/SumActivityDuration.php | 7 +- .../LinkedToACP/SumActivityVisitDuration.php | 7 +- .../Export/LinkedToPerson/CountActivity.php | 7 +- .../Export/LinkedToPerson/ListActivity.php | 10 +-- .../LinkedToPerson/StatActivityDuration.php | 6 +- .../ACPFilters/BySocialActionFilter.php | 6 +- .../Filter/ACPFilters/BySocialIssueFilter.php | 6 +- .../Export/Filter/ACPFilters/ByUserFilter.php | 6 +- .../Filter/ACPFilters/LocationTypeFilter.php | 6 +- .../Filter/ACPFilters/UserScopeFilter.php | 6 +- .../Export/Filter/ActivityTypeFilter.php | 19 ----- .../PersonFilters/ActivityReasonFilter.php | 34 +-------- .../Export/Aggregator/AgentAggregator.php | 6 +- .../Aggregator/CancelReasonAggregator.php | 4 +- .../Export/Aggregator/JobAggregator.php | 6 +- .../Export/Aggregator/LocationAggregator.php | 4 +- .../Aggregator/LocationTypeAggregator.php | 6 +- .../Export/Aggregator/ScopeAggregator.php | 6 +- .../Export/Filter/JobFilter.php | 6 +- .../Export/Filter/ScopeFilter.php | 6 +- .../HouseholdPositionAggregator.php | 8 +- .../MaritalStatusAggregator.php | 7 +- .../ActionTypeAggregator.php | 7 +- .../SocialWorkAggregators/GoalAggregator.php | 7 +- .../SocialWorkAggregators/JobAggregator.php | 6 +- .../ReferrerAggregator.php | 6 +- .../ResultAggregator.php | 17 ++++- .../SocialWorkAggregators/ScopeAggregator.php | 6 +- .../ActivityTypeFilter.php | 12 ++- .../SocialActionFilter.php | 6 +- .../ResidentialAddressAtThirdpartyFilter.php | 27 +++++-- .../ResidentialAddressAtUserFilter.php | 13 +++- .../Filter/SocialWorkFilters/JobFilter.php | 6 +- .../SocialWorkFilters/ReferrerFilter.php | 6 +- .../Filter/SocialWorkFilters/ScopeFilter.php | 6 +- .../ReferrerFilterTest.php | 4 +- 49 files changed, 343 insertions(+), 220 deletions(-) create mode 100644 exports_alias_conventions.csv create mode 100644 exports_alias_conventions.md diff --git a/exports_alias_conventions.csv b/exports_alias_conventions.csv new file mode 100644 index 000000000..1215479d8 --- /dev/null +++ b/exports_alias_conventions.csv @@ -0,0 +1,68 @@ +Entity,Join,Attribute,Alias +AccompanyingPeriod::class,,,acp +,AccompanyingPeriodWork::class,acp.works,acpw +,AccompanyingPeriodParticipation::class,acp.participations,acppart +,Location::class,acp.administrativeLocation,acploc +,ClosingMotive::class,acp.closingMotive,acpmotive +,UserJob::class,acp.job,acpjob +,Origin::class,acp.origin,acporigin +,Scope::class,acp.scopes,acpscope +,SocialIssue::class,acp.socialIssues,acpsocialissue +,User::class,acp.user,acpuser +AccompanyingPeriodWork::class,,,acpw +,AccompanyingPeriodWorkEvaluation::class,acpw.accompanyingPeriodWorkEvaluations,workeval +,Goal::class,acpw.goals,goal +,User::class,acpw.referrers,acpwuser +,Result::class,acpw.results,acpwresult +,SocialAction::class,acpw.socialAction,acpwsocialaction +AccompanyingPeriodParticipation::class,,,acppart +,Person::class,acppart.person,partperson +AccompanyingPeriodWorkEvaluation::class,,,workeval +,Evaluation::class,workeval.evaluation,eval +Goal::class,,,goal +,Result::class,goal.results,goalresult +Person::class,,,person +,Center::class,person.center,center +,HouseholdMember::class,partperson.householdParticipations,member +,MaritalStatus::class,person.maritalStatus,personmarital +ResidentialAddress::class,,,resaddr +,Person::class,resaddr.person,resaddrperson +,Center::class,resaddrperson.center,resaddrcenter +,ThirdParty::class,resaddr.hostThirdParty,tparty +ThirdParty::class,,,tparty +,ThirdPartyCategory::class,tparty.categories,tpartycat +HouseholdMember::class,,,member +,Household::class,member.household,household +,Person::class,member.person,memberperson +,,memberperson.center,membercenter +Household::class,,,household +,HouseholdComposition::class,household.compositions,composition +Activity::class,,,activity +,Person::class,activity.person,actperson +,AccompanyingPeriod::class,activity.accompanyingPeriod,actacp +,Person::class,activity_person_having_activity.person,person_person_having_activity +,ActivityReason::class,activity_person_having_activity.reasons,reasons_person_having_activity +,ActivityType::class,activity.activityType,acttype +,Location::class,activity.location,actloc +,SocialAction::class,activity.socialActions,actsocialaction +,SocialIssue::class,activity.socialIssues,actsocialssue +,ThirdParty::class,activity.thirdParties,acttparty +,User::class,activity.user,actuser +,User::class,activity.users,actusers +,ActivityReason::class,activity.reasons,actreasons +,Center::class,actperson.center,actcenter +ActivityReason::class,,,actreasons +,ActivityReasonCategory::class,actreason.category,actreasoncat +Calendar::class,,,cal +,CancelReason::class,cal.cancelReason,calcancel +,Location::class,cal.location,calloc +,User::class,cal.user,caluser +VendeePerson::class,,,vp +,Person::class,vp.person,vpperson +,Center::class,vpperson.center,vpcenter +,SituationProfessionelle::class,vp.situationProfessionelle,vpprof +,StatutLogement::class,vp.statutLogement,vplog +,TempsDeTravail::class,vp.tempsDeTravail,vptt +VendeePersonMineur::class,,,vpm +,Person::class,vpm.person,vpmperson +,Center::class,vpmperson.center,vpmcenter diff --git a/exports_alias_conventions.md b/exports_alias_conventions.md new file mode 100644 index 000000000..85973eec1 --- /dev/null +++ b/exports_alias_conventions.md @@ -0,0 +1,76 @@ +# Export conventions + + +Add condition with distinct alias on each export join clauses (Indicators + Filters + Aggregators) + +These are alias conventions : + +| Entity | Join | Attribute | Alias | +| :--- | :--- |:-------------------------------------------|:----------------------------------| +| AccompanyingPeriod::class | | | acp | +| | AccompanyingPeriodWork::class | acp.works | acpw | +| | AccompanyingPeriodParticipation::class | acp.participations | acppart | +| | Location::class | acp.administrativeLocation | acploc | +| | ClosingMotive::class | acp.closingMotive | acpmotive | +| | UserJob::class | acp.job | acpjob | +| | Origin::class | acp.origin | acporigin | +| | Scope::class | acp.scopes | acpscope | +| | SocialIssue::class | acp.socialIssues | acpsocialissue | +| | User::class | acp.user | acpuser | +| AccompanyingPeriodWork::class | | | acpw | +| | AccompanyingPeriodWorkEvaluation::class | acpw.accompanyingPeriodWorkEvaluations | workeval | +| | Goal::class | acpw.goals | goal | +| | User::class | acpw.referrers | acpwuser | +| | Result::class | acpw.results | acpwresult | +| | SocialAction::class | acpw.socialAction | acpwsocialaction | +| AccompanyingPeriodParticipation::class | | | acppart | +| | Person::class | acppart.person | partperson | +| AccompanyingPeriodWorkEvaluation::class | | | workeval | +| | Evaluation::class | workeval.evaluation | eval | +| Goal::class | | | goal | +| | Result::class | goal.results | goalresult | +| Person::class | | | person | +| | Center::class | person.center | center | +| | HouseholdMember::class | partperson.householdParticipations | member | +| | MaritalStatus::class | person.maritalStatus | personmarital | +| ResidentialAddress::class | | | resaddr | +| | Person::class | resaddr.person | resaddrperson | +| | Center::class | resaddrperson.center | resaddrcenter | +| | ThirdParty::class | resaddr.hostThirdParty | tparty | +| ThirdParty::class | | | tparty | +| | ThirdPartyCategory::class | tparty.categories | tpartycat | +| HouseholdMember::class | | | member | +| | Household::class | member.household | household | +| | Person::class | member.person | memberperson | +| | | memberperson.center | membercenter | +| Household::class | | | household | +| | HouseholdComposition::class | household.compositions | composition | +| Activity::class | | | activity | +| | Person::class | activity.person | actperson | +| | AccompanyingPeriod::class | activity.accompanyingPeriod | actacp | +| | Person::class | activity\_person\_having\_activity.person | person\_person\_having\_activity | +| | ActivityReason::class | activity\_person\_having\_activity.reasons | reasons\_person\_having\_activity | +| | ActivityType::class | activity.activityType | acttype | +| | Location::class | activity.location | actloc | +| | SocialAction::class | activity.socialActions | actsocialaction | +| | SocialIssue::class | activity.socialIssues | actsocialssue | +| | ThirdParty::class | activity.thirdParties | acttparty | +| | User::class | activity.user | actuser | +| | User::class | activity.users | actusers | +| | ActivityReason::class | activity.reasons | actreasons | +| | Center::class | actperson.center | actcenter | +| ActivityReason::class | | | actreasons | +| | ActivityReasonCategory::class | actreason.category | actreasoncat | +| Calendar::class | | | cal | +| | CancelReason::class | cal.cancelReason | calcancel | +| | Location::class | cal.location | calloc | +| | User::class | cal.user | caluser | +| VendeePerson::class | | | vp | +| | Person::class | vp.person | vpperson | +| | Center::class | vpperson.center | vpcenter | +| | SituationProfessionelle::class | vp.situationProfessionelle | vpprof | +| | StatutLogement::class | vp.statutLogement | vplog | +| | TempsDeTravail::class | vp.tempsDeTravail | vptt | +| VendeePersonMineur::class | | | vpm | +| | Person::class | vpm.person | vpmperson | +| | Center::class | vpmperson.center | vpmcenter | diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php index 19299eb6a..f35fe6e6b 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php @@ -40,11 +40,11 @@ class BySocialActionAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('socialaction', $qb->getAllAliases(), true)) { - $qb->join('activity.socialActions', 'socialaction'); + if (!in_array('actsocialaction', $qb->getAllAliases(), true)) { + $qb->join('activity.socialActions', 'actsocialaction'); } - $qb->addSelect('socialaction.id AS socialaction_aggregator'); + $qb->addSelect('actsocialaction.id AS socialaction_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php index 672076693..1126b9373 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php @@ -40,11 +40,11 @@ class BySocialIssueAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('socialissue', $qb->getAllAliases(), true)) { - $qb->join('activity.socialIssues', 'socialissue'); + if (!in_array('actsocialissue', $qb->getAllAliases(), true)) { + $qb->join('activity.socialIssues', 'actsocialissue'); } - $qb->addSelect('socialissue.id AS socialissue_aggregator'); + $qb->addSelect('actsocialissue.id AS socialissue_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php index 81822e801..4b56c6fc7 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php @@ -40,11 +40,11 @@ class ByThirdpartyAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('thirdparty', $qb->getAllAliases(), true)) { - $qb->join('activity.thirdParties', 'thirdparty'); + if (!in_array('acttparty', $qb->getAllAliases(), true)) { + $qb->join('activity.thirdParties', 'acttparty'); } - $qb->addSelect('thirdparty.id AS thirdparty_aggregator'); + $qb->addSelect('acttparty.id AS thirdparty_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByUserAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByUserAggregator.php index 55df3febd..3787e5286 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByUserAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByUserAggregator.php @@ -40,11 +40,11 @@ class ByUserAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('user', $qb->getAllAliases(), true)) { - $qb->join('activity.users', 'user'); + if (!in_array('actusers', $qb->getAllAliases(), true)) { + $qb->join('activity.users', 'actusers'); } - $qb->addSelect('user.id AS users_aggregator'); + $qb->addSelect('actusers.id AS users_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php index 9664060da..d05c0eb41 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php @@ -40,11 +40,11 @@ class LocationTypeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('location', $qb->getAllAliases(), true)) { - $qb->join('activity.location', 'location'); + if (!in_array('actloc', $qb->getAllAliases(), true)) { + $qb->join('activity.location', 'actloc'); } - $qb->addSelect('IDENTITY(location.locationType) AS locationtype_aggregator'); + $qb->addSelect('IDENTITY(actloc.locationType) AS locationtype_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/UserScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/UserScopeAggregator.php index c05196375..faaa08b8e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/UserScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/UserScopeAggregator.php @@ -40,11 +40,11 @@ class UserScopeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('user', $qb->getAllAliases(), true)) { - $qb->join('activity.user', 'user'); + if (!in_array('actuser', $qb->getAllAliases(), true)) { + $qb->join('activity.user', 'actuser'); } - $qb->addSelect('IDENTITY(user.mainScope) AS userscope_aggregator'); + $qb->addSelect('IDENTITY(actuser.mainScope) AS userscope_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php index f31e2e73f..5c285ca3e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php @@ -44,8 +44,8 @@ class ActivityTypeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('aty', $qb->getAllAliases(), true)) { - $qb->join('activity.activityType', 'aty'); + if (!in_array('acttype', $qb->getAllAliases(), true)) { + $qb->join('activity.activityType', 'acttype'); } $qb->addSelect(sprintf('IDENTITY(activity.activityType) AS %s', self::KEY)); @@ -94,23 +94,4 @@ class ActivityTypeAggregator implements AggregatorInterface { return 'Aggregate by activity type'; } - - /** - * Check if a join between Activity and another alias. - * - * @param Join[] $joins - * @param string $alias the alias to search for - * - * @return bool - */ - private function checkJoinAlreadyDefined(array $joins, $alias) - { - foreach ($joins as $join) { - if ($join->getAlias() === $alias) { - return true; - } - } - - return false; - } } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php index 83347bf11..9d7cd3116 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php @@ -67,29 +67,15 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali $qb->addSelect($elem . ' as ' . $alias); // make a jointure only if needed - $join = $qb->getDQLPart('join'); - - if ( - ( - array_key_exists('activity', $join) - && !$this->checkJoinAlreadyDefined($join['activity'], 'reasons') - ) - || (!array_key_exists('activity', $join)) - ) { - $qb->add( - 'join', - [ - 'activity' => new Join(Join::INNER_JOIN, 'activity.reasons', 'reasons'), - ], - true - ); + if (!in_array( 'actreasons', $qb->getAllAliases(), true)) { + $qb->innerJoin('activity.reasons', 'actreasons'); } // join category if necessary if ('activity_categories_id' === $alias) { // add join only if needed - if (!$this->checkJoinAlreadyDefined($qb->getDQLPart('join')['activity'], 'category')) { - $qb->join('reasons.category', 'category'); + if (!in_array('actreasoncat', $qb->getAllAliases(), true)) { + $qb->join('actreasons.category', 'actreasoncat'); } } @@ -193,23 +179,4 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali ->addViolation(); } } - - /** - * Check if a join between Activity and another alias. - * - * @param Join[] $joins - * @param string $alias the alias to search for - * - * @return bool - */ - private function checkJoinAlreadyDefined(array $joins, $alias) - { - foreach ($joins as $join) { - if ($join->getAlias() === $alias) { - return true; - } - } - - return false; - } } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php index 90fc7822b..be20d2b9c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php @@ -84,7 +84,7 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { $qb = $this->repository->createQueryBuilder('activity') - ->join('activity.accompanyingPeriod', 'acp'); + ->join('activity.accompanyingPeriod', 'actacp'); $qb->select('AVG(activity.durationTime) as export_avg_activity_duration'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php index 02ad4a5e3..021c82d72 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php @@ -84,7 +84,7 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { $qb = $this->repository->createQueryBuilder('activity') - ->join('activity.accompanyingPeriod', 'acp'); + ->join('activity.accompanyingPeriod', 'actacp'); $qb->select('AVG(activity.travelTime) as export_avg_activity_visit_duration'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php index aaf8c9463..1f8b742dd 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php @@ -84,8 +84,11 @@ class CountActivity implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $qb = $this->repository->createQueryBuilder('activity') - ->join('activity.accompanyingPeriod', 'acp'); + $qb = $this->repository->createQueryBuilder('activity'); + + if (!in_array('actacp', $qb->getAllAliases(), true)) { + $qb->join('activity.accompanyingPeriod', 'actacp'); + } $qb->select('COUNT(activity.id) as export_count_activity'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php index d11a7ded0..4d9b43034 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php @@ -83,8 +83,11 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $qb = $this->repository->createQueryBuilder('activity') - ->join('activity.accompanyingPeriod', 'acp'); + $qb = $this->repository->createQueryBuilder('activity'); + + if (!in_array('actacp', $qb->getAllAliases(), true)) { + $qb->join('activity.accompanyingPeriod', 'actacp'); + } $qb->select('SUM(activity.durationTime) as export_sum_activity_duration'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php index bc67e7569..212b1384f 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php @@ -83,8 +83,11 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $qb = $this->repository->createQueryBuilder('activity') - ->join('activity.accompanyingPeriod', 'acp'); + $qb = $this->repository->createQueryBuilder('activity'); + + if (!in_array('actacp', $qb->getAllAliases(), true)) { + $qb->join('activity.accompanyingPeriod', 'actacp'); + } $qb->select('SUM(activity.travelTime) as export_sum_activity_visit_duration'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php index 6881528f6..398fb14bb 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php @@ -84,8 +84,11 @@ class CountActivity implements ExportInterface, GroupedExportInterface { $centers = array_map(static fn ($el) => $el['center'], $acl); - $qb = $this->activityRepository->createQueryBuilder('activity') - ->join('activity.person', 'person'); + $qb = $this->activityRepository->createQueryBuilder('activity'); + + if (!in_array('actperson', $qb->getAllAliases(), true)) { + $qb->join('activity.person', 'actperson'); + } $qb->select('COUNT(activity.id) as export_count_activity'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index fd2b36e65..17b9bd687 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -210,9 +210,9 @@ class ListActivity implements ListInterface, GroupedExportInterface $qb ->from('ChillActivityBundle:Activity', 'activity') - ->join('activity.person', 'person') - ->join('person.center', 'center') - ->andWhere('center IN (:authorized_centers)') + ->join('activity.person', 'actperson') + ->join('actperson.center', 'actcenter') + ->andWhere('actcenter IN (:authorized_centers)') ->setParameter('authorized_centers', $centers); foreach ($this->fields as $f) { @@ -239,8 +239,8 @@ class ListActivity implements ListInterface, GroupedExportInterface break; case 'user_username': - $qb->join('activity.user', 'user'); - $qb->addSelect('user.username AS user_username'); + $qb->join('activity.user', 'actuser'); + $qb->addSelect('actuser.username AS user_username'); break; diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php index eabe5a15b..bcb4da05d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php @@ -120,9 +120,9 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface } return $qb->select($select) - ->join('activity.person', 'person') - ->join('person.center', 'center') - ->where($qb->expr()->in('center', ':centers')) + ->join('activity.person', 'actperson') + ->join('actperson.center', 'actcenter') + ->where($qb->expr()->in('actcenter', ':centers')) ->setParameter(':centers', $centers); } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php index 7c3508674..5737220b2 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php @@ -39,11 +39,11 @@ class BySocialActionFilter implements FilterInterface { $where = $qb->getDQLPart('where'); - if (!in_array('socialaction', $qb->getAllAliases(), true)) { - $qb->join('activity.socialActions', 'socialaction'); + if (!in_array('actsocialaction', $qb->getAllAliases(), true)) { + $qb->join('activity.socialActions', 'actsocialaction'); } - $clause = $qb->expr()->in('socialaction.id', ':socialactions'); + $clause = $qb->expr()->in('actsocialaction.id', ':socialactions'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php index a1b5ad1ba..1a9fdb519 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php @@ -39,11 +39,11 @@ class BySocialIssueFilter implements FilterInterface { $where = $qb->getDQLPart('where'); - if (!in_array('socialissue', $qb->getAllAliases(), true)) { - $qb->join('activity.socialIssues', 'socialissue'); + if (!in_array('actsocialissue', $qb->getAllAliases(), true)) { + $qb->join('activity.socialIssues', 'actsocialissue'); } - $clause = $qb->expr()->in('socialissue.id', ':socialissues'); + $clause = $qb->expr()->in('actsocialissue.id', ':socialissues'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByUserFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByUserFilter.php index 75e9dfa16..19ddee3ca 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByUserFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByUserFilter.php @@ -39,11 +39,11 @@ class ByUserFilter implements FilterInterface { $where = $qb->getDQLPart('where'); - if (!in_array('user', $qb->getAllAliases(), true)) { - $qb->join('activity.users', 'user'); + if (!in_array('actusers', $qb->getAllAliases(), true)) { + $qb->join('activity.users', 'actusers'); } - $clause = $qb->expr()->in('user.id', ':users'); + $clause = $qb->expr()->in('actusers.id', ':users'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php index def2ac84d..4ab27f043 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php @@ -37,12 +37,12 @@ class LocationTypeFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('location', $qb->getAllAliases(), true)) { - $qb->join('activity.location', 'location'); + if (!in_array('actloc', $qb->getAllAliases(), true)) { + $qb->join('activity.location', 'actloc'); } $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('location.locationType', ':locationtype'); + $clause = $qb->expr()->in('actloc.locationType', ':locationtype'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php index ba0f8cb75..c0cda26a4 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php @@ -37,13 +37,13 @@ class UserScopeFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('user', $qb->getAllAliases(), true)) { - $qb->join('activity.user', 'user'); + if (!in_array('actuser', $qb->getAllAliases(), true)) { + $qb->join('activity.user', 'actuser'); } $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('user.mainScope', ':userscope'); + $clause = $qb->expr()->in('actuser.mainScope', ':userscope'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php index e6504ba26..77d887fdf 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php @@ -102,23 +102,4 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter ->addViolation(); } } - - /** - * Check if a join between Activity and Reason is already defined. - * - * @param Join[] $joins - * @param mixed $alias - * - * @return bool - */ - private function checkJoinAlreadyDefined(array $joins, $alias) - { - foreach ($joins as $join) { - if ($join->getAlias() === $alias) { - return true; - } - } - - return false; - } } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php index 1ab5ffff4..6d78b3b38 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php @@ -52,20 +52,9 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt $where = $qb->getDQLPart('where'); $join = $qb->getDQLPart('join'); $clause = $qb->expr()->in('reasons', ':selected_activity_reasons'); - //dump($join); - // add a join to reasons only if needed - if ( - ( - array_key_exists('activity', $join) - && !$this->checkJoinAlreadyDefined($join['activity'], 'reasons') - ) - || (!array_key_exists('activity', $join)) - ) { - $qb->add( - 'join', - ['activity' => new Join(Join::INNER_JOIN, 'activity.reasons', 'reasons')], - true - ); + + if (!in_array('actreasons', $qb->getAllAliases(), true)) { + $qb->join('activity.reasons', 'actreasons'); } if ($where instanceof Expr\Andx) { @@ -123,21 +112,4 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt ->addViolation(); } } - - /** - * Check if a join between Activity and Reason is already defined. - * - * @param Join[] $joins - * @param mixed $alias - */ - private function checkJoinAlreadyDefined(array $joins, $alias): bool - { - foreach ($joins as $join) { - if ($join->getAlias() === $alias) { - return true; - } - } - - return false; - } } diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php index e0a024f45..57ec33cdd 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php @@ -40,9 +40,11 @@ final class AgentAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('cal.user', 'u'); + if (!in_array('caluser', $qb->getAllAliases(), true)) { + $qb->join('cal.user', 'caluser'); + } - $qb->addSelect('u.id AS agent_aggregator'); + $qb->addSelect('caluser.id AS agent_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php index 76b2cb133..a07f052bf 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php @@ -41,7 +41,9 @@ class CancelReasonAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { // TODO: still needs to take into account appointments without a cancel reason somehow - $qb->join('cal.cancelReason', 'cr'); + if (!in_array('calcancel', $qb->getAllAliases(), true)) { + $qb->join('cal.cancelReason', 'calcancel'); + } $qb->addSelect('IDENTITY(cal.cancelReason) as cancel_reason_aggregator'); diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php index 0e9352198..17905cf35 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php @@ -40,9 +40,11 @@ final class JobAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('cal.user', 'u'); + if (!in_array('caluser', $qb->getAllAliases(), true)) { + $qb->join('cal.user', 'caluser'); + } - $qb->addSelect('IDENTITY(u.userJob) as job_aggregator'); + $qb->addSelect('IDENTITY(caluser.userJob) as job_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php index cd7e88a1e..236b1b74f 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php @@ -36,7 +36,9 @@ final class LocationAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('cal.location', 'l'); + if (!in_array('calloc', $qb->getAllAliases(), true)) { + $qb->join('cal.location', 'calloc'); + } $qb->addSelect('IDENTITY(cal.location) as location_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php index dea8eecb4..c8d02160f 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php @@ -40,9 +40,11 @@ final class LocationTypeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('cal.location', 'l'); + if (!in_array('calloc', $qb->getAllAliases(), true)) { + $qb->join('cal.location', 'calloc'); + } - $qb->addSelect('IDENTITY(l.locationType) as location_type_aggregator'); + $qb->addSelect('IDENTITY(calloc.locationType) as location_type_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php index 4ae3fb99c..7605c3d5d 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php @@ -40,9 +40,11 @@ final class ScopeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('cal.user', 'u'); + if (!in_array('caluser', $qb->getAllAliases(), true)) { + $qb->join('cal.user', 'caluser'); + } - $qb->addSelect('IDENTITY(u.mainScope) as scope_aggregator'); + $qb->addSelect('IDENTITY(caluser.mainScope) as scope_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php index cb3b8b2cd..03cd4857d 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php @@ -42,10 +42,12 @@ class JobFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('cal.user', 'u'); + if (!in_array('caluser', $qb->getAllAliases(), true)) { + $qb->join('cal.user', 'caluser'); + } $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('u.userJob', ':job'); + $clause = $qb->expr()->in('caluser.userJob', ':job'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php index 55699d79a..cbd566e9e 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php @@ -42,10 +42,12 @@ class ScopeFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('cal.user', 'u'); + if (!in_array('caluser', $qb->getAllAliases(), true)) { + $qb->join('cal.user', 'caluser'); + } $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('u.mainScope', ':scope'); + $clause = $qb->expr()->in('caluser.mainScope', ':scope'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php index b63d3842f..c0b52053d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php @@ -48,12 +48,12 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl $qb->resetDQLPart('from'); $qb->from(HouseholdMember::class, 'member'); - if (!in_array('person', $qb->getAllAliases(), true)) { - $qb->join('member.person', 'person'); + if (!in_array('memberperson', $qb->getAllAliases(), true)) { + $qb->join('member.person', 'memberperson'); } - if (!in_array('center', $qb->getAllAliases(), true)) { - $qb->join('person.center', 'center'); + if (!in_array('membercenter', $qb->getAllAliases(), true)) { + $qb->join('memberperson.center', 'membercenter'); } $qb->andWhere($qb->expr()->andX( diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php index 5e39c6310..e799d8dfa 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php @@ -37,8 +37,11 @@ final class MaritalStatusAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('person.maritalStatus', 'ms'); - $qb->addSelect('ms.id as marital_status_aggregator'); + if (!in_array('personmarital', $qb->getAllAliases(), true)) { + $qb->join('person.maritalStatus', 'personmarital'); + } + + $qb->addSelect('personmarital.id as marital_status_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php index d0da45560..b76db495d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php @@ -38,8 +38,11 @@ final class ActionTypeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acpw.socialAction', 'sa'); - $qb->addSelect('sa.id as action_type_aggregator'); + if (!in_array('acpwsocialaction', $qb->getAllAliases(), true)) { + $qb->join('acpw.socialAction', 'acpwsocialaction'); + } + + $qb->addSelect('acpwsocialaction.id as action_type_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php index d1f33ca7a..4310dcac2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php @@ -37,8 +37,11 @@ final class GoalAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acpw.goals', 'g'); - $qb->addSelect('g.id as goal_aggregator'); + if (!in_array('goal', $qb->getAllAliases(), true)) { + $qb->join('acpw.goals', 'goal'); + } + + $qb->addSelect('goal.id as goal_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php index 10c588809..4d27aa873 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php @@ -39,9 +39,11 @@ final class JobAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acpw.referrers', 'u'); + if (!in_array('acpwuser', $qb->getAllAliases(), true)) { + $qb->join('acpw.referrers', 'acpwuser'); + } - $qb->addSelect('IDENTITY(u.userJob) as job_aggregator'); + $qb->addSelect('IDENTITY(acpwuser.userJob) as job_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php index efda6b783..35e1e218d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php @@ -39,9 +39,11 @@ final class ReferrerAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acpw.referrers', 'u'); + if (!in_array('acpwuser', $qb->getAllAliases(), true)) { + $qb->join('acpw.referrers', 'acpwuser'); + } - $qb->addSelect('u.id AS referrer_aggregator'); + $qb->addSelect('acpwuser.id AS referrer_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php index 9bdcebb60..47391ed69 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php @@ -37,10 +37,19 @@ final class ResultAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acpw.results', 'res'); - $qb->join('acpw.goals', 'g'); - $qb->join('g.results', 'gres'); - $qb->addSelect('res.id, IDENTITY(g.results) as result_aggregator'); + if (!in_array('acpwresult', $qb->getAllAliases(), true)) { + $qb->join('acpw.results', 'acpwresult'); + } + + if (!in_array('goal', $qb->getAllAliases(), true)) { + $qb->join('acpw.goals', 'goal'); + } + + if (!in_array('goalresult', $qb->getAllAliases(), true)) { + $qb->join('goal.results', 'goalresult'); + } + + $qb->addSelect('acpwresult.id, IDENTITY(goal.results) as result_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php index ee2509977..ee479d503 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php @@ -39,9 +39,11 @@ final class ScopeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acpw.referrers', 'u'); + if (!in_array('acpwuser', $qb->getAllAliases(), true)) { + $qb->join('acpw.referrers', 'acpwuser'); + } - $qb->addSelect('IDENTITY(u.mainScope) as scope_aggregator'); + $qb->addSelect('IDENTITY(acpwuser.mainScope) as scope_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActivityTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActivityTypeFilter.php index 2659172a4..f76a00c33 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActivityTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActivityTypeFilter.php @@ -45,12 +45,16 @@ class ActivityTypeFilter implements FilterInterface $qb->resetDQLPart('from'); $qb->from('ChillActivityBundle:Activity', 'activity'); - $qb - ->join('activity.accompanyingPeriod', 'acp') - ->join('activity.activityType', 'aty'); + if (!in_array('actacp', $qb->getAllAliases(), true)) { + $qb->join('activity.accompanyingPeriod', 'actacp'); + } + + if (!in_array('acttype', $qb->getAllAliases(), true)) { + $qb->join('activity.activityType', 'acttype'); + } $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('aty.id', ':activitytypes'); + $clause = $qb->expr()->in('acttype.id', ':activitytypes'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php index c0eb98513..0664f2a8d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php @@ -47,12 +47,12 @@ class SocialActionFilter implements FilterInterface $qb->join('acp.works', 'acpw'); } - if (!in_array('acpw', $qb->getAllAliases(), true)) { - $qb->join('acpw.socialAction', 'sa'); + if (!in_array('acpwsocialaction', $qb->getAllAliases(), true)) { + $qb->join('acpw.socialAction', 'acpwsocialaction'); } $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('sa.id', ':socialactions'); + $clause = $qb->expr()->in('acpwsocialaction.id', ':socialactions'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php index 860598927..73c551286 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php @@ -39,18 +39,29 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { $qb->resetDQLPart('from'); - $qb->from('ChillPersonBundle:Person\ResidentialAddress', 'ra'); + $qb->from('ChillPersonBundle:Person\ResidentialAddress', 'resaddr'); - $qb->join('ra.person', 'person'); - $qb->join('person.center', 'center'); - $qb->join('ra.hostThirdParty', 't'); - $qb->join('t.categories', 'tc'); + if (!in_array('resaddrperson', $qb->getAllAliases(), true)) { + $qb->join('resaddr.person', 'resaddrperson'); + } + + if (!in_array('resaddrcenter', $qb->getAllAliases(), true)) { + $qb->join('resaddrperson.center', 'resaddrcenter'); + } + + if (!in_array('tparty', $qb->getAllAliases(), true)) { + $qb->join('resaddr.hostThirdParty', 'tparty'); + } + + if (!in_array('tpartycat', $qb->getAllAliases(), true)) { + $qb->join('tparty.categories', 'tpartycat'); + } $where = $qb->getDQLPart('where'); $clause = $qb->expr()->andX( - $qb->expr()->isNotNull('ra.hostThirdParty'), - $qb->expr()->between(':date', 'ra.startDate', 'ra.endDate'), - $qb->expr()->in('tc.id', ':type') + $qb->expr()->isNotNull('resaddr.hostThirdParty'), + $qb->expr()->between(':date', 'resaddr.startDate', 'resaddr.endDate'), + $qb->expr()->in('tpartycat.id', ':type') ); if ($where instanceof Expr\Andx) { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php index 5fd2a718b..5e78e574e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php @@ -26,13 +26,18 @@ class ResidentialAddressAtUserFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { $qb->resetDQLPart('from'); - $qb->from('ChillPersonBundle:Person\ResidentialAddress', 'ra'); + $qb->from('ChillPersonBundle:Person\ResidentialAddress', 'resaddr'); - $qb->join('ra.person', 'person'); - $qb->join('person.center', 'center'); + if (!in_array('resaddrperson', $qb->getAllAliases(), true)) { + $qb->join('resaddr.person', 'resaddrperson'); + } + + if (!in_array('resaddrcenter', $qb->getAllAliases(), true)) { + $qb->join('resaddrperson.center', 'resaddrcenter'); + } $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->isNotNull('ra.hostPerson'); + $clause = $qb->expr()->isNotNull('resaddr.hostPerson'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php index 386570c8e..a93dae54d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php @@ -42,10 +42,12 @@ class JobFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acpw.referrers', 'u'); + if (!in_array('acpwuser', $qb->getAllAliases(), true)) { + $qb->join('acpw.referrers', 'acpwuser'); + } $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('u.userJob', ':job'); + $clause = $qb->expr()->in('acpwuser.userJob', ':job'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php index f3fa7e359..e1ddd70fd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php @@ -36,10 +36,12 @@ class ReferrerFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acpw.referrers', 'u'); + if (!in_array('acpwuser', $qb->getAllAliases(), true)) { + $qb->join('acpw.referrers', 'acpwuser'); + } $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('u', ':agents'); + $clause = $qb->expr()->in('acpwuser', ':agents'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php index d707edf7f..ae525a4e5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php @@ -42,10 +42,12 @@ class ScopeFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acpw.referrers', 'u'); + if (!in_array('acpwuser', $qb->getAllAliases(), true)) { + $qb->join('acpw.referrers', 'acpwuser'); + } $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('u.mainScope', ':scope'); + $clause = $qb->expr()->in('acpwuser.mainScope', ':scope'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ReferrerFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ReferrerFilterTest.php index a332c89dc..8d2c8ef5b 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ReferrerFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ReferrerFilterTest.php @@ -79,8 +79,8 @@ final class ReferrerFilterTest extends AbstractFilterTest ->select('acpw.id'), $em->createQueryBuilder() ->from('ChillPersonBundle:AccompanyingPeriod\AccompanyingPeriodWork', 'acpw') - ->join('acpw.referrers', 'r') - ->select('r.id'), + ->join('acpw.referrers', 'acpwuser') + ->select('acpwuser.id'), ]; } }