FOSSology  4.4.0
Open Source License Compliance by Open Source Software
ResoAgentPlugin.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2021 Orange
4  Author: Bartłomiej Dróżdż <bartlomiej.drozdz@orange.com>
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 
10 
16 {
17  public function __construct()
18  {
19  $this->Name = "agent_reso";
20  $this->Title = ("REUSE.Software Analysis (forces *Ojo License Analysis*)");
21  $this->AgentName = "reso";
22 
23  parent::__construct();
24  }
25 
30  function AgentHasResults($uploadId=0)
31  {
32  return CheckARS($uploadId, $this->AgentName, "reso agent", "reso_ars");
33  }
34 
39  public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
40  {
41  $copyrightAgentScheduled = GetParm("Check_agent_copyright", PARM_INTEGER) == 1;
42  $dependencies[] = "agent_ojo";
43  if ($copyrightAgentScheduled) {
44  $dependencies[] = "agent_copyright";
45  }
46  if ($this->AgentHasResults($uploadId) == 1) {
47  return 0;
48  }
49 
50  $jobQueueId = \IsAlreadyScheduled($jobId, $this->AgentName, $uploadId);
51  if ($jobQueueId != 0) {
52  return $jobQueueId;
53  }
54 
55  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, $dependencies, $uploadId);
56  }
57 
64  protected function isAgentIncluded($dependencies, $agentName)
65  {
66  foreach ($dependencies as $dependency) {
67  if ($dependency == $agentName) {
68  return true;
69  }
70  if (is_array($dependency) && $agentName == $dependency['name']) {
71  return true;
72  }
73  }
74  return false;
75  }
76 }
77 
78 register_plugin(new ResoAgentPlugin());
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null)
Create UI plugin for Reso agent.
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
AgentHasResults($uploadId=0)
isAgentIncluded($dependencies, $agentName)
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
const PARM_INTEGER
Definition: common-parm.php:14
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
Definition: common-parm.php:46