Skip to content
Snippets Groups Projects
Commit 51c9d75f authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

wip

parent 28f354a2
No related branches found
No related tags found
No related merge requests found
Showing
with 98 additions and 100 deletions
...@@ -44,6 +44,7 @@ services: ...@@ -44,6 +44,7 @@ services:
- .:/app - .:/app
- /tmp:/tmp - /tmp:/tmp
- /tmp/upload:/tmp/upload - /tmp/upload:/tmp/upload
- $HOME/.gitconfig:/root/.gitconfig
- $HOME/.ssh:/root/.ssh - $HOME/.ssh:/root/.ssh
- $HOME/.cache/composer:/root/.cache/composer - $HOME/.cache/composer:/root/.cache/composer
- $HOME/.config/composer/auth.json:/root/.config/composer/auth.json - $HOME/.config/composer/auth.json:/root/.config/composer/auth.json
......
...@@ -51,11 +51,6 @@ class AdmissionService extends BaseService ...@@ -51,11 +51,6 @@ class AdmissionService extends BaseService
private const DEFAULT_SOURCE_CODE = "SYG"; private const DEFAULT_SOURCE_CODE = "SYG";
/**
* @return AdmissionRepository
* @throws NotSupported
*/
public function getRepository(): AdmissionRepository public function getRepository(): AdmissionRepository
{ {
/** @var AdmissionRepository $repo */ /** @var AdmissionRepository $repo */
......
...@@ -5,7 +5,7 @@ namespace ApplicationFunctionalTest\Command; ...@@ -5,7 +5,7 @@ namespace ApplicationFunctionalTest\Command;
use Application\Command\CheckWSValidationFichierCinesCommand; use Application\Command\CheckWSValidationFichierCinesCommand;
use Application\Command\ShellCommandRunner; use Application\Command\ShellCommandRunner;
class CheckWSValidationFichierCinesCommandTest extends \PHPUnit_Framework_TestCase class CheckWSValidationFichierCinesCommandTest extends \PHPUnit\Framework\TestCase
{ {
public function test_throws_exception_if_sample_file_not_found() public function test_throws_exception_if_sample_file_not_found()
{ {
...@@ -124,7 +124,7 @@ class CheckWSValidationFichierCinesCommandTest extends \PHPUnit_Framework_TestCa ...@@ -124,7 +124,7 @@ class CheckWSValidationFichierCinesCommandTest extends \PHPUnit_Framework_TestCa
return $filePath; return $filePath;
} }
protected function tearDown() protected function tearDown(): void
{ {
if (file_exists($path = sys_get_temp_dir() . '/fake_script.sh')) { if (file_exists($path = sys_get_temp_dir() . '/fake_script.sh')) {
unlink($path); unlink($path);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace ApplicationFunctionalTest\Command; namespace ApplicationFunctionalTest\Command;
//class ValidationFichierCinesCommandTest extends \PHPUnit_Framework_TestCase //class ValidationFichierCinesCommandTest extends \PHPUnit\Framework\TestCase
//{ //{
// public function test_real_web_service_call_max_time() // public function test_real_web_service_call_max_time()
// { // {
......
...@@ -37,7 +37,7 @@ abstract class WorkflowServiceAbstractTest extends AbstractControllerTestCase ...@@ -37,7 +37,7 @@ abstract class WorkflowServiceAbstractTest extends AbstractControllerTestCase
$this->em()->flush($this->these); $this->em()->flush($this->these);
} }
public function tearDown() protected function tearDown(): void
{ {
$this->ep()->removeNewEntities(); $this->ep()->removeNewEntities();
} }
......
...@@ -8,7 +8,7 @@ use DateTime; ...@@ -8,7 +8,7 @@ use DateTime;
use Prophecy\Prophecy\ObjectProphecy; use Prophecy\Prophecy\ObjectProphecy;
use Prophecy\Prophet; use Prophecy\Prophet;
class NotificationDepotVersionCorrigeeAttenduRuleTest extends \PHPUnit_Framework_TestCase class NotificationDepotVersionCorrigeeAttenduRuleTest extends \PHPUnit\Framework\TestCase
{ {
public function test_retourne_date_null_si_date_butoire_null() public function test_retourne_date_null_si_date_butoire_null()
{ {
......
...@@ -7,7 +7,7 @@ use Fichier\Service\Fichier\FichierStorageServiceFactory; ...@@ -7,7 +7,7 @@ use Fichier\Service\Fichier\FichierStorageServiceFactory;
use UnicaenApp\Exception\RuntimeException; use UnicaenApp\Exception\RuntimeException;
use Interop\Container\ContainerInterface; use Interop\Container\ContainerInterface;
class FileServiceFactoryTest extends \PHPUnit_Framework_TestCase class FileServiceFactoryTest extends \PHPUnit\Framework\TestCase
{ {
/** @var ContainerInterface|\PHPUnit_Framework_MockObject_MockObject */ /** @var ContainerInterface|\PHPUnit_Framework_MockObject_MockObject */
private $container; private $container;
...@@ -15,7 +15,7 @@ class FileServiceFactoryTest extends \PHPUnit_Framework_TestCase ...@@ -15,7 +15,7 @@ class FileServiceFactoryTest extends \PHPUnit_Framework_TestCase
/** @var string */ /** @var string */
private $rootDirPath; private $rootDirPath;
protected function setUp() protected function setUp(): void
{ {
$this->container = $this->createMock(ContainerInterface::class); $this->container = $this->createMock(ContainerInterface::class);
$this->rootDirPath = '/tmp/' . uniqid('sygal_test_'); $this->rootDirPath = '/tmp/' . uniqid('sygal_test_');
......
...@@ -9,14 +9,14 @@ use Structure\Entity\Db\UniteRecherche; ...@@ -9,14 +9,14 @@ use Structure\Entity\Db\UniteRecherche;
use Fichier\Service\Fichier\FichierStorageService; use Fichier\Service\Fichier\FichierStorageService;
use UnicaenApp\Exception\RuntimeException; use UnicaenApp\Exception\RuntimeException;
class FileServiceTest extends \PHPUnit_Framework_TestCase class FileServiceTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @var \Fichier\Service\Fichier\FichierStorageService * @var \Fichier\Service\Fichier\FichierStorageService
*/ */
private $fileService; private $fileService;
protected function setUp() protected function setUp(): void
{ {
$this->fileService = new \Fichier\Service\Fichier\FichierStorageService(); $this->fileService = new \Fichier\Service\Fichier\FichierStorageService();
// $this->fileService->setRootDirectoryPathForUploadedFiles('/root/directory/path'); // $this->fileService->setRootDirectoryPathForUploadedFiles('/root/directory/path');
......
...@@ -14,7 +14,7 @@ use ApplicationUnitTest\Test\Provider\MockProviderAwareTrait; ...@@ -14,7 +14,7 @@ use ApplicationUnitTest\Test\Provider\MockProviderAwareTrait;
use DateTime; use DateTime;
use PHPUnit_Framework_MockObject_MockObject; use PHPUnit_Framework_MockObject_MockObject;
class NotifCorrectionAttendueTest extends \PHPUnit_Framework_TestCase class NotifCorrectionAttendueTest extends \PHPUnit\Framework\TestCase
{ {
use MockProviderAwareTrait; use MockProviderAwareTrait;
......
...@@ -7,21 +7,21 @@ use These\Service\These\TheseService; ...@@ -7,21 +7,21 @@ use These\Service\These\TheseService;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use PHPUnit_Framework_MockObject_MockObject; use PHPUnit_Framework_MockObject_MockObject;
use PHPUnit_Framework_TestCase; use \PHPUnit\Framework\TestCase;
class MockProvider class MockProvider
{ {
/** /**
* @var PHPUnit_Framework_TestCase * @var \PHPUnit\Framework\TestCase
*/ */
private $testCase; private $testCase;
/** /**
* MockProvider constructor. * MockProvider constructor.
* *
* @param PHPUnit_Framework_TestCase $testCase * @param \PHPUnit\Framework\TestCase $testCase
*/ */
public function __construct(PHPUnit_Framework_TestCase $testCase) public function __construct(\PHPUnit\Framework\TestCase $testCase)
{ {
$this->testCase = $testCase; $this->testCase = $testCase;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace ApplicationUnitTest\Test\Provider; namespace ApplicationUnitTest\Test\Provider;
use PHPUnit_Framework_TestCase; use \PHPUnit\Framework\TestCase;
trait MockProviderAwareTrait trait MockProviderAwareTrait
{ {
...@@ -17,10 +17,10 @@ trait MockProviderAwareTrait ...@@ -17,10 +17,10 @@ trait MockProviderAwareTrait
public function mp() public function mp()
{ {
if (null === $this->mockProvider) { if (null === $this->mockProvider) {
if (! $this instanceof PHPUnit_Framework_TestCase) { if (! $this instanceof \PHPUnit\Framework\TestCase) {
throw new \RuntimeException("La classe utilisant ce trait doit être du type " . PHPUnit_Framework_TestCase::class); throw new \RuntimeException("La classe utilisant ce trait doit être du type " . \PHPUnit\Framework\TestCase::class);
} }
/** @var PHPUnit_Framework_TestCase $this */ /** @var \PHPUnit\Framework\TestCase $this */
$this->mockProvider = new MockProvider($this); $this->mockProvider = new MockProvider($this);
} }
......
...@@ -7,7 +7,7 @@ use ApplicationUnitTest\TheseProphetTrait; ...@@ -7,7 +7,7 @@ use ApplicationUnitTest\TheseProphetTrait;
use ApplicationUnitTest\UserContextServiceProphetTrait; use ApplicationUnitTest\UserContextServiceProphetTrait;
use Prophecy\Prophet; use Prophecy\Prophet;
class DepotVersionCorrigeeTest extends \PHPUnit_Framework_TestCase class DepotVersionCorrigeeTest extends \PHPUnit\Framework\TestCase
{ {
use TheseProphetTrait; use TheseProphetTrait;
use UserContextServiceProphetTrait; use UserContextServiceProphetTrait;
......
...@@ -9,7 +9,7 @@ use ApplicationUnitTest\TheseProphetTrait; ...@@ -9,7 +9,7 @@ use ApplicationUnitTest\TheseProphetTrait;
use ApplicationUnitTest\UserContextServiceProphetTrait; use ApplicationUnitTest\UserContextServiceProphetTrait;
use Prophecy\Prophet; use Prophecy\Prophet;
class DepotVersionInitialeTest extends \PHPUnit_Framework_TestCase class DepotVersionInitialeTest extends \PHPUnit\Framework\TestCase
{ {
use TheseProphetTrait; use TheseProphetTrait;
use UserContextServiceProphetTrait; use UserContextServiceProphetTrait;
......
...@@ -9,7 +9,7 @@ use ApplicationUnitTest\TheseProphetTrait; ...@@ -9,7 +9,7 @@ use ApplicationUnitTest\TheseProphetTrait;
use ApplicationUnitTest\UserContextServiceProphetTrait; use ApplicationUnitTest\UserContextServiceProphetTrait;
use Prophecy\Prophet; use Prophecy\Prophet;
class TheseEntityAssertionTest extends \PHPUnit_Framework_TestCase class TheseEntityAssertionTest extends \PHPUnit\Framework\TestCase
{ {
use TheseProphetTrait; use TheseProphetTrait;
use UserContextServiceProphetTrait; use UserContextServiceProphetTrait;
......
...@@ -4,7 +4,7 @@ namespace DepotUnitTest\Filter; ...@@ -4,7 +4,7 @@ namespace DepotUnitTest\Filter;
use Depot\Filter\MotsClesFilter; use Depot\Filter\MotsClesFilter;
class MotsClesFilterTest extends \PHPUnit_Framework_TestCase class MotsClesFilterTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @var MotsClesFilter * @var MotsClesFilter
......
...@@ -145,7 +145,7 @@ create or replace view src_these as ...@@ -145,7 +145,7 @@ create or replace view src_these as
EOS; EOS;
} }
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
...@@ -157,7 +157,7 @@ EOS; ...@@ -157,7 +157,7 @@ EOS;
/** /**
* @throws \Exception * @throws \Exception
*/ */
protected function tearDown() protected function tearDown(): void
{ {
$this->restoreSrcTheseView(); $this->restoreSrcTheseView();
......
...@@ -12,6 +12,11 @@ use InscriptionAdministrative\Process\Reception\ReceptionProcess; ...@@ -12,6 +12,11 @@ use InscriptionAdministrative\Process\Reception\ReceptionProcess;
use InscriptionAdministrative\Process\Reception\ReceptionProcessFactory; use InscriptionAdministrative\Process\Reception\ReceptionProcessFactory;
use InscriptionAdministrative\Rule\Reception\ReceptionRule; use InscriptionAdministrative\Rule\Reception\ReceptionRule;
use InscriptionAdministrative\Rule\Reception\ReceptionRuleFactory; use InscriptionAdministrative\Rule\Reception\ReceptionRuleFactory;
use InscriptionAdministrative\Rule\Reception\ReceptionRulePluginManager;
use InscriptionAdministrative\Rule\Reception\ReceptionRulePluginManagerFactory;
use InscriptionAdministrative\Rule\Reception\StatutAnnulee\StatutAnnuleeRule;
use InscriptionAdministrative\Rule\Reception\StatutValidee\StatutValideeRule;
use InscriptionAdministrative\Rule\Reception\StatutValidee\StatutValideeRuleFactory;
use InscriptionAdministrative\Service\InscriptionAdministrativeService; use InscriptionAdministrative\Service\InscriptionAdministrativeService;
use InscriptionAdministrative\Service\InscriptionAdministrativeServiceFactory; use InscriptionAdministrative\Service\InscriptionAdministrativeServiceFactory;
use InscriptionAdministrative\Service\Search\InscriptionAdministrativeSearchService; use InscriptionAdministrative\Service\Search\InscriptionAdministrativeSearchService;
...@@ -160,7 +165,7 @@ return [ ...@@ -160,7 +165,7 @@ return [
InscriptionAdministrativeSearchService::class => InscriptionAdministrativeSearchServiceFactory::class, InscriptionAdministrativeSearchService::class => InscriptionAdministrativeSearchServiceFactory::class,
ImportProcessListener::class => ImportProcessListenerFactory::class, ImportProcessListener::class => ImportProcessListenerFactory::class,
ReceptionProcess::class => ReceptionProcessFactory::class, ReceptionProcess::class => ReceptionProcessFactory::class,
ReceptionRule::class => ReceptionRuleFactory::class, ReceptionRulePluginManager::class => ReceptionRulePluginManagerFactory::class,
] ]
] ]
]; ];
...@@ -5,23 +5,23 @@ namespace InscriptionAdministrative\Controller; ...@@ -5,23 +5,23 @@ namespace InscriptionAdministrative\Controller;
use Admission\Service\Admission\AdmissionServiceAwareTrait; use Admission\Service\Admission\AdmissionServiceAwareTrait;
use Application\Controller\AbstractController; use Application\Controller\AbstractController;
use Application\Service\AnneeUniv\AnneeUnivServiceAwareTrait; use Application\Service\AnneeUniv\AnneeUnivServiceAwareTrait;
use Doctorant\Service\DoctorantServiceAwareTrait;
use InscriptionAdministrative\Entity\Db\InscriptionAdministrative; use InscriptionAdministrative\Entity\Db\InscriptionAdministrative;
use InscriptionAdministrative\Process\Reception\ReceptionProcessAwareTrait; use InscriptionAdministrative\Process\Reception\ReceptionProcessAwareTrait;
use InscriptionAdministrative\Process\Reception\ReceptionProcessResult; use InscriptionAdministrative\Rule\Reception\ReceptionRulePluginManagerAwareTrait;
use InscriptionAdministrative\Rule\Reception\ReceptionRuleAwareTrait;
use InscriptionAdministrative\Service\InscriptionAdministrativeServiceAwareTrait; use InscriptionAdministrative\Service\InscriptionAdministrativeServiceAwareTrait;
use Laminas\Http\Response; use Laminas\Http\Response;
use Laminas\View\Model\ViewModel; use Laminas\View\Model\ViewModel;
use RuntimeException;
use UnicaenApp\Traits\MessageAwareInterface; use UnicaenApp\Traits\MessageAwareInterface;
class InscriptionAdministrativeController extends AbstractController class InscriptionAdministrativeController extends AbstractController
{ {
use ReceptionRuleAwareTrait;
use InscriptionAdministrativeServiceAwareTrait; use InscriptionAdministrativeServiceAwareTrait;
use AdmissionServiceAwareTrait; use AdmissionServiceAwareTrait;
use DoctorantServiceAwareTrait;
use AnneeUnivServiceAwareTrait; use AnneeUnivServiceAwareTrait;
use ReceptionRulePluginManagerAwareTrait;
use ReceptionProcessAwareTrait; use ReceptionProcessAwareTrait;
private InscriptionAdministrative $inscriptionAdministrative; private InscriptionAdministrative $inscriptionAdministrative;
...@@ -35,16 +35,19 @@ class InscriptionAdministrativeController extends AbstractController ...@@ -35,16 +35,19 @@ class InscriptionAdministrativeController extends AbstractController
{ {
$id = $this->params('id'); $id = $this->params('id');
/** @var \InscriptionAdministrative\Entity\Db\InscriptionAdministrative $inscriptionAdministrative */
$this->inscriptionAdministrative = $this->inscriptionAdministrativeService->getRepository()->findOneById($id); $this->inscriptionAdministrative = $this->inscriptionAdministrativeService->getRepository()->findOneById($id);
$inscriptionAdministrativeApprenant = $this->inscriptionAdministrative->getInscriptionAdministrativeApprenant();
$admission = $this->admissionService->getRepository()->findOneByNumeroCandidature( $admission = $this->admissionService->getRepository()->findOneByNumeroCandidature($this->inscriptionAdministrative->getNoCandidat());
$this->inscriptionAdministrative->getNoCandidat() $doctorantTrouveAvecCode = $this->doctorantService->getRepository()->findOneByCodeApprenant($inscriptionAdministrativeApprenant->getCode());
); $doctorantTrouveAvecINE = $this->doctorantService->getRepository()->findOneByIne($inscriptionAdministrativeApprenant->getINE());
$vm = new ViewModel([ $vm = new ViewModel([
'inscriptionAdministrative' => $this->inscriptionAdministrative, 'inscriptionAdministrative' => $this->inscriptionAdministrative,
'inscriptionAdministrativeApprenant' => $inscriptionAdministrativeApprenant,
'admission' => $admission, 'admission' => $admission,
'doctorantTrouveAvecCode' => $doctorantTrouveAvecCode,
'doctorantTrouveAvecINE' => $doctorantTrouveAvecINE,
'anneeUnivService' => $this->anneeUnivService, 'anneeUnivService' => $this->anneeUnivService,
]); ]);
...@@ -57,13 +60,13 @@ class InscriptionAdministrativeController extends AbstractController ...@@ -57,13 +60,13 @@ class InscriptionAdministrativeController extends AbstractController
private function createReceptionProcessChildModel(): ViewModel private function createReceptionProcessChildModel(): ViewModel
{ {
// Lancement de la Rule pour savoir si les conditions pour créer la thèse et le doctorant sont rassemblées. // Lancement de la Rule pour savoir si les conditions pour créer la thèse et le doctorant sont rassemblées.
$this->receptionRule->setInscriptionAdministrative($this->inscriptionAdministrative); $receptionRule = $this->receptionRulePluginManager->getRuleForInscriptionAdministrative($this->inscriptionAdministrative);
$this->receptionRule->execute(); $receptionRule->execute();
$childModel = new ViewModel(); $childModel = new ViewModel();
$childModel->setVariables([ $childModel->setVariables([
'inscriptionAdministrative' => $this->inscriptionAdministrative, 'inscriptionAdministrative' => $this->inscriptionAdministrative,
'receptionRule' => $this->receptionRule, 'receptionRule' => $receptionRule,
]); ]);
$childModel->setTemplate('inscription-administrative/inscription-administrative/partial/reception-process'); $childModel->setTemplate('inscription-administrative/inscription-administrative/partial/reception-process');
...@@ -96,15 +99,6 @@ class InscriptionAdministrativeController extends AbstractController ...@@ -96,15 +99,6 @@ class InscriptionAdministrativeController extends AbstractController
return $this->redirect()->toRoute('inscription-administrative/voir', ['id' => $this->inscriptionAdministrative->getId()]); return $this->redirect()->toRoute('inscription-administrative/voir', ['id' => $this->inscriptionAdministrative->getId()]);
} }
private function runReceptionProcess(bool $dryRun = false): ReceptionProcessResult
{
$this->receptionProcess->setInscriptionAdministrative($this->inscriptionAdministrative);
$this->receptionProcess->setDryRun($dryRun);
$this->receptionProcess->run();
return $this->receptionProcess->getResult();
}
private function getRequestedInscriptionAdministrative(): ?InscriptionAdministrative private function getRequestedInscriptionAdministrative(): ?InscriptionAdministrative
{ {
/** @var InscriptionAdministrative $inscriptionAdministrative */ /** @var InscriptionAdministrative $inscriptionAdministrative */
......
...@@ -4,8 +4,9 @@ namespace InscriptionAdministrative\Controller; ...@@ -4,8 +4,9 @@ namespace InscriptionAdministrative\Controller;
use Admission\Service\Admission\AdmissionService; use Admission\Service\Admission\AdmissionService;
use Application\Service\AnneeUniv\AnneeUnivService; use Application\Service\AnneeUniv\AnneeUnivService;
use Doctorant\Service\DoctorantService;
use InscriptionAdministrative\Process\Reception\ReceptionProcess; use InscriptionAdministrative\Process\Reception\ReceptionProcess;
use InscriptionAdministrative\Rule\Reception\ReceptionRule; use InscriptionAdministrative\Rule\Reception\ReceptionRulePluginManager;
use InscriptionAdministrative\Service\InscriptionAdministrativeService; use InscriptionAdministrative\Service\InscriptionAdministrativeService;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
...@@ -23,9 +24,9 @@ class InscriptionAdministrativeControllerFactory ...@@ -23,9 +24,9 @@ class InscriptionAdministrativeControllerFactory
$inscriptionAdministrativeService = $container->get(InscriptionAdministrativeService::class); $inscriptionAdministrativeService = $container->get(InscriptionAdministrativeService::class);
$controller->setInscriptionAdministrativeService($inscriptionAdministrativeService); $controller->setInscriptionAdministrativeService($inscriptionAdministrativeService);
/** @var ReceptionRule $receptionRule */ /** @var \InscriptionAdministrative\Rule\Reception\ReceptionRulePluginManager $receptionRulePluginManager */
$receptionRule = $container->get(ReceptionRule::class); $receptionRulePluginManager = $container->get(ReceptionRulePluginManager::class);
$controller->setReceptionRule($receptionRule); $controller->setReceptionRulePluginManager($receptionRulePluginManager);
/** @var \Application\Service\AnneeUniv\AnneeUnivService $anneeUnivService */ /** @var \Application\Service\AnneeUniv\AnneeUnivService $anneeUnivService */
$anneeUnivService = $container->get(AnneeUnivService::class); $anneeUnivService = $container->get(AnneeUnivService::class);
...@@ -35,6 +36,10 @@ class InscriptionAdministrativeControllerFactory ...@@ -35,6 +36,10 @@ class InscriptionAdministrativeControllerFactory
$admissionService = $container->get(AdmissionService::class); $admissionService = $container->get(AdmissionService::class);
$controller->setAdmissionService($admissionService); $controller->setAdmissionService($admissionService);
/** @var DoctorantService $doctorantService */
$doctorantService = $container->get(DoctorantService::class);
$controller->setDoctorantService($doctorantService);
/** @var ReceptionProcess $receptionProcess */ /** @var ReceptionProcess $receptionProcess */
$receptionProcess = $container->get(ReceptionProcess::class); $receptionProcess = $container->get(ReceptionProcess::class);
$controller->setReceptionProcess($receptionProcess); $controller->setReceptionProcess($receptionProcess);
......
...@@ -8,13 +8,15 @@ use Doctorant\Entity\Db\Doctorant; ...@@ -8,13 +8,15 @@ use Doctorant\Entity\Db\Doctorant;
use Doctorant\Service\DoctorantServiceAwareTrait; use Doctorant\Service\DoctorantServiceAwareTrait;
use Exception; use Exception;
use Individu\Service\IndividuServiceAwareTrait; use Individu\Service\IndividuServiceAwareTrait;
use InscriptionAdministrative\Entity\Db\InscriptionAdministrative;
use InscriptionAdministrative\Entity\Db\InscriptionAdministrativeApprenant; use InscriptionAdministrative\Entity\Db\InscriptionAdministrativeApprenant;
use InscriptionAdministrative\Entity\Db\InscriptionAdministrativeDoctorant; use InscriptionAdministrative\Entity\Db\InscriptionAdministrativeDoctorant;
use InscriptionAdministrative\Entity\Db\Traits\InscriptionAdministrativeAwareTrait; use InscriptionAdministrative\Entity\Db\Traits\InscriptionAdministrativeAwareTrait;
use InscriptionAdministrative\Process\AbstractProcess; use InscriptionAdministrative\Process\AbstractProcess;
use InscriptionAdministrative\Rule\Reception\ReceptionRuleAwareTrait; use InscriptionAdministrative\Rule\Reception\ReceptionRuleInterface;
use InscriptionAdministrative\Rule\Reception\ReceptionRulePluginManagerAwareTrait;
use InscriptionAdministrative\Service\InscriptionAdministrativeServiceAwareTrait; use InscriptionAdministrative\Service\InscriptionAdministrativeServiceAwareTrait;
use RuntimeException; use InvalidArgumentException;
use These\Entity\Db\These; use These\Entity\Db\These;
use These\Entity\Db\TheseAnneeUniv; use These\Entity\Db\TheseAnneeUniv;
use These\Service\These\TheseServiceAwareTrait; use These\Service\These\TheseServiceAwareTrait;
...@@ -24,7 +26,8 @@ use Webmozart\Assert\Assert; ...@@ -24,7 +26,8 @@ use Webmozart\Assert\Assert;
class ReceptionProcess extends AbstractProcess class ReceptionProcess extends AbstractProcess
{ {
use ReceptionRuleAwareTrait; use ReceptionRulePluginManagerAwareTrait;
use InscriptionAdministrativeServiceAwareTrait; use InscriptionAdministrativeServiceAwareTrait;
use IndividuServiceAwareTrait; use IndividuServiceAwareTrait;
use DoctorantServiceAwareTrait; use DoctorantServiceAwareTrait;
...@@ -42,25 +45,31 @@ class ReceptionProcess extends AbstractProcess ...@@ -42,25 +45,31 @@ class ReceptionProcess extends AbstractProcess
private ?These $these = null; private ?These $these = null;
private ?TheseAnneeUniv $theseAnneeUniv = null; private ?TheseAnneeUniv $theseAnneeUniv = null;
private ReceptionRuleInterface $receptionRule;
private ReceptionProcessResult $result; private ReceptionProcessResult $result;
/** public function setInscriptionAdministrative(InscriptionAdministrative $inscriptionAdministrative): void
* Point d'entrée.
*/
public function run(): void
{ {
$this->receptionRule->setInscriptionAdministrative($this->inscriptionAdministrative); $this->inscriptionAdministrative = $inscriptionAdministrative;
$this->receptionRule->execute();
$this->result = new ReceptionProcessResult();
/** @var InscriptionAdministrativeApprenant $iaApprenant */ /** @var InscriptionAdministrativeApprenant $iaApprenant */
$iaApprenant = $this->inscriptionAdministrative->getInscriptionAdministrativeApprenant(); $iaApprenant = $this->inscriptionAdministrative->getInscriptionAdministrativeApprenant();
if ($iaApprenant === null) { if ($iaApprenant === null) {
throw new RuntimeException("Anomalie : l'IA n'est liée à aucun apprenant"); throw new InvalidArgumentException("Anomalie : l'IA n'est liée à aucun apprenant");
} }
$this->inscriptionAdministrativeApprenant = $iaApprenant; $this->inscriptionAdministrativeApprenant = $iaApprenant;
}
/**
* Point d'entrée.
*/
public function run(): void
{
$this->receptionRule = $this->receptionRulePluginManager->getRuleForInscriptionAdministrative($this->inscriptionAdministrative);
$this->result = new ReceptionProcessResult();
$this->beginTransaction(); $this->beginTransaction();
try { try {
...@@ -90,18 +99,20 @@ class ReceptionProcess extends AbstractProcess ...@@ -90,18 +99,20 @@ class ReceptionProcess extends AbstractProcess
*/ */
private function process(): void private function process(): void
{ {
$this->receptionRule->execute();
if ($this->receptionRule->canCreateDoctorant()) { if ($this->receptionRule->canCreateDoctorant()) {
$this->createDoctorantFromApprenant(); $this->createDoctorant();
} else { } else {
$this->doctorant = $this->receptionRule->getDoctorant(); $this->doctorant = $this->receptionRule->getFoundDoctorant();
} }
if ($this->receptionRule->canUpdateDoctorant()) { if ($this->receptionRule->canUpdateDoctorant()) {
$this->updateDoctorantFromApprenant(); $this->updateDoctorant();
// NB : la mise à jour complète du doctorant inclue la màj du code apprenant // NB : la mise à jour complète du doctorant inclue la màj du code apprenant
} else { } else {
if ($this->receptionRule->canUpdateCodeApprenantDoctorantFromApprenant()) { if ($this->receptionRule->canUpdateCodeApprenantDoctorant()) {
$this->updateCodeApprenantDoctorantFromApprenant(); $this->updateCodeApprenantDoctorant();
} }
} }
...@@ -110,14 +121,14 @@ class ReceptionProcess extends AbstractProcess ...@@ -110,14 +121,14 @@ class ReceptionProcess extends AbstractProcess
} }
if ($this->receptionRule->canCreateThese()) { if ($this->receptionRule->canCreateThese()) {
$this->admission = $this->receptionRule->getAdmission(); $this->admission = $this->receptionRule->getFoundAdmission();
$this->createTheseFromAdmission(); $this->createThese();
} else { } else {
$this->these = $this->receptionRule->getThese(); // évite de fetcher à nouveau la thèse $this->these = $this->receptionRule->getFoundThese(); // évite de fetcher à nouveau la thèse
} }
if ($this->receptionRule->canCreateTheseAnneeUniv()) { if ($this->receptionRule->canCreateTheseAnneeUniv()) {
$this->createTheseAnneeUnivFromInscriptionAdministrative(); $this->createTheseAnneeUniv();
} }
if ($this->receptionRule->canLinkTheseAnneeUnivToInscriptionAdministrative()) { if ($this->receptionRule->canLinkTheseAnneeUnivToInscriptionAdministrative()) {
$this->linkTheseAnneeUnivToInscriptionAdministrative(); $this->linkTheseAnneeUnivToInscriptionAdministrative();
...@@ -128,7 +139,13 @@ class ReceptionProcess extends AbstractProcess ...@@ -128,7 +139,13 @@ class ReceptionProcess extends AbstractProcess
} }
} }
private function createDoctorantFromApprenant(): void public function getResult(): ReceptionProcessResult
{
return $this->result;
}
private function createDoctorant(): void
{ {
$etablissement = $this->inscriptionAdministrativeApprenant->getSource()->getEtablissement(); $etablissement = $this->inscriptionAdministrativeApprenant->getSource()->getEtablissement();
...@@ -147,7 +164,7 @@ class ReceptionProcess extends AbstractProcess ...@@ -147,7 +164,7 @@ class ReceptionProcess extends AbstractProcess
$this->result->setDoctorant($this->doctorant); $this->result->setDoctorant($this->doctorant);
} }
private function updateDoctorantFromApprenant(): void private function updateDoctorant(): void
{ {
$individu = $this->doctorant->getIndividu(); $individu = $this->doctorant->getIndividu();
$this->individuService->updateIndividuFromApprenant($individu, $this->inscriptionAdministrativeApprenant); $this->individuService->updateIndividuFromApprenant($individu, $this->inscriptionAdministrativeApprenant);
...@@ -165,7 +182,7 @@ class ReceptionProcess extends AbstractProcess ...@@ -165,7 +182,7 @@ class ReceptionProcess extends AbstractProcess
$this->result->setDoctorant($this->doctorant); $this->result->setDoctorant($this->doctorant);
} }
private function createTheseFromAdmission(): void private function createThese(): void
{ {
$this->these = $this->theseService->newTheseFromAdmission($this->admission, $this->doctorant); $this->these = $this->theseService->newTheseFromAdmission($this->admission, $this->doctorant);
$this->theseService->saveThese($this->these); $this->theseService->saveThese($this->these);
...@@ -180,7 +197,7 @@ class ReceptionProcess extends AbstractProcess ...@@ -180,7 +197,7 @@ class ReceptionProcess extends AbstractProcess
$this->result->setCreatedThese($this->these); $this->result->setCreatedThese($this->these);
} }
private function createTheseAnneeUnivFromInscriptionAdministrative(): void private function createTheseAnneeUniv(): void
{ {
Assert::notNull($this->these, "Incohérence dans l'algo : une thèse devrait être dispo !"); // todo : généraliser ce type de vérif ? Assert::notNull($this->these, "Incohérence dans l'algo : une thèse devrait être dispo !"); // todo : généraliser ce type de vérif ?
...@@ -203,7 +220,7 @@ class ReceptionProcess extends AbstractProcess ...@@ -203,7 +220,7 @@ class ReceptionProcess extends AbstractProcess
private function linkTheseAnneeUnivToInscriptionAdministrative(): void private function linkTheseAnneeUnivToInscriptionAdministrative(): void
{ {
$this->theseAnneeUniv = $this->receptionRule->getTheseAnneeUniv(); $this->theseAnneeUniv = $this->receptionRule->getFoundTheseAnneeUniv();
$this->theseAnneeUniv->setInscriptionAdministrative($this->inscriptionAdministrative); $this->theseAnneeUniv->setInscriptionAdministrative($this->inscriptionAdministrative);
$this->theseAnneeUnivService->save($this->theseAnneeUniv); $this->theseAnneeUnivService->save($this->theseAnneeUniv);
...@@ -214,7 +231,7 @@ class ReceptionProcess extends AbstractProcess ...@@ -214,7 +231,7 @@ class ReceptionProcess extends AbstractProcess
$this->result->addMessage($message, MessageAwareInterface::INFO); $this->result->addMessage($message, MessageAwareInterface::INFO);
} }
private function updateCodeApprenantDoctorantFromApprenant(): void private function updateCodeApprenantDoctorant(): void
{ {
$codeApprenant = $this->inscriptionAdministrativeApprenant->getCode(); $codeApprenant = $this->inscriptionAdministrativeApprenant->getCode();
$this->doctorant->setCodeApprenantInSource($codeApprenant); $this->doctorant->setCodeApprenantInSource($codeApprenant);
...@@ -256,23 +273,4 @@ class ReceptionProcess extends AbstractProcess ...@@ -256,23 +273,4 @@ class ReceptionProcess extends AbstractProcess
); );
$this->result->addMessage($message, MessageAwareInterface::INFO); $this->result->addMessage($message, MessageAwareInterface::INFO);
} }
/************************************************ IA annulée ****************************************************/
/**
* Cas d'une IA annulée.
*/
private function processInscriptionAnnulee(): void
{
// ?
}
/************************************************ Communs ****************************************************/
public function getResult(): ReceptionProcessResult
{
return $this->result;
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment