FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
AjaxJobStatus.php
1 <?php
2 /***********************************************************
3  * Copyright (C) 2015 Siemens AG
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 
19 namespace Fossology\UI\Ajax;
20 
26 
28 {
29  const NAME = "jobstatus";
31  private $dbManager;
32 
33  function __construct()
34  {
35  parent::__construct(self::NAME, array(
36  self::PERMISSION => Auth::PERM_READ
37  ));
38  $this->dbManager = $this->getObject('db.manager');
39  }
40 
46  protected function handle(Request $request)
47  {
48  $response = '1';
49  $jobInfo = $this->dbManager->getSingleRow(
50  "SELECT jq_end_bits FROM jobqueue WHERE jq_end_bits = '0' LIMIT 1;");
51  if (empty($jobInfo)) {
52  $response = '0';
53  }
54  $status = 1;
56  $status = empty($status) ? JsonResponse::HTTP_INTERNAL_SERVER_ERROR : JsonResponse::HTTP_OK;
57  return new JsonResponse(array("status" => $response), $status);
58  }
59 }
60 
61 register_plugin(new AjaxJobStatus());
ReportCachePurgeAll()
Purge all records from the report cache.
handle(Request $request)
: returns 1 when jobs are running else 0
fo_dbManager * dbManager
fo_dbManager object
Definition: process.c:28