mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
Merge branch '111_exports' into social_action_exports
This commit is contained in:
@@ -78,10 +78,10 @@ final class EvaluationAggregator implements AggregatorInterface
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb
|
||||
->join('acp.works', 'acpw')
|
||||
->join('acpw.accompanyingPeriodWorkEvaluations', 'we')
|
||||
;
|
||||
if (!in_array('acpw', $qb->getAllAliases())) {
|
||||
$qb->join('acp.works', 'acpw');
|
||||
}
|
||||
$qb->join('acpw.accompanyingPeriodWorkEvaluations', 'we');
|
||||
|
||||
$qb->addSelect('IDENTITY(we.evaluation) AS evaluation_aggregator');
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator;
|
||||
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\UserJobRepository;
|
||||
@@ -80,21 +80,9 @@ final class JobAggregator implements AggregatorInterface
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
switch ($this->getBaseEntityAppliedOn($qb)) {
|
||||
$qb->join('acp.job', 'j');
|
||||
|
||||
case 'acp':
|
||||
$qb->join('acp.job', 'j');
|
||||
$qb->addSelect('IDENTITY(acp.job) AS job_aggregator');
|
||||
break;
|
||||
|
||||
case 'acpw':
|
||||
$qb->join('acpw.referrers', 'r');
|
||||
$qb->addSelect('IDENTITY(r.userJob) as job_aggregator');
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \Exception("Does not apply on that base entity");
|
||||
}
|
||||
$qb->addSelect('IDENTITY(acp.job) AS job_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
@@ -110,14 +98,6 @@ final class JobAggregator implements AggregatorInterface
|
||||
*/
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ACP_SHARED;
|
||||
}
|
||||
|
||||
private function getBaseEntityAppliedOn(QueryBuilder $qb): string
|
||||
{
|
||||
/** @var From $from */
|
||||
$from = $qb->getDQLPart('from');
|
||||
|
||||
return $from[0]->getAlias();
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
}
|
@@ -9,7 +9,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator;
|
||||
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\UserRepository;
|
||||
@@ -40,21 +40,9 @@ final class ReferrerAggregator implements AggregatorInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
switch ($this->getBaseEntityAppliedOn($qb)) {
|
||||
$qb->join('acp.user', 'u');
|
||||
|
||||
case 'acp':
|
||||
$qb->join('acp.user', 'u');
|
||||
$qb->addSelect('u.id AS referrer_aggregator');
|
||||
break;
|
||||
|
||||
case 'acpw':
|
||||
$qb->join('acpw.referrers', 'r');
|
||||
$qb->addSelect('r.id AS referrer_aggregator');
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \Exception("Does not apply on that base entity");
|
||||
}
|
||||
$qb->addSelect('u.id AS referrer_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
@@ -68,7 +56,7 @@ final class ReferrerAggregator implements AggregatorInterface
|
||||
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ACP_SHARED;
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
@@ -98,12 +86,4 @@ final class ReferrerAggregator implements AggregatorInterface
|
||||
{
|
||||
return 'Group by referrers';
|
||||
}
|
||||
|
||||
private function getBaseEntityAppliedOn(QueryBuilder $qb): string
|
||||
{
|
||||
/** @var From $from */
|
||||
$from = $qb->getDQLPart('from');
|
||||
|
||||
return $from[0]->getAlias();
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator;
|
||||
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\ScopeRepository;
|
||||
@@ -80,21 +80,9 @@ final class ScopeAggregator implements AggregatorInterface
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
switch ($this->getBaseEntityAppliedOn($qb)) {
|
||||
$qb->join('acp.scopes', 's');
|
||||
|
||||
case 'acp':
|
||||
$qb->join('acp.scopes', 's');
|
||||
$qb->addSelect('s.id as scope_aggregator');
|
||||
break;
|
||||
|
||||
case 'acpw':
|
||||
$qb->join('acpw.referrers', 'r');
|
||||
$qb->addSelect('IDENTITY(r.mainScope) as scope_aggregator');
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \Exception("Does not apply on that base entity");
|
||||
}
|
||||
$qb->addSelect('s.id as scope_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
@@ -110,14 +98,6 @@ final class ScopeAggregator implements AggregatorInterface
|
||||
*/
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ACP_SHARED;
|
||||
}
|
||||
|
||||
private function getBaseEntityAppliedOn(QueryBuilder $qb): string
|
||||
{
|
||||
/** @var From $from */
|
||||
$from = $qb->getDQLPart('from');
|
||||
|
||||
return $from[0]->getAlias();
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
}
|
@@ -76,7 +76,9 @@ final class SocialActionAggregator implements AggregatorInterface
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb->join('acp.works', 'acpw');
|
||||
if (!in_array('acpw', $qb->getAllAliases())) {
|
||||
$qb->join('acp.works', 'acpw');
|
||||
}
|
||||
|
||||
$qb->addSelect('IDENTITY(acpw.socialAction) AS socialaction_aggregator'); // DISTINCT ??
|
||||
|
||||
|
@@ -76,8 +76,7 @@ class EvaluationTypeAggregator implements AggregatorInterface
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb->join('eval.evaluation', 'ev');
|
||||
$qb->addSelect('ev.id AS evaluationtype_aggregator');
|
||||
$qb->addSelect('IDENTITY(eval.evaluation) AS evaluationtype_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
|
@@ -76,6 +76,10 @@ class ChildrenNumberAggregator implements AggregatorInterface
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('composition', $qb->getAllAliases())) {
|
||||
$qb->join('household.compositions', 'composition');
|
||||
}
|
||||
|
||||
$qb->addSelect('composition.numberOfChildren AS childrennumber_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
@@ -83,6 +83,10 @@ class CompositionAggregator implements AggregatorInterface
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('composition', $qb->getAllAliases())) {
|
||||
$qb->join('household.compositions', 'composition');
|
||||
}
|
||||
|
||||
$qb->addSelect('IDENTITY(composition.householdCompositionType) AS composition_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\UserJobRepository;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\Query\Expr\From;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
final class JobAggregator implements AggregatorInterface
|
||||
{
|
||||
|
||||
private UserJobRepository $jobRepository;
|
||||
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
public function __construct(
|
||||
UserJobRepository $jobRepository,
|
||||
TranslatableStringHelper $translatableStringHelper
|
||||
) {
|
||||
$this->jobRepository = $jobRepository;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
return function($value): string {
|
||||
if ($value === '_header') {
|
||||
return 'Job';
|
||||
}
|
||||
|
||||
$j = $this->jobRepository->find($value);
|
||||
|
||||
return $this->translatableStringHelper->localize(
|
||||
$j->getLabel()
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return ['job_aggregator'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
// no form
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Group by treating agent job';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addRole()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb->join('acpw.referrers', 'u');
|
||||
|
||||
$qb->addSelect('IDENTITY(u.userJob) as job_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
if (!empty($groupBy)) {
|
||||
$qb->addGroupBy('job_aggregator');
|
||||
} else {
|
||||
$qb->groupBy('job_aggregator');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::SOCIAL_WORK_ACTION_TYPE;
|
||||
}
|
||||
}
|
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\UserRepository;
|
||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\Query\Expr\From;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
final class ReferrerAggregator implements AggregatorInterface
|
||||
{
|
||||
private UserRepository $userRepository;
|
||||
|
||||
private UserRender $userRender;
|
||||
|
||||
public function __construct(
|
||||
UserRepository $userRepository,
|
||||
UserRender $userRender
|
||||
) {
|
||||
$this->userRepository = $userRepository;
|
||||
$this->userRender = $userRender;
|
||||
}
|
||||
|
||||
public function addRole()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb->join('acpw.referrers', 'u');
|
||||
|
||||
$qb->addSelect('u.id AS referrer_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
if (!empty($groupBy)) {
|
||||
$qb->addGroupBy('referrer_aggregator');
|
||||
} else {
|
||||
$qb->groupBy('referrer_aggregator');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::SOCIAL_WORK_ACTION_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
// no form
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
return 'Referrer';
|
||||
}
|
||||
|
||||
$r = $this->userRepository->find($value);
|
||||
|
||||
return $this->userRender->renderString($r, []);
|
||||
};
|
||||
}
|
||||
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return ['referrer_aggregator'];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Group by treating agent';
|
||||
}
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\ScopeRepository;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\Query\Expr\From;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
final class ScopeAggregator implements AggregatorInterface
|
||||
{
|
||||
|
||||
private ScopeRepository $scopeRepository;
|
||||
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
public function __construct(
|
||||
ScopeRepository $scopeRepository,
|
||||
TranslatableStringHelper $translatableStringHelper
|
||||
) {
|
||||
$this->scopeRepository = $scopeRepository;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
return function ($value): string {
|
||||
if ($value === '_header') {
|
||||
return 'Scope';
|
||||
}
|
||||
|
||||
$s = $this->scopeRepository->find($value);
|
||||
|
||||
return $this->translatableStringHelper->localize(
|
||||
$s->getName()
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return ['scope_aggregator'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
// no form
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Group by treating agent scope';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addRole()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb->join('acpw.referrers', 'u');
|
||||
|
||||
$qb->addSelect('IDENTITY(u.mainScope) as scope_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
if (!empty($groupBy)) {
|
||||
$qb->addGroupBy('scope_aggregator');
|
||||
} else {
|
||||
$qb->groupBy('scope_aggregator');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::SOCIAL_WORK_ACTION_TYPE;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user