/** * Funkce pro nalezení úlohy dle zadaného ID a kontrolu oprávnění aktuálního uživatele pracovat s daným pravidlem * * @param int $taskId * @return Task * @throws \Nette\Application\BadRequestException */ protected function findTaskWithCheckAccess($taskId) { try { /** @var Task $task */ $task = $this->tasksFacade->findTask($taskId); } catch (EntityNotFoundException $e) { $this->error('Requested task was not found.'); return null; } $this->minersFacade->checkMinerAccess($task->miner, $this->getCurrentUser()); return $task; }
/** * Akce pro odebrání celého obsahu rule clipboard z konkrétního rulesetu * @param int $id * @param int $miner * @param int $ruleset * @param string $returnRules ='' - IDčka oddělená čárkami, případně jedno ID * @throws ForbiddenRequestException * @throws BadRequestException */ public function actionRemoveRulesFromRuleSet($id = null, $miner, $ruleset, $returnRules = '') { //načtení dané úlohy a zkontrolování přístupu k mineru $task = $this->tasksFacade->findTask($id); $this->checkMinerAccess($task->miner); $ruleIdsArr = explode(',', str_replace(';', ',', $returnRules)); //najití RuleSetu a kontroly $ruleSet = $this->ruleSetsFacade->findRuleSet($ruleset); $this->ruleSetsFacade->checkRuleSetAccess($ruleSet, $this->user->id); //přidání pravidel $this->ruleSetsFacade->removeAllRuleClipboardRulesFromRuleSet($task, $ruleSet); $result = array(); if (count($ruleIdsArr) > 0) { foreach ($ruleIdsArr as $ruleId) { try { $rule = $this->rulesFacade->findRule($ruleId); //TODO optimalizovat kontroly... $ruleTask = $rule->task; if ($ruleTask->taskId != $task->taskId) { throw new InvalidArgumentException(); } if ($ruleTask->miner->minerId != $miner) { throw new InvalidArgumentException(); } $result[$rule->ruleId] = $rule->getBasicDataArr(); } catch (\Exception $e) { continue; } } } $this->sendJsonResponse(array('rules' => $result)); }
/** * @param Task|int $task * @param User $user * @return \EasyMinerCenter\Model\Mining\IMiningDriver */ public function getTaskMiningDriver($task, User $user) { if (!$task instanceof Task) { $task = $this->tasksFacade->findTask($task); } return $this->miningDriverFactory->getDriverInstance($task, $this, $this->rulesFacade, $this->metaAttributesFacade, $user); }
/** * Akce pro vykreslení detailů úlohy ve formátu PMML * @param int $id * @throws \Exception * @throws BadRequestException * @throws ForbiddenRequestException */ public function renderTaskDetails($id) { $task = $this->tasksFacade->findTask($id); $this->checkMinerAccess($task->miner); //vygenerování PMML $pmml = $this->prepareTaskPmml($task); $this->template->task = $task; $this->template->content = $this->xmlTransformator->transformToHtml($pmml); }