-
Notifications
You must be signed in to change notification settings - Fork 448
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-LIB][main] #4860 Add JAV support to publications #10666
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ | |
use PKP\notification\NotificationSubscriptionSettingsDAO; | ||
use PKP\plugins\Hook; | ||
use PKP\plugins\PluginRegistry; | ||
use PKP\publication\enums\JavStage; | ||
use PKP\security\authorization\ContextAccessPolicy; | ||
use PKP\security\authorization\DecisionWritePolicy; | ||
use PKP\security\authorization\internal\SubmissionCompletePolicy; | ||
|
@@ -111,7 +112,10 @@ class PKPSubmissionController extends PKPBaseController | |
'getPublicationIdentifierForm', | ||
'getPublicationLicenseForm', | ||
'getPublicationTitleAbstractForm', | ||
'getChangeLanguageMetadata' | ||
'getChangeLanguageMetadata', | ||
'getJAVStageMetadata', | ||
'changeJavStageAndNumbering', | ||
'getNextAvailableJavVersionNumberingForStage', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above, maybe |
||
]; | ||
|
||
/** @var array Handlers that must be authorized to write to a publication */ | ||
|
@@ -122,6 +126,7 @@ class PKPSubmissionController extends PKPBaseController | |
'editContributor', | ||
'saveContributorsOrder', | ||
'changeLocale', | ||
'changeJavStageAndNumbering' | ||
]; | ||
|
||
/** @var array Handlers that must be authorized to access a submission's production stage */ | ||
|
@@ -236,6 +241,14 @@ public function getGroupRoutes(): void | |
Route::put('{submissionId}/publications/{publicationId}/changeLocale', $this->changeLocale(...)) | ||
->name('submission.publication.changeLocale') | ||
->whereNumber(['submissionId', 'publicationId']); | ||
|
||
Route::put('{submissionId}/publications/{publicationId}/changeJavStageAndNumbering', $this->changeJavStageAndNumbering(...)) | ||
->name('submission.publication.changeJavStageAndNumbering') | ||
->whereNumber(['submissionId', 'publicationId']); | ||
|
||
Route::get('{submissionId}/getNextAvailableJavVersionNumberingForStage', $this->getNextAvailableJavVersionNumberingForStage(...)) | ||
->name('submission.getNextAvailableJavVersionNumberingForStage') | ||
->whereNumber(['submissionId']); | ||
}); | ||
|
||
Route::middleware([ | ||
|
@@ -301,6 +314,7 @@ public function getGroupRoutes(): void | |
Route::get('reference', $this->getPublicationReferenceForm(...))->name('submission.publication._components.reference'); | ||
Route::get('titleAbstract', $this->getPublicationTitleAbstractForm(...))->name('submission.publication._components.titleAbstract'); | ||
Route::get('changeLanguageMetadata', $this->getChangeLanguageMetadata(...))->name('submission.publication._components.changeLanguageMetadata'); | ||
Route::get('getJAVStageMetadata', $this->getJAVStageMetadata(...))->name('submission.publication._components.getJAVStageMetadata'); | ||
})->whereNumber(['submissionId', 'publicationId']); | ||
}); | ||
|
||
|
@@ -943,6 +957,68 @@ public function changeLocale(Request $illuminateRequest): JsonResponse | |
return $this->edit($illuminateRequest); | ||
} | ||
|
||
/** | ||
* Change version stage | ||
*/ | ||
public function changeJavStageAndNumbering(Request $illuminateRequest): JsonResponse | ||
{ | ||
$request = $this->getRequest(); | ||
$publication = Repo::publication()->get((int) $illuminateRequest->route('publicationId')); | ||
|
||
if (!$publication) { | ||
return response()->json([ | ||
'error' => __('api.404.resourceNotFound'), | ||
], Response::HTTP_NOT_FOUND); | ||
} | ||
|
||
// $submission = Repo::submission()->get((int) $illuminateRequest->route('submissionId')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dead code should be removed |
||
$submission = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_SUBMISSION); | ||
|
||
if ($submission->getId() !== $publication->getData('submissionId')) { | ||
return response()->json([ | ||
'error' => __('api.publications.403.submissionsDidNotMatch'), | ||
], Response::HTTP_FORBIDDEN); | ||
} | ||
|
||
$params = $this->convertStringsToSchema(PKPSchemaService::SCHEMA_PUBLICATION, $illuminateRequest->input()); | ||
|
||
$submissionContext = $request->getContext(); | ||
|
||
$errors = Repo::publication()->validate($publication, $params, $submission, $submissionContext); | ||
|
||
if (!empty($errors)) { | ||
return response()->json($errors, Response::HTTP_BAD_REQUEST); | ||
} | ||
|
||
$versionStage = $params['javVersionStage']; | ||
$versionStageIsMinor = (bool) $params['javVersionIsMinor']; | ||
|
||
Repo::publication()->updateJavVersionStageAndNumbering($publication, JavStage::from($versionStage), $versionStageIsMinor); | ||
|
||
return $this->edit($illuminateRequest); | ||
} | ||
|
||
/** | ||
* Get next potential JAV version stage | ||
*/ | ||
public function getNextAvailableJavVersionNumberingForStage(Request $illuminateRequest): JsonResponse | ||
{ | ||
$submission = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_SUBMISSION); | ||
|
||
$params = $illuminateRequest->input(); | ||
$potentialVersionStage = JavStage::from($params['javVersionStage']); | ||
$potentialIsMinor = ($params['javVersionIsMinor'] === 'false') ? false : (bool) $params['javVersionIsMinor']; | ||
|
||
$potentialVersionStage = $submission->getNextAvailableJavVersionNumberingForStage($potentialVersionStage, $potentialIsMinor); | ||
|
||
$retValue = $potentialVersionStage->getVersionStageDisplay(); | ||
|
||
return response()->json( | ||
$retValue, | ||
Response::HTTP_OK | ||
); | ||
} | ||
|
||
/** | ||
* Get the decisions recorded on a submission | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
/** | ||
* @file classes/migration/upgrade/v3_5_0/I4860_AddJavStageDataToPublication.php | ||
* | ||
* Copyright (c) 2024 Simon Fraser University | ||
* Copyright (c) 2024 John Willinsky | ||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. | ||
* | ||
* @class I4860_AddJavStageDataToPublication | ||
* | ||
* @brief Add columns for JAV Versioning and migrate existing data | ||
*/ | ||
|
||
namespace PKP\migration\upgrade\v3_5_0; | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\DB; | ||
use Illuminate\Support\Facades\Schema; | ||
use PKP\migration\Migration; | ||
use PKP\publication\enums\JavStage; | ||
use PKP\publication\helpers\JavStageAndNumbering; | ||
|
||
class I4860_AddJavStageDataToPublication extends Migration | ||
{ | ||
/** | ||
* Run the migration. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('publications', function (Blueprint $table) { | ||
// Adding the enum column for VersionStage | ||
$table->enum('jav_version_stage', array_column(JavStage::cases(), 'value')) | ||
->default(JavStage::VERSION_OF_RECORD); | ||
|
||
// Adding minorVersion and majorVersion as integers | ||
$table->integer('jav_version_minor') | ||
->default(JavStageAndNumbering::JAV_DEFAULT_NUMBERING_MINOR); | ||
|
||
$table->integer('jav_version_major') | ||
->default(JavStageAndNumbering::JAV_DEFAULT_NUMBERING_MAJOR); | ||
}); | ||
|
||
// Update the version_major column based on the version column | ||
DB::table('publications')->update([ | ||
'jav_version_major' => DB::raw('version') | ||
]); | ||
} | ||
|
||
/** | ||
* Reverses the migration | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('publications', function (Blueprint $table) { | ||
$table->dropColumn(['jav_version_stage', 'jav_version_minor', 'jav_version_major']); | ||
}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
/** | ||
* @file publication/enums/JavStage.php | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because this refers to an external standard, it would be good to add a URL to where it's specified. |
||
* | ||
* Copyright (c) 2023-2024 Simon Fraser University | ||
* Copyright (c) 2023-2024 John Willinsky | ||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. | ||
* | ||
* @class JavStage | ||
* | ||
* @brief Enumeration for JAV versioning stages | ||
*/ | ||
|
||
namespace PKP\publication\enums; | ||
|
||
enum JavStage: string | ||
{ | ||
case AUTHOR_ORIGINAL = 'AO'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While these are fine to use in the codebase, we should be careful not to present them straight to the front end without having them map to translatable locale keys. |
||
case ACCEPTED_MANUSCRIPT = 'AM'; | ||
case SUBMITTED_MANUSCRIPT = 'SM'; | ||
case PROOF = 'PF'; | ||
case VERSION_OF_RECORD = 'VoR'; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/** | ||
* @file classes/publication/JavStageAndNumbering.php | ||
* | ||
* Copyright (c) 2016-2021 Simon Fraser University | ||
* Copyright (c) 2003-2021 John Willinsky | ||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. | ||
* | ||
* @class JavStageAndNumbering | ||
* | ||
* @brief Base class for JavStageAndNumbering. | ||
*/ | ||
|
||
namespace PKP\publication\helpers; | ||
|
||
use PKP\publication\enums\JavStage; | ||
|
||
class JavStageAndNumbering extends \PKP\core\DataObject | ||
{ | ||
public const JAV_DEFAULT_NUMBERING_MINOR = 0; | ||
public const JAV_DEFAULT_NUMBERING_MAJOR = 1; | ||
|
||
public JavStage $javStage; | ||
public int $javVersionMajor; | ||
public int $javVersionMinor; | ||
|
||
public function getVersionStageDisplay(): string | ||
{ | ||
$versionStageValue = $this->javStage->value; | ||
|
||
return "$versionStageValue $this->javVersionMajor.$this->javVersionMinor"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably be localized. |
||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's inconsistency between these two lines on
JAV
vs.Jav
; I don't have a strong preference but they should be consistent. In any case, I think it would be better to avoid the acronym, as most won't be familiar with it. And listing stage and numbering in the API name is overspecific. Instead, maybechangeVersionData
?