1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* nextCloud - ocr |
4
|
|
|
* |
5
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
6
|
|
|
* later. See the COPYING file. |
7
|
|
|
* |
8
|
|
|
* @author Janis Koehr <[email protected]> |
9
|
|
|
* @copyright Janis Koehr 2016 |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace OCA\Ocr\Db; |
13
|
|
|
|
14
|
|
|
use OCP\AppFramework\Db\Mapper; |
15
|
|
|
use OCP\IDBConnection; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class OcrStatusMapper |
19
|
|
|
* |
20
|
|
|
* @package OCA\Ocr\Db |
21
|
|
|
*/ |
22
|
|
|
class OcrStatusMapper extends Mapper { |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* OcrStatusMapper constructor. |
26
|
|
|
* |
27
|
|
|
* @param IDBConnection $db |
28
|
|
|
*/ |
29
|
2 |
|
public function __construct(IDBConnection $db) { |
30
|
2 |
|
parent::__construct($db, 'ocr_status', 'OCA\Ocr\Db\OcrStatus'); |
31
|
2 |
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Find a specific status entity |
35
|
|
|
* |
36
|
|
|
* @param $id |
37
|
|
|
* @return \OCP\AppFramework\Db\Entity |
38
|
|
|
*/ |
39
|
|
|
public function find($id) { |
40
|
|
|
$sql = 'SELECT * FROM *PREFIX*ocr_status WHERE id = ?'; |
41
|
|
|
return $this->findEntity($sql, [$id]); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Finds all status PROCESSED entities for a given userid |
46
|
|
|
* @param $userId |
47
|
|
|
* @return array |
48
|
|
|
*/ |
49
|
|
|
public function findAllProcessed($userId) { |
50
|
|
|
$sql = 'SELECT * FROM *PREFIX*ocr_status WHERE user_id = ? AND status = ?'; |
51
|
|
|
return $this->findEntities($sql, [$userId, 'PROCESSED']); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Finds all status PENDING entities for a given userid |
56
|
|
|
* @param $userId |
57
|
|
|
* @return array |
58
|
|
|
*/ |
59
|
|
|
public function findAllPending($userId) { |
60
|
|
|
$sql = 'SELECT * FROM *PREFIX*ocr_status WHERE user_id = ? AND status = ?'; |
61
|
|
|
return $this->findEntities($sql, [$userId, 'PENDING']); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Finds all status FAILED entities for a given userid |
66
|
|
|
* @param $userId |
67
|
|
|
* @return array |
68
|
|
|
*/ |
69
|
|
|
public function findAllFailed($userId) { |
70
|
|
|
$sql = 'SELECT * FROM *PREFIX*ocr_status WHERE user_id = ? AND status = ?'; |
71
|
|
|
return $this->findEntities($sql, [$userId, 'FAILED']); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
} |