45 const NAME =
"license";
47 private $uploadtree_tablename =
"";
57 private $clearingFilter;
59 private $licenseProjector;
61 protected $agentNames = AgentRef::AGENT_LIST;
63 public function __construct()
65 parent::__construct(self::NAME, array(
66 self::TITLE => _(
"License Browser"),
67 self::DEPENDENCIES => array(
"browse",
"view"),
69 self::REQUIRES_LOGIN =>
false 73 $this->uploadDao = $container->get(
'dao.upload');
74 $this->licenseDao = $container->get(
'dao.license');
75 $this->clearingDao = $container->get(
'dao.clearing');
76 $this->agentDao = $container->get(
'dao.agent');
77 $this->clearingFilter = $container->get(
'businessrules.clearing_decision_filter');
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 = _(
"license histogram");
102 menu_insert(
"View::$menuName", 99, $viewLicenseURI, $text);
103 menu_insert(
"View-Meta::$menuName", 99, $viewLicenseURI, $text);
111 protected function handle(Request $request)
113 $upload = intval($request->get(
"upload"));
115 if (!$this->uploadDao->isAccessible($upload, $groupId)) {
116 return $this->flushContent(_(
"Permission Denied"));
119 $item = intval($request->get(
"item"));
122 $vars[
'uploadId'] = $upload;
124 if ($request->get(
'show')==
'quick') {
127 $vars[
'itemId'] = $item;
129 $vars[
'micromenu'] =
Dir2Browse($this->Name, $item, NULL, $showBox = 0,
"Browse",
131 $vars[
'licenseArray'] = $this->licenseDao->getLicenseArray();
134 $left = $itemTreeBounds->getLeft();
136 return $this->flushContent(_(
"Job unpack/adj2nest hasn't completed."));
139 if (is_a($histVars,
'Symfony\\Component\\HttpFoundation\\RedirectResponse')) {
142 $vars = array_merge($vars, $histVars);
144 $vars[
'content'] =
js_url();
146 return $this->
render(
"browse.html.twig",$this->mergeWithDefault($vars));
162 $scannerAgents = array_keys($this->agentNames);
163 $scanJobProxy =
new ScanJobProxy($this->agentDao, $uploadId);
164 $scannerVars = $scanJobProxy->createAgentStatus($scannerAgents);
165 $agentMap = $scanJobProxy->getAgentMap();
169 'agentMap' => $agentMap,
170 'scanners'=>$scannerVars);
172 $selectedAgentIds = empty($selectedAgentId) ? $scanJobProxy->getLatestSuccessfulAgentIds() : $selectedAgentId;
174 if (!empty($agentMap)) {
176 $tag_pk, $itemTreeBounds, $selectedAgentIds, $groupId);
177 $vars = array_merge($vars, $licVars);
180 $this->licenseProjector =
new LicenseMap($this->
getObject(
'db.manager'),$groupId,LicenseMap::CONCLUSION,
true);
182 $childCount = $dirVars[
'iTotalRecords'];
192 if ($childCount == 0) {
193 return new RedirectResponse(
"?mod=view-license" .
Traceback_parm_keep(array(
"upload",
"item")));
196 $vars[
'licenseUri'] =
Traceback_uri() .
"?mod=popup-license&rf=";
199 return array_merge($vars, $dirVars);
208 $isFlat = isset($_GET[
'flatten']);
209 $vars[
'isFlat'] = $isFlat;
210 $vars[
'iTotalRecords'] = $this->uploadDao->countNonArtifactDescendants($itemTreeBounds, $isFlat);
211 $uri =
Traceback_uri().
'?mod='.$this->Name.Traceback_parm_keep(array(
'upload',
'folder',
'show',
'item'));
212 $vars[
'fileSwitch'] = $isFlat ? $uri : $uri.
"&flatten=yes";
227 $fileCount = $this->uploadDao->countPlainFiles($itemTreeBounds);
228 $licenseHistogram = $this->licenseDao->getLicenseHistogram($itemTreeBounds, $agentIds);
229 $editedLicensesHist = $this->clearingDao->getClearedLicenseIdAndMultiplicities($itemTreeBounds, $groupId);
232 $licListUri =
Traceback_uri().
"?mod=license_list_files&item=$uploadTreeId";
234 $licListUri .=
"&tag=$tagId";
237 $licListUri .=
"&agentId=$agentId";
241 list($tableData, $totalScannerLicenseCount, $editedTotalLicenseCount)
244 $uniqueLicenseCount = count($tableData);
245 $scannerUniqueLicenseCount = count( $licenseHistogram );
246 $editedUniqueLicenseCount = count($editedLicensesHist);
247 $noScannerLicenseFoundCount = array_key_exists(LicenseDao::NO_LICENSE_FOUND, $licenseHistogram)
248 ? $licenseHistogram[LicenseDao::NO_LICENSE_FOUND][
'count'] : 0;
249 $editedNoLicenseFoundCount = array_key_exists(LicenseDao::NO_LICENSE_FOUND, $editedLicensesHist)
250 ? $editedLicensesHist[LicenseDao::NO_LICENSE_FOUND][
'count'] : 0;
252 $vars = array(
'tableDataJson'=>json_encode($tableData),
253 'uniqueLicenseCount'=>$uniqueLicenseCount,
254 'fileCount'=>$fileCount,
255 'scannerUniqueLicenseCount'=>$scannerUniqueLicenseCount,
256 'editedUniqueLicenseCount'=>$editedUniqueLicenseCount,
257 'scannerLicenseCount'=> $totalScannerLicenseCount,
258 'editedLicenseCount'=> $editedTotalLicenseCount-$editedNoLicenseFoundCount,
259 'noScannerLicenseFoundCount'=>$noScannerLicenseFoundCount,
260 'editedNoLicenseFoundCount'=>$editedNoLicenseFoundCount,
261 'scannerLicenses'=>$licenseHistogram,
262 'editedLicenses'=>$editedLicensesHist
277 $allScannerLicenseNames = array_keys($scannerLics);
278 $allEditedLicenseNames = array_keys($editedLics);
280 $allLicNames = array_unique(array_merge($allScannerLicenseNames, $allEditedLicenseNames));
281 $realLicNames = array_diff($allLicNames, array(LicenseDao::NO_LICENSE_FOUND));
283 $totalScannerLicenseCount = 0;
284 $editedTotalLicenseCount = 0;
286 $tableData = array();
287 foreach ($realLicNames as $licenseShortName) {
289 if (array_key_exists($licenseShortName, $scannerLics)) {
290 $count = $scannerLics[$licenseShortName][
'unique'];
291 $rfId = $scannerLics[$licenseShortName][
'rf_pk'];
293 $rfId = $editedLics[$licenseShortName][
'rf_pk'];
295 $editedCount = array_key_exists($licenseShortName, $editedLics) ? $editedLics[$licenseShortName][
'count'] : 0;
297 $totalScannerLicenseCount += $count;
298 $editedTotalLicenseCount += $editedCount;
300 $scannerCountLink = ($count > 0) ?
"<a href='$licListUri&lic=" .
301 urlencode($licenseShortName) .
"'>$count</a>":
"0";
302 $editedLink = ($editedCount > 0) ? $editedCount :
"0";
304 $tableData[] = array($scannerCountLink, $editedLink, array($licenseShortName,$rfId));
307 return array($tableData, $totalScannerLicenseCount, $editedTotalLicenseCount);
317 return $this->renderer->loadTemplate($templateName)->render($vars);
countFileListing(ItemTreeBounds $itemTreeBounds)
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.
createLicenseHistogram($uploadTreeId, $tagId, ItemTreeBounds $itemTreeBounds, $agentIds, $groupId)
Traceback_parm($ShowMod=1)
Get the URI query to this location.
getUploadHist($itemTreeBounds)
render($templateName, $vars=null, $headers=null)
Wrapper class for license map.
createLicenseHistogramJSarray($scannerLics, $editedLics, $licListUri)
RegisterMenus()
Customize submenus.
renderString($templateName, $vars)
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
char * uploadtree_tablename
upload.uploadtree_tablename
list_t type structure used to keep various lists. (e.g. there are multiple lists).
showUploadHist(ItemTreeBounds $itemTreeBounds)
Given an $Uploadtree_pk, display:
static getGroupId()
Get the current user's group id.
Traceback_parm_keep($List)
Create a new URI, keeping only these items.