FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
agent-nomos.php
Go to the documentation of this file.
1 <?php
2 /***********************************************************
3  * Copyright (C) 2008-2013 Hewlett-Packard Development Company, L.P.
4  * Copyright (C) 2015 Siemens AG
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * version 2 as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  ***********************************************************/
24 
30 {
31 
32  public function __construct()
33  {
34  $this->Name = "agent_nomos";
35  $this->Title = _(
36  "Nomos License Analysis, scanning for licenses using regular expressions");
37  $this->AgentName = "nomos";
38 
39  parent::__construct();
40  }
41 
46  function AgentHasResults($uploadId = 0)
47  {
48  return CheckARS($uploadId, $this->AgentName, "license scanner", "nomos_ars");
49  }
50 
55  public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
56  {
57  $unpackArgs = intval(@$_POST['scm']) == 1 ? '-I' : '';
58  if ($this->AgentHasResults($uploadId) == 1) {
59  return 0;
60  }
61 
62  $jobQueueId = \IsAlreadyScheduled($jobId, $this->AgentName, $uploadId);
63  if ($jobQueueId != 0) {
64  return $jobQueueId;
65  }
66 
67  $args = $unpackArgs;
68  if (!empty($unpackArgs)) {
69  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_mimetype"),$uploadId,$args);
70  } else {
71  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_adj2nest"), $uploadId);
72  }
73  }
74 
81  protected function isAgentIncluded($dependencies, $agentName)
82  {
83  foreach ($dependencies as $dependency) {
84  if ($dependency == $agentName) {
85  return true;
86  }
87  if (is_array($dependency) && $agentName == $dependency['name']) {
88  return true;
89  }
90  }
91  return false;
92  }
93 }
94 
95 register_plugin(new NomosAgentPlugin());
IsAlreadyScheduled($job_pk, $AgentName, $upload_pk)
Check if an agent is already scheduled in a job.
Definition: common-job.php:380
AgentHasResults($uploadId=0)
Definition: agent-nomos.php:46
isAgentIncluded($dependencies, $agentName)
Definition: agent-nomos.php:81
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
Definition: agent-nomos.php:55
UI plugin for NOMOS.
Definition: agent-nomos.php:29
CheckARS($upload_pk, $AgentName, $AgentDesc, $AgentARSTableName)
Check the ARS table to see if an agent has successfully scanned an upload.
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null)