first test datacite schema
This commit is contained in:
parent
d0ed3e9105
commit
3c50618c8a
8 changed files with 411 additions and 99 deletions
|
@ -7,8 +7,9 @@ use App\Models\Dataset;
|
|||
use Illuminate\Support\Facades\Log;
|
||||
use App\Exceptions\OaiModelException;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use App\Models\OaiModelError;
|
||||
|
||||
use App\Models\Oai\OaiModelError;
|
||||
use App\Models\Oai\ResumptionToken;
|
||||
|
||||
class RequestController extends Controller
|
||||
{
|
||||
/**
|
||||
|
@ -18,6 +19,7 @@ class RequestController extends Controller
|
|||
* @var array
|
||||
*/
|
||||
private $deliveringDocumentStates = array('published', 'deleted'); // maybe deleted documents too
|
||||
private $xMetaDissRestriction = array('doctoralthesis', 'habilitation');
|
||||
const SET_SPEC_PATTERN = '[A-Za-z0-9\-_\.!~\*\'\(\)]+';
|
||||
|
||||
|
||||
|
@ -102,7 +104,7 @@ class RequestController extends Controller
|
|||
private function __handleRequest(array $oaiRequest)
|
||||
{
|
||||
// Setup stylesheet
|
||||
$this->loadStyleSheet('oai-pmh.xslt');
|
||||
$this->loadStyleSheet('datasetxml2oai-pmh.xslt');
|
||||
|
||||
// Set response time
|
||||
$this->_proc->setParameter('', 'responseDate', date("Y-m-d\TH:i:s\Z"));
|
||||
|
@ -143,18 +145,18 @@ class RequestController extends Controller
|
|||
private function handleIdentify()
|
||||
{
|
||||
$email = "repository@geologie.ac.at";
|
||||
$repositoryName = "Data Research Repository";
|
||||
$repositoryName = "RDR - Data Research Repository";
|
||||
$repIdentifier = "rdr.gba.ac.at";
|
||||
//$sampleIdentifier = $this->_configuration->getSampleIdentifier();
|
||||
$sampleIdentifier = "oai:" . $repIdentifier . ":27";//$this->_configuration->getSampleIdentifier();
|
||||
$earliestDateFromDb = Dataset::earliestPublicationDate();
|
||||
|
||||
// set parameters for oai-pmh.xslt
|
||||
$this->_proc->setParameter('', 'email', $email);
|
||||
$this->_proc->setParameter('', 'repositoryName', $repositoryName);
|
||||
$this->_proc->setParameter('', 'repIdentifier', $repIdentifier);
|
||||
//$this->_proc->setParameter('', 'sampleIdentifier', $sampleIdentifier);
|
||||
$this->_proc->setParameter('', 'sampleIdentifier', $sampleIdentifier);
|
||||
$this->_proc->setParameter('', 'earliestDatestamp', $earliestDateFromDb);
|
||||
$this->_xml->appendChild($this->_xml->createElement('Documents'));
|
||||
$this->_xml->appendChild($this->_xml->createElement('Datasets'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -186,13 +188,11 @@ class RequestController extends Controller
|
|||
if (is_null($dataset)
|
||||
//or (false === in_array($dataset->getServerState(), $this->_deliveringDocumentStates))
|
||||
or (false === $dataset->whereIn('server_state', $this->deliveringDocumentStates))
|
||||
|
||||
|
||||
or (false === $dataset->hasEmbargoPassed())) {
|
||||
throw new OaiModelException('Document is not available for OAI export!', OaiModelError::NORECORDSMATCH);
|
||||
}
|
||||
|
||||
$this->_xml->appendChild($this->_xml->createElement('Documents'));
|
||||
$this->_xml->appendChild($this->_xml->createElement('Datasets'));
|
||||
$this->createXmlRecord($dataset);
|
||||
}
|
||||
|
||||
|
@ -208,15 +208,6 @@ class RequestController extends Controller
|
|||
|
||||
$dataId = null;
|
||||
switch ($identifierParts[0]) {
|
||||
// case 'urn':
|
||||
// //$finder = new Opus_DocumentFinder();
|
||||
// $finder = Dataset::query();
|
||||
// // $finder->setIdentifierTypeValue('urn', $oaiIdentifier);
|
||||
// // $finder->setServerStateInList($this->_deliveringDocumentStates);
|
||||
// $finder->whereIn('server_state', $this->deliveringDocumentStates);
|
||||
// $docIds = $finder->ids();
|
||||
// $docId = $docIds[0];
|
||||
// break;
|
||||
case 'oai':
|
||||
if (isset($identifierParts[2])) {
|
||||
$dataId = $identifierParts[2];
|
||||
|
@ -251,7 +242,7 @@ class RequestController extends Controller
|
|||
*/
|
||||
private function handleListMetadataFormats()
|
||||
{
|
||||
$this->_xml->appendChild($this->_xml->createElement('Documents'));
|
||||
$this->_xml->appendChild($this->_xml->createElement('Datasets'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -274,7 +265,7 @@ class RequestController extends Controller
|
|||
*/
|
||||
private function handleListIdentifiers(array &$oaiRequest)
|
||||
{
|
||||
$maxIdentifier = 20;//$this->_configuration->getMaxListIdentifiers();
|
||||
$maxIdentifier = 5;//$this->_configuration->getMaxListIdentifiers();
|
||||
$this->handlingOfLists($oaiRequest, $maxIdentifier);
|
||||
}
|
||||
|
||||
|
@ -288,7 +279,7 @@ class RequestController extends Controller
|
|||
{
|
||||
$repIdentifier = "rdr.gba.ac.at";
|
||||
$this->_proc->setParameter('', 'repIdentifier', $repIdentifier);
|
||||
$this->_xml->appendChild($this->_xml->createElement('Documents'));
|
||||
$this->_xml->appendChild($this->_xml->createElement('Datasets'));
|
||||
|
||||
//$oaiSets = new Oai_Model_Sets();
|
||||
$sets = array(
|
||||
|
@ -336,9 +327,12 @@ class RequestController extends Controller
|
|||
if (true === empty($maxRecords)) {
|
||||
$maxRecords = 100;
|
||||
}
|
||||
|
||||
$repIdentifier = "rdr.gba.ac.at";
|
||||
$tokenTempPath = storage_path('app/resumption'); //$this->_configuration->getResumptionTokenPath();
|
||||
|
||||
$this->_proc->setParameter('', 'repIdentifier', $repIdentifier);
|
||||
$this->_xml->appendChild($this->_xml->createElement('Documents'));
|
||||
$this->_xml->appendChild($this->_xml->createElement('Datasets'));
|
||||
|
||||
// do some initialisation
|
||||
$cursor = 0;
|
||||
|
@ -352,21 +346,27 @@ class RequestController extends Controller
|
|||
}
|
||||
$this->_proc->setParameter('', 'oai_metadataPrefix', $metadataPrefix);
|
||||
|
||||
// no resumptionToken is given
|
||||
$finder = Dataset::query();
|
||||
// add server state restrictions
|
||||
$finder->whereIn('server_state', $this->deliveringDocumentStates);
|
||||
if (array_key_exists('set', $oaiRequest)) {
|
||||
$setarray = explode(':', $oaiRequest['set']);
|
||||
if ($setarray[0] == 'doc-type') {
|
||||
if (count($setarray) === 2 and !empty($setarray[1])) {
|
||||
$finder->where('type', $setarray[1]);
|
||||
// parameter resumptionToken is given
|
||||
if (false === empty($oaiRequest['resumptionToken'])) {
|
||||
$tokenWorker = new ResumptionToken();
|
||||
$resParam = $oaiRequest['resumptionToken'];
|
||||
} else {
|
||||
// no resumptionToken is given
|
||||
$finder = Dataset::query();
|
||||
// add server state restrictions
|
||||
$finder->whereIn('server_state', $this->deliveringDocumentStates);
|
||||
if (array_key_exists('set', $oaiRequest)) {
|
||||
$setarray = explode(':', $oaiRequest['set']);
|
||||
if ($setarray[0] == 'data-type') {
|
||||
if (count($setarray) === 2 and !empty($setarray[1])) {
|
||||
$finder->where('type', $setarray[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$totalIds = $finder->count();
|
||||
$reldocIds = $finder->pluck('id')->toArray();
|
||||
}
|
||||
|
||||
$totalIds = $finder->count();
|
||||
$reldocIds = $finder->pluck('id')->toArray();
|
||||
|
||||
// handling of document ids
|
||||
$restIds = $reldocIds;
|
||||
|
@ -401,7 +401,7 @@ class RequestController extends Controller
|
|||
//$node->appendChild($child);
|
||||
|
||||
//$type = $dataset->type;
|
||||
$this->addSpecInformation($node, 'doc-type:' . $dataset->type);
|
||||
$this->addSpecInformation($node, 'data-type:' . $dataset->type);
|
||||
//$this->addSpecInformation($node, 'bibliography:' . 'false');
|
||||
|
||||
$this->_xml->documentElement->appendChild($node);
|
||||
|
@ -472,7 +472,7 @@ class RequestController extends Controller
|
|||
continue;
|
||||
}
|
||||
|
||||
$setSpec = 'doc-type:' . $doctype;
|
||||
$setSpec = 'data-type:' . $doctype;
|
||||
// $count = $row['count'];
|
||||
$sets[$setSpec] = "Set for document type '$doctype'";
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
namespace App\Models\Oai;
|
||||
|
||||
class OaiModelError
|
||||
{
|
152
app/Models/Oai/ResumptionToken.php
Normal file
152
app/Models/Oai/ResumptionToken.php
Normal file
|
@ -0,0 +1,152 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Oai;
|
||||
|
||||
/**
|
||||
* Contains content and structure of a resumption token
|
||||
*/
|
||||
class ResumptionToken
|
||||
{
|
||||
|
||||
/**
|
||||
* Holds dataset ids
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $datasetIds = array();
|
||||
|
||||
/**
|
||||
* Holds metadata prefix information
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $metadataPrefix = null;
|
||||
|
||||
/**
|
||||
* Holds resumption id (only if token is stored)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $resumptionId = null;
|
||||
|
||||
/**
|
||||
* Holds start postion
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $startPostition = 0;
|
||||
|
||||
/**
|
||||
* Holds total amount of document ids
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $totalIds = 0;
|
||||
|
||||
/**
|
||||
* Returns current holded document ids.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDocumentIds()
|
||||
{
|
||||
return $this->_documentIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns metadata prefix information.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMetadataPrefix()
|
||||
{
|
||||
return $this->_metadataPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return setted resumption id after successful storing of resumption token.
|
||||
*
|
||||
* @return string Returns resumption id
|
||||
*/
|
||||
public function getResumptionId()
|
||||
{
|
||||
return $this->_resumptionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns start position.
|
||||
*
|
||||
* @return in
|
||||
*/
|
||||
public function getStartPosition()
|
||||
{
|
||||
return $this->_startPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns total number of document ids for this request
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalIds()
|
||||
{
|
||||
return $this->_totalIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set document ids for this token.
|
||||
*
|
||||
* @param $idsToStore Set of document ids to store.
|
||||
* @return void
|
||||
*/
|
||||
public function setDocumentIds($idsToStore)
|
||||
{
|
||||
if (false === is_array($idsToStore)) {
|
||||
$idsToStore = array($idsToStore);
|
||||
}
|
||||
|
||||
$this->_documentIds = $idsToStore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set metadata prefix information.
|
||||
*
|
||||
* @param string $prefix
|
||||
* @return void
|
||||
*/
|
||||
public function setMetadataPrefix($prefix)
|
||||
{
|
||||
$this->_metadataPrefix = $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set resumption id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setResumptionId($resumptionId)
|
||||
{
|
||||
$this->_resumptionId = $resumptionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set postion where to start on next request.
|
||||
*
|
||||
* @param $startPostion Positon where to start on next request
|
||||
* @return void
|
||||
*/
|
||||
public function setStartPosition($startPosition)
|
||||
{
|
||||
$this->_startPosition = (int) $startPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set count of document ids for this request.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setTotalIds($totalIds)
|
||||
{
|
||||
$this->_totalIds = (int) $totalIds;
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@ class Person extends Model
|
|||
'email',
|
||||
'identifier_orcid',
|
||||
'status',
|
||||
'name_type'
|
||||
];
|
||||
protected $table = 'persons';
|
||||
public $timestamps = false;
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue