* create new report * * @param string $file * @return int */ * Create a report based on a data file. * * @param int|string $file Path to the file or the numeric file ID * * @return int ID of the newly created report */
($file = '')
| 285 | * @return int ID of the newly created report |
| 286 | */ |
| 287 | public function createFromDataFile($file = '') { |
| 288 | $this->ActivityManager->triggerEvent(0, ActivityManager::OBJECT_REPORT, ActivityManager::SUBJECT_REPORT_ADD); |
| 289 | |
| 290 | $reportId = 0; |
| 291 | |
| 292 | if ($file !== '') { |
| 293 | if (is_numeric($file)) { |
| 294 | $userFolder = $this->rootFolder->getUserFolder($this->userId); |
| 295 | $nodes = $userFolder->getById((int)$file); |
| 296 | if (isset($nodes[0])) { |
| 297 | $file = $userFolder->getRelativePath($nodes[0]->getPath()); |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | $name = explode('.', end(explode('/', $file)))[0]; |
| 302 | $subheader = $file; |
| 303 | $parent = 0; |
| 304 | $dataset = 0; |
| 305 | $type = DatasourceController::DATASET_TYPE_LOCAL_CSV; |
| 306 | $link = $file; |
| 307 | $visualization = 'table'; |
| 308 | $chart = 'line'; |
| 309 | $reportId = $this->ReportMapper->create($name, $subheader, $parent, $type, $dataset, $link, $visualization, $chart, '', '', ''); |
| 310 | } |
| 311 | return $reportId; |
| 312 | } |
| 313 | |
| 314 | /** |
| 315 | * update report details |
nothing calls this directly
no test coverage detected