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 {
18  private $resoDesc = "REUSE.Software agent marks licensed files with a license found in the .license files (outside of the licensed files), Note: forces *Ojo License Analysis*";
19 
20  public function __construct()
21  {
22  $this->Name = "agent_reso";
23  $this->Title = ("REUSE.Software Analysis <img src=\"images/info_16.png\" data-toggle=\"tooltip\" title=\"".$this->resoDesc."\" class=\"info-bullet\"/>");
24  $this->AgentName = "reso";
25 
26  parent::__construct();
27  }
28 
33  function AgentHasResults($uploadId=0)
34  {
35  return CheckARS($uploadId, $this->AgentName, "reso agent", "reso_ars");
36  }
37 
42  public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=[],
43  $arguments=null, $request=null, $unpackArgs=null)
44  {
45  if ($request != null) {
46  $copyrightAgentScheduled = intval($request->get("Check_agent_copyright",
47  0)) == 1;
48  } else {
49  $copyrightAgentScheduled = GetParm("Check_agent_copyright",
50  PARM_INTEGER) == 1;
51  }
52  $dependencies[] = "agent_ojo";
53  if ($copyrightAgentScheduled) {
54  $dependencies[] = "agent_copyright";
55  }
56  if ($this->AgentHasResults($uploadId) == 1) {
57  return 0;
58  }
59 
60  $jobQueueId = \IsAlreadyScheduled($jobId, $this->AgentName, $uploadId);
61  if ($jobQueueId != 0) {
62  return $jobQueueId;
63  }
64 
65  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, $dependencies,
66  $uploadId, null, $request);
67  }
68 
75  protected function isAgentIncluded($dependencies, $agentName)
76  {
77  foreach ($dependencies as $dependency) {
78  if ($dependency == $agentName) {
79  return true;
80  }
81  if (is_array($dependency) && $agentName == $dependency['name']) {
82  return true;
83  }
84  }
85  return false;
86  }
87 }
88 
89 register_plugin(new ResoAgentPlugin());
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null, $request=null)
Create UI plugin for Reso agent.
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=[], $arguments=null, $request=null, $unpackArgs=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