Skip to content
Snippets Groups Projects
Commit 29746374 authored by Demian Katz's avatar Demian Katz
Browse files

Allow harvest of multiple sets to a single directory.

- Resolves VUFIND-413.
parent 04e8074b
No related merge requests found
......@@ -27,7 +27,8 @@
; url is the base URL for the OAI-PMH source.
;
; set is the identifier of a set to harvest (normally found in the <setSpec> tag of
; an OAI-PMH ListSets response). Omit this setting to harvest all records.
; an OAI-PMH ListSets response). You may harvest multiple sets by putting multiple
; "set[] = x" lines into your configuration. Omit set to harvest all records.
;
; metadataPrefix is the metadata format to harvest (oai_dc will be used by default
; if the value is omitted).
......
......@@ -56,9 +56,9 @@ class OAI
protected $baseURL;
/**
* Target set to harvest (null for all records)
* Target set(s) to harvest (null for all records)
*
* @var string
* @var string|array
*/
protected $set = null;
......@@ -256,12 +256,21 @@ class OAI
*/
public function launch()
{
// Start harvesting at the requested date:
$token = $this->getRecordsByDate($this->startDate, $this->set);
// Normalize sets setting to an array:
$sets = (array)$this->set;
if (empty($sets)) {
$sets = array(null);
}
// Keep harvesting as long as a resumption token is provided:
while ($token !== false) {
$token = $this->getRecordsByToken($token);
// Loop through all of the selected sets:
foreach ($sets as $set) {
// Start harvesting at the requested date:
$token = $this->getRecordsByDate($this->startDate, $set);
// Keep harvesting as long as a resumption token is provided:
while ($token !== false) {
$token = $this->getRecordsByToken($token);
}
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment