FOSSology  4.4.0
Open Source License Compliance by Open Source Software
agent-ojos.php
1 <?php
2 # SPDX-FileCopyrightText: © 2019 Siemens AG
3 
4 # SPDX-License-Identifier: GPL-2.0-only
5 
6 namespace Fossology\Ojo\Ui;
7 
9 
11 {
12  public function __construct()
13  {
14  $this->Name = "agent_ojo";
15  $this->Title = _("Ojo License Analysis, scanning for licenses using SPDX-License-Identifier");
16  $this->AgentName = "ojo";
17 
18  parent::__construct();
19  }
20 
21  function AgentHasResults($uploadId=0)
22  {
23  return CheckARS($uploadId, $this->AgentName, "ojo agent", "ojo_ars");
24  }
25 
30  public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
31  {
32  $unpackArgs = intval(@$_POST['scm']) == 1 ? '-I' : '';
33  if ($this->AgentHasResults($uploadId) == 1) {
34  return 0;
35  }
36 
37  $jobQueueId = \IsAlreadyScheduled($jobId, $this->AgentName, $uploadId);
38  if ($jobQueueId != 0) {
39  return $jobQueueId;
40  }
41 
42  $args = $unpackArgs;
43  if (!empty($unpackArgs)) {
44  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_mimetype"),$uploadId,$args);
45  } else {
46  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_adj2nest"), $uploadId);
47  }
48  }
49 
56  protected function isAgentIncluded($dependencies, $agentName)
57  {
58  foreach ($dependencies as $dependency) {
59  if ($dependency == $agentName) {
60  return true;
61  }
62  if (is_array($dependency) && $agentName == $dependency['name']) {
63  return true;
64  }
65  }
66  return false;
67  }
68 }
69 register_plugin(new OjosAgentPlugin());
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null)
isAgentIncluded($dependencies, $agentName)
Definition: agent-ojos.php:56
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
Definition: agent-ojos.php:30
CheckARS($upload_pk, $AgentName, $AgentDesc, $AgentARSTableName)
Check the ARS table to see if an agent has successfully scanned an upload.
IsAlreadyScheduled($job_pk, $AgentName, $upload_pk)
Check if an agent is already scheduled in a job.
Definition: common-job.php:378