public function init()
 {
     $this->_service = DownloadReportService::getInstance();
     $this->_downloadTokenSrv = Download\Service\DownloadTokenService::getInstance();
 }
 public function validateCorrelationReport()
 {
     $reports = DownloadReportService::getInstance()->listAll();
     foreach ($reports as $report) {
         if ($report->params->reportType == ReportModel::CORRELATION) {
             throw new InvalidArgumentException('User already have a correlation report');
         }
     }
 }
 protected function _internalCreateWatcher($watcher)
 {
     return DownloadReportService::getInstance()->createWatcher($watcher);
 }
 public function createSupervisionReport($params, $type)
 {
     $reportPath = $this->getSupervisionReport($params, $type);
     if (!$reportPath) {
         return;
     }
     $watcher = $this->getMapper()->constructWatcherToTransaction();
     $watcher->entityType = 'report';
     $txId = uniqid('report-');
     $watcher->entityIds = array($txId);
     $watcher->params->reportType = $type;
     $watcher->params->params = $params;
     $watcher->params->fileName = $watcher->entityType . '-' . $params['fileType'] . ".csv";
     $reportSrv = DownloadReportService::getInstance();
     $reportSrv->createWatcher($watcher);
     $watcherSrv = WatcherService::getInstance();
     $event = $this->getMapper()->constructEventToTransaction();
     $event->entityType = 'report';
     $event->entityId = $txId;
     $event->hiddenData = array('path' => $reportPath);
     $watcherSrv->publishEvent($event);
     return $watcher;
 }
 public function init()
 {
     $this->_service = DownloadReportService::getInstance();
 }
Esempio n. 6
0
 /**
  * @param  string $id
  * @return void
  */
 public function delete($idOrModel)
 {
     if ($idOrModel instanceof UserModel) {
         $user = $idOrModel;
     } else {
         $user = $this->load($idOrModel);
     }
     parent::delete($user);
     try {
         $filterList = DownloadReportService::getInstance()->buildFilterList(array());
         DownloadReportService::getInstance()->deleteAll($filterList, array('overrideDefaultFilter' => array('owner' => $user->id)));
     } catch (\Exception $e) {
         \App::log()->warn($e);
         // Nothing to do
     }
     WatcherService::getInstance()->removeByScope('user', $user->id);
     try {
         $this->sendEmailRemove($user);
     } catch (\Exception $e) {
         \App::log()->ERR('[mailto:' . $user->getEmail() . '] ' . $e->getMessage());
     }
     return true;
 }