14 use Symfony\Component\Config\Definition\Exception\Exception;
16 include_once(__DIR__ .
"/../../lib/php/common-job.php");
48 public function rerunBulkAndDeciderOnUpload($uploadId, $groupId, $userId, $bulkId, $dependency)
53 $uploadDao =
$GLOBALS[
'container']->get(
'dao.upload');
54 $nTopItem = $uploadDao->getUploadParent($uploadId);
55 $pUTree = $this->
dbManager->getSingleRow(
"SELECT uploadtree_fk FROM license_ref_bulk WHERE lrb_pk=$1",
56 array($bulkId), __METHOD__);
57 $uploadEntry = $uploadDao->getUploadEntry($pUTree[
'uploadtree_fk']);
58 $pUID = intval($uploadEntry[
'upload_fk']);
59 $pTopItem = $uploadDao->getUploadParent($pUID);
60 if ($pTopItem == $pUTree[
'uploadtree_fk']) {
63 $pfUTree = $this->
dbManager->getSingleRow(
"SELECT uploadtree_pk FROM uploadtree WHERE upload_fk=$1 AND ufile_name=$2 AND ufile_mode=$3",
64 array($uploadId, $uploadEntry[
'ufile_name'], $uploadEntry[
'ufile_mode']), __METHOD__.
'getRealUploadtreeEntry');
65 if (!empty($pfUTree) && count($pfUTree) <= 1) {
66 $topItem = $pfUTree[
'uploadtree_pk'];
71 if (!empty($topItem)) {
76 $dependecies = array();
77 $sql =
"INSERT INTO license_ref_bulk (user_fk,group_fk,rf_text,upload_fk,uploadtree_fk,ignore_irrelevant,bulk_delimiters,scan_findings) "
78 .
"SELECT $1 AS user_fk, $2 AS group_fk,rf_text,$3 AS upload_fk, $4 as uploadtree_fk, ignore_irrelevant, bulk_delimiters, scan_findings
79 FROM license_ref_bulk WHERE lrb_pk=$5 RETURNING lrb_pk, $5 as lrb_origin";
80 $sqlLic =
"INSERT INTO license_set_bulk (lrb_fk, rf_fk, removing, comment, reportinfo, acknowledgement) "
81 .
"SELECT $1 as lrb_fk, rf_fk, removing, comment, reportinfo, acknowledgement FROM license_set_bulk WHERE lrb_fk=$2";
82 $this->
dbManager->prepare($stmt=__METHOD__.
'cloneBulk', $sql);
83 $this->
dbManager->prepare($stmtLic=__METHOD__.
'cloneBulkLic', $sqlLic);
84 $res = $this->
dbManager->execute($stmt,array($userId,$groupId,$uploadId,$topItem, $bulkId));
85 $row = $this->
dbManager->fetchArray($res);
87 $resLic = $this->
dbManager->execute($stmtLic,array($row[
'lrb_pk'],$row[
'lrb_origin']));
89 $upload = $uploadDao->getUpload($uploadId);
90 $uploadName = $upload->getFilename();
91 $job_pk = \JobAddJob($userId, $groupId, $uploadName, $uploadId);
92 $dependecies = array(array(
'name' =>
'agent_monk_bulk',
'args' => $row[
'lrb_pk']));
94 $jqId =
$deciderPlugin->AgentAdd($job_pk, $uploadId, $errorMsg, $dependecies);
96 if (!empty($errorMsg)) {
97 throw new Exception(str_replace(
'<br>',
"\n", $errorMsg));
UI plugin for DeciderJobAgent.
Prepares bulk licenses for an upload and run DeciderJob on it.
__construct()
Get Database Manager from containers.
fo_dbManager * dbManager
fo_dbManager object
Namespace for decider agent.
$GLOBALS['xyyzzzDeciderJob']
plugin_find($x)
Mock function to get decider plugin required by BulkReuser.