Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions CrossrefExportPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use PKP\file\FileManager;
use PKP\file\TemporaryFileManager;
use PKP\plugins\Hook;
use PKP\submission\reviewAssignment\ReviewAssignment;

class CrossrefExportPlugin extends DOIPubIdExportPlugin
{
Expand Down Expand Up @@ -83,6 +84,14 @@ public function getSubmissionFilter()
return 'article=>crossref-xml';
}

/**
* @copydoc PubObjectsExportPlugin::getPeerReviewFilter()
*/
public function getPeerReviewFilter(): string
{
return 'peerReview=>crossref-xml';

}
/**
* @copydoc PubObjectsExportPlugin::getIssueFilter()
*/
Expand Down Expand Up @@ -283,7 +292,7 @@ public function exportAsDownload(Journal $context, array $objects, string $filte
}

/**
* @param Submission $objects
* @param mixed $objects
* @param Journal $context
* @param string $filename Export XML filename
*
Expand Down Expand Up @@ -407,12 +416,14 @@ public function depositXML($objects, $context, $filename)
/**
* Update the local DOI deposit status and related metadata for the given object.
*/
public function updateDepositStatus(Journal $context, Issue|Submission $object, int $status, ?string $batchId = null, ?string $failedMsg = null, ?string $successMsg = null)
public function updateDepositStatus(Journal $context, Issue|Submission|ReviewAssignment $object, int $status, ?string $batchId = null, ?string $failedMsg = null, ?string $successMsg = null)
{
if ($object instanceof Submission) {
$doiIds = Repo::doi()->getDoisForSubmission($object->getId());
} else {
} else if ($object instanceof Issue) {
$doiIds = Repo::doi()->getDoisForIssue($object->getId(), true);
} else {
$doiIds = Repo::doi()->getDoisForReviewAssignment($object->getId(), true);
}

foreach ($doiIds as $doiId) {
Expand All @@ -437,11 +448,15 @@ public function updateDepositStatus(Journal $context, Issue|Submission $object,
/**
* Get part of the file name based on the object that is being exported
*/
private function _getObjectFileNamePart(Submission|Issue $object): string
private function _getObjectFileNamePart(Submission|Issue|ReviewAssignment $object): string
{
if ($object instanceof Submission) {
return 'articles-' . $object->getId();
}

if ($object instanceof ReviewAssignment) {
return 'peerReviews-' . $object->getId();
}
return 'issues-' . $object->getId();
}
}
29 changes: 28 additions & 1 deletion CrossrefPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,19 @@ public function exportSubmissions(array $submissions, Context $context): array
return ['temporaryFileId' => $temporaryFileId, 'xmlErrors' => $xmlErrors];
}


/*
* @copyDoc IDoiRegistrationAgency::exportPeerReviews()
*/
public function exportPeerReviews(array $reviewAssignments, Context $context): array
{
$filterName = $this->_exportPlugin->getPeerReviewFilter();
$xmlErrors = [];

$temporaryFileId = $this->_exportPlugin->exportAsDownload($context, $reviewAssignments, $filterName, 'peerReviews', null, $xmlErrors);

return ['temporaryFileId' => $temporaryFileId, 'xmlErrors' => $xmlErrors];
}
/**
* @param Submission[] $submissions
*/
Expand All @@ -361,6 +374,20 @@ public function depositSubmissions(array $submissions, Context $context): array
];
}

/*
* @copyDoc IDoiRegistrationAgency::depositPeerReviews()
*/
public function depositPeerReviews(array $peerReviews, Context $context): array
{
$filterName = $this->_exportPlugin->getPeerReviewFilter();
$responseMessage = '';
$status = $this->_exportPlugin->exportAndDeposit($context, $peerReviews, $filterName, $responseMessage);

return [
'hasErrors' => !$status,
'responseMessage' => $responseMessage
];
}
/**
* @param Issue[] $issues
*/
Expand Down Expand Up @@ -436,7 +463,7 @@ public function getSettingsObject(): RegistrationAgencySettings
*/
public function getAllowedDoiTypes(): array
{
return [Repo::doi()::TYPE_PUBLICATION, Repo::doi()::TYPE_ISSUE];
return [Repo::doi()::TYPE_PUBLICATION, Repo::doi()::TYPE_ISSUE, Repo::doi()::TYPE_PEER_REVIEW];
}

/**
Expand Down
13 changes: 12 additions & 1 deletion filter/ArticleCrossrefXmlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,18 @@ public function createComponentListNode(DOMDocument $doc, Publication $publicati
$componentNode->appendChild($titlesNode);
}
// DOI data node
$resourceURL = $dispatcher->url($request, PKPApplication::ROUTE_PAGE, $context->getPath(), 'article', 'download', [$publication->getData('urlPath') ?? $submission->getId(), $componentGalley->getBestGalleyId()], null, null, true, '');
$resourceURL = $dispatcher->url(
$request,
PKPApplication::ROUTE_PAGE,
$context->getPath(),
'article',
'download',
[$publication->getData('urlPath') ?? $submission->getId(), $componentGalley->getBestGalleyId()],
null,
null,
true,
''
);
$componentNode->appendChild($this->createDOIDataNode($doc, $componentGalley->getStoredPubId('doi'), $resourceURL));
$componentListNode->appendChild($componentNode);
}
Expand Down
73 changes: 3 additions & 70 deletions filter/IssueCrossrefXmlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@
use APP\core\Request;
use APP\issue\Issue;
use APP\plugins\generic\crossref\CrossrefExportDeployment;
use APP\plugins\generic\crossref\filter\trait\CrossrefFilterBuilder;
use DOMDocument;
use DOMElement;
use PKP\core\Dispatcher;
use PKP\core\PKPApplication;

class IssueCrossrefXmlFilter extends \PKP\plugins\importexport\native\filter\NativeExportFilter
{
use CrossrefFilterBuilder;

/**
* Constructor
*
Expand Down Expand Up @@ -76,52 +79,6 @@ public function &process(&$pubObjects)
//
// Issue conversion functions
//
/**
* Create and return the root node 'doi_batch'.
*/
public function createRootNode(DOMDocument $doc): DOMElement
{
/** @var CrossrefExportDeployment $deployment */
$deployment = $this->getDeployment();
$rootNode = $doc->createElementNS($deployment->getNamespace(), $deployment->getRootElementName());
$rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', $deployment->getXmlSchemaInstance());
$rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:jats', $deployment->getJATSNamespace());
$rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:ai', $deployment->getAINamespace());
$rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:rel', $deployment->getRelNamespace());
$rootNode->setAttribute('version', $deployment->getXmlSchemaVersion());
$rootNode->setAttribute('xsi:schemaLocation', $deployment->getNamespace() . ' ' . $deployment->getSchemaFilename());
return $rootNode;
}

/**
* Create and return the head node 'head'.
*/
public function createHeadNode(DOMDocument $doc): DOMElement
{
/** @var CrossrefExportDeployment $deployment */
$deployment = $this->getDeployment();
$context = $deployment->getContext();
$plugin = $deployment->getPlugin();
$headNode = $doc->createElementNS($deployment->getNamespace(), 'head');
$headNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'doi_batch_id', htmlspecialchars($context->getData('acronym', $context->getPrimaryLocale()) . '_' . time(), ENT_COMPAT, 'UTF-8')));
$headNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'timestamp', date('YmdHisv')));
$depositorNode = $doc->createElementNS($deployment->getNamespace(), 'depositor');
$depositorName = $plugin->getSetting($context->getId(), 'depositorName');
if (empty($depositorName)) {
$depositorName = $context->getData('supportName');
}
$depositorEmail = $plugin->getSetting($context->getId(), 'depositorEmail');
if (empty($depositorEmail)) {
$depositorEmail = $context->getData('supportEmail');
}
$depositorNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'depositor_name', htmlspecialchars($depositorName, ENT_COMPAT, 'UTF-8')));
$depositorNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'email_address', htmlspecialchars($depositorEmail, ENT_COMPAT, 'UTF-8')));
$headNode->appendChild($depositorNode);
$publisherInstitution = $context->getData('publisherInstitution');
$headNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'registrant', htmlspecialchars($publisherInstitution, ENT_COMPAT, 'UTF-8')));
return $headNode;
}

/**
* Create and return the journal node 'journal'.
*/
Expand Down Expand Up @@ -217,28 +174,4 @@ public function createDateNode(DOMDocument $doc, string $objectPublicationDate,
$publicationDateNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'year', date('Y', $publicationDate)));
return $publicationDateNode;
}

/**
* Create and return the DOI data node 'doi_data'.
*/
public function createDOIDataNode(DOMDocument $doc, string $doi, string $url): DOMElement
{
$deployment = $this->getDeployment();
$doiDataNode = $doc->createElementNS($deployment->getNamespace(), 'doi_data');
$doiDataNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'doi', htmlspecialchars($doi, ENT_COMPAT, 'UTF-8')));
$doiDataNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'resource', $url));
return $doiDataNode;
}

/**
* Helper to ensure dispatcher is available even when called from CLI tools
*/
protected function _getDispatcher(Request $request): Dispatcher
{
$dispatcher = $request->getDispatcher();
if ($dispatcher === null) {
$dispatcher = Application::get()->getDispatcher();
}
return $dispatcher;
}
}
Loading