16 import(
'lib.pkp.classes.scheduledTask.ScheduledTask');
30 $this->_plugin = $plugin;
32 if (is_a($plugin,
'MedraExportPlugin')) {
33 $plugin->addLocaleData();
36 parent::__construct($args);
43 return __(
'plugins.importexport.medra.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=>medra-xml', $journal,
'issues');
68 if ($doiPubIdPlugin->getSetting($journal->getId(),
'enablePublicationDoi')) {
70 $unregisteredArticles = $plugin->getUnregisteredArticles($journal);
72 if (
count($unregisteredArticles)) {
73 $this->
_registerObjects($unregisteredArticles,
'article=>medra-xml', $journal,
'articles');
77 if ($doiPubIdPlugin->getSetting($journal->getId(),
'enableRepresentationDoi')) {
79 $unregisteredGalleys = $plugin->getUnregisteredGalleys($journal);
81 if (
count($unregisteredGalleys)) {
82 $this->
_registerObjects($unregisteredGalleys,
'galley=>medra-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');
134 $exportXml = $plugin->exportXML($objects, $filter, $journal);
136 $exportFileName = $plugin->getExportFileName($plugin->getExportPath(), $objectFileNamePart, $journal,
'.xml');
137 $fileManager->writeFile($exportFileName, $exportXml);
139 $result = $plugin->depositXML($objects, $journal, $exportFileName);
140 if ($result !==
true) {
144 $fileManager->deleteByPath($exportFileName);
152 if (is_array($result)) {
153 foreach($result as $error) {
154 assert(is_array($error) && count($error) >= 1);
156 __($error[0], array(
'param' => (isset($error[1]) ? $error[1] :
null))),
157 SCHEDULED_TASK_MESSAGE_TYPE_WARNING
162 __(
'plugins.importexport.common.register.error.mdsError', array(
'param' =>
' - ')),
163 SCHEDULED_TASK_MESSAGE_TYPE_WARNING