mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
exports: add condition with distinct alias on join clauses (wip)
This commit is contained in:
parent
3851e65777
commit
81359877c4
@ -44,8 +44,8 @@ class ActivityTypeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('type', $qb->getAllAliases(), true)) {
|
if (!in_array('aty', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.activityType', 'type');
|
$qb->join('activity.activityType', 'aty');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect(sprintf('IDENTITY(activity.activityType) AS %s', self::KEY));
|
$qb->addSelect(sprintf('IDENTITY(activity.activityType) AS %s', self::KEY));
|
||||||
|
@ -39,7 +39,9 @@ class AdministrativeLocationAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$qb->addSelect('IDENTITY(acp.administrativeLocation) AS location_aggregator');
|
||||||
|
|
||||||
|
@ -40,7 +40,9 @@ class ClosingMotiveAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$qb->addSelect('IDENTITY(acp.closingMotive) AS closingmotive_aggregator');
|
||||||
|
|
||||||
|
@ -43,9 +43,12 @@ final class EvaluationAggregator implements AggregatorInterface
|
|||||||
if (!in_array('acpw', $qb->getAllAliases(), true)) {
|
if (!in_array('acpw', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('acp.works', 'acpw');
|
$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');
|
$groupby = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -39,7 +39,9 @@ final class JobAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$qb->addSelect('IDENTITY(acp.job) AS job_aggregator');
|
||||||
|
|
||||||
|
@ -41,7 +41,9 @@ final class OriginAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$qb->addSelect('o.id AS origin_aggregator');
|
||||||
|
|
||||||
|
@ -39,9 +39,11 @@ final class ReferrerAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -35,8 +35,8 @@ final class RequestorAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('part', $qb->getAllAliases(), true)) {
|
if (!in_array('acppart', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('acp.participations', 'part');
|
$qb->join('acp.participations', 'acppart');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect("
|
$qb->addSelect("
|
||||||
@ -44,7 +44,7 @@ final class RequestorAggregator implements AggregatorInterface
|
|||||||
WHEN acp.requestorPerson IS NOT NULL
|
WHEN acp.requestorPerson IS NOT NULL
|
||||||
THEN
|
THEN
|
||||||
( CASE
|
( CASE
|
||||||
WHEN acp.requestorPerson = part.person
|
WHEN acp.requestorPerson = acppart.person
|
||||||
THEN 'is person concerned'
|
THEN 'is person concerned'
|
||||||
ELSE 'is other person'
|
ELSE 'is other person'
|
||||||
END )
|
END )
|
||||||
|
@ -39,9 +39,11 @@ final class ScopeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -39,8 +39,11 @@ final class SocialIssueAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$qb->join('acp.socialIssues', 'si');
|
if (!in_array('acpsocialissue', $qb->getAllAliases(), true)) {
|
||||||
$qb->addSelect('si.id as socialissue_aggregator');
|
$qb->join('acp.socialIssues', 'acpsocialissue');
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->addSelect('acpsocialissue.id as socialissue_aggregator');
|
||||||
|
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -46,22 +46,27 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl
|
|||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$qb->resetDQLPart('from');
|
$qb->resetDQLPart('from');
|
||||||
$qb->from(HouseholdMember::class, 'hm');
|
$qb->from(HouseholdMember::class, 'member');
|
||||||
|
|
||||||
$qb->join('hm.person', 'person');
|
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->join('person.center', 'center');
|
||||||
|
}
|
||||||
|
|
||||||
$qb->andWhere($qb->expr()->andX(
|
$qb->andWhere($qb->expr()->andX(
|
||||||
$qb->expr()->lte('hm.startDate', ':date'),
|
$qb->expr()->lte('member.startDate', ':date'),
|
||||||
$qb->expr()->orX(
|
$qb->expr()->orX(
|
||||||
$qb->expr()->isNull('hm.endDate'),
|
$qb->expr()->isNull('member.endDate'),
|
||||||
$qb->expr()->gte('hm.endDate', ':date')
|
$qb->expr()->gte('member.endDate', ':date')
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
$qb->setParameter('date', $data['date_position']);
|
$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');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -88,11 +88,17 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface
|
|||||||
|
|
||||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||||
{
|
{
|
||||||
$qb = $this->repository->createQueryBuilder('acp')
|
$qb = $this->repository->createQueryBuilder('acp');
|
||||||
->join('acp.works', 'acpw')
|
|
||||||
->join('acpw.accompanyingPeriodWorkEvaluations', 'eval');
|
|
||||||
|
|
||||||
$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;
|
return $qb;
|
||||||
}
|
}
|
||||||
|
@ -88,13 +88,26 @@ class CountHousehold implements ExportInterface, GroupedExportInterface
|
|||||||
|
|
||||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||||
{
|
{
|
||||||
$qb = $this->repository->createQueryBuilder('acp')
|
$qb = $this->repository->createQueryBuilder('acp');
|
||||||
->join('acp.participations', 'acppart')
|
|
||||||
->join('acppart.person', 'person')
|
|
||||||
->join('person.householdParticipations', 'householdmember')
|
|
||||||
->join('householdmember.household', 'household');
|
|
||||||
|
|
||||||
$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;
|
return $qb;
|
||||||
}
|
}
|
||||||
|
@ -88,11 +88,17 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor
|
|||||||
|
|
||||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||||
{
|
{
|
||||||
$qb = $this->repository->createQueryBuilder('acp')
|
$qb = $this->repository->createQueryBuilder('acp');
|
||||||
->join('acp.participations', 'acppart')
|
|
||||||
->join('acppart.person', 'person');
|
|
||||||
|
|
||||||
$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;
|
return $qb;
|
||||||
}
|
}
|
||||||
|
@ -90,8 +90,11 @@ class CountSocialWorkActions implements ExportInterface, GroupedExportInterface
|
|||||||
|
|
||||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder
|
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder
|
||||||
{
|
{
|
||||||
$qb = $this->repository->createQueryBuilder('acp')
|
$qb = $this->repository->createQueryBuilder('acp');
|
||||||
->join('acp.works', 'acpw');
|
|
||||||
|
if (!in_array('acpw', $qb->getAllAliases(), true)) {
|
||||||
|
$qb->join('acp.works', 'acpw');
|
||||||
|
}
|
||||||
|
|
||||||
$qb->select('COUNT(acpw.id) as export_result');
|
$qb->select('COUNT(acpw.id) as export_result');
|
||||||
|
|
||||||
|
@ -43,11 +43,11 @@ class ActivityTypeFilter implements FilterInterface
|
|||||||
// we replace indicator 'from' clause by 'act', and put 'acp' in a join
|
// we replace indicator 'from' clause by 'act', and put 'acp' in a join
|
||||||
|
|
||||||
$qb->resetDQLPart('from');
|
$qb->resetDQLPart('from');
|
||||||
$qb->from('ChillActivityBundle:Activity', 'act');
|
$qb->from('ChillActivityBundle:Activity', 'activity');
|
||||||
|
|
||||||
$qb
|
$qb
|
||||||
->join('act.accompanyingPeriod', 'acp')
|
->join('activity.accompanyingPeriod', 'acp')
|
||||||
->join('act.activityType', 'aty');
|
->join('activity.activityType', 'aty');
|
||||||
|
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->in('aty.id', ':activitytypes');
|
$clause = $qb->expr()->in('aty.id', ':activitytypes');
|
||||||
|
@ -42,10 +42,12 @@ class CurrentUserScopeFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->eq('s.id', ':userscope');
|
$clause = $qb->expr()->eq('acpscope.id', ':userscope');
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
|
@ -37,13 +37,20 @@ class EvaluationFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$qb
|
if (!in_array('acpw', $qb->getAllAliases(), true)) {
|
||||||
->join('acp.works', 'acpw')
|
$qb->join('acp.works', 'acpw');
|
||||||
->join('acpw.accompanyingPeriodWorkEvaluations', 'we')
|
}
|
||||||
->join('we.evaluation', 'ev');
|
|
||||||
|
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');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->in('ev.id', ':evaluations');
|
$clause = $qb->expr()->in('eval.id', ':evaluations');
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
|
@ -55,11 +55,14 @@ final class RequestorFilter implements FilterInterface
|
|||||||
|
|
||||||
switch ($data['accepted_choices']) {
|
switch ($data['accepted_choices']) {
|
||||||
case 'participation':
|
case 'participation':
|
||||||
$qb->join('acp.participations', 'part');
|
|
||||||
|
if (!in_array('acppart', $qb->getAllAliases(), true)) {
|
||||||
|
$qb->join('acp.participations', 'acppart');
|
||||||
|
}
|
||||||
|
|
||||||
$clause = $qb->expr()->andX(
|
$clause = $qb->expr()->andX(
|
||||||
$qb->expr()->isNotNull('acp.requestorPerson'),
|
$qb->expr()->isNotNull('acp.requestorPerson'),
|
||||||
$qb->expr()->eq('acp.requestorPerson', 'part.person')
|
$qb->expr()->eq('acp.requestorPerson', 'acppart.person')
|
||||||
);
|
);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -67,7 +70,9 @@ final class RequestorFilter implements FilterInterface
|
|||||||
case 'other_person':
|
case 'other_person':
|
||||||
$expr = $this->em->getExpressionBuilder();
|
$expr = $this->em->getExpressionBuilder();
|
||||||
|
|
||||||
$qb->join('acp.participations', 'part');
|
if (!in_array('acppart', $qb->getAllAliases(), true)) {
|
||||||
|
$qb->join('acp.participations', 'acppart');
|
||||||
|
}
|
||||||
|
|
||||||
$clause = $expr->andX(
|
$clause = $expr->andX(
|
||||||
$expr->isNotNull('acp.requestorPerson'),
|
$expr->isNotNull('acp.requestorPerson'),
|
||||||
@ -76,10 +81,10 @@ final class RequestorFilter implements FilterInterface
|
|||||||
|
|
||||||
// subquery
|
// subquery
|
||||||
$this->em->createQueryBuilder()
|
$this->em->createQueryBuilder()
|
||||||
->select('identity(acp2.requestorPerson)')
|
|
||||||
->from('ChillPersonBundle:AccompanyingPeriod', 'acp2')
|
->from('ChillPersonBundle:AccompanyingPeriod', 'acp2')
|
||||||
->join('acp2.participations', 'part2')
|
->join('acp2.participations', 'acppart2')
|
||||||
->where($expr->eq('acp2.requestorPerson', 'part2.person'))
|
->select('identity(acp2.requestorPerson)')
|
||||||
|
->where($expr->eq('acp2.requestorPerson', 'acppart2.person'))
|
||||||
->getDQL()
|
->getDQL()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -46,7 +46,10 @@ class SocialActionFilter implements FilterInterface
|
|||||||
if (!in_array('acpw', $qb->getAllAliases(), true)) {
|
if (!in_array('acpw', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('acp.works', 'acpw');
|
$qb->join('acp.works', 'acpw');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!in_array('acpw', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('acpw.socialAction', 'sa');
|
$qb->join('acpw.socialAction', 'sa');
|
||||||
|
}
|
||||||
|
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->in('sa.id', ':socialactions');
|
$clause = $qb->expr()->in('sa.id', ':socialactions');
|
||||||
|
@ -50,10 +50,12 @@ class SocialIssueFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->in('si.id', ':socialissues');
|
$clause = $qb->expr()->in('acpsocialissue.id', ':socialissues');
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user