successfully harvested metadata from dspace

This commit is contained in:
Daniel Neis 2013-05-11 22:00:10 +00:00
parent 04669d927b
commit 41b005ae1a
8 changed files with 44 additions and 36 deletions

View File

@ -3,7 +3,6 @@
* \file
* \brief classes related to generating RIF-CS XML response file for ANDS.
*
*
* Generate RIF-CS set records of Activity, Collection, Party.
* - They are closely bounded to ANDS requirements, need to know the database for getting information.
*/

View File

@ -1,7 +1,6 @@
<?php
/**
* \file
* \brief Response to Verb Identify
* Response to Verb Identify
*
* Tell the world what the data provider is. Usually it is static once the provider has been set up.
*
@ -129,7 +128,7 @@ if (false) {
}
if(strlen($output)>10) {
$des = $outputObj->doc->createDocumentFragment();
$des->appendXML($output);
$outputObj->verbNode->appendChild($des);
$des = $outputObj->doc->createDocumentFragment();
$des->appendXML($output);
$outputObj->verbNode->appendChild($des);
}

View File

@ -113,14 +113,12 @@ if ($num_rows - $deliveredrecords > $maxItems) {
$cursor = (int)$deliveredrecords + $maxItems;
$restoken = createResumToken($cursor, $extquery, $metadataPrefix);
$expirationdatetime = gmstrftime('%Y-%m-%dT%TZ', time()+TOKEN_VALID);
}
} elseif (isset($args['resumptionToken'])) {
// Last delivery, return empty ResumptionToken
elseif (isset($args['resumptionToken'])) {
$restoken = $args['resumptionToken']; // just used as an indicator
unset($expirationdatetime);
}
if (isset($args['resumptionToken'])) {
debug_message("Try to resume because a resumptionToken supplied.") ;
$record = $res->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_ABS, $deliveredrecords);

View File

@ -1,7 +1,5 @@
<?php
/**
* \file oai2.php
* \brief
* OAI Data Provider command processor
*
* OAI Data Provider is not designed for human to retrieve data.
@ -55,7 +53,9 @@ foreach ($args as $key => $val) {
$errors[] = oai_error('badArgument', $checking);
} else {$args[$key] = $checking; }
}
if (!empty($errors)) { oai_exit(); }
if (!empty($errors)) {
oai_exit();
}
foreach($attribs as $val) {
unset($$val);
@ -96,7 +96,7 @@ if (isset($args['verb'])) {
case 'Identify':
// we never use compression in Identify
$compress = FALSE;
if(count($args)>1) {
if (count($args)>1) {
foreach($args as $key => $val) {
if(strcmp($key,"verb")!=0) {
$errors[] = oai_error('badArgument', $key, $val);
@ -113,7 +113,7 @@ if (isset($args['verb'])) {
break;
case 'ListSets':
if(isset($args['resumptionToken']) && count($args) > 2) {
if (isset($args['resumptionToken']) && count($args) > 2) {
$errors[] = oai_error('exclusiveArgument');
}
$checkList = array("ops"=>array("resumptionToken"));

View File

@ -54,7 +54,7 @@ $identifyResponse = array();
// MUST (only one)
// please adjust
$identifyResponse["repositoryName"] = 'Moodle Dev2';
$identifyResponse["repositoryName"] = 'Moodle Neis';
// For ANDS to harvest of RIF-CS, originatingSource is plantaccelerator.org.au
// $dataSource = "plantaccelerator.org.au";

View File

@ -54,30 +54,24 @@ function debug_message($msg) {
* is needed.
*/
function checkArgs($args, $checkList) {
// global $errors, $TOKEN_VALID, $METADATAFORMATS;
global $errors, $METADATAFORMATS;
// $verb = $args['verb'];
unset($args["verb"]);
debug_print_r('checkList',$checkList);
debug_print_r('args',$args);
// "verb" has been checked before, no further check is needed
unset($args["verb"]);
if(isset($checkList['required'])) {
for($i = 0; $i < count($checkList["required"]); $i++) {
debug_message("Checking: par$i: ". $checkList['required'][$i] . " in ");
debug_var_dump("isset(\$args[\$checkList['required'][\$i]])",isset($args[$checkList['required'][$i]]));
// echo "key exists". array_key_exists($checkList["required"][$i],$args)."\n";
if(isset($args[$checkList['required'][$i]])==false) {
// echo "caught\n";
$errors[] = oai_error('missingArgument', $checkList["required"][$i]);
} else {
// if metadataPrefix is set, it is in required section
if(isset($args['metadataPrefix'])) {
$metadataPrefix = $args['metadataPrefix'];
// Check if the format is supported, it has enough infor (an array), last if a handle has been defined.
if (!array_key_exists ($metadataPrefix, $METADATAFORMATS) || !(is_array($METADATAFORMATS[$metadataPrefix])
|| !isset($METADATAFORMATS[$metadataPrefix]['myhandler']))) {
if (!array_key_exists($metadataPrefix, $METADATAFORMATS) ||
!(is_array($METADATAFORMATS[$metadataPrefix]) ||
!isset($METADATAFORMATS[$metadataPrefix]['myhandler']))) {
$errors[] = oai_error('cannotDisseminateFormat', 'metadataPrefix', $metadataPrefix);
}
}
@ -85,15 +79,13 @@ function checkArgs($args, $checkList) {
}
}
}
debug_message('Before return');
debug_print_r('errors',$errors);
if (!empty($errors)) return;
// check to see if there is unwanted
foreach($args as $key => $val) {
debug_message("checkArgs: $key");
if(!in_array($key, $checkList["ops"])) {
debug_message("Wrong\n".print_r($checkList['ops'],true));
$errors[] = oai_error('badArgument', $key, $val);
}
switch ($key) {

View File

@ -6,9 +6,31 @@
* to demonstrate how a new metadata can be supported. For a working
* example, please see record_rif.php.
*
* \sa oaidp-config.php
*/
*/
function create_metadata($outputObj, $cur_record, $identifier, $setspec, $db) {
$metadata_node = $outputObj->create_metadata($cur_record);
$sql = "SELECT dc_title, dc_creator, dc_subject, dc_description, dc_contributor, dc_publisher,
dc_date , dc_type , dc_format , dc_identifier , dc_source , dc_language,
dc_relation , dc_coverage , dc_rights
FROM oai_records
WHERE oai_set = '{$setspec}'
AND oai_identifier = '{$identifier}'";
$res = exec_pdo_query($db,$sql);
$record = $res->fetch(PDO::FETCH_ASSOC);
$meta_node = $outputObj->addChild($cur_record ,"metadata");
$schema_node = $outputObj->addChild($meta_node, 'oai_dc:dc');
$schema_node->setAttribute('xmlns:oai_dc', "http://www.openarchives.org/OAI/2.0/oai_dc/");
$schema_node->setAttribute('xmlns:dc',"http://purl.org/dc/elements/1.1/");
$schema_node->setAttribute('xmlns:xsi',"http://www.w3.org/2001/XMLSchema-instance");
$schema_node->setAttribute('xsi:schemaLocation',
'http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd');
foreach ($record as $r => $v) {
if (!empty($v)) {
$outputObj->addChild($schema_node, str_replace('_', ':', $r), $v);
}
}
}

View File

@ -20,9 +20,7 @@
// Create a metadata object and a registryObjects, and its only child registryObject
function create_metadata($outputObj, $cur_record, $identifier, $setspec, $db) {
// debug_message('In '.__FILE__.' function '.__FUNCTION__.' was called.');
// debug_var_dump('metadata_node',$metadata_node);
$metadata_node = $outputObj->create_metadata($cur_record);
$obj_node = new ANDS_TPA($outputObj, $metadata_node, $db);
try {