From caa2e7676b3ccb6ba13974600ed293376f805b0e Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Mon, 29 Aug 2022 17:06:28 +0600 Subject: [PATCH] pkp/pkp-lib#7725 editorial decision constants synced up --- classes/decision/Decision.php | 42 ---- classes/decision/types/Accept.php | 2 +- classes/decision/types/SkipExternalReview.php | 2 +- .../v3_4_0/I7725_DecisionConstantsUpdate.php | 207 ++++++++++++++++++ dbscripts/xml/upgrade.xml | 1 + .../datacite/filter/DataciteXmlFilter.php | 2 +- .../pubmed/filter/ArticlePubMedXmlFilter.php | 2 +- .../reports/articles/ArticleReportPlugin.php | 2 +- 8 files changed, 213 insertions(+), 47 deletions(-) delete mode 100644 classes/decision/Decision.php create mode 100644 classes/migration/upgrade/v3_4_0/I7725_DecisionConstantsUpdate.php diff --git a/classes/decision/Decision.php b/classes/decision/Decision.php deleted file mode 100644 index 16c824357f0..00000000000 --- a/classes/decision/Decision.php +++ /dev/null @@ -1,42 +0,0 @@ - [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()); + } + } +} diff --git a/dbscripts/xml/upgrade.xml b/dbscripts/xml/upgrade.xml index 121ed7fc353..fde63e32d2e 100644 --- a/dbscripts/xml/upgrade.xml +++ b/dbscripts/xml/upgrade.xml @@ -174,6 +174,7 @@ + diff --git a/plugins/generic/datacite/filter/DataciteXmlFilter.php b/plugins/generic/datacite/filter/DataciteXmlFilter.php index 9e826ba46a7..1e969ef417d 100644 --- a/plugins/generic/datacite/filter/DataciteXmlFilter.php +++ b/plugins/generic/datacite/filter/DataciteXmlFilter.php @@ -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; diff --git a/plugins/importexport/pubmed/filter/ArticlePubMedXmlFilter.php b/plugins/importexport/pubmed/filter/ArticlePubMedXmlFilter.php index b3a90d700b8..8a2275772e4 100644 --- a/plugins/importexport/pubmed/filter/ArticlePubMedXmlFilter.php +++ b/plugins/importexport/pubmed/filter/ArticlePubMedXmlFilter.php @@ -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; diff --git a/plugins/reports/articles/ArticleReportPlugin.php b/plugins/reports/articles/ArticleReportPlugin.php index 46ce8fbc0ee..81fa4103ac5 100644 --- a/plugins/reports/articles/ArticleReportPlugin.php +++ b/plugins/reports/articles/ArticleReportPlugin.php @@ -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;