15 namespace Fossology\DecisionExporter\UI;
21 use Symfony\Component\HttpFoundation\Request;
30 const NAME =
'agent_fodecisionexporter';
32 function __construct()
34 parent::__construct(self::NAME, array(
35 self::TITLE => _(
"FOSSology Dump Exporter"),
37 self::REQUIRES_LOGIN => TRUE
45 protected function handle(Request $request)
48 $uploadId = intval($request->get(
'upload'));
50 $upload = $this->getUpload($uploadId, $groupId);
51 }
catch(Exception $e) {
52 return $this->flushContent($e->getMessage());
57 if ($jobQueueId < 0) {
58 return $this->flushContent(_(
'Cannot schedule').
": $error");
61 $vars = array(
'jqPk' => $jobQueueId,
62 'downloadLink' =>
Traceback_uri().
"?mod=download&report=".$jobId,
63 'reportType' =>
"dumpexporter");
64 $text = sprintf(_(
"Generating FOSSology Decisions for '%s'"), $upload->getFilename());
65 $vars[
'content'] =
"<h2>".$text.
"</h2>";
66 $content = $this->renderer->load(
"report.html.twig")->render($vars);
67 $message =
'<h3 id="jobResult"></h3>';
68 $request->duplicate(array(
'injectedMessage'=>$message,
'injectedFoot'=>$content,
'mod'=>
'showjobs'))->overrideGlobals();
70 $showJobsPlugin->OutputOpen();
71 return $showJobsPlugin->getResponse();
81 protected function getUpload($uploadId, $groupId)
84 throw new Exception(_(
"parameter error"));
87 $uploadDao = $this->
getObject(
'dao.upload');
88 if (!$uploadDao->isAccessible($uploadId, $groupId)) {
89 throw new Exception(_(
"permission denied"));
92 $upload = $uploadDao->getUpload($uploadId);
93 if ($upload ===
null) {
94 throw new Exception(_(
'cannot find uploadId'));
105 $text = _(
"Decision Dump Exporter");
106 menu_insert(
"Browse-Pfile::Export FOSSology Dump", 0, self::NAME, $text);
118 $decisionExpoAgent =
plugin_find(
'agent_decisionexporter');
120 $uploadId = $upload->getId();
121 $jobId = JobAddJob($userId, $groupId, $upload->getFilename(), $uploadId);
124 $url = preg_replace(
"/api\/.*/i",
"", $url);
125 $jobQueueId = $decisionExpoAgent->AgentAdd($jobId, $uploadId, $error, array(), $url);
126 return array($jobId, $jobQueueId, $error);
FOSSology Decision Exporter UI plugin.
FOSSology Decision Exporter UI plugin.
scheduleAgent($groupId, $upload)
const NAME
Plugin mod name.
Contains the constants and helpers for authentication of user.
static getUserId()
Get the current user's id.
static getGroupId()
Get the current user's group id.
Traceback_uri()
Get the URI without query to this location.
tracebackTotalUri()
Get the total url without query.
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.
list_t type structure used to keep various lists. (e.g. there are multiple lists).