FOSSology  4.4.0
Open Source License Compliance by Open Source Software
agent-nomos.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2008-2013 Hewlett-Packard Development Company, L.P.
4  SPDX-FileCopyrightText: © 2015 Siemens AG
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
14 
20 {
22  private $nomosDesc = "Scan files for licenses using regular expressions";
23 
24  public function __construct()
25  {
26  $this->Name = "agent_nomos";
27  $this->Title = _(
28  "Nomos License Analysis <img src=\"images/info_16.png\" data-toggle=\"tooltip\" title=\"".$this->nomosDesc."\" class=\"info-bullet\"/>");
29  $this->AgentName = "nomos";
30 
31  parent::__construct();
32  }
33 
38  function AgentHasResults($uploadId = 0)
39  {
40  return CheckARS($uploadId, $this->AgentName, "license scanner", "nomos_ars");
41  }
42 
47  public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=[],
48  $arguments=null, $request=null, $unpackArgs=null)
49  {
50  if ($request != null && !is_array($request)) {
51  $unpackArgs = intval($request->get('scm', 0)) == 1 ? '-I' : '';
52  } else {
53  $unpackArgs = intval(@$_POST['scm']) == 1 ? '-I' : '';
54  }
55  if ($this->AgentHasResults($uploadId) == 1) {
56  return 0;
57  }
58 
59  $jobQueueId = \IsAlreadyScheduled($jobId, $this->AgentName, $uploadId);
60  if ($jobQueueId != 0) {
61  return $jobQueueId;
62  }
63 
64  $args = $unpackArgs;
65  if (!empty($unpackArgs)) {
66  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_mimetype"),$uploadId,$args,$request);
67  } else {
68  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_adj2nest"), $uploadId, null, $request);
69  }
70  }
71 
78  protected function isAgentIncluded($dependencies, $agentName)
79  {
80  foreach ($dependencies as $dependency) {
81  if ($dependency == $agentName) {
82  return true;
83  }
84  if (is_array($dependency) && $agentName == $dependency['name']) {
85  return true;
86  }
87  }
88  return false;
89  }
90 }
91 
92 register_plugin(new NomosAgentPlugin());
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null, $request=null)
UI plugin for NOMOS.
Definition: agent-nomos.php:20
isAgentIncluded($dependencies, $agentName)
Definition: agent-nomos.php:78
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=[], $arguments=null, $request=null, $unpackArgs=null)
Definition: agent-nomos.php:47
AgentHasResults($uploadId=0)
Definition: agent-nomos.php:38
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