25 use \Fossology\Lib\Plugin\DefaultPlugin;
28 use \Symfony\Component\HttpFoundation\Request;
38 public $AgentName =
"agent_softwareHeritage";
40 private $uploadtree_tablename =
"";
63 protected $agentNames = array(
'softwareHeritage' =>
'SH');
65 public function __construct()
67 parent::__construct(self::NAME, array(
68 self::TITLE => _(
"Software Heritage details"),
70 self::REQUIRES_LOGIN =>
false 72 $this->Title = _(
"Software Heritage");
73 $this->dbManeger = $this->container->get(
'db.manager');
74 $this->uploadDao = $this->container->get(
'dao.upload');
75 $this->shDao = $this->container->get(
'dao.softwareHeritage');
76 $this->agentDao = $this->container->get(
'dao.agent');
90 if (empty($Item) || empty($Upload)) {
93 $viewLicenseURI =
"view-license" .
Traceback_parm_keep(array(
"show",
"format",
"page",
"upload",
"item"));
94 $menuName = $this->Title;
100 $text = _(
"Software Heritage");
101 menu_insert(
"Browse::$menuName", 101, $URI, $text);
102 menu_insert(
"View::$menuName", 101, $viewLicenseURI, $text);
103 menu_insert(
"View-Meta::$menuName", 101, $viewLicenseURI, $text);
107 public function handle(Request $request)
109 $upload = intval($request->get(
"upload"));
111 if (!$this->uploadDao->isAccessible($upload, $groupId)) {
112 return $this->flushContent(_(
"Permission Denied"));
114 $item = intval($request->get(
"item"));
116 $vars[
'uploadId'] = $upload;
118 if ($request->get(
'show')==
'quick') {
121 $vars[
'itemId'] = $item;
122 $vars[
'micromenu'] =
Dir2Browse($this->Name, $item, NULL, $showBox = 0,
"Browse", -1,
125 $left = $itemTreeBounds->getLeft();
127 return $this->flushContent(_(
"Job unpack/adj2nest hasn't completed."));
130 if (is_a($histVars,
'Symfony\\Component\\HttpFoundation\\RedirectResponse')) {
133 $vars = array_merge($vars, $histVars);
134 return $this->
render(
"softwareHeritage.html.twig",$this->mergeWithDefault($vars));
145 $agentId = $this->agentDao->getCurrentAgentId(
"softwareHeritage");
148 $scannerAgents = array_keys($this->agentNames);
149 $scanJobProxy =
new ScanJobProxy($this->agentDao, $uploadId);
150 $scannerVars = $scanJobProxy->createAgentStatus($scannerAgents);
151 $agentMap = $scanJobProxy->getAgentMap();
154 'agentId' => $agentId,
155 'agentMap' => $agentMap,
156 'scanners'=>$scannerVars
159 $selectedAgentIds = empty($selectedAgentId) ? $scanJobProxy->getLatestSuccessfulAgentIds() : $agentId;
161 $this->licenseProjector =
new LicenseMap($this->
getObject(
'db.manager'),$groupId,LicenseMap::CONCLUSION,
true);
163 $childCount = $dirVars[
'iTotalRecords'];
173 if ($childCount == 0) {
174 return new RedirectResponse(
"?mod=view-license" .
Traceback_parm_keep(array(
"upload",
"item")));
176 return array_merge($vars, $dirVars);
185 $isFlat = isset($_GET[
'flatten']);
186 $vars[
'isFlat'] = $isFlat;
187 $vars[
'iTotalRecords'] = $this->uploadDao->countNonArtifactDescendants($itemTreeBounds, $isFlat);
188 $uri =
Traceback_uri().
'?mod='.$this->Name.Traceback_parm_keep(array(
'upload',
'folder',
'show',
'item'));
189 $vars[
'fileSwitch'] = $isFlat ? $uri : $uri.
"&flatten=yes";
200 return $this->renderer->loadTemplate($templateName)->render($vars);
Dir2Browse($Mod, $UploadtreePk, $LinkLast=NULL, $ShowBox=1, $ShowMicro=NULL, $Enumerate=-1, $PreText='', $PostText='', $uploadtree_tablename="uploadtree")
Get an html linked string of a file browse path.
Traceback_uri()
Get the URI without query to this location.
render($templateName, $vars=null, $headers=null)
RegisterMenus()
Customize submenus.
showUploadHist(ItemTreeBounds $itemTreeBounds)
Given an $Uploadtree_pk, display:
Wrapper class for license map.
countFileListing(ItemTreeBounds $itemTreeBounds)
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
char * uploadtree_tablename
upload.uploadtree_tablename
renderString($templateName, $vars)
static getGroupId()
Get the current user's group id.
Traceback_parm_keep($List)
Create a new URI, keeping only these items.