FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
check4jobs.php
1 <?php
2 /***********************************************************
3  Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  ***********************************************************/
18 
38 require_once (TESTROOT . '/testClasses/db.php');
39 
40 define('SQL', "SELECT *
41  FROM jobqueue
42  INNER JOIN job ON jobqueue.jq_job_fk = job.job_pk
43  LEFT OUTER JOIN upload ON upload_pk = job.job_upload_fk
44  LEFT JOIN jobdepends ON jobqueue.jq_pk = jobdepends.jdep_jq_fk
45  WHERE (jobqueue.jq_starttime IS NULL OR jobqueue.jq_endtime IS
46  NULL OR jobqueue.jq_end_bits > 1)
47  ORDER BY upload_filename,upload.upload_pk,job.job_pk,jobqueue.jq_pk," .
48  "jobdepends.jdep_jq_fk;");
49 
50 class check4jobs {
51 
52  protected $jobCount=NULL;
53  private $Db;
54 
55  function __construct() {
56  /*
57  * always use the installed root user for the db.
58  */
59  if(file_exists('/etc/fossology/Db.conf')) {
60  $options = file_get_contents('/etc/fossology/Db.conf');
61  }
62  else if (file_exists('/usr/local/etc/fossology/Db.conf')) {
63  $options = file_get_contents('/usr/local/etc/fossology/Db.conf');
64  }
65  else {
66  return(FALSE);
67  }
68  $this->Db = new db($options);
69  $connection = $this->Db->connect();
70  if (!(is_resource($connection))) {
71  print "check4jobs:FATAL ERROR!, could not connect to the data-base\n";
72  return(FALSE);
73  }
74  $this->_ck4j();
75  return;
76  }
77 
78  public function Check() {
79  $this->_ck4j();
80  return($this->jobCount);
81  }
82  private function _ck4j() {
83  $results = $this->Db->dbQuery(SQL);
84  $howMany = count($results);
85  $this->jobCount = $howMany;
86  return;
87  }
88 
89  public function getJobCount() {
90  return($this->jobCount);
91  }
92 } // check4jobs
93 ?>
Definition: db.php:41
char SQL[256]
SQL query to execute.
Definition: adj2nest.c:90