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 */
13 
19 {
20 
21  public function __construct()
22  {
23  $this->Name = "agent_nomos";
24  $this->Title = _(
25  "Nomos License Analysis, scanning for licenses using regular expressions");
26  $this->AgentName = "nomos";
27 
28  parent::__construct();
29  }
30 
35  function AgentHasResults($uploadId = 0)
36  {
37  return CheckARS($uploadId, $this->AgentName, "license scanner", "nomos_ars");
38  }
39 
44  public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
45  {
46  $unpackArgs = intval(@$_POST['scm']) == 1 ? '-I' : '';
47  if ($this->AgentHasResults($uploadId) == 1) {
48  return 0;
49  }
50 
51  $jobQueueId = \IsAlreadyScheduled($jobId, $this->AgentName, $uploadId);
52  if ($jobQueueId != 0) {
53  return $jobQueueId;
54  }
55 
56  $args = $unpackArgs;
57  if (!empty($unpackArgs)) {
58  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_mimetype"),$uploadId,$args);
59  } else {
60  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_adj2nest"), $uploadId);
61  }
62  }
63 
70  protected function isAgentIncluded($dependencies, $agentName)
71  {
72  foreach ($dependencies as $dependency) {
73  if ($dependency == $agentName) {
74  return true;
75  }
76  if (is_array($dependency) && $agentName == $dependency['name']) {
77  return true;
78  }
79  }
80  return false;
81  }
82 }
83 
84 register_plugin(new NomosAgentPlugin());
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null)
UI plugin for NOMOS.
Definition: agent-nomos.php:19
isAgentIncluded($dependencies, $agentName)
Definition: agent-nomos.php:70
AgentHasResults($uploadId=0)
Definition: agent-nomos.php:35
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
Definition: agent-nomos.php:44
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