Skip to content

Commit

Permalink
Merge pull request #16 from lepidus/stable-3_3_0
Browse files Browse the repository at this point in the history
Fix DOI retrieving (OMP 3.3.0)
  • Loading branch information
pablovp86 authored Oct 25, 2024
2 parents 7bcf4a3 + 164aeb1 commit 6f5177b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
17 changes: 15 additions & 2 deletions classes/services/ThothWorkService.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ public function getQueryBuilder($thothClient)
return new ThothWorkQueryBuilder($thothClient);
}

private function getDoiResolvingUrl($doi)
{
if (empty($doi)) {
return $doi;
}

$search = ['%', '"', '#', ' ', '<', '>', '{'];
$replace = ['%25', '%22', '%23', '%20', '%3c', '%3e', '%7b'];
$encodedDoi = str_replace($search, $replace, $doi);

return "https://doi.org/$encodedDoi";
}

public function getDataBySubmission($submission, $publication = null)
{
$request = Application::get()->getRequest();
Expand All @@ -40,7 +53,7 @@ public function getDataBySubmission($submission, $publication = null)
$data['subtitle'] = $publication->getLocalizedData('subtitle');
$data['longAbstract'] = $publication->getLocalizedData('abstract');
$data['edition'] = $publication->getData('version');
$data['doi'] = $publication->getStoredPubId('doi');
$data['doi'] = $this->getDoiResolvingUrl($publication->getStoredPubId('doi'));
$data['publicationDate'] = $publication->getData('datePublished');
$data['license'] = $publication->getData('licenseUrl');
$data['copyrightHolder'] = $publication->getLocalizedData('copyrightHolder');
Expand Down Expand Up @@ -74,7 +87,7 @@ public function newByChapter($chapter)
$params['pageCount'] = $chapter->getPages();
$params['publicationDate'] = $chapter->getDatePublished() ??
Services::get('publication')->get($chapter->getData('publicationId'))->getData('datePublished');
$params['doi'] = $chapter->getStoredPubId('doi');
$params['doi'] = $this->getDoiResolvingUrl($chapter->getStoredPubId('doi'));

return $this->new($params);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/classes/services/ThothWorkServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function testCreateNewWorkBySubmission()
);
$publication->setData(
'pub-id::doi',
'https://doi.org/10.1234/0000af0000'
'10.1234/0000af0000'
);
$publication->setData(
'datePublished',
Expand Down Expand Up @@ -236,7 +236,7 @@ public function testCreateNewWorkByChapter()
$chapter->setTitle('Chapter 1: Interactions Affording Distance Science Education', 'en_US');
$chapter->setDatePublished('2024-03-21');
$chapter->setPages(27);
$chapter->setStoredPubId('doi', 'https://doi.org/10.1234/jpk.14.c54');
$chapter->setStoredPubId('doi', '10.1234/jpk.14.c54');

$thothWork = $this->workService->newByChapter($chapter);
$this->assertEquals($expectedThothWork, $thothWork);
Expand Down
4 changes: 2 additions & 2 deletions version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<version>
<application>thoth</application>
<type>plugins.generic</type>
<release>0.1.3.1</release>
<date>2024-10-22</date>
<release>0.1.3.2</release>
<date>2024-10-25</date>
<lazy-load>1</lazy-load>
<class>ThothPlugin</class>
</version>

0 comments on commit 6f5177b

Please sign in to comment.