Skip to content

Commit

Permalink
pkp/pkp-lib#7725 editorial decision constants synced up
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir committed Aug 29, 2022
1 parent a78b619 commit caa2e76
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 47 deletions.
42 changes: 0 additions & 42 deletions classes/decision/Decision.php

This file was deleted.

2 changes: 1 addition & 1 deletion classes/decision/types/Accept.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
namespace APP\decision\types;

use APP\core\Application;
use APP\decision\Decision;
use APP\decision\types\traits\RequestPayment;
use APP\submission\Submission;
use Illuminate\Validation\Validator;
use PKP\context\Context;
use PKP\decision\Decision;
use PKP\decision\Steps;
use PKP\decision\types\Accept as TypesAccept;
use PKP\submission\reviewRound\ReviewRound;
Expand Down
2 changes: 1 addition & 1 deletion classes/decision/types/SkipExternalReview.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

namespace APP\decision\types;

use APP\decision\Decision;
use APP\decision\types\traits\RequestPayment;
use APP\submission\Submission;
use Illuminate\Validation\Validator;
use PKP\context\Context;
use PKP\decision\Decision;
use PKP\decision\types\SkipExternalReview as PKPSkipExternalReview;
use PKP\user\User;

Expand Down
207 changes: 207 additions & 0 deletions classes/migration/upgrade/v3_4_0/I7725_DecisionConstantsUpdate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
<?php

/**
* @file classes/migration/upgrade/v3_4_0/I7725_DecisionConstantsUpdate.inc.php
*
* Copyright (c) 2014-2022 Simon Fraser University
* Copyright (c) 2000-2022 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class I7725_DecisionConstantsUpdate
* @brief Editorial decision constant sync up accross all application
*
* @see https://github.com/pkp/pkp-lib/issues/7725
*/

namespace APP\migration\upgrade\v3_4_0;

use Illuminate\Support\Facades\DB;
use PKP\migration\Migration;
use Throwable;

class I7725_DecisionConstantsUpdate extends Migration
{
/**
* Updated decision constant value mapping
*
* @var array
*/
protected $decisionMappings = [
// \PKP\decision\Decision::ACCEPT
[
'stage_id' => [WORKFLOW_STAGE_ID_EDITING],
'current_value' => 1,
'updated_value' => 2,
],

// \PKP\decision\Decision::EXTERNAL_REVIEW
[
'stage_id' => [WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
'current_value' => 8,
'updated_value' => 3,
],

// \PKP\decision\Decision::PENDING_REVISIONS
[
'stage_id' => [WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
'current_value' => 2,
'updated_value' => 4,
],

// \PKP\decision\Decision::RESUBMIT
[
'stage_id' => [WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
'current_value' => 3,
'updated_value' => 5,
],

// \PKP\decision\Decision::DECLINE
[
'stage_id' => [WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
'current_value' => 4,
'updated_value' => 6,
],

// \PKP\decision\Decision::INITIAL_DECLINE
[
'stage_id' => [WORKFLOW_STAGE_ID_SUBMISSION],
'current_value' => 9,
'updated_value' => 8,
],

// \PKP\decision\Decision::RECOMMEND_ACCEPT
[
'stage_id' => [WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
'current_value' => 11,
'updated_value' => 9,
],

// \PKP\decision\Decision::RECOMMEND_PENDING_REVISIONS
[
'stage_id' => [WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
'current_value' => 12,
'updated_value' => 10,
],

// \PKP\decision\Decision::RECOMMEND_RESUBMIT
[
'stage_id' => [WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
'current_value' => 13,
'updated_value' => 11,
],

// \PKP\decision\Decision::RECOMMEND_DECLINE
[
'stage_id' => [WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
'current_value' => 14,
'updated_value' => 12,
],

// \PKP\decision\Decision::NEW_EXTERNAL_ROUND
[
'stage_id' => [WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
'current_value' => 16,
'updated_value' => 14,
],

// \PKP\decision\Decision::REVERT_DECLINE
[
'stage_id' => [WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
'current_value' => 17,
'updated_value' => 15,
],

// \PKP\decision\Decision::REVERT_INITIAL_DECLINE
[
'stage_id' => [WORKFLOW_STAGE_ID_SUBMISSION],
'current_value' => 18,
'updated_value' => 16
],

// \PKP\decision\Decision::SKIP_EXTERNAL_REVIEW
[
'stage_id' => [WORKFLOW_STAGE_ID_EDITING],
'current_value' => 19,
'updated_value' => 17,
],

// \PKP\decision\Decision::BACK_FROM_PRODUCTION
[
'stage_id' => [WORKFLOW_STAGE_ID_EDITING],
'current_value' => 31,
'updated_value' => 29,
],

// \PKP\decision\Decision::BACK_FROM_COPYEDITING
[
'stage_id' => [WORKFLOW_STAGE_ID_SUBMISSION, WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
'current_value' => 32,
'updated_value' => 30,
],

// \PKP\decision\Decision::CANCEL_REVIEW_ROUND
[
'stage_id' => [WORKFLOW_STAGE_ID_SUBMISSION, WORKFLOW_STAGE_ID_EXTERNAL_REVIEW],
'current_value' => 33,
'updated_value' => 31,
],
];

/**
* Run the migrations.
*/
public function up(): void
{
try {
DB::beginTransaction();

collect($this->decisionMappings)
->each(
fn ($decisionMapping) => DB::table('edit_decisions')
->when(
isset($decisionMapping['stage_id']) && !empty($decisionMapping['stage_id']),
fn ($query) => $query->whereIn('stage_id', $decisionMapping['stage_id'])
)
->where('decision', $decisionMapping['current_value'])
->update([
'decision' => $decisionMapping['updated_value'],
])
);

DB::commit();
} catch (Throwable $exception) {
DB::rollBack();

error_log($exception->__toString());
}
}

/**
* Reverse the migrations.
*/
public function down(): void
{
try {
DB::beginTransaction();

collect($this->decisionMappings)
->each(
fn ($decisionMapping) => DB::table('edit_decisions')
->when(
isset($decisionMapping['stage_id']) && !empty($decisionMapping['stage_id']),
fn ($query) => $query->whereIn('stage_id', $decisionMapping['stage_id'])
)
->where('decision', $decisionMapping['updated_value'])
->update([
'decision' => $decisionMapping['current_value'],
])
);

DB::commit();
} catch (Throwable $exception) {
DB::rollBack();

error_log($exception->__toString());
}
}
}
1 change: 1 addition & 0 deletions dbscripts/xml/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
<migration class="APP\migration\upgrade\v3_4_0\I7901_Duplicate_OAI_IDs"/>
<migration class="PKP\migration\upgrade\v3_4_0\I7366_UpdateUserAPIKeySettings"/>
<migration class="PKP\migration\upgrade\v3_4_0\I8093_UpdateUserGroupRelationTablesFK"/>
<migration class="APP\migration\upgrade\v3_4_0\I7725_DecisionConstantsUpdate"/>
<data file="dbscripts/xml/upgrade/3.4.0_preupdate_email_templates.xml" />
<code function="installEmailTemplate" key="EDITOR_DECISION_NOTIFY_OTHER_AUTHORS" locales="en_US" />
<code function="installEmailTemplate" key="EDITOR_DECISION_NEW_ROUND" locales="en_US" />
Expand Down
2 changes: 1 addition & 1 deletion plugins/generic/datacite/filter/DataciteXmlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

use APP\core\Application;
use APP\core\Services;
use APP\decision\Decision;
use APP\facades\Repo;
use APP\issue\Issue;
use APP\submission\Submission;
use PKP\core\PKPString;
use PKP\db\DAORegistry;
use PKP\decision\Decision;
use PKP\facades\Locale;
use PKP\galley\Galley;
use PKP\i18n\LocaleConversion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
namespace APP\plugins\importexport\pubmed\filter;

use APP\author\Author;
use APP\decision\Decision;
use APP\facades\Repo;
use APP\issue\Issue;
use APP\journal\Journal;
use APP\submission\Submission;
use PKP\core\PKPString;
use PKP\db\DAORegistry;
use PKP\decision\Decision;
use PKP\filter\PersistableFilter;
use PKP\i18n\LocaleConversion;

Expand Down
2 changes: 1 addition & 1 deletion plugins/reports/articles/ArticleReportPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

namespace APP\plugins\reports\articles;

use APP\decision\Decision;
use APP\facades\Repo;
use APP\i18n\AppLocale;
use PKP\core\PKPString;
use PKP\db\DAORegistry;
use PKP\decision\Decision;
use PKP\plugins\ReportPlugin;
use PKP\security\Role;
use PKP\submission\PKPSubmission;
Expand Down

0 comments on commit caa2e76

Please sign in to comment.