FOSSology  4.4.0
Open Source License Compliance by Open Source Software
JobDao.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2015 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 namespace Fossology\Lib\Dao;
9 
11 use Monolog\Logger;
12 
13 class JobDao
14 {
16  private $dbManager;
18  private $logger;
19 
20  function __construct(DbManager $dbManager, Logger $logger)
21  {
22  $this->dbManager = $dbManager;
23  $this->logger = $logger;
24  }
25 
26  public function getAllJobStatus($uploadId, $userId, $groupId)
27  {
28  $result = array();
29  $stmt = __METHOD__;
30  $this->dbManager->prepare($stmt,
31  "SELECT jobqueue.jq_pk as jq_pk,
32  jobqueue.jq_end_bits as end_bits
33  FROM jobqueue
34  INNER JOIN job
35  ON jobqueue.jq_job_fk = job.job_pk
36  LEFT JOIN group_user_member gm
37  ON gm.user_fk = job_user_fk
38  WHERE job.job_upload_fk = $1
39  AND (job_user_fk = $2
40  OR gm.group_fk = $3)");
41 
42  $res = $this->dbManager->execute($stmt, array($uploadId, $userId, $groupId));
43  while ($row = $this->dbManager->fetchArray($res)) {
44  $result[$row['jq_pk']] = $row['end_bits'];
45  }
46  $this->dbManager->freeResult($res);
47 
48  return $result;
49  }
50 
51  public function getChlidJobStatus($jobId)
52  {
53  $result = array();
54  $stmt = __METHOD__;
55  $this->dbManager->prepare($stmt,
56  "SELECT jobqueue.jq_pk as jq_pk,
57  jobqueue.jq_end_bits as end_bits
58  FROM jobqueue
59  WHERE jq_job_fk = $1");
60 
61  $res = $this->dbManager->execute($stmt, array($jobId));
62  while ($row = $this->dbManager->fetchArray($res)) {
63  $result[$row['jq_pk']] = $row['end_bits'];
64  }
65  $this->dbManager->freeResult($res);
66 
67  return $result;
68  }
69 
70  public function hasActionPermissionsOnJob($jobId, $userId, $groupId)
71  {
72  $result = array();
73  $stmt = __METHOD__;
74  $this->dbManager->prepare($stmt,
75  "SELECT *
76  FROM job
77  LEFT JOIN group_user_member gm
78  ON gm.user_fk = job_user_fk
79  WHERE job_pk = $1
80  AND (job_user_fk = $2
81  OR gm.group_fk = $3)");
82 
83  $res = $this->dbManager->execute($stmt, array($jobId, $userId, $groupId));
84  while ($row = $this->dbManager->fetchArray($res)) {
85  $result[$row['jq_pk']] = $row['end_bits'];
86  }
87  $this->dbManager->freeResult($res);
88 
89  return $result;
90  }
91 }
fo_dbManager * dbManager
fo_dbManager object
Definition: process.c:16