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 change tracker.
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
31namespace VuFind\Db\Service;
32
33use DateTime;
34use VuFind\Db\Entity\ChangeTrackerEntityInterface;
35
36/**
37 * Database service interface for change tracker.
38 *
39 * @category VuFind
40 * @package  Database
41 * @author   Sudharma Kellampalli <skellamp@villanova.edu>
42 * @author   Demian Katz <demian.katz@villanova.edu>
43 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
44 * @link     https://vufind.org/wiki/development:plugins:database_gateways Wiki
45 */
46interface ChangeTrackerServiceInterface extends DbServiceInterface
47{
48    /**
49     * Retrieve a row from the database based on primary key; return null if it
50     * is not found.
51     *
52     * @param string $indexName The name of the Solr index holding the record.
53     * @param string $id        The ID of the record being indexed.
54     *
55     * @return ?ChangeTrackerEntityInterface
56     */
57    public function getChangeTrackerEntity(string $indexName, string $id): ?ChangeTrackerEntityInterface;
58
59    /**
60     * Retrieve a count of deleted rows from the database.
61     *
62     * @param string   $indexName The name of the Solr index holding the record.
63     * @param DateTime $from      The beginning date of the range to search.
64     * @param DateTime $until     The end date of the range to search.
65     *
66     * @return int
67     */
68    public function getDeletedCount(string $indexName, DateTime $from, DateTime $until): int;
69
70    /**
71     * Retrieve a set of deleted rows from the database.
72     *
73     * @param string   $indexName The name of the Solr index holding the record.
74     * @param DateTime $from      The beginning date of the range to search.
75     * @param DateTime $until     The end date of the range to search.
76     * @param int      $offset    Record number to retrieve first.
77     * @param ?int     $limit     Retrieval limit (null for no limit)
78     *
79     * @return ChangeTrackerEntityInterface[]
80     */
81    public function getDeletedEntities(
82        string $indexName,
83        DateTime $from,
84        DateTime $until,
85        int $offset = 0,
86        ?int $limit = null
87    ): array;
88
89    /**
90     * Update the change tracker table to indicate that a record has been deleted.
91     *
92     * The method returns the updated/created row when complete.
93     *
94     * @param string $core The Solr core holding the record.
95     * @param string $id   The ID of the record being indexed.
96     *
97     * @return ChangeTrackerEntityInterface
98     */
99    public function markDeleted(string $core, string $id): ChangeTrackerEntityInterface;
100
101    /**
102     * Update the change_tracker table to reflect that a record has been indexed.
103     * We need to know the date of the last change to the record (independent of
104     * its addition to the index) in order to tell the difference between a
105     * reindex of a previously-encountered record and a genuine change.
106     *
107     * The method returns the updated/created row when complete.
108     *
109     * @param string $core   The Solr core holding the record.
110     * @param string $id     The ID of the record being indexed.
111     * @param int    $change The timestamp of the last record change.
112     *
113     * @return ChangeTrackerEntityInterface
114     */
115    public function index(string $core, string $id, int $change): ChangeTrackerEntityInterface;
116}