FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
DeciderJobAgentPlugin.php
1 <?php
2 /***********************************************************
3  * Copyright (C) 2014-2015, Siemens AG
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * version 2 as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  ***********************************************************/
22 namespace Fossology\DeciderJob\UI;
23 
25 
26 include_once(__DIR__ . "/../agent/version.php");
27 
33 {
34  const CONFLICT_STRATEGY_FLAG = "-k";
35 
36  function __construct()
37  {
38  $this->Name = "agent_deciderjob";
39  $this->Title = _("Automatic User License Decider");
40  $this->AgentName = AGENT_DECIDER_JOB_NAME;
41 
42  parent::__construct();
43  }
44 
49  function preInstall()
50  {
51  // no menue entry
52  }
53 
58  public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $conflictStrategyId=null)
59  {
60  $dependencies[] = "agent_adj2nest";
61 
62  $jobQueueId = \IsAlreadyScheduled($jobId, $this->AgentName, $uploadId);
63  if ($jobQueueId != 0) {
64  return $jobQueueId;
65  }
66 
67  $args = ($conflictStrategyId !== null) ? $this::CONFLICT_STRATEGY_FLAG.$conflictStrategyId : '';
68 
69  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, $dependencies, $uploadId, $args);
70  }
71 }
72 
73 register_plugin(new DeciderJobAgentPlugin());
IsAlreadyScheduled($job_pk, $AgentName, $upload_pk)
Check if an agent is already scheduled in a job.
Definition: common-job.php:380
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $conflictStrategyId=null)
DeciderJobAgent&#39;s UI.
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null)