3232namespace VuFind \OAI ;
3333
3434use SimpleXMLElement ;
35+ use VuFind \Db \Entity \ChangeTrackerEntityInterface ;
36+ use VuFind \Db \Service \ChangeTrackerServiceInterface ;
3537use VuFind \Db \Service \OaiResumptionServiceInterface ;
3638use VuFind \Exception \RecordMissing as RecordMissingException ;
3739use VuFind \SimpleXML ;
@@ -213,13 +215,13 @@ class Server
213215 *
214216 * @param \VuFind\Search\Results\PluginManager $resultsManager Search manager for retrieving records
215217 * @param \VuFind\Record\Loader $recordLoader Record loader
216- * @param \VuFind\Db\Table\PluginManager $tableManager Table manager
218+ * @param ChangeTrackerServiceInterface $trackerService ChangeTracker Service
217219 * @param OaiResumptionServiceInterface $resumptionService Database service for resumption tokens
218220 */
219221 public function __construct (
220222 protected \VuFind \Search \Results \PluginManager $ resultsManager ,
221223 protected \VuFind \Record \Loader $ recordLoader ,
222- protected \ VuFind \ Db \ Table \ PluginManager $ tableManager ,
224+ protected ChangeTrackerServiceInterface $ trackerService ,
223225 protected OaiResumptionServiceInterface $ resumptionService
224226 ) {
225227 }
@@ -321,22 +323,22 @@ public function getResponse()
321323 /**
322324 * Assign necessary interface variables to display a deleted record.
323325 *
324- * @param SimpleXMLElement $xml XML to update
325- * @param array $tracker Array representing a change_tracker row
326- * @param bool $headerOnly Only attach the header?
326+ * @param SimpleXMLElement $xml XML to update
327+ * @param ChangeTrackerEntityInterface $trackerEntity ChangeTracker entity
328+ * @param bool $headerOnly Only attach the header?
327329 *
328330 * @return void
329331 */
330- protected function attachDeleted ($ xml , $ tracker , $ headerOnly = false )
332+ protected function attachDeleted ($ xml , $ trackerEntity , $ headerOnly = false )
331333 {
332334 // Deleted records only have a header, no metadata. However, depending
333335 // on the context we are attaching them, they may or may not need a
334336 // <record> tag wrapping the header.
335337 $ record = $ headerOnly ? $ xml : $ xml ->addChild ('record ' );
336338 $ this ->attachRecordHeader (
337339 $ record ,
338- $ this ->prefixID ($ tracker [ ' id ' ] ),
339- date ($ this ->iso8601 , $ this -> normalizeDate ( $ tracker [ ' deleted ' ] )),
340+ $ this ->prefixID ($ trackerEntity -> getId () ),
341+ date ($ this ->iso8601 , $ trackerEntity -> getDeleted ()-> getTimestamp ( )),
340342 [],
341343 'deleted '
342344 );
@@ -530,13 +532,13 @@ protected function getRecord()
530532 }
531533 } else {
532534 // No record in index -- is this deleted?
533- $ tracker = $ this -> tableManager -> get ( ' ChangeTracker ' );
534- $ row = $ tracker -> retrieve (
535+
536+ $ row = $ this -> trackerService -> getChangeTrackerEntity (
535537 $ this ->core ,
536538 $ this ->stripID ($ this ->params ['identifier ' ])
537539 );
538- if (!empty ($ row ) && !empty ($ row ->deleted )) {
539- $ this ->attachDeleted ($ xml , $ row-> toArray () );
540+ if (!empty ($ row ) && !empty ($ row ->getDeleted () )) {
541+ $ this ->attachDeleted ($ xml , $ row );
540542 } else {
541543 // Not deleted and not found in index -- error!
542544 return $ this ->showError ('idDoesNotExist ' , 'Unknown Record ' );
@@ -944,15 +946,14 @@ protected function listSets()
944946 * @param int $until End date.
945947 * @param int $currentCursor Offset into result set
946948 *
947- * @return \Laminas\Db\ResultSet\AbstractResultSet
949+ * @return ChangeTrackerEntityInterface[]
948950 */
949951 protected function listRecordsGetDeleted ($ from , $ until , $ currentCursor )
950952 {
951- $ tracker = $ this ->tableManager ->get ('ChangeTracker ' );
952- return $ tracker ->retrieveDeleted (
953+ return $ this ->trackerService ->getDeletedEntities (
953954 $ this ->core ,
954- date ( ' Y-m-d H:i:s ' , $ from ),
955- date ( ' Y-m-d H:i:s ' , $ until ),
955+ \DateTime:: createFromFormat ( ' U ' , $ from ),
956+ \DateTime:: createFromFormat ( ' U ' , $ until ),
956957 $ currentCursor ,
957958 $ this ->pageSize
958959 );
@@ -968,11 +969,10 @@ protected function listRecordsGetDeleted($from, $until, $currentCursor)
968969 */
969970 protected function listRecordsGetDeletedCount ($ from , $ until )
970971 {
971- $ tracker = $ this ->tableManager ->get ('ChangeTracker ' );
972- return $ tracker ->retrieveDeletedCount (
972+ return $ this ->trackerService ->getDeletedCount (
973973 $ this ->core ,
974- date ( ' Y-m-d H:i:s ' , $ from ),
975- date ( ' Y-m-d H:i:s ' , $ until )
974+ \DateTime:: createFromFormat ( ' U ' , $ from ),
975+ \DateTime:: createFromFormat ( ' U ' , $ until )
976976 );
977977 }
978978
0 commit comments