Skip to content

Commit

Permalink
- cli inteface working
Browse files Browse the repository at this point in the history
- error message added when first auther check fails
  • Loading branch information
ronste committed Dec 18, 2020
1 parent 9c9af49 commit 7c7f913
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 14 deletions.
5 changes: 4 additions & 1 deletion DNBExportPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,10 @@ function getGalleyPackage($galley, $filter, $noValidation, $journal, $journalExp
$param = __('plugins.importexport.dnb.export.error.articleMetadataInvalidCharacters.param', array('submissionId' => $submissionId, 'node' => $e->getMessage()));
return array('plugins.importexport.dnb.export.error.articleMetadataInvalidCharacters', $param);
case URN_SET:
return array('plugins.importexport.dnb.export.error.urnSet');
return array('plugins.importexport.dnb.export.error.urnSet');
case FIRST_AUTHOR_NOT_REGISTERED:
$param = __('plugins.importexport.dnb.export.error.firestAuthorNotRegistred.param', array('submissionId' => $submissionId, 'msg' => $e->getMessage()));
return array('plugins.importexport.dnb.export.error.firestAuthorNotRegistred', $param);
}
}

Expand Down
15 changes: 8 additions & 7 deletions DNBInfoSender.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,19 @@ function executeActions() {
}
$journalExportPath = $result;

foreach ($notDepositedArticles as $article) {
if (is_a($article, 'PublishedArticle')) {
foreach ($notDepositedArticles as $submission) {
if (is_a($submission, 'Submission')) {
$issue = null;
$galleys = array();
// Get issue and galleys, and check if the article can be exported
if (!$plugin->canBeExported($article, $issue, $galleys)) {
$errors[] = array('plugins.importexport.dnb.export.error.articleCannotBeExported', $article->getId());
if (!$plugin->canBeExported($submission, $issue, $galleys)) {
$errors[] = array('plugins.importexport.dnb.export.error.articleCannotBeExported', $submission->getId());
// continue with other articles
continue;
}

$fullyDeposited = true;
$articleId = $article->getId();
$submissionId = $submission->getId();
foreach ($galleys as $galley) {
// check if it is a full text
$galleyFile = $galley->getFile();
Expand Down Expand Up @@ -131,8 +131,9 @@ function executeActions() {
// Update article status
//TODO @RS cleanup
//$articleDao->updateSetting($articleId, $plugin->getDepositStatusSettingName(), DNB_STATUS_DEPOSITED, 'string');
$object->setData($plugin->getDepositStatusSettingName(), DNB_STATUS_DEPOSITED);
+ $this->updateObject($object);
$submissionDao = DAORegistry::getDAO('SubmissionDAO');
$submission->setData($plugin->getDepositStatusSettingName(), DNB_STATUS_DEPOSITED);
$submissionDao->updateObject($submission);
}
}
}
Expand Down
15 changes: 10 additions & 5 deletions filter/DNBXmlFilter.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import('lib.pkp.plugins.importexport.native.filter.NativeExportFilter');
define('XML_NON_VALID_CHARCTERS', 100);
define('FIRST_AUTHOR_NOT_REGISTERED', 102);
define('URN_SET', 101);
define('MESSAGE_URN_SET','An URN has been set.'); // @RS refine

Expand Down Expand Up @@ -115,7 +116,9 @@ function &process(&$pubObject) {
// so the array can be used later in the field 700 1 _
$firstAuthor = array_shift($authors);
}
assert($firstAuthor);
if (!$firstAuthor) {
throw new ErrorException("DNBXmlFilter Error: ", FIRST_AUTHOR_NOT_REGISTERED);
}

// extract submission translators
$translators = array_filter($contributors, array($this, '_filterTranslators'));
Expand Down Expand Up @@ -229,7 +232,8 @@ function &process(&$pubObject) {
$abstract = mb_substr($abstract, 0, 996,"UTF-8");
$abstract .= '...';
}
$abstractURL = $request->url($journal->getPath(), 'article', 'view', array($article->getId()));
//$abstractURL = $request->url($journal->getPath(), 'article', 'view', array($article->getId())); //TODO @RS
$abstractURL = $request->url($journal->getPath(), 'article', 'view', array($submissionId));
$datafield520 = $this->createDatafieldNode($doc, $recordNode, '520', '3', ' ');
$this->createSubfieldNode($doc, $datafield520, 'a', $abstract);
$this->createSubfieldNode($doc, $datafield520, 'u', $abstractURL);
Expand Down Expand Up @@ -291,7 +295,8 @@ function &process(&$pubObject) {
$journalDatafield773 = $this->createDatafieldNode($doc, $recordNode, '773', '1', '8');
$this->createSubfieldNode($doc, $journalDatafield773, 'x', $issn);
// file data
$galleyURL = $request->url($journal->getPath(), 'article', 'view', array($article->getId(), $galley->getId()));
//$galleyURL = $request->url($journal->getPath(), 'article', 'view', array($article->getId(), $galley->getId())); //TODO @RS
$galleyURL = $request->url($journal->getPath(), 'article', 'view', array($submissionId, $galley->getId()));
$datafield856 = $this->createDatafieldNode($doc, $recordNode, '856', '4', ' ');
$this->createSubfieldNode($doc, $datafield856, 'u', $galleyURL);
$this->createSubfieldNode($doc, $datafield856, 'q', $this->_getGalleyFileType($galley));
Expand All @@ -309,7 +314,7 @@ function &process(&$pubObject) {
}

/**
* Check if the contributor is an author.
* Check if the contributor is an author resistered with the journal.
* @param $contributor Author
* @return boolean
*/
Expand All @@ -319,7 +324,7 @@ function _filterAuthors($contributor) {
}

/**
* Check if the contributor is a translator.
* Check if the contributor is a translator resistered with the journal.
* @param $contributor Author
* @return boolean
*/
Expand Down
3 changes: 3 additions & 0 deletions locale/de_DE/locale.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
<message key="plugins.importexport.dnb.export.error.galleyFileNotFound">Die Fahnendatei {$param} konnte nicht gefunden werden.</message>
<message key="plugins.importexport.dnb.export.error.galleyFileNoCopy">Die Fahnendatei {$param} kopiert werden.</message>
<message key="plugins.importexport.dnb.export.error.galleyFileNoCopy.param">{$sourceGalleyFilePath} konnte nicht nach {$targetGalleyFilePath}</message>
<message key="plugins.importexport.dnb.export.error.firestAuthorNotRegistred.param">Fehler beim Export der Fahne {$submissionId}. {$msg}</message>
<message key="plugins.importexport.dnb.export.error.firestAuthorNotRegistred">{$param} Der Erstautor der Fahe muss bei dieser Zeitschrift als Autor registriert sein.</message>

<message key="plugins.importexport.dnb.senderTask.name">DNB automatic deposit task</message>

</locale>
2 changes: 2 additions & 0 deletions locale/en_US/locale.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
<message key="plugins.importexport.dnb.export.error.galleyFileNotFound">The galley file {$param} could not be found.</message>
<message key="plugins.importexport.dnb.export.error.galleyFileNoCopy">The galley file {$param}.</message>
<message key="plugins.importexport.dnb.export.error.galleyFileNoCopy.param">{$sourceGalleyFilePath} could not be copied to {$targetGalleyFilePath}</message>
<message key="plugins.importexport.dnb.export.error.firestAuthorNotRegistred.param">Error exporting submission {$submissionId}. {$msg}</message>
<message key="plugins.importexport.dnb.export.error.firestAuthorNotRegistred">{$param} The primary auther of the submission is required to be a registered author with this journal.</message>
<message key="plugins.importexport.dnb.senderTask.name">DNB automatic deposit task</message>

</locale>
2 changes: 1 addition & 1 deletion templates/settingsForm.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{fbvElement type="text" id="folderId" value=$folderId label="plugins.importexport.dnb.settings.form.folderId" maxlength="50" size=$fbvStyles.size.MEDIUM}
<span class="instruct">{translate key="plugins.importexport.dnb.settings.form.folderId.description"}</span><br/>
{/fbvFormSection}
{fbvFormSection list="true"}
{fbvFormSection list="true"}
{fbvElement type="checkbox" id="automaticDeposit" label="plugins.importexport.dnb.settings.form.automaticDeposit.description" checked=$automaticDeposit|compare:true}
{/fbvFormSection}

Expand Down

0 comments on commit 7c7f913

Please sign in to comment.