Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | |
3 | /** |
4 | * Database service interface for Records. |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2024. |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 2, |
12 | * as published by the Free Software Foundation. |
13 | * |
14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | * GNU General Public License for more details. |
18 | * |
19 | * You should have received a copy of the GNU General Public License |
20 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 | * |
23 | * @category VuFind |
24 | * @package Database |
25 | * @author Sudharma Kellampalli <skellamp@villanova.edu> |
26 | * @author Demian Katz <demian.katz@villanova.edu> |
27 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
28 | * @link https://vufind.org/wiki/development:plugins:database_gateways Wiki |
29 | */ |
30 | |
31 | namespace VuFind\Db\Service; |
32 | |
33 | use Exception; |
34 | use VuFind\Db\Entity\RecordEntityInterface; |
35 | |
36 | /** |
37 | * Database service interface for Records. |
38 | * |
39 | * @category VuFind |
40 | * @package Database |
41 | * @author Sudharma Kellampalli <skellamp@villanova.edu> |
42 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
43 | * @link https://vufind.org/wiki/development:plugins:database_gateways Wiki |
44 | */ |
45 | interface RecordServiceInterface extends DbServiceInterface |
46 | { |
47 | /** |
48 | * Retrieve a record by id. |
49 | * |
50 | * @param string $id Record ID |
51 | * @param string $source Record source |
52 | * |
53 | * @return ?RecordEntityInterface |
54 | */ |
55 | public function getRecord(string $id, string $source): ?RecordEntityInterface; |
56 | |
57 | /** |
58 | * Retrieve records by ids. |
59 | * |
60 | * @param string[] $ids Record IDs |
61 | * @param string $source Record source |
62 | * |
63 | * @return RecordEntityInterface[] Array of record objects found |
64 | */ |
65 | public function getRecords(array $ids, string $source): array; |
66 | |
67 | /** |
68 | * Update an existing entry in the record table or create a new one. |
69 | * |
70 | * @param string $id Record ID |
71 | * @param string $source Data source |
72 | * @param mixed $rawData Raw data from source (must be serializable) |
73 | * |
74 | * @return RecordEntityInterface |
75 | */ |
76 | public function updateRecord(string $id, string $source, $rawData): RecordEntityInterface; |
77 | |
78 | /** |
79 | * Clean up orphaned entries (i.e. entries that are not in favorites anymore) |
80 | * |
81 | * @return int Number of records deleted |
82 | */ |
83 | public function cleanup(): int; |
84 | |
85 | /** |
86 | * Delete a record by source and id. Return true if found and deleted, false if not found. |
87 | * Throws exception if something goes wrong. |
88 | * |
89 | * @param string $id Record ID |
90 | * @param string $source Record source |
91 | * |
92 | * @return bool |
93 | * @throws Exception |
94 | */ |
95 | public function deleteRecord(string $id, string $source): bool; |
96 | |
97 | /** |
98 | * Create a record entity object. |
99 | * |
100 | * @return RecordEntityInterface |
101 | */ |
102 | public function createEntity(): RecordEntityInterface; |
103 | } |