1 | <?php |
||
23 | class OcrJobMapper extends Mapper { |
||
24 | |||
25 | /** |
||
26 | * OcrJobMapper constructor. |
||
27 | * |
||
28 | * @param IDBConnection $db |
||
29 | */ |
||
30 | public function __construct(IDBConnection $db) { |
||
31 | parent::__construct($db, 'ocr_jobs', 'OCA\Ocr\Db\OcrJob'); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Find a specific job entity |
||
36 | * |
||
37 | * @param $id |
||
38 | * @return OcrJob |
||
39 | */ |
||
40 | public function find($id) { |
||
41 | $sql = 'SELECT * FROM *PREFIX*ocr_jobs WHERE id = ?'; |
||
42 | return $this->findEntity($sql, [$id]); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Finds all user specific jobs entities |
||
47 | * |
||
48 | * @param $userId |
||
49 | * @return OcrJob[] |
||
50 | */ |
||
51 | public function findAll($userId) { |
||
52 | $sql = 'SELECT * FROM *PREFIX*ocr_jobs WHERE user_id = ?'; |
||
53 | return $this->findEntities($sql, [$userId]); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Finds all jobs PROCESSED entities for a given userid |
||
58 | * @param $userId |
||
59 | * @return OcrJob[] |
||
60 | */ |
||
61 | public function findAllProcessed($userId) { |
||
62 | $sql = 'SELECT * FROM *PREFIX*ocr_jobs WHERE user_id = ? AND status = ?'; |
||
63 | return $this->findEntities($sql, [$userId, OcrConstants::STATUS_PROCESSED]); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * Finds all jobs PENDING entities for a given userid. |
||
68 | * @param $userId |
||
69 | * @return OcrJob[] |
||
70 | */ |
||
71 | public function findAllPending($userId) { |
||
75 | |||
76 | /** |
||
77 | * Finds all jobs FAILED entities for a given userid, which were not displayed yet. |
||
78 | * @param $userId |
||
79 | * @return OcrJob[] |
||
80 | */ |
||
81 | public function findAllFailed($userId) { |
||
85 | |||
86 | } |