Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#10744 Increase opportunity for ORCID work/review deposits #4574

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good for now, but just as a note, I'd eventually like to move all things making use of this for downstream metadata consumers do so via event listeners, but not necessary for 3.5. We can revisit once 3.5 is out.

(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
Loading