first test datacite schema

This commit is contained in:
Arno Kaimbacher 2018-12-10 17:26:57 +01:00
parent d0ed3e9105
commit 3c50618c8a
8 changed files with 411 additions and 99 deletions

View file

@ -0,0 +1,42 @@
<?php
namespace App\Models\Oai;
class OaiModelError
{
/**
* Define all valid error codes.
*/
const BADVERB = 1010;
const BADARGUMENT = 1011;
const CANNOTDISSEMINATEFORMAT = 1012;
const BADRESUMPTIONTOKEN = 1013;
const NORECORDSMATCH = 1014;
const IDDOESNOTEXIST = 1015;
/**
* Holds OAI error codes for internal error numbers.
*
* @var array Valid OAI parameters.
*/
protected static $oaiErrorCodes = array(
self::BADVERB => 'badVerb',
self::BADARGUMENT => 'badArgument',
self::NORECORDSMATCH => 'noRecordsMatch',
self::CANNOTDISSEMINATEFORMAT => 'cannotDisseminateFormat',
self::BADRESUMPTIONTOKEN => 'badResumptionToken',
self::IDDOESNOTEXIST => 'idDoesNotExist',
);
/**
* Map internal error codes to OAI error codes.
*
* @param int $code Internal error code.
* @return string OAI error code.
*/
public static function mapCode($code)
{
if (false === array_key_exists($code, self::$oaiErrorCodes)) {
throw new Oai_Model_Exception("Unknown oai error code $code");
}
return self::$oaiErrorCodes[$code];
}
}

View 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;
}
}