17 private $bucketDesc =
"Performs grouping based on different needs. you can group licenses as 'Good Licenses', 'Academic Licenses', 'Copyleft Licenses' etc. One can also group files by copyright holder, or by file-type, or files without my copyright.
18 Note: There is no FOSSology UI to create bucket pools, bucket definitions, scripts, or anything else you need.";
20 public function __construct() {
21 $this->Name =
"agent_bucket";
22 $this->Title = _(
"Bucket Analysis <img src=\"images/info_16.png\" data-toggle=\"tooltip\" title=\"".$this->bucketDesc.
"\" class=\"info-bullet\"/>");
23 $this->AgentName =
"buckets";
25 parent::__construct();
32 protected function getDefaultBucketPool()
34 $user_pk = Auth::getUserId();
35 if (empty($user_pk)) {
40 $dbManager = $GLOBALS[
'container']->get(
'db.manager');
41 $usersRec = $dbManager->getSingleRow(
'SELECT default_bucketpool_fk FROM users WHERE user_pk=$1', array($user_pk));
42 return $usersRec[
'default_bucketpool_fk'];
52 $bucketPool = $this->getDefaultBucketPool();
53 if (!empty($bucketPool))
55 menu_insert(
"Agents::" . $this->Title, 0, $this->Name);
65 $default_bucketpool_fk = $this->getDefaultBucketPool();
66 if (empty($default_bucketpool_fk)) {
70 $agentDao = $GLOBALS[
'container']->get(
'dao.agent');
71 $latestNomosAgentId = $agentDao->getCurrentAgentId(
"nomos",
"Nomos license scanner");
72 if (empty($latestNomosAgentId)) {
75 $latestBucketAgentId = $agentDao->getCurrentAgentId($this->AgentName,
"Bucket scanner");
76 if (empty($latestBucketAgentId)) {
80 $dbManager = $GLOBALS[
'container']->get(
'db.manager');
82 $bucketLatestArsRec = $dbManager->getSingleRow(
"SELECT * FROM bucket_ars WHERE bucketpool_fk=$1 AND upload_fk=$2 AND nomosagent_fk=$3 and agent_fk=$4 AND ars_success=$5",
83 array($default_bucketpool_fk,$uploadId,$latestNomosAgentId,$latestBucketAgentId,$dbManager->booleanToDb(
true)),
84 __METHOD__.
'.latestNomosAndBucketScannedThisPool');
85 if (!empty($bucketLatestArsRec))
return 1;
87 $bucketOldArsRec = $dbManager->getSingleRow(
"SELECT * FROM bucket_ars WHERE bucketpool_fk=$1 AND upload_fk=$2 AND ars_success=$3",
88 array($default_bucketpool_fk,$uploadId,$dbManager->booleanToDb(
true)),
89 __METHOD__.
'.anyBucketScannedThisPool');
90 if (!empty($bucketOldArsRec))
return 2;
99 public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=[],
100 $arguments=
null, $request=
null, $unpackArgs=
null)
102 $default_bucketpool_fk = $this->getDefaultBucketPool();
103 if (!$default_bucketpool_fk)
105 $errorMsg = _(
"User does not have a default bucketpool. Bucket agent cannot be scheduled without this.");
109 $dependencies[] =
"agent_nomos";
110 $dependencies[] =
"agent_pkgagent";
111 $jqargs =
"bppk=$default_bucketpool_fk, upk=$uploadId";
112 return $this->
doAgentAdd($jobId, $uploadId, $errorMsg, $dependencies,
113 $jqargs,
null, $request);
AgentHasResults($uploadId=0)
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=[], $arguments=null, $request=null, $unpackArgs=null)
Contains the constants and helpers for authentication of user.
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null, $request=null)