コード例 #1
0
 public function delete($idOrModel)
 {
     if ($idOrModel instanceof ModelAbstract) {
         $model = $idOrModel;
     } else {
         $model = $this->load($idOrModel);
     }
     $id = $model->getId();
     if (!$model || !isset($id)) {
         throw new InvalidArgumentException('Invalid Id');
     }
     $entityIds = $model->entityIds;
     $txId = array_shift($entityIds);
     ReportAsyncService::getInstance()->delete($txId);
     return parent::delete($model);
 }
コード例 #2
0
 public function postAction()
 {
     $reqData = $this->_helper->requestData();
     $reqKeys = array_keys($reqData);
     if (count($reqKeys) != 1) {
         throw new InvalidArgumentException("Report type is required as a main key");
     }
     $type = $reqKeys[0];
     $params = $reqData[$type];
     // Check report permissions by type
     $dumpReport = new ReportModel();
     $dumpReport->setType($type);
     if ($type !== ReportModel::AUDIT_LOG) {
         $this->_helper->allowed('create', $dumpReport);
     } else {
         $dumpAudit = new \Application\Model\AuditLogModel();
         $this->_helper->allowed('create', $dumpAudit);
     }
     // Custom download report name
     switch ($type) {
         case ReportModel::KPI_MONTHLY:
             $fileType = 'arpu';
             break;
         default:
             $fileType = $type;
     }
     if ($type !== ReportModel::AUDIT_LOG) {
         try {
             $headers = ReportAsyncService::getInstance()->getHeaders($type, $params);
             $dumpReport->setHeaders($headers);
             $this->_helper->filterNotAllowedCols("read_field", $dumpReport);
             $columns = array_keys($dumpReport->headers);
             if (isset($params['requiredFields'])) {
                 $columns = array_intersect($columns, $params['requiredFields']);
             }
             $params['columns'] = $columns;
         } catch (InvalidArgumentException $e) {
             \App::log()->info("Report {$type} does not have defined headers");
         }
     }
     $params['fileType'] = $fileType;
     $dumpReport->params = $params;
     //validate organization exists
     $validateOrgExist = new App_Validate_Ericsson_OrganizationExistsById();
     if (isset($params['orgId'])) {
         $result = $validateOrgExist->isValid($params['orgId']);
         if (!$result) {
             throw new InvalidArgumentException("Invalid parameter value: orgId. Supported values are orgId belonging to the current organization");
         }
     }
     try {
         $this->_service->create($dumpReport);
     } catch (Application\Exceptions\NotFoundException $e) {
         if ($e->getMessage() == "Resource supervisionGroup does not exists") {
             throw new InvalidArgumentException("Invalid parameter value supervisionGroup");
         }
         throw $e;
     }
     $url = $this->getFrontController()->getRouter()->assemble(array('controller' => $this->getRequest()->getControllerName(), 'action' => $this->getRequest()->getActionName(), 'id' => $dumpReport->getId()));
     $this->getResponse()->setHeader('Location', $url);
     $this->getResponse()->setHttpResponseCode(202);
 }
コード例 #3
0
 public function init()
 {
     $this->_reportSrv = \Application\Service\ReportAsyncService::getInstance();
 }
コード例 #4
0
 public function testValidateCorrelationReport()
 {
     $this->_reportService->validateParams(ReportModel::CORRELATION);
 }
コード例 #5
0
 public function postAction()
 {
     $params = $this->_helper->requestData();
     if (!isset($params['type'])) {
         throw new InvalidArgumentException("Report type is required");
     }
     $type = $params['type'];
     // Check report permissions by type
     $dumpReport = new ReportModel();
     $dumpReport->setType($type);
     // Custom download report name
     switch ($type) {
         case ReportModel::KPI_MONTHLY:
             $fileType = 'arpu';
             break;
         default:
             $fileType = $type;
     }
     if ($type !== ReportModel::AUDIT_LOG) {
         try {
             $headers = ReportAsyncService::getInstance()->getHeaders($type, $params);
             $dumpReport->setHeaders($headers);
             $this->_helper->filterNotAllowedCols("read_field", $dumpReport);
             $columns = array_keys($dumpReport->headers);
             if (isset($params['requiredFields'])) {
                 $columns = array_intersect($columns, $params['requiredFields']);
             }
             $params['columns'] = $columns;
         } catch (InvalidArgumentException $e) {
             \App::log()->info("Report {$type} does not have defined headers");
         }
     }
     $params['fileType'] = $fileType;
     $dumpReport->params = $params;
     if ($type !== ReportModel::AUDIT_LOG) {
         $this->_helper->allowed('create', $dumpReport);
     } else {
         $dumpAudit = new \Application\Model\AuditLogModel();
         $this->_helper->allowed('create', $dumpAudit);
     }
     $this->view->watcher = $this->_service->create($dumpReport);
     if (is_null($this->view->watcher)) {
         throw new NotFoundException("Report not available");
     }
     $this->view->watcher->reload();
     $this->_helper->filterNotAllowedFields('read_field', $this->view->watcher);
 }
コード例 #6
0
 public function init()
 {
     $this->_service = ReportAsyncService::getInstance();
 }