8 namespace Fossology\Lib\Plugin;
10 use Symfony\Component\HttpFoundation\Request;
14 const PRE_JOB_QUEUE =
'preJq';
17 public $Name =
"agent_abstract";
18 public $Dependency = array();
19 public $Title =
'how to show checkbox';
20 public $PluginLevel = 10;
21 public $State = PLUGIN_STATE_READY;
24 function __construct()
30 function postInstall()
36 menu_insert(
"Agents::" . $this->Title, 0, $this->Name);
76 public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=[],
77 $arguments=
null, $request=
null, $unpackArgs=
null)
79 $dependencies[] =
"agent_adj2nest";
85 if ($jobQueueId != 0) {
89 $args = is_array($arguments) ?
'' : $arguments;
90 return $this->
doAgentAdd($jobId, $uploadId, $errorMsg, $dependencies,
91 $uploadId, $args, $request);
107 protected function doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies,
108 $jqargs =
"", $jq_cmd_args =
null, $request =
null)
111 foreach ($dependencies as $dependency) {
113 $dependency, $request);
120 if (empty($jqargs)) {
123 $jobQueueId =
\JobQueueAdd($jobId, $this->AgentName, $jqargs,
"", $deps, NULL, $jq_cmd_args);
124 if (empty($jobQueueId)) {
125 $errorMsg =
"Failed to insert agent $this->AgentName into job queue. jqargs: $jqargs";
130 $errorMsg .=
"\n" . $output;
145 $dependency, $request)
147 if (is_array($dependency)) {
148 $pluginName = $dependency[
'name'];
149 $depArgs = array_key_exists(
'args', $dependency) ? $dependency[
'args'] :
null;
150 $preJq = array_key_exists(self::PRE_JOB_QUEUE, $dependency) ? $dependency[self::PRE_JOB_QUEUE] : array();
152 $pluginName = $dependency;
158 $errorMsg =
"Invalid plugin name: $pluginName, (implicitAgentAdd())";
162 return $depPlugin->AgentAdd($jobId, $uploadId, $errorMsg, $preJq,
166 function __toString()
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=[], $arguments=null, $request=null, $unpackArgs=null)
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null, $request=null)
implicitAgentAdd($jobId, $uploadId, &$errorMsg, $dependency, $request)
AgentHasResults($uploadId=0)
JobQueueAdd($job_pk, $jq_type, $jq_args, $jq_runonpfile, $Depends, $host=NULL, $jq_cmd_args=NULL)
Insert a jobqueue + jobdepends records.
IsAlreadyScheduled($job_pk, $AgentName, $upload_pk)
Check if an agent is already scheduled in a job.
getStringRepresentation($vars, $classname)
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.
fo_communicate_with_scheduler($input, &$output, &$error_msg)
Communicate with scheduler, send commands to the scheduler, then get the output.
#define PLUGIN_DB_WRITE
Plugin requires write permission on DB.