Harvester
in package
Uses
WriterAwareTrait
OAI-PMH Harvest Tool
Tags
Table of Contents
- $communicator : Communicator
- Low-level OAI-PMH communicator
- $granularity : string
- Date granularity ('auto' to autodetect)
- $harvestEndDate : string
- Harvest end date (null for no specific end)
- $identifyResponse : stdClass
- Identify information from OAI host
- $metadataPrefix : string
- Metadata type to harvest
- $outputWriter : WriterInterface
- Writer helper
- $recordsCount : mixed
- Count harvested records.
- $set : string|array<string|int, mixed>
- Target set(s) to harvest (null for all records)
- $startDate : string
- Harvest start date (null for no specific start)
- $stateManager : StateManager
- State manager
- $stopAfter : int|null
- Flag to limit number of harvested records (null = no limit).
- $writer : RecordWriter
- Record writer
- __construct() : mixed
- Constructor.
- launch() : void
- Harvest all available documents.
- setEndDate() : void
- Set an end date for the harvest (only harvest records BEFORE this date).
- setOutputWriter() : void
- Set an object to accept console output messages.
- setStartDate() : void
- Set a start date for the harvest (only harvest records AFTER this date).
- checkResponseForErrors() : void
- Check an OAI-PMH response for errors that need to be handled.
- getIdentifyResponse() : stdClass
- Get identify information from OAI-PMH host. Unless $reset = TRUE, this method will only invoke an OAI-PMH call upon its first usage and will return cached data after that.
- getRecords() : mixed
- Harvest records using OAI-PMH.
- getRecordsByDate() : mixed
- Harvest records via OAI-PMH using date and set.
- getRecordsByToken() : mixed
- Harvest records via OAI-PMH using resumption token.
- sendRequest() : object
- Make an OAI-PMH request. Die if there is an error; return a SimpleXML object on success.
- storeDateSettings() : void
- Set date range configuration (support method for constructor).
- storeMiscSettings() : void
- Set miscellaneous configuration (support method for constructor).
- write() : void
- Write a string to the console output writer (if set).
- writeLine() : void
- Write a string w/newline to the console output writer (if set).
Properties
$communicator
Low-level OAI-PMH communicator
protected
Communicator
$communicator
$granularity
Date granularity ('auto' to autodetect)
protected
string
$granularity
= 'auto'
$harvestEndDate
Harvest end date (null for no specific end)
protected
string
$harvestEndDate
$identifyResponse
Identify information from OAI host
protected
stdClass
$identifyResponse
= null
$metadataPrefix
Metadata type to harvest
protected
string
$metadataPrefix
= 'oai_dc'
$outputWriter
Writer helper
protected
WriterInterface
$outputWriter
= null
$recordsCount
Count harvested records.
protected
mixed
$recordsCount
= 0
$set
Target set(s) to harvest (null for all records)
protected
string|array<string|int, mixed>
$set
= null
$startDate
Harvest start date (null for no specific start)
protected
string
$startDate
= null
$stateManager
State manager
protected
StateManager
$stateManager
$stopAfter
Flag to limit number of harvested records (null = no limit).
protected
int|null
$stopAfter
= null
Used only for testing.
$writer
Record writer
protected
RecordWriter
$writer
Methods
__construct()
Constructor.
public
__construct(Communicator $communicator, RecordWriter $writer, StateManager $stateManager[, array<string|int, mixed> $settings = [] ]) : mixed
Parameters
- $communicator : Communicator
-
Low-level API client
- $writer : RecordWriter
-
Record writer
- $stateManager : StateManager
-
State manager
- $settings : array<string|int, mixed> = []
-
OAI-PMH settings
Return values
mixed —launch()
Harvest all available documents.
public
launch() : void
Tags
Return values
void —setEndDate()
Set an end date for the harvest (only harvest records BEFORE this date).
public
setEndDate(string $date) : void
Parameters
- $date : string
-
End date (YYYY-MM-DD format).
Return values
void —setOutputWriter()
Set an object to accept console output messages.
public
setOutputWriter(WriterInterface $writer) : void
Parameters
- $writer : WriterInterface
-
Writer object
Return values
void —setStartDate()
Set a start date for the harvest (only harvest records AFTER this date).
public
setStartDate(string $date) : void
Parameters
- $date : string
-
Start date (YYYY-MM-DD format).
Return values
void —checkResponseForErrors()
Check an OAI-PMH response for errors that need to be handled.
protected
checkResponseForErrors(object $result) : void
Parameters
- $result : object
-
OAI-PMH response (SimpleXML object)
Tags
Return values
void —getIdentifyResponse()
Get identify information from OAI-PMH host. Unless $reset = TRUE, this method will only invoke an OAI-PMH call upon its first usage and will return cached data after that.
protected
getIdentifyResponse([bool $reset = false ]) : stdClass
Parameters
- $reset : bool = false
-
Whether-or-not to reset identity information already fetched during this request.
Tags
Return values
stdClass —An object of response properties as defined by http://www.openarchives.org/OAI/openarchivesprotocol.html#Identify plus a 'responseDate' property representing the datestamp of the identify response in the form YYYY-MM-DDThh:mm:ssZ
getRecords()
Harvest records using OAI-PMH.
protected
getRecords(array<string|int, mixed> $params) : mixed
Parameters
- $params : array<string|int, mixed>
-
GET parameters for ListRecords method.
Return values
mixed —Resumption token if provided, false if finished
getRecordsByDate()
Harvest records via OAI-PMH using date and set.
protected
getRecordsByDate([string $from = null ][, string $set = null ][, string $until = null ]) : mixed
Parameters
- $from : string = null
-
Harvest start date (null for no specific start).
- $set : string = null
-
Set to harvest (null for all records).
- $until : string = null
-
Harvest end date (null for no specific end).
Return values
mixed —Resumption token if provided, false if finished
getRecordsByToken()
Harvest records via OAI-PMH using resumption token.
protected
getRecordsByToken(string $token) : mixed
Parameters
- $token : string
-
Resumption token.
Return values
mixed —Resumption token if provided, false if finished
sendRequest()
Make an OAI-PMH request. Die if there is an error; return a SimpleXML object on success.
protected
sendRequest(string $verb[, array<string|int, mixed> $params = [] ]) : object
Parameters
- $verb : string
-
OAI-PMH verb to execute.
- $params : array<string|int, mixed> = []
-
GET parameters for ListRecords method.
Return values
object —SimpleXML-formatted response.
storeDateSettings()
Set date range configuration (support method for constructor).
protected
storeDateSettings(array<string|int, mixed> $settings) : void
Parameters
- $settings : array<string|int, mixed>
-
Configuration
Return values
void —storeMiscSettings()
Set miscellaneous configuration (support method for constructor).
protected
storeMiscSettings(array<string|int, mixed> $settings) : void
Parameters
- $settings : array<string|int, mixed>
-
Configuration
Return values
void —write()
Write a string to the console output writer (if set).
protected
write(string $str) : void
Parameters
- $str : string
-
String to write.
Return values
void —writeLine()
Write a string w/newline to the console output writer (if set).
protected
writeLine(string $str) : void
Parameters
- $str : string
-
String to write.