query("SELECT setspec FROM $dbtable[archives_sets] WHERE archive='$archive'");
+
+ while($set = $db->assoc_array($result)) {
+ $sets .= $set[setspec] . " ";
+ }
+
+ if(!empty($sets)) {
+ $sets = substr($sets,0,strlen($sets)-4);
+ }
+
// get archive info from database
$result = $db->query("SELECT * FROM $dbtable[archives] WHERE id='$archive'");
if($db->num_rows($result) == 0) {
@@ -606,6 +659,11 @@
+ OAI archive sets:
+
+
+
+
OAI protocol version:
diff -Naur harvester/include/db.inc.php harvester.new/include/db.inc.php
--- harvester/include/db.inc.php 2004-02-22 17:50:03.000000000 -0700
+++ harvester.new/include/db.inc.php 2005-11-11 15:31:08.000000000 -0700
@@ -36,22 +36,23 @@
$db_config['type'] = "mysql";
// Name of database
-$db_config['name'] = "harvester";
+$db_config['name'] = "pkp";
// Hostname, port, username, and password to database server
$db_config['host'] = "localhost";
$db_config['port'] = "";
-$db_config['uname'] = "root";
-$db_config['password'] = "";
+$db_config['uname'] = "pkp";
+$db_config['password'] = "copy*support";
// Set to 1 to enable persistent connections, 0 to disable
-$db_config['pconnect'] = 1;
+$db_config['pconnect'] = 0;
// database tables
$dbtable = array();
$dbtable['harvester_config'] = "harvester_config";
$dbtable['archives'] = "archives";
+$dbtable['archives_sets'] = "archives_sets";
$dbtable['metadata'] = "metadata";
$dbtable['links'] = "links";
$dbtable['oai_resumption_tokens'] = "oai_resumption_tokens";
diff -Naur harvester/include/harvester.inc.php harvester.new/include/harvester.inc.php
--- harvester/include/harvester.inc.php 2004-02-22 17:50:03.000000000 -0700
+++ harvester.new/include/harvester.inc.php 2005-11-11 15:31:15.000000000 -0700
@@ -5,19 +5,19 @@
// PKP OAI Harvester
// Copyright (c) 2003-2004 The Public Knowledge Project
// http://www.pkp.ubc.ca
-//
+//
// This file is part of the PKP OAI Harvester.
-//
+//
// The PKP OAI Harvester is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
-//
+//
// The PKP OAI Harvester is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with the PKP OAI Harvester; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -32,63 +32,65 @@
// index papers from a specific archive, or all archives if $archive = 0
function indexArchives($archive = 0) {
global $db, $dbtable;
-
+
// make sure we don't timeout too early
set_time_limit(1200);
-
+
// get archive info from database
- $sql = "SELECT * FROM $dbtable[archives] ";
- if(!empty($archive)) { $sql .= "WHERE id='$archive' "; }
+ $sql = "SELECT a.*, s.setspec FROM $dbtable[archives] as a \n";
+ $sql .= "LEFT OUTER JOIN $dbtable[archives_sets] as s \n";
+ $sql .= "ON a.id = s.archive \n";
+ if(!empty($archive)) { $sql .= "WHERE a.id='$archive' \n"; }
$sql .= "ORDER BY LOWER(name)";
-
+
$result = $db->query($sql);
-
+
// loop through each archive
for($i=0; $i<$db->num_rows($result); $i++) {
$archive_items = $db->assoc_array($result, $i);
$num_records = 0;
-
- echo "Indexing $archive_items[name] ... ";
-
+
+ echo "Indexing $archive_items[name]";
+ echo ((empty($archive_items[setspec])) ? "" : " - $archive_items[setspec]");
+ echo " ... ";
+
// determine which protocol version archive uses
if(preg_match("/^2/", $archive_items[protocol])) {
// OAI 2.0
$protocol = 2;
-
} else {
// OAI 1.1
$protocol = 1;
}
-
+
// fetch records via OAI ListIdentifiers or ListRecords functions
// loop until a resumption token is not returned
$resumptiontoken = "";
do {
if($archive_items[index_method] == "I") {
- list($oai_records, $resumptiontoken) = parseListIdentifiers($archive_items[oai], $protocol, $resumptiontoken);
+ list($oai_records, $resumptiontoken) = parseListIdentifiers($archive_items[oai], $protocol, $archive_items[setspec], $resumptiontoken);
} else {
- list($oai_records, $resumptiontoken) = parseListRecords($archive_items[oai], $protocol, $resumptiontoken);
+ list($oai_records, $resumptiontoken) = parseListRecords($archive_items[oai], $protocol, $archive_items[setspec], $resumptiontoken);
}
-
- // add records to database
+ // add records to database
for($j=0; $j $v) {
$metadata[$k] = sanitize_db_input(utf8_decode($v));
}
-
+
// check if this item has already been indexed
$record_result = $db->query("SELECT id, datestamp FROM $dbtable[metadata] WHERE oai_identifier='$metadata[oai_identifier]' AND archive='$archive_items[id]'");
-
+
if($db->num_rows($record_result) != 0) {
// record exists, check if datestamp is newer
$record_items = $db->assoc_array($record_result);
@@ -133,31 +135,30 @@
}
}
} while($resumptiontoken != "");
-
-
+
// update datestamp and record count for archive
$count_result = $db->query("SELECT COUNT(*) FROM $dbtable[metadata] WHERE archive='$archive_items[id]'");
list($total_records) = $db->assoc_array($count_result);
$db->query("UPDATE $dbtable[archives] SET num_records='$total_records', datestamp=NOW() WHERE id='$archive_items[id]'");
-
+
echo "done ($num_records new/updated record";
if($num_records != 1) { echo "s"; }
echo " indexed)