diff --git a/classes/search/ArticleSearchIndex.php b/classes/search/ArticleSearchIndex.php index d3d2998f1e3..fb845aacfbe 100644 --- a/classes/search/ArticleSearchIndex.php +++ b/classes/search/ArticleSearchIndex.php @@ -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; @@ -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; @@ -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(); + } } /** diff --git a/jobs/orcid/DepositOrcidReview.php b/jobs/orcid/DepositOrcidReview.php index b45d2fed06f..02a5b5df30c 100644 --- a/jobs/orcid/DepositOrcidReview.php +++ b/jobs/orcid/DepositOrcidReview.php @@ -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 { @@ -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')); @@ -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'; @@ -89,7 +94,7 @@ public function handle(): void $uri, [ 'headers' => $headers, - 'json' => $orcidReview->toArray(), + 'json' => $orcidReview, ] ); @@ -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);