16 import(
'lib.pkp.classes.scheduledTask.ScheduledTask');
30 $this->_plugin = $plugin;
32 if (is_a($plugin,
'DataciteExportPlugin')) {
33 $plugin->addLocaleData();
36 parent::__construct($args);
43 return __(
'plugins.importexport.datacite.senderTask.name');
50 if (!$this->_plugin)
return false;
55 foreach ($journals as $journal) {
57 $doiPubIdPlugin = $pubIdPlugins[
'doipubidplugin'];
59 if ($doiPubIdPlugin->getSetting($journal->getId(),
'enableIssueDoi')) {
61 $unregisteredIssues = $plugin->getUnregisteredIssues($journal);
63 if (count($unregisteredIssues)) {
64 $this->
_registerObjects($unregisteredIssues,
'issue=>datacite-xml', $journal,
'issues');
68 if ($doiPubIdPlugin->getSetting($journal->getId(),
'enablePublicationDoi')) {
70 $unregisteredArticles = $plugin->getUnregisteredArticles($journal);
72 if (
count($unregisteredArticles)) {
73 $this->
_registerObjects($unregisteredArticles,
'article=>datacite-xml', $journal,
'articles');
77 if ($doiPubIdPlugin->getSetting($journal->getId(),
'enableRepresentationDoi')) {
79 $unregisteredGalleys = $plugin->getUnregisteredGalleys($journal);
81 if (
count($unregisteredGalleys)) {
82 $this->
_registerObjects($unregisteredGalleys,
'galley=>datacite-xml', $journal,
'galleys');
97 $journalFactory = $contextDao->getAll(
true);
100 while($journal = $journalFactory->next()) {
101 $journalId = $journal->getId();
102 if (!$plugin->getSetting($journalId,
'username') || !$plugin->getSetting($journalId,
'password') || !$plugin->getSetting($journalId,
'automaticRegistration'))
continue;
106 if (isset($pubIdPlugins[
'doipubidplugin'])) {
107 $doiPubIdPlugin = $pubIdPlugins[
'doipubidplugin'];
108 if (!$doiPubIdPlugin->getSetting($journalId,
'enabled'))
continue;
109 $doiPrefix = $doiPubIdPlugin->getSetting($journalId,
'doiPrefix');
113 $journals[] = $journal;
115 $this->
addExecutionLogEntry(__(
'plugins.importexport.common.senderTask.warning.noDOIprefix', array(
'path' => $journal->getPath())), SCHEDULED_TASK_MESSAGE_TYPE_WARNING);
129 function _registerObjects($objects, $filter, $journal, $objectsFileNamePart) {
131 import(
'lib.pkp.classes.file.FileManager');
133 foreach ($objects as $object) {
135 $exportXml = $plugin->exportXML($object, $filter, $journal);
138 $objectFileNamePart = $objectsFileNamePart .
'-' . $object->getId();
139 $exportFileName = $plugin->getExportFileName($plugin->getExportPath(), $objectFileNamePart, $journal,
'.xml');
140 $fileManager->writeFile($exportFileName, $exportXml);
142 $result = $plugin->depositXML($object, $journal, $exportFileName);
143 if ($result !==
true) {
147 $fileManager->deleteByPath($exportFileName);
156 if (is_array($result)) {
157 foreach($result as $error) {
158 assert(is_array($error) && count($error) >= 1);
160 __($error[0], array(
'param' => (isset($error[1]) ? $error[1] :
null))),
161 SCHEDULED_TASK_MESSAGE_TYPE_WARNING
166 __(
'plugins.importexport.common.register.error.mdsError', array(
'param' =>
' - ')),
167 SCHEDULED_TASK_MESSAGE_TYPE_WARNING