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
This commit is contained in:
parent
81359877c4
commit
1dcff2f23c
68
exports_alias_conventions.csv
Normal file
68
exports_alias_conventions.csv
Normal file
@ -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
|
|
76
exports_alias_conventions.md
Normal file
76
exports_alias_conventions.md
Normal file
@ -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 |
|
@ -40,11 +40,11 @@ class BySocialActionAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('socialaction', $qb->getAllAliases(), true)) {
|
if (!in_array('actsocialaction', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.socialActions', 'socialaction');
|
$qb->join('activity.socialActions', 'actsocialaction');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect('socialaction.id AS socialaction_aggregator');
|
$qb->addSelect('actsocialaction.id AS socialaction_aggregator');
|
||||||
|
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ class BySocialIssueAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('socialissue', $qb->getAllAliases(), true)) {
|
if (!in_array('actsocialissue', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.socialIssues', 'socialissue');
|
$qb->join('activity.socialIssues', 'actsocialissue');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect('socialissue.id AS socialissue_aggregator');
|
$qb->addSelect('actsocialissue.id AS socialissue_aggregator');
|
||||||
|
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ class ByThirdpartyAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('thirdparty', $qb->getAllAliases(), true)) {
|
if (!in_array('acttparty', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.thirdParties', 'thirdparty');
|
$qb->join('activity.thirdParties', 'acttparty');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect('thirdparty.id AS thirdparty_aggregator');
|
$qb->addSelect('acttparty.id AS thirdparty_aggregator');
|
||||||
|
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ class ByUserAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('user', $qb->getAllAliases(), true)) {
|
if (!in_array('actusers', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.users', 'user');
|
$qb->join('activity.users', 'actusers');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect('user.id AS users_aggregator');
|
$qb->addSelect('actusers.id AS users_aggregator');
|
||||||
|
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ class LocationTypeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('location', $qb->getAllAliases(), true)) {
|
if (!in_array('actloc', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.location', 'location');
|
$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');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ class UserScopeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('user', $qb->getAllAliases(), true)) {
|
if (!in_array('actuser', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.user', 'user');
|
$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');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ class ActivityTypeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('aty', $qb->getAllAliases(), true)) {
|
if (!in_array('acttype', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.activityType', 'aty');
|
$qb->join('activity.activityType', 'acttype');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect(sprintf('IDENTITY(activity.activityType) AS %s', self::KEY));
|
$qb->addSelect(sprintf('IDENTITY(activity.activityType) AS %s', self::KEY));
|
||||||
@ -94,23 +94,4 @@ class ActivityTypeAggregator implements AggregatorInterface
|
|||||||
{
|
{
|
||||||
return 'Aggregate by activity type';
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -67,29 +67,15 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali
|
|||||||
$qb->addSelect($elem . ' as ' . $alias);
|
$qb->addSelect($elem . ' as ' . $alias);
|
||||||
|
|
||||||
// make a jointure only if needed
|
// make a jointure only if needed
|
||||||
$join = $qb->getDQLPart('join');
|
if (!in_array( 'actreasons', $qb->getAllAliases(), true)) {
|
||||||
|
$qb->innerJoin('activity.reasons', 'actreasons');
|
||||||
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
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// join category if necessary
|
// join category if necessary
|
||||||
if ('activity_categories_id' === $alias) {
|
if ('activity_categories_id' === $alias) {
|
||||||
// add join only if needed
|
// add join only if needed
|
||||||
if (!$this->checkJoinAlreadyDefined($qb->getDQLPart('join')['activity'], 'category')) {
|
if (!in_array('actreasoncat', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('reasons.category', 'category');
|
$qb->join('actreasons.category', 'actreasoncat');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,23 +179,4 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali
|
|||||||
->addViolation();
|
->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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ class AvgActivityDuration 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('activity')
|
$qb = $this->repository->createQueryBuilder('activity')
|
||||||
->join('activity.accompanyingPeriod', 'acp');
|
->join('activity.accompanyingPeriod', 'actacp');
|
||||||
|
|
||||||
$qb->select('AVG(activity.durationTime) as export_avg_activity_duration');
|
$qb->select('AVG(activity.durationTime) as export_avg_activity_duration');
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac
|
|||||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||||
{
|
{
|
||||||
$qb = $this->repository->createQueryBuilder('activity')
|
$qb = $this->repository->createQueryBuilder('activity')
|
||||||
->join('activity.accompanyingPeriod', 'acp');
|
->join('activity.accompanyingPeriod', 'actacp');
|
||||||
|
|
||||||
$qb->select('AVG(activity.travelTime) as export_avg_activity_visit_duration');
|
$qb->select('AVG(activity.travelTime) as export_avg_activity_visit_duration');
|
||||||
|
|
||||||
|
@ -84,8 +84,11 @@ class CountActivity 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('activity')
|
$qb = $this->repository->createQueryBuilder('activity');
|
||||||
->join('activity.accompanyingPeriod', 'acp');
|
|
||||||
|
if (!in_array('actacp', $qb->getAllAliases(), true)) {
|
||||||
|
$qb->join('activity.accompanyingPeriod', 'actacp');
|
||||||
|
}
|
||||||
|
|
||||||
$qb->select('COUNT(activity.id) as export_count_activity');
|
$qb->select('COUNT(activity.id) as export_count_activity');
|
||||||
|
|
||||||
|
@ -83,8 +83,11 @@ class SumActivityDuration 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('activity')
|
$qb = $this->repository->createQueryBuilder('activity');
|
||||||
->join('activity.accompanyingPeriod', 'acp');
|
|
||||||
|
if (!in_array('actacp', $qb->getAllAliases(), true)) {
|
||||||
|
$qb->join('activity.accompanyingPeriod', 'actacp');
|
||||||
|
}
|
||||||
|
|
||||||
$qb->select('SUM(activity.durationTime) as export_sum_activity_duration');
|
$qb->select('SUM(activity.durationTime) as export_sum_activity_duration');
|
||||||
|
|
||||||
|
@ -83,8 +83,11 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac
|
|||||||
|
|
||||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||||
{
|
{
|
||||||
$qb = $this->repository->createQueryBuilder('activity')
|
$qb = $this->repository->createQueryBuilder('activity');
|
||||||
->join('activity.accompanyingPeriod', 'acp');
|
|
||||||
|
if (!in_array('actacp', $qb->getAllAliases(), true)) {
|
||||||
|
$qb->join('activity.accompanyingPeriod', 'actacp');
|
||||||
|
}
|
||||||
|
|
||||||
$qb->select('SUM(activity.travelTime) as export_sum_activity_visit_duration');
|
$qb->select('SUM(activity.travelTime) as export_sum_activity_visit_duration');
|
||||||
|
|
||||||
|
@ -84,8 +84,11 @@ class CountActivity implements ExportInterface, GroupedExportInterface
|
|||||||
{
|
{
|
||||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
||||||
|
|
||||||
$qb = $this->activityRepository->createQueryBuilder('activity')
|
$qb = $this->activityRepository->createQueryBuilder('activity');
|
||||||
->join('activity.person', 'person');
|
|
||||||
|
if (!in_array('actperson', $qb->getAllAliases(), true)) {
|
||||||
|
$qb->join('activity.person', 'actperson');
|
||||||
|
}
|
||||||
|
|
||||||
$qb->select('COUNT(activity.id) as export_count_activity');
|
$qb->select('COUNT(activity.id) as export_count_activity');
|
||||||
|
|
||||||
|
@ -210,9 +210,9 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
|||||||
|
|
||||||
$qb
|
$qb
|
||||||
->from('ChillActivityBundle:Activity', 'activity')
|
->from('ChillActivityBundle:Activity', 'activity')
|
||||||
->join('activity.person', 'person')
|
->join('activity.person', 'actperson')
|
||||||
->join('person.center', 'center')
|
->join('actperson.center', 'actcenter')
|
||||||
->andWhere('center IN (:authorized_centers)')
|
->andWhere('actcenter IN (:authorized_centers)')
|
||||||
->setParameter('authorized_centers', $centers);
|
->setParameter('authorized_centers', $centers);
|
||||||
|
|
||||||
foreach ($this->fields as $f) {
|
foreach ($this->fields as $f) {
|
||||||
@ -239,8 +239,8 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'user_username':
|
case 'user_username':
|
||||||
$qb->join('activity.user', 'user');
|
$qb->join('activity.user', 'actuser');
|
||||||
$qb->addSelect('user.username AS user_username');
|
$qb->addSelect('actuser.username AS user_username');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -120,9 +120,9 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $qb->select($select)
|
return $qb->select($select)
|
||||||
->join('activity.person', 'person')
|
->join('activity.person', 'actperson')
|
||||||
->join('person.center', 'center')
|
->join('actperson.center', 'actcenter')
|
||||||
->where($qb->expr()->in('center', ':centers'))
|
->where($qb->expr()->in('actcenter', ':centers'))
|
||||||
->setParameter(':centers', $centers);
|
->setParameter(':centers', $centers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,11 +39,11 @@ class BySocialActionFilter implements FilterInterface
|
|||||||
{
|
{
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
|
|
||||||
if (!in_array('socialaction', $qb->getAllAliases(), true)) {
|
if (!in_array('actsocialaction', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.socialActions', 'socialaction');
|
$qb->join('activity.socialActions', 'actsocialaction');
|
||||||
}
|
}
|
||||||
|
|
||||||
$clause = $qb->expr()->in('socialaction.id', ':socialactions');
|
$clause = $qb->expr()->in('actsocialaction.id', ':socialactions');
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
|
@ -39,11 +39,11 @@ class BySocialIssueFilter implements FilterInterface
|
|||||||
{
|
{
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
|
|
||||||
if (!in_array('socialissue', $qb->getAllAliases(), true)) {
|
if (!in_array('actsocialissue', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.socialIssues', 'socialissue');
|
$qb->join('activity.socialIssues', 'actsocialissue');
|
||||||
}
|
}
|
||||||
|
|
||||||
$clause = $qb->expr()->in('socialissue.id', ':socialissues');
|
$clause = $qb->expr()->in('actsocialissue.id', ':socialissues');
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
|
@ -39,11 +39,11 @@ class ByUserFilter implements FilterInterface
|
|||||||
{
|
{
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
|
|
||||||
if (!in_array('user', $qb->getAllAliases(), true)) {
|
if (!in_array('actusers', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.users', 'user');
|
$qb->join('activity.users', 'actusers');
|
||||||
}
|
}
|
||||||
|
|
||||||
$clause = $qb->expr()->in('user.id', ':users');
|
$clause = $qb->expr()->in('actusers.id', ':users');
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
|
@ -37,12 +37,12 @@ class LocationTypeFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('location', $qb->getAllAliases(), true)) {
|
if (!in_array('actloc', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.location', 'location');
|
$qb->join('activity.location', 'actloc');
|
||||||
}
|
}
|
||||||
|
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->in('location.locationType', ':locationtype');
|
$clause = $qb->expr()->in('actloc.locationType', ':locationtype');
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
|
@ -37,13 +37,13 @@ class UserScopeFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('user', $qb->getAllAliases(), true)) {
|
if (!in_array('actuser', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.user', 'user');
|
$qb->join('activity.user', 'actuser');
|
||||||
}
|
}
|
||||||
|
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
|
|
||||||
$clause = $qb->expr()->in('user.mainScope', ':userscope');
|
$clause = $qb->expr()->in('actuser.mainScope', ':userscope');
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
|
@ -102,23 +102,4 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter
|
|||||||
->addViolation();
|
->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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -52,20 +52,9 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt
|
|||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
$join = $qb->getDQLPart('join');
|
$join = $qb->getDQLPart('join');
|
||||||
$clause = $qb->expr()->in('reasons', ':selected_activity_reasons');
|
$clause = $qb->expr()->in('reasons', ':selected_activity_reasons');
|
||||||
//dump($join);
|
|
||||||
// add a join to reasons only if needed
|
if (!in_array('actreasons', $qb->getAllAliases(), true)) {
|
||||||
if (
|
$qb->join('activity.reasons', 'actreasons');
|
||||||
(
|
|
||||||
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 ($where instanceof Expr\Andx) {
|
if ($where instanceof Expr\Andx) {
|
||||||
@ -123,21 +112,4 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt
|
|||||||
->addViolation();
|
->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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -40,9 +40,11 @@ final class AgentAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -41,7 +41,9 @@ class CancelReasonAggregator implements AggregatorInterface
|
|||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
// TODO: still needs to take into account appointments without a cancel reason somehow
|
// 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');
|
$qb->addSelect('IDENTITY(cal.cancelReason) as cancel_reason_aggregator');
|
||||||
|
|
||||||
|
@ -40,9 +40,11 @@ final class JobAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -36,7 +36,9 @@ final class LocationAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$qb->addSelect('IDENTITY(cal.location) as location_aggregator');
|
||||||
|
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
@ -40,9 +40,11 @@ final class LocationTypeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -40,9 +40,11 @@ final class ScopeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -42,10 +42,12 @@ class JobFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->in('u.userJob', ':job');
|
$clause = $qb->expr()->in('caluser.userJob', ':job');
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
|
@ -42,10 +42,12 @@ class ScopeFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->in('u.mainScope', ':scope');
|
$clause = $qb->expr()->in('caluser.mainScope', ':scope');
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
|
@ -48,12 +48,12 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl
|
|||||||
$qb->resetDQLPart('from');
|
$qb->resetDQLPart('from');
|
||||||
$qb->from(HouseholdMember::class, 'member');
|
$qb->from(HouseholdMember::class, 'member');
|
||||||
|
|
||||||
if (!in_array('person', $qb->getAllAliases(), true)) {
|
if (!in_array('memberperson', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('member.person', 'person');
|
$qb->join('member.person', 'memberperson');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array('center', $qb->getAllAliases(), true)) {
|
if (!in_array('membercenter', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('person.center', 'center');
|
$qb->join('memberperson.center', 'membercenter');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->andWhere($qb->expr()->andX(
|
$qb->andWhere($qb->expr()->andX(
|
||||||
|
@ -37,8 +37,11 @@ final class MaritalStatusAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$qb->join('person.maritalStatus', 'ms');
|
if (!in_array('personmarital', $qb->getAllAliases(), true)) {
|
||||||
$qb->addSelect('ms.id as marital_status_aggregator');
|
$qb->join('person.maritalStatus', 'personmarital');
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->addSelect('personmarital.id as marital_status_aggregator');
|
||||||
|
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -38,8 +38,11 @@ final class ActionTypeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$qb->join('acpw.socialAction', 'sa');
|
if (!in_array('acpwsocialaction', $qb->getAllAliases(), true)) {
|
||||||
$qb->addSelect('sa.id as action_type_aggregator');
|
$qb->join('acpw.socialAction', 'acpwsocialaction');
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->addSelect('acpwsocialaction.id as action_type_aggregator');
|
||||||
|
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -37,8 +37,11 @@ final class GoalAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$qb->join('acpw.goals', 'g');
|
if (!in_array('goal', $qb->getAllAliases(), true)) {
|
||||||
$qb->addSelect('g.id as goal_aggregator');
|
$qb->join('acpw.goals', 'goal');
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->addSelect('goal.id as goal_aggregator');
|
||||||
|
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -39,9 +39,11 @@ final class JobAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -39,9 +39,11 @@ final class ReferrerAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -37,10 +37,19 @@ final class ResultAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$qb->join('acpw.results', 'res');
|
if (!in_array('acpwresult', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('acpw.goals', 'g');
|
$qb->join('acpw.results', 'acpwresult');
|
||||||
$qb->join('g.results', 'gres');
|
}
|
||||||
$qb->addSelect('res.id, IDENTITY(g.results) as result_aggregator');
|
|
||||||
|
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');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -39,9 +39,11 @@ final class ScopeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
@ -45,12 +45,16 @@ class ActivityTypeFilter implements FilterInterface
|
|||||||
$qb->resetDQLPart('from');
|
$qb->resetDQLPart('from');
|
||||||
$qb->from('ChillActivityBundle:Activity', 'activity');
|
$qb->from('ChillActivityBundle:Activity', 'activity');
|
||||||
|
|
||||||
$qb
|
if (!in_array('actacp', $qb->getAllAliases(), true)) {
|
||||||
->join('activity.accompanyingPeriod', 'acp')
|
$qb->join('activity.accompanyingPeriod', 'actacp');
|
||||||
->join('activity.activityType', 'aty');
|
}
|
||||||
|
|
||||||
|
if (!in_array('acttype', $qb->getAllAliases(), true)) {
|
||||||
|
$qb->join('activity.activityType', 'acttype');
|
||||||
|
}
|
||||||
|
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->in('aty.id', ':activitytypes');
|
$clause = $qb->expr()->in('acttype.id', ':activitytypes');
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
|
@ -47,12 +47,12 @@ class SocialActionFilter implements FilterInterface
|
|||||||
$qb->join('acp.works', 'acpw');
|
$qb->join('acp.works', 'acpw');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array('acpw', $qb->getAllAliases(), true)) {
|
if (!in_array('acpwsocialaction', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('acpw.socialAction', 'sa');
|
$qb->join('acpw.socialAction', 'acpwsocialaction');
|
||||||
}
|
}
|
||||||
|
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->in('sa.id', ':socialactions');
|
$clause = $qb->expr()->in('acpwsocialaction.id', ':socialactions');
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
|
@ -39,18 +39,29 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface
|
|||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$qb->resetDQLPart('from');
|
$qb->resetDQLPart('from');
|
||||||
$qb->from('ChillPersonBundle:Person\ResidentialAddress', 'ra');
|
$qb->from('ChillPersonBundle:Person\ResidentialAddress', 'resaddr');
|
||||||
|
|
||||||
$qb->join('ra.person', 'person');
|
if (!in_array('resaddrperson', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('person.center', 'center');
|
$qb->join('resaddr.person', 'resaddrperson');
|
||||||
$qb->join('ra.hostThirdParty', 't');
|
}
|
||||||
$qb->join('t.categories', 'tc');
|
|
||||||
|
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');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->andX(
|
$clause = $qb->expr()->andX(
|
||||||
$qb->expr()->isNotNull('ra.hostThirdParty'),
|
$qb->expr()->isNotNull('resaddr.hostThirdParty'),
|
||||||
$qb->expr()->between(':date', 'ra.startDate', 'ra.endDate'),
|
$qb->expr()->between(':date', 'resaddr.startDate', 'resaddr.endDate'),
|
||||||
$qb->expr()->in('tc.id', ':type')
|
$qb->expr()->in('tpartycat.id', ':type')
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($where instanceof Expr\Andx) {
|
if ($where instanceof Expr\Andx) {
|
||||||
|
@ -26,13 +26,18 @@ class ResidentialAddressAtUserFilter implements FilterInterface
|
|||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$qb->resetDQLPart('from');
|
$qb->resetDQLPart('from');
|
||||||
$qb->from('ChillPersonBundle:Person\ResidentialAddress', 'ra');
|
$qb->from('ChillPersonBundle:Person\ResidentialAddress', 'resaddr');
|
||||||
|
|
||||||
$qb->join('ra.person', 'person');
|
if (!in_array('resaddrperson', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('person.center', 'center');
|
$qb->join('resaddr.person', 'resaddrperson');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_array('resaddrcenter', $qb->getAllAliases(), true)) {
|
||||||
|
$qb->join('resaddrperson.center', 'resaddrcenter');
|
||||||
|
}
|
||||||
|
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->isNotNull('ra.hostPerson');
|
$clause = $qb->expr()->isNotNull('resaddr.hostPerson');
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
|
@ -42,10 +42,12 @@ class JobFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->in('u.userJob', ':job');
|
$clause = $qb->expr()->in('acpwuser.userJob', ':job');
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
|
@ -36,10 +36,12 @@ class ReferrerFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->in('u', ':agents');
|
$clause = $qb->expr()->in('acpwuser', ':agents');
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
|
@ -42,10 +42,12 @@ class ScopeFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
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');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->in('u.mainScope', ':scope');
|
$clause = $qb->expr()->in('acpwuser.mainScope', ':scope');
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
|
@ -79,8 +79,8 @@ final class ReferrerFilterTest extends AbstractFilterTest
|
|||||||
->select('acpw.id'),
|
->select('acpw.id'),
|
||||||
$em->createQueryBuilder()
|
$em->createQueryBuilder()
|
||||||
->from('ChillPersonBundle:AccompanyingPeriod\AccompanyingPeriodWork', 'acpw')
|
->from('ChillPersonBundle:AccompanyingPeriod\AccompanyingPeriodWork', 'acpw')
|
||||||
->join('acpw.referrers', 'r')
|
->join('acpw.referrers', 'acpwuser')
|
||||||
->select('r.id'),
|
->select('acpwuser.id'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user