Skip to content

Commit

Permalink
pkp/pkp-lib#10744 Increase opportunity for ORCID work/review deposits
Browse files Browse the repository at this point in the history
  • Loading branch information
taslangraham committed Dec 31, 2024
1 parent 142aaef commit 6666143
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 7 additions & 0 deletions classes/search/ArticleSearchIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@

namespace APP\search;

use APP\core\Application;
use APP\facades\Repo;
use APP\journal\Journal;
use APP\journal\JournalDAO;
use APP\orcid\actions\SendSubmissionToOrcid;
use APP\submission\Submission;
use Exception;
use PKP\core\PKPApplication;
Expand All @@ -28,6 +30,7 @@
use PKP\search\SearchFileParser;
use PKP\search\SubmissionSearch;
use PKP\search\SubmissionSearchIndex;
use PKP\submission\PKPSubmission;
use PKP\submissionFile\SubmissionFile;
use Throwable;

Expand Down Expand Up @@ -74,6 +77,10 @@ public function submissionMetadataChanged($submission)
$this->_updateTextIndex($submissionId, SubmissionSearch::SUBMISSION_SEARCH_TYPE, (array) $publication->getData('type'));
$this->_updateTextIndex($submissionId, SubmissionSearch::SUBMISSION_SEARCH_COVERAGE, (array) $publication->getData('coverage'));
// FIXME Index sponsors too?
if ($publication->getData('status') == PKPSubmission::STATUS_PUBLISHED) {
(new SendSubmissionToOrcid($publication, Application::getContextDAO()->getById($submission->getData('contextId'))))->execute();
}
}

/**
Expand Down
11 changes: 8 additions & 3 deletions jobs/orcid/DepositOrcidReview.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use PKP\config\Config;
use PKP\jobs\BaseJob;
use PKP\orcid\OrcidManager;
use PKP\submission\reviewAssignment\ReviewAssignment;

class DepositOrcidReview extends BaseJob
{
Expand All @@ -43,6 +44,10 @@ public function handle(): void
$this->fail('Review assignment does not exist.');
}

if (!in_array($reviewAssignment->getStatus(), ReviewAssignment::REVIEW_COMPLETE_STATUSES)) {
$this->fail('Review assignment was not completed.');
}

$submission = Repo::submission()->get($reviewAssignment->getSubmissionId());
$context = Application::getContextDAO()->getById($submission->getData('contextId'));

Expand All @@ -67,7 +72,7 @@ public function handle(): void
# Extract only the ORCID from the stored ORCID uri
$orcid = basename(parse_url($reviewer->getOrcid(), PHP_URL_PATH));

$orcidReview = new OrcidReview($submission, $reviewAssignment, $context);
$orcidReview = (new OrcidReview($submission, $reviewAssignment, $context))->toArray();

$uri = OrcidManager::getApiPath($context) . OrcidManager::ORCID_API_VERSION_URL . $orcid . '/' . OrcidManager::ORCID_REVIEW_URL;
$method = 'POST';
Expand All @@ -89,7 +94,7 @@ public function handle(): void
$uri,
[
'headers' => $headers,
'json' => $orcidReview->toArray(),
'json' => $orcidReview,
]
);

Expand All @@ -101,7 +106,7 @@ public function handle(): void
OrcidManager::logInfo("Review updated in profile, putCode: {$putCode}");
break;
case 201:
$location = $responseHeaders['Location'][0];
$location = $responseHeaders['location'][0];
// Extract the ORCID work put code for updates/deletion.
$putCode = basename(parse_url($location, PHP_URL_PATH));
$reviewer->setData('orcidReviewPutCode', $putCode);
Expand Down

0 comments on commit 6666143

Please sign in to comment.