protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var User $user */
     $user = new User('tpateffoz', [], $this->getContainer()->getParameter('api_recolnat_user'), $this->getContainer()->getParameter('user_group'));
     $user->init($this->getContainer()->getParameter('export_path'));
     $testDir = $user->getDataDirPath() . 'test/';
     $testFile = $testDir . 'test.txt';
     $userGroup = $this->getContainer()->getParameter('user_group');
     UtilityService::createDir($testDir, $userGroup);
     UtilityService::createFile($testFile, $userGroup);
     $output->writeln($testDir);
 }
 /**
  * @param array  $datas
  * @param string $exportPath
  * @param string $userGroup
  */
 public function __construct($datas, $exportPath, $userGroup)
 {
     $this->datas = $datas;
     $this->exportPath = $exportPath;
     $this->userGroup = $userGroup;
     UtilityService::createDir($exportPath, $userGroup);
     foreach ($this->entitiesName as $className) {
         $entityExporterConstructor = '\\AppBundle\\Business\\Exporter\\Entity\\' . ucfirst($className) . 'Exporter';
         /* @var $entityExporter \AppBundle\Business\Exporter\Entity\AbstractEntityExporter */
         $this->arrayEntityExport[$className] = new $entityExporterConstructor();
     }
 }
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @return string
  * @throws \Exception
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->translator = $this->getContainer()->get('translator');
     $this->collectionCode = $input->getArgument('collectionCode');
     $this->institutionCode = $input->getArgument('institutionCode');
     $this->collection = $this->getContainer()->get('utility')->getCollection($this->institutionCode, $this->collectionCode);
     $this->setLogFilePath();
     $this->user = $this->getUser($input);
     $diffHandler = new DiffHandler($this->user->getDataDirPath(), $this->collection, $this->getContainer()->getParameter('user_group'));
     $this->collectionPath = $diffHandler->getCollectionPath();
     if (UtilityService::isDateWellFormatted($input->getArgument('startDate'))) {
         $this->startDate = \DateTime::createFromFormat('d/m/Y', $input->getArgument('startDate'));
     } else {
         $this->log($this->translator->trans($input->getArgument('username') . ' ' . 'access.denied.wrongDateFormat', [], 'exceptions'));
         throw new \Exception($this->translator->trans('access.denied.wrongDateFormat', [], 'exceptions'));
     }
     $this->log('startDate : ' . $this->startDate->format('c'));
     $this->log('Collection Code : ' . $this->collectionCode);
     $diffManager = $this->getContainer()->get('diff.manager');
     $diffManager->setCollectionCode($this->collectionCode);
     $diffManager->setStartDate($this->startDate);
     $diffManager->harvestDiffs();
     $diffComputer = $this->getContainer()->get('diff.computer');
     $diffComputer->setCollection($this->collection);
     $catalogNumbersFiles = $this->createCatalogNumbersFiles($diffManager, $diffHandler);
     try {
         $this->launchDiffProcesses($diffManager, $output);
         $mergeResult = $this->mergeFiles($diffManager::ENTITIES_NAME, $diffHandler->getCollectionPath());
         $diffHandler->saveData($mergeResult['data']);
         $diffHandler->saveTaxons($mergeResult['taxons']);
         $this->removeCatalogNumbersFiles($catalogNumbersFiles);
         $this->sendMail('success');
     } catch (ProcessFailedException $e) {
         $this->sendMail('error');
         throw $e;
     }
     $this->closeLogFile();
 }
Beispiel #4
0
 /**
  * @param Prefs $prefs
  */
 public function savePrefs(Prefs $prefs)
 {
     UtilityService::createFile($this->getPrefsFileName(), $this->userGroup);
     $handle = fopen($this->getPrefsFileName(), 'w');
     fwrite($handle, $prefs->toJson());
     fclose($handle);
 }
 /**
  * @param string $dirPath
  * @param string $userGroup
  */
 public function __construct($dirPath, $userGroup)
 {
     $path = UtilityService::createFile($dirPath . self::FILENAME, $userGroup);
     parent::__construct($path, 'c+');
 }
Beispiel #6
0
 /**
  * @param string $dirPath
  * @param string $userGroup
  */
 public function __construct($dirPath, $userGroup)
 {
     $filePath = UtilityService::createFile($dirPath . '/choices.json', $userGroup);
     parent::__construct($filePath, 'c+');
 }
 /**
  * @return string
  */
 public function getCollectionPath()
 {
     $institutionPath = $this->getPath() . '/' . $this->collection->getInstitution()->getInstitutioncode() . '/';
     UtilityService::createDir($institutionPath, $this->userGroup);
     $collectionPath = $institutionPath . $this->collection->getCollectioncode();
     return UtilityService::createDir($collectionPath, $this->userGroup);
 }
 /**
  * @param array $specimen
  * @return array
  */
 private function addKeys(array $specimen)
 {
     if (!is_null($specimen['Recolte'])) {
         $specimen['Specimen']['eventid'] = UtilityService::formatRawId($specimen['Recolte']['eventid']);
     }
     if (!is_null($specimen['Localisation'])) {
         $specimen['Recolte']['locationid'] = $specimen['Localisation']['locationid'];
     }
     if (count($specimen['Bibliography'])) {
         foreach ($specimen['Bibliography'] as $key => $item) {
             $specimen['Bibliography'][$key]['occurrenceid'] = UtilityService::formatRawId($specimen['Specimen']['occurrenceid']);
         }
     }
     if (count($specimen['Multimedia'])) {
         foreach ($specimen['Multimedia'] as $key => $item) {
             $specimen['Multimedia'][$key]['occurrenceid'] = UtilityService::formatRawId($specimen['Specimen']['occurrenceid']);
         }
     }
     if (!is_null($specimen['Stratigraphy'])) {
         $specimen['Specimen']['geologicalcontextid'] = $specimen['Stratigraphy']['geologicalcontextid'];
     }
     return $specimen;
 }