Skip to content

Commit

Permalink
*4965* Changed DOI storage and expanded capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed Aug 9, 2010
1 parent 970ce92 commit 83e83b8
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 54 deletions.
16 changes: 16 additions & 0 deletions classes/article/Article.inc.php
Expand Up @@ -143,6 +143,22 @@ function setSectionId($sectionId) {
return $this->setData('sectionId', $sectionId);
}

/**
* Get stored DOI of the submission.
* @return int
*/
function getStoredDOI() {
return $this->getData('doi');
}

/**
* Set the stored DOI of the submission.
* @param $doi string
*/
function setStoredDOI($doi) {
return $this->setData('doi', $doi);
}

/**
* Get title of article's section.
* @return string
Expand Down
77 changes: 58 additions & 19 deletions classes/article/ArticleDAO.inc.php
Expand Up @@ -146,6 +146,7 @@ function _articleFromRow(&$article, &$row) {
$article->setSectionId($row['section_id']);
$article->setSectionTitle($row['section_title']);
$article->setSectionAbbrev($row['section_abbrev']);
$article->setStoredDOI($row['doi']);
$article->setLanguage($row['language']);
$article->setCommentsToEditor($row['comments_to_ed']);
$article->setCitations($row['citations']);
Expand Down Expand Up @@ -180,9 +181,9 @@ function insertArticle(&$article) {
$article->stampModified();
$this->update(
sprintf('INSERT INTO articles
(locale, user_id, journal_id, section_id, language, comments_to_ed, citations, date_submitted, date_status_modified, last_modified, status, submission_progress, current_round, submission_file_id, revised_file_id, review_file_id, editor_file_id, pages, fast_tracked, hide_author, comments_status)
(locale, user_id, journal_id, section_id, language, comments_to_ed, citations, date_submitted, date_status_modified, last_modified, status, submission_progress, current_round, submission_file_id, revised_file_id, review_file_id, editor_file_id, pages, fast_tracked, hide_author, comments_status, doi)
VALUES
(?, ?, ?, ?, ?, ?, ?, %s, %s, %s, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
(?, ?, ?, ?, ?, ?, ?, %s, %s, %s, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
$this->datetimeToDB($article->getDateSubmitted()), $this->datetimeToDB($article->getDateStatusModified()), $this->datetimeToDB($article->getLastModified())),
array(
$article->getLocale(),
Expand All @@ -202,7 +203,8 @@ function insertArticle(&$article) {
$article->getPages(),
$article->getFastTracked()?1:0,
$article->getHideAuthor() === null ? 0 : $article->getHideAuthor(),
$article->getCommentsStatus() === null ? 0 : $article->getCommentsStatus()
$article->getCommentsStatus() === null ? 0 : $article->getCommentsStatus(),
$article->getStoredDOI()
)
);

Expand Down Expand Up @@ -246,7 +248,8 @@ function updateArticle(&$article) {
pages = ?,
fast_tracked = ?,
hide_author = ?,
comments_status = ?
comments_status = ?,
doi = ?
WHERE article_id = ?',
$this->datetimeToDB($article->getDateSubmitted()), $this->datetimeToDB($article->getDateStatusModified()), $this->datetimeToDB($article->getLastModified())),
array(
Expand All @@ -266,6 +269,7 @@ function updateArticle(&$article) {
$article->getFastTracked(),
$article->getHideAuthor(),
$article->getCommentsStatus(),
$article->getStoredDOI(),
$article->getId()
)
);
Expand Down Expand Up @@ -383,16 +387,28 @@ function deleteArticleById($articleId) {
}

/**
* Get all articles for a journal.
* Get all articles for a journal (or all articles in the system).
* @param $userId int
* @param $journalId int
* @return DAOResultFactory containing matching Articles
*/
function &getArticlesByJournalId($journalId) {
function &getArticlesByJournalId($journalId = null) {
$primaryLocale = Locale::getPrimaryLocale();
$locale = Locale::getLocale();
$articles = array();

$params = array(
'title',
$primaryLocale,
'title',
$locale,
'abbrev',
$primaryLocale,
'abbrev',
$locale
);
if ($journalId !== null) $params[] = (int) $journalId;

$result =& $this->retrieve(
'SELECT a.*,
COALESCE(stl.setting_value, stpl.setting_value) AS section_title,
Expand All @@ -403,18 +419,8 @@ function &getArticlesByJournalId($journalId) {
LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?)
LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?)
LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?)
WHERE a.journal_id = ?',
array(
'title',
$primaryLocale,
'title',
$locale,
'abbrev',
$primaryLocale,
'abbrev',
$locale,
$journalId
)
' . ($journalId !== null ? 'WHERE a.journal_id = ?' : ''),
$params
);

$returner = new DAOResultFactory($result, $this, '_returnArticleFromRow');
Expand Down Expand Up @@ -527,12 +533,45 @@ function incompleteSubmissionExists($articleId, $userId, $journalId) {
*/
function changeArticleStatus($articleId, $status) {
$this->update(
'UPDATE articles SET status = ? WHERE article_id = ?', array($status, $articleId)
'UPDATE articles SET status = ? WHERE article_id = ?', array((int) $status, (int) $articleId)
);

$this->flushCache();
}

/**
* Change the DOI of an article
* @param $articleId int
* @param $doi string
*/
function changeDOI($articleId, $doi) {
$this->update(
'UPDATE articles SET doi = ? WHERE article_id = ?', array($doi, (int) $articleId)
);

$this->flushCache();
}

function assignDOIs($forceReassign = false, $journalId = null) {
if ($forceReassign) {
$this->update(
'UPDATE articles SET doi = null' . ($journalId !== null?' WHERE journal_id = ?':''),
$journalId !== null?array((int) $journalId):false
);
$this->flushCache();
}

$publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
$articles =& $publishedArticleDao->getPublishedArticlesByJournalId($journalId);
while ($article =& $articles->next()) {
// Cause a DOI to be fetched and stored.
$article->getDOI();
unset($article);
}

$this->flushCache();
}

/**
* Removes articles from a section by section ID
* @param $sectionId int
Expand Down
18 changes: 15 additions & 3 deletions classes/article/PublishedArticle.inc.php
Expand Up @@ -248,6 +248,11 @@ function getBestArticleId($journal = null) {
* Get a DOI for this article.
*/
function getDOI() {
// If we already have an assigned DOI, use it.
$storedDOI = $this->getStoredDOI();
if ($storedDOI) return $storedDOI;

// Otherwise, create a new one.
$journalId = $this->getJournalId();

// Get the Journal object (optimized)
Expand All @@ -269,7 +274,7 @@ function getDOI() {

switch ( $doiSuffixSetting ) {
case 'customIdentifier':
return $doiPrefix . '/' . $this->getBestArticleId();
$doi = $doiPrefix . '/' . $this->getBestArticleId();
break;
case 'pattern':
$suffixPattern = $journal->getSetting('doiSuffixPattern');
Expand All @@ -283,11 +288,18 @@ function getDOI() {
$suffixPattern = String::regexp_replace('/%a/', $this->getArticleId(), $suffixPattern);
// %p - page number
$suffixPattern = String::regexp_replace('/%p/', $this->getPages(), $suffixPattern);
return $doiPrefix . '/' . $suffixPattern;
$doi = $doiPrefix . '/' . $suffixPattern;
break;
default:
return $doiPrefix . '/' . String::strtolower($journal->getLocalizedSetting('initials')) . '.v' . $issue->getVolume() . 'i' . $issue->getNumber() . '.' . $this->getArticleId();
$doi = $doiPrefix . '/' . String::strtolower($journal->getLocalizedSetting('initials')) . '.v' . $issue->getVolume() . 'i' . $issue->getNumber() . '.' . $this->getArticleId();
}

// Save the generated DOI
$this->setStoredDOI($doi);
$articleDao =& DAORegistry::getDAO('ArticleDAO');
$articleDao->changeDOI($this->getId(), $doi);

return $doi;
}
}

Expand Down
78 changes: 64 additions & 14 deletions classes/article/PublishedArticleDAO.inc.php
Expand Up @@ -137,11 +137,23 @@ function getPublishedArticleCountByJournalId($journalId) {
* Retrieve all published articles in a journal.
* @param $journalId int
* @param $rangeInfo object
* @param $reverse boolean Whether to reverse the sort order
* @return object
*/
function &getPublishedArticlesByJournalId($journalId, $rangeInfo = null, $reverse = false) {
function &getPublishedArticlesByJournalId($journalId = null, $rangeInfo = null, $reverse = false) {
$primaryLocale = Locale::getPrimaryLocale();
$locale = Locale::getLocale();
$params = array(
'title',
$primaryLocale,
'title',
$locale,
'abbrev',
$primaryLocale,
'abbrev',
$locale
);
if ($journalId !== null) $params[] = (int) $journalId;
$result =& $this->retrieveRange(
'SELECT pa.*,
a.*,
Expand All @@ -155,21 +167,59 @@ function &getPublishedArticlesByJournalId($journalId, $rangeInfo = null, $revers
LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?)
LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?)
LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?)
WHERE a.journal_id = ?
AND i.published = 1
WHERE i.published = 1
' . ($journalId !== null?'AND a.journal_id = ?':'') . '
AND a.status <> ' . STATUS_ARCHIVED . '
ORDER BY date_published '. ($reverse?'DESC':'ASC'),
array(
'title',
$primaryLocale,
'title',
$locale,
'abbrev',
$primaryLocale,
'abbrev',
$locale,
$journalId
),
$params,
$rangeInfo
);

$returner = new DAOResultFactory($result, $this, '_returnPublishedArticleFromRow');
return $returner;
}

/**
* Retrieve all published articles in a journal by DOI.
* @param $doi string
* @param $journalId int
* @param $rangeInfo object
* @return object
*/
function &getPublishedArticlesByDOI($doi, $journalId = null, $rangeInfo = null) {
$primaryLocale = Locale::getPrimaryLocale();
$locale = Locale::getLocale();
$params = array(
'title',
$primaryLocale,
'title',
$locale,
'abbrev',
$primaryLocale,
'abbrev',
$locale,
$doi
);
if ($journalId !== null) $params[] = (int) $journalId;
$result =& $this->retrieveRange(
'SELECT pa.*,
a.*,
COALESCE(stl.setting_value, stpl.setting_value) AS section_title,
COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev
FROM published_articles pa
LEFT JOIN articles a ON pa.article_id = a.article_id
LEFT JOIN issues i ON pa.issue_id = i.issue_id
LEFT JOIN sections s ON s.section_id = a.section_id
LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?)
LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?)
LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?)
LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?)
WHERE i.published = 1
AND a.doi = ?
' . ($journalId !== null?'AND a.journal_id = ?':'') . '
AND a.status <> ' . STATUS_ARCHIVED . '
ORDER BY date_published '. ($reverse?'DESC':'ASC'),

This comment has been minimized.

Copy link
@jalperin

jalperin Sep 9, 2011

Member

this reverse parameter is never defined

This comment has been minimized.

Copy link
@asmecher

asmecher Sep 9, 2011

Author Member

Fixed.

$params,
$rangeInfo
);

Expand Down
4 changes: 3 additions & 1 deletion classes/plugins/GatewayPlugin.inc.php
Expand Up @@ -109,8 +109,10 @@ function manage($verb, $args) {

/**
* Handle fetch requests for this plugin.
* @param $args array
* @param $request object
*/
function fetch($args) {
function fetch($args, $request) {
// Subclasses should override this function.
return false;
}
Expand Down
1 change: 1 addition & 0 deletions dbscripts/xml/ojs_schema.xml
Expand Up @@ -456,6 +456,7 @@
<field name="review_file_id" type="I8"/>
<field name="editor_file_id" type="I8"/>
<field name="pages" type="C2" size="255"/>
<field name="doi" type="C2" size="255"/>
<field name="fast_tracked" type="I1">
<NOTNULL/>
<DEFAULT VALUE="0"/>
Expand Down
2 changes: 2 additions & 0 deletions locale/en_US/manager.xml
Expand Up @@ -247,6 +247,8 @@
<message key="manager.setup.doiSuffixPattern.example">For example, vol%viss%ipp%p could create a DOI such as 10.1234/vol3iss2pp230</message>
<message key="manager.setup.doiSuffixDescription">A DOI suffix can take any form, but must be unique for each published item.</message>
<message key="manager.setup.doiSuffixCustomIdentifier">Use the "Custom Identifier" for published items as the DOI suffix (must be enabled in Step 4).</message>
<message key="manager.setup.doiReassign">Reassign DOIs</message>
<message key="manager.setup.doiReassign.description">If you change your DOI configuration, DOIs that have already been assigned will not be affected. Once the DOI configuration is saved, use this button to clear all existing DOIs so that the new settings will take effect with existing articles.</message>
<message key="manager.setup.editorDecision">Editor Decision</message>
<message key="manager.setup.editorialMembers">Go to Board Members and add Editorial Board and/or Review Board members. This can be done at any point in operating the journal.</message>
<message key="manager.setup.editorialProcess1">One or more editors handle the basic steps without designated roles.</message>
Expand Down
21 changes: 11 additions & 10 deletions pages/gateway/GatewayHandler.inc.php
Expand Up @@ -25,23 +25,23 @@ function GatewayHandler() {
parent::Handler();
}

function index() {
Request::redirect(null, 'index');
function index($args, $request) {
$request->redirect(null, 'index');
}

function lockss() {
function lockss($args, $request) {
$this->validate();
$this->setupTemplate();

$journal =& Request::getJournal();
$journal =& $request->getJournal();
$templateMgr =& TemplateManager::getManager();

if ($journal != null) {
if (!$journal->getSetting('enableLockss')) {
Request::redirect(null, 'index');
$request->redirect(null, 'index');
}

$year = Request::getUserVar('year');
$year = $request->getUserVar('year');

$issueDao =& DAORegistry::getDAO('IssueDAO');

Expand Down Expand Up @@ -117,18 +117,19 @@ function lockss() {
/**
* Handle requests for gateway plugins.
*/
function plugin($args) {
function plugin($args, $request) {
$this->validate();
$pluginName = array_shift($args);

$plugins =& PluginRegistry::loadCategory('gateways');
if (isset($pluginName) && isset($plugins[$pluginName])) {
$plugin =& $plugins[$pluginName];
if (!$plugin->fetch($args)) {
Request::redirect(null, 'index');
if (!$plugin->fetch($args, $request)) {
$request->redirect(null, 'index');
}
} else {
$request->redirect(null, 'index');
}
else Request::redirect(null, 'index');
}
}

Expand Down

0 comments on commit 83e83b8

Please sign in to comment.