From 310f020ab0a4f6137b5cb3fb4a24b3343dac8538 Mon Sep 17 00:00:00 2001 From: Jhon Date: Tue, 21 Jan 2025 14:16:17 -0400 Subject: [PATCH 01/17] Adds data statement to submission model Issue: documentacao-e-tarefas/scielo#738 Signed-off-by: Jhon --- classes/SubmissionModel.php | 5 +++++ tests/SubmissionTest.php | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/classes/SubmissionModel.php b/classes/SubmissionModel.php index 605c396..c976750 100644 --- a/classes/SubmissionModel.php +++ b/classes/SubmissionModel.php @@ -89,4 +89,9 @@ public function getCitation(): ?string { return $this->getData('citation'); } + + public function getDataStatement(): ?array + { + return $this->getData('dataStatement'); + } } diff --git a/tests/SubmissionTest.php b/tests/SubmissionTest.php index cc9f439..e4cabc5 100644 --- a/tests/SubmissionTest.php +++ b/tests/SubmissionTest.php @@ -19,7 +19,10 @@ class SubmissionTest extends PKPTestCase private $versionJustification = 'Nova versão criada para corrigir erros de ortografia'; private $isTranslation = false; private $citation = 'Lispector, C. & Iamarino, A. (2024). An adventure in an imaginary world. Public Knowledge Preprint Server'; - private $galleys = array(); + private $dataStatement = [ + 'Os dados de pesquisa estão disponíveis sob demanda, condição justificada no manuscrito' + ]; + private $galleys = []; private function getSubmissionForTests() { @@ -41,6 +44,7 @@ private function getSubmissionForTests() 'versionJustification' => $this->versionJustification, 'isTranslation' => $this->isTranslation, 'citation' => $this->citation, + 'dataStatement' => $this->dataStatement, 'galleys' => $this->galleys ]); @@ -150,4 +154,10 @@ public function testHasCitation(): void $submission = $this->getSubmissionForTests(); $this->assertEquals($this->citation, $submission->getCitation()); } + + public function testHasDataStatement(): void + { + $submission = $this->getSubmissionForTests(); + $this->assertEquals($this->dataStatement, $submission->getDataStatement()); + } } From e88bf67dc70e016dd6ac70d9e7090cf09d5fda37 Mon Sep 17 00:00:00 2001 From: Jhon Date: Tue, 21 Jan 2025 15:19:43 -0400 Subject: [PATCH 02/17] Adds unit test - Writing of data statement in title page Issue: documentacao-e-tarefas/scielo#738 Signed-off-by: Jhon --- tests/PdfHandlingTest.php | 4 ++++ tests/TitlePageTest.php | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/tests/PdfHandlingTest.php b/tests/PdfHandlingTest.php index 97fa2f2..d388949 100644 --- a/tests/PdfHandlingTest.php +++ b/tests/PdfHandlingTest.php @@ -36,6 +36,9 @@ class PdfHandlingTest extends PKPTestCase protected $versionJustification = 'Nova versão criada para corrigir erros de ortografia'; protected $isTranslation = false; protected $citation = 'Silva, C. & Carlos, J. (2024). Thus spoke Zarathustra. Public Knowledge Preprint Server'; + protected $dataStatement = [ + 'Os dados de pesquisa estão disponíveis sob demanda, condição justificada no manuscrito' + ]; protected function setUp(): void { @@ -83,6 +86,7 @@ protected function getSubmissionForTests(): SubmissionModel 'versionJustification' => $this->versionJustification, 'isTranslation' => $this->isTranslation, 'citation' => $this->citation, + 'dataStatement' => $this->dataStatement ]); return $submission; diff --git a/tests/TitlePageTest.php b/tests/TitlePageTest.php index e05c9b7..dffb7b8 100644 --- a/tests/TitlePageTest.php +++ b/tests/TitlePageTest.php @@ -219,6 +219,19 @@ public function testInsertingInExistingPdfStampsCitation(): void $this->assertTrue($this->searchForTextInPdf($pdf, $expectedText)); } + public function testInsertingInExistingPdfStampsDataStatement(): void + { + $titlePage = $this->getTitlePageForTests(); + $pdf = new Pdf($this->pathOfTestPdf); + + $titlePage->insertTitlePageFirstTime($pdf); + $expectedText = __('plugins.generic.titlePageForPreprint.dataStatement', [], $this->locale); + $this->assertTrue($this->searchForTextInPdf($pdf, $expectedText)); + + $firstStatement = $this->dataStatement[0]; + $this->assertTrue($this->searchForTextInPdf($pdf, $firstStatement)); + } + public function testInsertingInExistingPdfStampsHeader(): void { $titlePage = $this->getTitlePageForTests(); From 215a16a156178b2f22138adf7bb7f18b0a9c838b Mon Sep 17 00:00:00 2001 From: Jhon Date: Tue, 21 Jan 2025 15:41:43 -0400 Subject: [PATCH 03/17] Title page writes data statement Issue: documentacao-e-tarefas/scielo#738 Signed-off-by: Jhon --- classes/TitlePage.php | 10 ++++++++++ locale/en/locale.po | 3 +++ locale/es/locale.po | 3 +++ locale/pt_BR/locale.po | 3 +++ 4 files changed, 19 insertions(+) diff --git a/classes/TitlePage.php b/classes/TitlePage.php index 94de740..ada6309 100644 --- a/classes/TitlePage.php +++ b/classes/TitlePage.php @@ -111,6 +111,16 @@ private function generateTitlePage(): string $titlePage->writeHTML(__('plugins.generic.titlePageForPreprint.endorsement', ['endorserName' => $endorserName, 'endorserOrcid' => $endorserOrcid], $this->locale)); } + if (!empty($this->submission->getDataStatement())) { + $titlePage->Ln(5); + $titlePage->Write(0, __('plugins.generic.titlePageForPreprint.dataStatement', [], $this->locale), '', 0, 'JUSTIFY', true, 0, false, false, 0); + + foreach ($this->submission->getDataStatement() as $statement) { + $titlePage->Ln(5); + $titlePage->Write(0, $statement, '', 0, 'JUSTIFY', true, 0, false, false, 0); + } + } + $versionJustification = $this->submission->getVersionJustification(); if ($this->submission->getVersion() > 1 && !is_null($versionJustification)) { $versionJustification = __('plugins.generic.titlePageForPreprint.versionJustification', [], $this->locale) . ": " . $versionJustification; diff --git a/locale/en/locale.po b/locale/en/locale.po index 5c2c849..1761757 100644 --- a/locale/en/locale.po +++ b/locale/en/locale.po @@ -42,6 +42,9 @@ msgstr "" "How to cite this translation:" "{$citation}" +msgid "plugins.generic.titlePageForPreprint.dataStatement" +msgstr "Data statement" + msgid "plugins.generic.titlePageForPreprint.versionJustification" msgstr "Version justification" diff --git a/locale/es/locale.po b/locale/es/locale.po index 144afb9..2ad8eea 100644 --- a/locale/es/locale.po +++ b/locale/es/locale.po @@ -42,6 +42,9 @@ msgstr "" "Cómo citar esta traducción:" "{$citation}" +msgid "plugins.generic.titlePageForPreprint.dataStatement" +msgstr "Declaración de datos" + msgid "plugins.generic.titlePageForPreprint.versionJustification" msgstr "Justificación de la versión" diff --git a/locale/pt_BR/locale.po b/locale/pt_BR/locale.po index dde968c..37a6ac9 100644 --- a/locale/pt_BR/locale.po +++ b/locale/pt_BR/locale.po @@ -42,6 +42,9 @@ msgstr "" "Como citar esta tradução:" "{$citation}" +msgid "plugins.generic.titlePageForPreprint.dataStatement" +msgstr "Declaração de dados" + msgid "plugins.generic.titlePageForPreprint.versionJustification" msgstr "Justificativa da versão" From 2e3a1261b471e2418e48fa7c571e2f7552139076 Mon Sep 17 00:00:00 2001 From: Jhon Date: Tue, 21 Jan 2025 18:15:59 -0400 Subject: [PATCH 04/17] WIP: Writing of data statement in title page There is still need to localize text and add sub-items Issue: documentacao-e-tarefas/scielo#738 Signed-off-by: Jhon --- classes/SubmissionPressFactory.php | 21 +++++++++++++++++++++ classes/TitlePage.php | 6 ++++-- locale/en/locale.po | 2 +- locale/es/locale.po | 2 +- locale/pt_BR/locale.po | 2 +- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/classes/SubmissionPressFactory.php b/classes/SubmissionPressFactory.php index 7e0f9a2..fbbb661 100644 --- a/classes/SubmissionPressFactory.php +++ b/classes/SubmissionPressFactory.php @@ -41,6 +41,7 @@ public function createSubmissionPress($submission, $publication, $context): Subm 'versionJustification' => $dataPress['versionJustification'], 'isTranslation' => $dataPress['isTranslation'], 'citation' => $dataPress['citation'], + 'dataStatement' => $dataPress['dataStatement'], 'galleys' => $submissionGalleys ]); @@ -105,6 +106,10 @@ private function getDataForPress($submission, $publication) $data['isTranslation'] = !is_null($publication->getData('originalDocumentDoi')); $data['citation'] = ($data['isTranslation'] ? $this->getSubmissionCitation($submission) : ''); + if ($publication->getData('dataStatementTypes')) { + $data['dataStatement'] = $this->getDataStatement($publication); + } + $data['endorserName'] = $publication->getData('endorserName'); $data['endorserOrcid'] = $publication->getData('endorserOrcid'); @@ -124,4 +129,20 @@ private function getSubmissionCitation($submission) return $citation; } + + private function getDataStatement($publication) + { + $dataStatementService = new \APP\plugins\generic\dataverse\classes\services\DataStatementService(); + $dataStatementTypes = $dataStatementService->getDataStatementTypes(false); + $processedDataStatement = []; + + // Problema aqui: os textos precisam estar no idioma da submissão + foreach ($publication->getData('dataStatementTypes') as $selectedStatement) { + if (isset($dataStatementTypes[$selectedStatement])) { + $processedDataStatement[] = $dataStatementTypes[$selectedStatement]; + } + } + + return $processedDataStatement; + } } diff --git a/classes/TitlePage.php b/classes/TitlePage.php index ada6309..0e2a9d2 100644 --- a/classes/TitlePage.php +++ b/classes/TitlePage.php @@ -115,10 +115,12 @@ private function generateTitlePage(): string $titlePage->Ln(5); $titlePage->Write(0, __('plugins.generic.titlePageForPreprint.dataStatement', [], $this->locale), '', 0, 'JUSTIFY', true, 0, false, false, 0); + $statementList = '
    '; foreach ($this->submission->getDataStatement() as $statement) { - $titlePage->Ln(5); - $titlePage->Write(0, $statement, '', 0, 'JUSTIFY', true, 0, false, false, 0); + $statementList .= "
  • $statement
  • "; } + + $titlePage->writeHTML($statementList.'
'); } $versionJustification = $this->submission->getVersionJustification(); diff --git a/locale/en/locale.po b/locale/en/locale.po index 1761757..9ccb4e0 100644 --- a/locale/en/locale.po +++ b/locale/en/locale.po @@ -43,7 +43,7 @@ msgstr "" "{$citation}" msgid "plugins.generic.titlePageForPreprint.dataStatement" -msgstr "Data statement" +msgstr "Data statement:" msgid "plugins.generic.titlePageForPreprint.versionJustification" msgstr "Version justification" diff --git a/locale/es/locale.po b/locale/es/locale.po index 2ad8eea..8560788 100644 --- a/locale/es/locale.po +++ b/locale/es/locale.po @@ -43,7 +43,7 @@ msgstr "" "{$citation}" msgid "plugins.generic.titlePageForPreprint.dataStatement" -msgstr "Declaración de datos" +msgstr "Declaración de datos:" msgid "plugins.generic.titlePageForPreprint.versionJustification" msgstr "Justificación de la versión" diff --git a/locale/pt_BR/locale.po b/locale/pt_BR/locale.po index 37a6ac9..77dab5e 100644 --- a/locale/pt_BR/locale.po +++ b/locale/pt_BR/locale.po @@ -43,7 +43,7 @@ msgstr "" "{$citation}" msgid "plugins.generic.titlePageForPreprint.dataStatement" -msgstr "Declaração de dados" +msgstr "Declaração de dados:" msgid "plugins.generic.titlePageForPreprint.versionJustification" msgstr "Justificativa da versão" From 9b23ee1e4af13b179f398737a95b5eaa77e0ed66 Mon Sep 17 00:00:00 2001 From: Jhon Date: Wed, 22 Jan 2025 14:26:45 -0400 Subject: [PATCH 05/17] Stamps data statement on PDF language Issue: documentacao-e-tarefas/scielo#738 Signed-off-by: Jhon --- classes/SubmissionPressFactory.php | 8 ++++++-- classes/TitlePage.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/classes/SubmissionPressFactory.php b/classes/SubmissionPressFactory.php index fbbb661..be2f6df 100644 --- a/classes/SubmissionPressFactory.php +++ b/classes/SubmissionPressFactory.php @@ -133,10 +133,14 @@ private function getSubmissionCitation($submission) private function getDataStatement($publication) { $dataStatementService = new \APP\plugins\generic\dataverse\classes\services\DataStatementService(); - $dataStatementTypes = $dataStatementService->getDataStatementTypes(false); + $dataStatementTypes = [ + $dataStatementService::DATA_STATEMENT_TYPE_IN_MANUSCRIPT => 'plugins.generic.dataverse.dataStatement.inManuscript', + $dataStatementService::DATA_STATEMENT_TYPE_REPO_AVAILABLE => 'plugins.generic.dataverse.dataStatement.repoAvailable', + $dataStatementService::DATA_STATEMENT_TYPE_ON_DEMAND => 'plugins.generic.dataverse.dataStatement.onDemand', + $dataStatementService::DATA_STATEMENT_TYPE_PUBLICLY_UNAVAILABLE => 'plugins.generic.dataverse.dataStatement.publiclyUnavailable' + ]; $processedDataStatement = []; - // Problema aqui: os textos precisam estar no idioma da submissão foreach ($publication->getData('dataStatementTypes') as $selectedStatement) { if (isset($dataStatementTypes[$selectedStatement])) { $processedDataStatement[] = $dataStatementTypes[$selectedStatement]; diff --git a/classes/TitlePage.php b/classes/TitlePage.php index 0e2a9d2..f09b843 100644 --- a/classes/TitlePage.php +++ b/classes/TitlePage.php @@ -117,7 +117,7 @@ private function generateTitlePage(): string $statementList = '
    '; foreach ($this->submission->getDataStatement() as $statement) { - $statementList .= "
  • $statement
  • "; + $statementList .= '
  • ' . __($statement, [], $this->locale) . '
  • '; } $titlePage->writeHTML($statementList.'
'); From 43283a62bdddd3702348ea31a310ce1271a2f3d5 Mon Sep 17 00:00:00 2001 From: Jhon Date: Wed, 22 Jan 2025 15:12:38 -0400 Subject: [PATCH 06/17] Writes data statement URLs in title page Issue: documentacao-e-tarefas/scielo#738 Signed-off-by: Jhon --- classes/SubmissionPressFactory.php | 10 +++++---- classes/TitlePage.php | 33 ++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/classes/SubmissionPressFactory.php b/classes/SubmissionPressFactory.php index be2f6df..1e13810 100644 --- a/classes/SubmissionPressFactory.php +++ b/classes/SubmissionPressFactory.php @@ -139,14 +139,16 @@ private function getDataStatement($publication) $dataStatementService::DATA_STATEMENT_TYPE_ON_DEMAND => 'plugins.generic.dataverse.dataStatement.onDemand', $dataStatementService::DATA_STATEMENT_TYPE_PUBLICLY_UNAVAILABLE => 'plugins.generic.dataverse.dataStatement.publiclyUnavailable' ]; - $processedDataStatement = []; + $dataStatement = ['selectedStatements' => []]; foreach ($publication->getData('dataStatementTypes') as $selectedStatement) { - if (isset($dataStatementTypes[$selectedStatement])) { - $processedDataStatement[] = $dataStatementTypes[$selectedStatement]; + $dataStatement['selectedStatements'][$selectedStatement] = $dataStatementTypes[$selectedStatement]; + + if ($selectedStatement == $dataStatementService::DATA_STATEMENT_TYPE_REPO_AVAILABLE) { + $dataStatement['dataStatementUrls'] = $publication->getData('dataStatementUrls'); } } - return $processedDataStatement; + return $dataStatement; } } diff --git a/classes/TitlePage.php b/classes/TitlePage.php index f09b843..0660e52 100644 --- a/classes/TitlePage.php +++ b/classes/TitlePage.php @@ -65,6 +65,29 @@ private function writePublicationStatusOnTitlePage($titlePage) $titlePage->Ln(5); } + private function writeDataStatementOnTitlePage($titlePage) + { + $dataStatementService = new \APP\plugins\generic\dataverse\classes\services\DataStatementService(); + $dataStatement = $this->submission->getDataStatement(); + $statementBody = '
    '; + + foreach ($dataStatement['selectedStatements'] as $statementType => $statementMsg) { + $statementBody .= '
  • ' . __($statementMsg, [], $this->locale) . '
  • '; + + if ($statementType == $dataStatementService::DATA_STATEMENT_TYPE_REPO_AVAILABLE) { + $statementBody .= '
      '; + foreach ($dataStatement['dataStatementUrls'] as $url) { + $statementBody .= "
    • $url
    • "; + } + $statementBody .= '
    '; + } + } + + $titlePage->Ln(5); + $titlePage->Write(0, __('plugins.generic.titlePageForPreprint.dataStatement', [], $this->locale), '', 0, 'JUSTIFY', true, 0, false, false, 0); + $titlePage->writeHTML($statementBody.'
'); + } + private function generateTitlePage(): string { $errorMessage = 'plugins.generic.titlePageForPreprint.requirements.generateTitlePageMissing'; @@ -112,15 +135,7 @@ private function generateTitlePage(): string } if (!empty($this->submission->getDataStatement())) { - $titlePage->Ln(5); - $titlePage->Write(0, __('plugins.generic.titlePageForPreprint.dataStatement', [], $this->locale), '', 0, 'JUSTIFY', true, 0, false, false, 0); - - $statementList = '
    '; - foreach ($this->submission->getDataStatement() as $statement) { - $statementList .= '
  • ' . __($statement, [], $this->locale) . '
  • '; - } - - $titlePage->writeHTML($statementList.'
'); + $this->writeDataStatementOnTitlePage($titlePage); } $versionJustification = $this->submission->getVersionJustification(); From 4a10308e77e8bb15a7447a4c591844d6d81c299f Mon Sep 17 00:00:00 2001 From: Jhon Date: Wed, 22 Jan 2025 17:27:35 -0400 Subject: [PATCH 07/17] Write data statement reason on title page Issue: documentacao-e-tarefas/scielo#738 Signed-off-by: Jhon --- classes/SubmissionPressFactory.php | 4 ++++ classes/TitlePage.php | 2 ++ 2 files changed, 6 insertions(+) diff --git a/classes/SubmissionPressFactory.php b/classes/SubmissionPressFactory.php index 1e13810..19d6081 100644 --- a/classes/SubmissionPressFactory.php +++ b/classes/SubmissionPressFactory.php @@ -147,6 +147,10 @@ private function getDataStatement($publication) if ($selectedStatement == $dataStatementService::DATA_STATEMENT_TYPE_REPO_AVAILABLE) { $dataStatement['dataStatementUrls'] = $publication->getData('dataStatementUrls'); } + + if ($selectedStatement == $dataStatementService::DATA_STATEMENT_TYPE_PUBLICLY_UNAVAILABLE) { + $dataStatement['dataStatementReason'] = $publication->getLocalizedData('dataStatementReason'); + } } return $dataStatement; diff --git a/classes/TitlePage.php b/classes/TitlePage.php index 0660e52..0840b0f 100644 --- a/classes/TitlePage.php +++ b/classes/TitlePage.php @@ -80,6 +80,8 @@ private function writeDataStatementOnTitlePage($titlePage) $statementBody .= "
  • $url
  • "; } $statementBody .= ''; + } elseif ($statementType == $dataStatementService::DATA_STATEMENT_TYPE_PUBLICLY_UNAVAILABLE) { + $statementBody .= '
    • ' . $dataStatement['dataStatementReason'] . '
    '; } } From 23eb9f869cd28f5dc965225d65aa3d7003029c34 Mon Sep 17 00:00:00 2001 From: Jhon Date: Wed, 22 Jan 2025 17:58:36 -0400 Subject: [PATCH 08/17] Adds research data to submission model Issue: documentacao-e-tarefas/scielo#738 Signed-off-by: Jhon --- classes/SubmissionModel.php | 5 +++++ tests/SubmissionTest.php | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/classes/SubmissionModel.php b/classes/SubmissionModel.php index c976750..2e77316 100644 --- a/classes/SubmissionModel.php +++ b/classes/SubmissionModel.php @@ -94,4 +94,9 @@ public function getDataStatement(): ?array { return $this->getData('dataStatement'); } + + public function getResearchData(): ?string + { + return $this->getData('researchData'); + } } diff --git a/tests/SubmissionTest.php b/tests/SubmissionTest.php index e4cabc5..c6a5d45 100644 --- a/tests/SubmissionTest.php +++ b/tests/SubmissionTest.php @@ -22,6 +22,7 @@ class SubmissionTest extends PKPTestCase private $dataStatement = [ 'Os dados de pesquisa estão disponíveis sob demanda, condição justificada no manuscrito' ]; + private $researchData = 'Linspector, Clarice; Iamarino, Atila, 2025, "Replication data for: An adventure in an imaginary world", https://doi.org/10.70122/FK2/9ET, Demo Dataverse, V1'; private $galleys = []; private function getSubmissionForTests() @@ -45,6 +46,7 @@ private function getSubmissionForTests() 'isTranslation' => $this->isTranslation, 'citation' => $this->citation, 'dataStatement' => $this->dataStatement, + 'researchData' => $this->researchData, 'galleys' => $this->galleys ]); @@ -160,4 +162,10 @@ public function testHasDataStatement(): void $submission = $this->getSubmissionForTests(); $this->assertEquals($this->dataStatement, $submission->getDataStatement()); } + + public function testHasResearchData(): void + { + $submission = $this->getSubmissionForTests(); + $this->assertEquals($this->researchData, $submission->getResearchData()); + } } From 1f2c2459f21a7192c2b1acefac17a74ebc0cdaac Mon Sep 17 00:00:00 2001 From: Jhon Date: Wed, 22 Jan 2025 18:06:53 -0400 Subject: [PATCH 09/17] Adds unit test - Writing of research data on title page Issue: documentacao-e-tarefas/scielo#738 Signed-off-by: Jhon --- tests/PdfHandlingTest.php | 4 +++- tests/TitlePageTest.php | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/PdfHandlingTest.php b/tests/PdfHandlingTest.php index d388949..7ab3f4b 100644 --- a/tests/PdfHandlingTest.php +++ b/tests/PdfHandlingTest.php @@ -39,6 +39,7 @@ class PdfHandlingTest extends PKPTestCase protected $dataStatement = [ 'Os dados de pesquisa estão disponíveis sob demanda, condição justificada no manuscrito' ]; + protected $researchData = 'Linspector, Clarice; Iamarino, Atila, 2025, "Replication data for: An adventure in an imaginary world", https://doi.org/10.70122/FK2/9ET, Demo Dataverse, V1'; protected function setUp(): void { @@ -86,7 +87,8 @@ protected function getSubmissionForTests(): SubmissionModel 'versionJustification' => $this->versionJustification, 'isTranslation' => $this->isTranslation, 'citation' => $this->citation, - 'dataStatement' => $this->dataStatement + 'dataStatement' => $this->dataStatement, + 'researchData' => $this->researchData ]); return $submission; diff --git a/tests/TitlePageTest.php b/tests/TitlePageTest.php index dffb7b8..cab43e6 100644 --- a/tests/TitlePageTest.php +++ b/tests/TitlePageTest.php @@ -232,6 +232,18 @@ public function testInsertingInExistingPdfStampsDataStatement(): void $this->assertTrue($this->searchForTextInPdf($pdf, $firstStatement)); } + public function testInsertingInExistingPdfStampsResearchData(): void + { + $titlePage = $this->getTitlePageForTests(); + $pdf = new Pdf($this->pathOfTestPdf); + + $titlePage->insertTitlePageFirstTime($pdf); + $expectedText = __('plugins.generic.titlePageForPreprint.researchData', [], $this->locale); + $this->assertTrue($this->searchForTextInPdf($pdf, $expectedText)); + + $this->assertTrue($this->searchForTextInPdf($pdf, $this->researchData)); + } + public function testInsertingInExistingPdfStampsHeader(): void { $titlePage = $this->getTitlePageForTests(); From 98e8fefa3038751766720fc8d04c82e0ed8044ef Mon Sep 17 00:00:00 2001 From: Jhon Date: Thu, 23 Jan 2025 14:00:36 -0400 Subject: [PATCH 10/17] Writes research data on title page Also refactors previous tests classes Issue: documentacao-e-tarefas/scielo#738 Signed-off-by: Jhon --- classes/TitlePage.php | 6 ++++++ locale/en/locale.po | 3 +++ locale/es/locale.po | 3 +++ locale/pt_BR/locale.po | 3 +++ tests/PdfHandlingTest.php | 4 +++- tests/SubmissionTest.php | 4 +++- tests/TitlePageTest.php | 2 +- 7 files changed, 22 insertions(+), 3 deletions(-) diff --git a/classes/TitlePage.php b/classes/TitlePage.php index 0840b0f..285f040 100644 --- a/classes/TitlePage.php +++ b/classes/TitlePage.php @@ -140,6 +140,12 @@ private function generateTitlePage(): string $this->writeDataStatementOnTitlePage($titlePage); } + if ($this->submission->getResearchData()) { + $titlePage->Ln(5); + $titlePage->Write(0, __('plugins.generic.titlePageForPreprint.researchData', [], $this->locale), '', 0, 'JUSTIFY', true, 0, false, false, 0); + $titlePage->Write(0, $this->submission->getResearchData(), '', 0, 'JUSTIFY', true, 0, false, false, 0); + } + $versionJustification = $this->submission->getVersionJustification(); if ($this->submission->getVersion() > 1 && !is_null($versionJustification)) { $versionJustification = __('plugins.generic.titlePageForPreprint.versionJustification', [], $this->locale) . ": " . $versionJustification; diff --git a/locale/en/locale.po b/locale/en/locale.po index 9ccb4e0..0cb0396 100644 --- a/locale/en/locale.po +++ b/locale/en/locale.po @@ -45,6 +45,9 @@ msgstr "" msgid "plugins.generic.titlePageForPreprint.dataStatement" msgstr "Data statement:" +msgid "plugins.generic.titlePageForPreprint.researchData" +msgstr "Research data:" + msgid "plugins.generic.titlePageForPreprint.versionJustification" msgstr "Version justification" diff --git a/locale/es/locale.po b/locale/es/locale.po index 8560788..27c24ca 100644 --- a/locale/es/locale.po +++ b/locale/es/locale.po @@ -45,6 +45,9 @@ msgstr "" msgid "plugins.generic.titlePageForPreprint.dataStatement" msgstr "Declaración de datos:" +msgid "plugins.generic.titlePageForPreprint.researchData" +msgstr "Datos de investigación:" + msgid "plugins.generic.titlePageForPreprint.versionJustification" msgstr "Justificación de la versión" diff --git a/locale/pt_BR/locale.po b/locale/pt_BR/locale.po index 77dab5e..0c50bef 100644 --- a/locale/pt_BR/locale.po +++ b/locale/pt_BR/locale.po @@ -45,6 +45,9 @@ msgstr "" msgid "plugins.generic.titlePageForPreprint.dataStatement" msgstr "Declaração de dados:" +msgid "plugins.generic.titlePageForPreprint.researchData" +msgstr "Dados de pesquisa:" + msgid "plugins.generic.titlePageForPreprint.versionJustification" msgstr "Justificativa da versão" diff --git a/tests/PdfHandlingTest.php b/tests/PdfHandlingTest.php index 7ab3f4b..daa7e7e 100644 --- a/tests/PdfHandlingTest.php +++ b/tests/PdfHandlingTest.php @@ -37,7 +37,9 @@ class PdfHandlingTest extends PKPTestCase protected $isTranslation = false; protected $citation = 'Silva, C. & Carlos, J. (2024). Thus spoke Zarathustra. Public Knowledge Preprint Server'; protected $dataStatement = [ - 'Os dados de pesquisa estão disponíveis sob demanda, condição justificada no manuscrito' + 'selectedStatements' => [ + 'Os dados de pesquisa estão disponíveis sob demanda, condição justificada no manuscrito' + ] ]; protected $researchData = 'Linspector, Clarice; Iamarino, Atila, 2025, "Replication data for: An adventure in an imaginary world", https://doi.org/10.70122/FK2/9ET, Demo Dataverse, V1'; diff --git a/tests/SubmissionTest.php b/tests/SubmissionTest.php index c6a5d45..b15891f 100644 --- a/tests/SubmissionTest.php +++ b/tests/SubmissionTest.php @@ -20,7 +20,9 @@ class SubmissionTest extends PKPTestCase private $isTranslation = false; private $citation = 'Lispector, C. & Iamarino, A. (2024). An adventure in an imaginary world. Public Knowledge Preprint Server'; private $dataStatement = [ - 'Os dados de pesquisa estão disponíveis sob demanda, condição justificada no manuscrito' + 'selectedStatements' => [ + 'Os dados de pesquisa estão disponíveis sob demanda, condição justificada no manuscrito' + ] ]; private $researchData = 'Linspector, Clarice; Iamarino, Atila, 2025, "Replication data for: An adventure in an imaginary world", https://doi.org/10.70122/FK2/9ET, Demo Dataverse, V1'; private $galleys = []; diff --git a/tests/TitlePageTest.php b/tests/TitlePageTest.php index cab43e6..4644bb9 100644 --- a/tests/TitlePageTest.php +++ b/tests/TitlePageTest.php @@ -228,7 +228,7 @@ public function testInsertingInExistingPdfStampsDataStatement(): void $expectedText = __('plugins.generic.titlePageForPreprint.dataStatement', [], $this->locale); $this->assertTrue($this->searchForTextInPdf($pdf, $expectedText)); - $firstStatement = $this->dataStatement[0]; + $firstStatement = $this->dataStatement['selectedStatements'][0]; $this->assertTrue($this->searchForTextInPdf($pdf, $firstStatement)); } From 36d0b9e65d57a47d18a2fbb81481231c60c8a26c Mon Sep 17 00:00:00 2001 From: Jhon Date: Thu, 23 Jan 2025 15:03:22 -0400 Subject: [PATCH 11/17] Removes research data stamping from title page test Issue: documentacao-e-tarefas/scielo#738 Signed-off-by: Jhon --- tests/PdfHandlingTest.php | 10 +--------- tests/TitlePageTest.php | 25 ------------------------- 2 files changed, 1 insertion(+), 34 deletions(-) diff --git a/tests/PdfHandlingTest.php b/tests/PdfHandlingTest.php index daa7e7e..de81bdd 100644 --- a/tests/PdfHandlingTest.php +++ b/tests/PdfHandlingTest.php @@ -36,12 +36,6 @@ class PdfHandlingTest extends PKPTestCase protected $versionJustification = 'Nova versão criada para corrigir erros de ortografia'; protected $isTranslation = false; protected $citation = 'Silva, C. & Carlos, J. (2024). Thus spoke Zarathustra. Public Knowledge Preprint Server'; - protected $dataStatement = [ - 'selectedStatements' => [ - 'Os dados de pesquisa estão disponíveis sob demanda, condição justificada no manuscrito' - ] - ]; - protected $researchData = 'Linspector, Clarice; Iamarino, Atila, 2025, "Replication data for: An adventure in an imaginary world", https://doi.org/10.70122/FK2/9ET, Demo Dataverse, V1'; protected function setUp(): void { @@ -88,9 +82,7 @@ protected function getSubmissionForTests(): SubmissionModel 'version' => $this->version, 'versionJustification' => $this->versionJustification, 'isTranslation' => $this->isTranslation, - 'citation' => $this->citation, - 'dataStatement' => $this->dataStatement, - 'researchData' => $this->researchData + 'citation' => $this->citation ]); return $submission; diff --git a/tests/TitlePageTest.php b/tests/TitlePageTest.php index 4644bb9..e05c9b7 100644 --- a/tests/TitlePageTest.php +++ b/tests/TitlePageTest.php @@ -219,31 +219,6 @@ public function testInsertingInExistingPdfStampsCitation(): void $this->assertTrue($this->searchForTextInPdf($pdf, $expectedText)); } - public function testInsertingInExistingPdfStampsDataStatement(): void - { - $titlePage = $this->getTitlePageForTests(); - $pdf = new Pdf($this->pathOfTestPdf); - - $titlePage->insertTitlePageFirstTime($pdf); - $expectedText = __('plugins.generic.titlePageForPreprint.dataStatement', [], $this->locale); - $this->assertTrue($this->searchForTextInPdf($pdf, $expectedText)); - - $firstStatement = $this->dataStatement['selectedStatements'][0]; - $this->assertTrue($this->searchForTextInPdf($pdf, $firstStatement)); - } - - public function testInsertingInExistingPdfStampsResearchData(): void - { - $titlePage = $this->getTitlePageForTests(); - $pdf = new Pdf($this->pathOfTestPdf); - - $titlePage->insertTitlePageFirstTime($pdf); - $expectedText = __('plugins.generic.titlePageForPreprint.researchData', [], $this->locale); - $this->assertTrue($this->searchForTextInPdf($pdf, $expectedText)); - - $this->assertTrue($this->searchForTextInPdf($pdf, $this->researchData)); - } - public function testInsertingInExistingPdfStampsHeader(): void { $titlePage = $this->getTitlePageForTests(); From 97062f4df83c459ba83ea80f6e966d34167e2a6d Mon Sep 17 00:00:00 2001 From: Jhon Date: Thu, 23 Jan 2025 16:26:32 -0400 Subject: [PATCH 12/17] Passes research data citation to title page Issue: documentacao-e-tarefas/scielo#738 Signed-off-by: Jhon --- classes/SubmissionPressFactory.php | 55 +++++++++++++++++++----------- classes/TitlePage.php | 3 +- locale/en/locale.po | 4 ++- locale/es/locale.po | 4 ++- locale/pt_BR/locale.po | 4 ++- 5 files changed, 46 insertions(+), 24 deletions(-) diff --git a/classes/SubmissionPressFactory.php b/classes/SubmissionPressFactory.php index 19d6081..a2bc6b8 100644 --- a/classes/SubmissionPressFactory.php +++ b/classes/SubmissionPressFactory.php @@ -17,8 +17,9 @@ public function createSubmissionPress($submission, $publication, $context): Subm { $checklist = $this->getContextChecklist($context); $logoPath = $this->getLogoPath($context); - $dataPress = $this->getDataForPress($submission, $publication); + $dataForPress = $this->getDataForPress($submission, $publication); $galleys = $publication->getData('galleys'); + $submissionGalleys = []; foreach ($galleys as $galley) { $submissionFileRepo = Repo::submissionFile(); @@ -26,24 +27,9 @@ public function createSubmissionPress($submission, $publication, $context): Subm $submissionGalleys[] = $galleyAdapterFactory->createGalleyAdapter($submission, $galley); } + $dataForPress['galleys'] = $submissionGalleys; $submissionModel = new SubmissionModel(); - $submissionModel->setAllData([ - 'title' => $dataPress['title'], - 'status' => $dataPress['status'], - 'doi' => $dataPress['doi'], - 'doiJournal' => $dataPress['doiJournal'], - 'authors' => $dataPress['authors'], - 'submissionDate' => $dataPress['submissionDate'], - 'publicationDate' => $dataPress['publicationDate'], - 'endorserName' => $dataPress['endorserName'], - 'endorserOrcid' => $dataPress['endorserOrcid'], - 'version' => $dataPress['version'], - 'versionJustification' => $dataPress['versionJustification'], - 'isTranslation' => $dataPress['isTranslation'], - 'citation' => $dataPress['citation'], - 'dataStatement' => $dataPress['dataStatement'], - 'galleys' => $submissionGalleys - ]); + $submissionModel->setAllData($dataForPress); return new SubmissionPress($submissionModel, $checklist, $logoPath); } @@ -108,6 +94,13 @@ private function getDataForPress($submission, $publication) if ($publication->getData('dataStatementTypes')) { $data['dataStatement'] = $this->getDataStatement($publication); + + if ($data['dataStatement']['hasResearchData']) { + $researchDataCitation = $this->getResearchDataCitation($submission); + if ($researchDataCitation) { + $data['researchData'] = $researchDataCitation; + } + } } $data['endorserName'] = $publication->getData('endorserName'); @@ -139,9 +132,14 @@ private function getDataStatement($publication) $dataStatementService::DATA_STATEMENT_TYPE_ON_DEMAND => 'plugins.generic.dataverse.dataStatement.onDemand', $dataStatementService::DATA_STATEMENT_TYPE_PUBLICLY_UNAVAILABLE => 'plugins.generic.dataverse.dataStatement.publiclyUnavailable' ]; - $dataStatement = ['selectedStatements' => []]; + $dataStatement = ['selectedStatements' => [], 'hasResearchData' => false]; foreach ($publication->getData('dataStatementTypes') as $selectedStatement) { + if ($selectedStatement == $dataStatementService::DATA_STATEMENT_TYPE_DATAVERSE_SUBMITTED) { + $dataStatement['hasResearchData'] = true; + continue; + } + $dataStatement['selectedStatements'][$selectedStatement] = $dataStatementTypes[$selectedStatement]; if ($selectedStatement == $dataStatementService::DATA_STATEMENT_TYPE_REPO_AVAILABLE) { @@ -155,4 +153,23 @@ private function getDataStatement($publication) return $dataStatement; } + + private function getResearchDataCitation($submission) + { + $dataverseRepo = new \APP\plugins\generic\dataverse\classes\facades\Repo(); + $dataverseStudy = $dataverseRepo::dataverseStudy()->getBySubmissionId($submission->getId()); + + if ($dataverseStudy) { + $dataverseClient = new \APP\plugins\generic\dataverse\dataverseAPI\DataverseClient(); + + try { + $citation = $dataverseClient->getDatasetActions()->getCitation($dataverseStudy->getPersistentId(), null); + return $citation; + } catch (\Exception $e) { + error_log('Error getting research data citation for title page: ' . $e->getMessage()); + } + } + + return null; + } } diff --git a/classes/TitlePage.php b/classes/TitlePage.php index 285f040..78e91ca 100644 --- a/classes/TitlePage.php +++ b/classes/TitlePage.php @@ -142,8 +142,7 @@ private function generateTitlePage(): string if ($this->submission->getResearchData()) { $titlePage->Ln(5); - $titlePage->Write(0, __('plugins.generic.titlePageForPreprint.researchData', [], $this->locale), '', 0, 'JUSTIFY', true, 0, false, false, 0); - $titlePage->Write(0, $this->submission->getResearchData(), '', 0, 'JUSTIFY', true, 0, false, false, 0); + $titlePage->writeHTML(__('plugins.generic.titlePageForPreprint.researchData', ['researchDataCitation' => $this->submission->getResearchData()], $this->locale)); } $versionJustification = $this->submission->getVersionJustification(); diff --git a/locale/en/locale.po b/locale/en/locale.po index 0cb0396..e780d65 100644 --- a/locale/en/locale.po +++ b/locale/en/locale.po @@ -46,7 +46,9 @@ msgid "plugins.generic.titlePageForPreprint.dataStatement" msgstr "Data statement:" msgid "plugins.generic.titlePageForPreprint.researchData" -msgstr "Research data:" +msgstr "" +"Research data:
    " +"{$researchDataCitation}" msgid "plugins.generic.titlePageForPreprint.versionJustification" msgstr "Version justification" diff --git a/locale/es/locale.po b/locale/es/locale.po index 27c24ca..a5421c6 100644 --- a/locale/es/locale.po +++ b/locale/es/locale.po @@ -46,7 +46,9 @@ msgid "plugins.generic.titlePageForPreprint.dataStatement" msgstr "Declaración de datos:" msgid "plugins.generic.titlePageForPreprint.researchData" -msgstr "Datos de investigación:" +msgstr "" +"Datos de investigación:
    " +"{$researchDataCitation}" msgid "plugins.generic.titlePageForPreprint.versionJustification" msgstr "Justificación de la versión" diff --git a/locale/pt_BR/locale.po b/locale/pt_BR/locale.po index 0c50bef..465f0ec 100644 --- a/locale/pt_BR/locale.po +++ b/locale/pt_BR/locale.po @@ -46,7 +46,9 @@ msgid "plugins.generic.titlePageForPreprint.dataStatement" msgstr "Declaração de dados:" msgid "plugins.generic.titlePageForPreprint.researchData" -msgstr "Dados de pesquisa:" +msgstr "" +"Dados de pesquisa:
    " +"{$researchDataCitation}" msgid "plugins.generic.titlePageForPreprint.versionJustification" msgstr "Justificativa da versão" From b78d62e520aa2e5506b78232c72d89a77412c453 Mon Sep 17 00:00:00 2001 From: Jhon Date: Thu, 23 Jan 2025 17:53:55 -0400 Subject: [PATCH 13/17] Refactors passing of data statement to title page Issue: documentacao-e-tarefas/scielo#738 Signed-off-by: Jhon --- classes/TitlePage.php | 25 ++++++++++++++----------- tests/PdfHandlingTest.php | 11 ++++++++++- tests/SubmissionTest.php | 4 +--- tests/TitlePageTest.php | 19 +++++++++++++++++++ 4 files changed, 44 insertions(+), 15 deletions(-) diff --git a/classes/TitlePage.php b/classes/TitlePage.php index 78e91ca..1516ea3 100644 --- a/classes/TitlePage.php +++ b/classes/TitlePage.php @@ -67,21 +67,24 @@ private function writePublicationStatusOnTitlePage($titlePage) private function writeDataStatementOnTitlePage($titlePage) { - $dataStatementService = new \APP\plugins\generic\dataverse\classes\services\DataStatementService(); $dataStatement = $this->submission->getDataStatement(); $statementBody = '
      '; - foreach ($dataStatement['selectedStatements'] as $statementType => $statementMsg) { - $statementBody .= '
    • ' . __($statementMsg, [], $this->locale) . '
    • '; - - if ($statementType == $dataStatementService::DATA_STATEMENT_TYPE_REPO_AVAILABLE) { - $statementBody .= '
        '; - foreach ($dataStatement['dataStatementUrls'] as $url) { - $statementBody .= "
      • $url
      • "; + foreach ($dataStatement as $statement) { + if (is_array($statement)) { + $statementBody .= '
      • ' . __($statement['message'], [], $this->locale) . '
      • '; + + if (isset($statement['dataStatementUrls'])) { + $statementBody .= '
          '; + foreach ($statement['dataStatementUrls'] as $url) { + $statementBody .= "
        • $url
        • "; + } + $statementBody .= '
        '; + } elseif (isset($statement['dataStatementReason'])) { + $statementBody .= '
        • ' . $statement['dataStatementReason'] . '
        '; } - $statementBody .= '
      '; - } elseif ($statementType == $dataStatementService::DATA_STATEMENT_TYPE_PUBLICLY_UNAVAILABLE) { - $statementBody .= '
      • ' . $dataStatement['dataStatementReason'] . '
      '; + } else { + $statementBody .= '
    • ' . __($statement, [], $this->locale) . '
    • '; } } diff --git a/tests/PdfHandlingTest.php b/tests/PdfHandlingTest.php index de81bdd..3781365 100644 --- a/tests/PdfHandlingTest.php +++ b/tests/PdfHandlingTest.php @@ -36,6 +36,14 @@ class PdfHandlingTest extends PKPTestCase protected $versionJustification = 'Nova versão criada para corrigir erros de ortografia'; protected $isTranslation = false; protected $citation = 'Silva, C. & Carlos, J. (2024). Thus spoke Zarathustra. Public Knowledge Preprint Server'; + protected $dataStatement = [ + 'Os dados de pesquisa estão disponíveis sob demanda, condição justificada no manuscrito', + [ + 'message' => 'Os dados de pesquisa não podem ser disponibilizados publicamente', + 'dataStatementReason' => 'Research data has sensitive data' + ] + ]; + protected function setUp(): void { @@ -82,7 +90,8 @@ protected function getSubmissionForTests(): SubmissionModel 'version' => $this->version, 'versionJustification' => $this->versionJustification, 'isTranslation' => $this->isTranslation, - 'citation' => $this->citation + 'citation' => $this->citation, + 'dataStatement' => $this->dataStatement ]); return $submission; diff --git a/tests/SubmissionTest.php b/tests/SubmissionTest.php index b15891f..c6a5d45 100644 --- a/tests/SubmissionTest.php +++ b/tests/SubmissionTest.php @@ -20,9 +20,7 @@ class SubmissionTest extends PKPTestCase private $isTranslation = false; private $citation = 'Lispector, C. & Iamarino, A. (2024). An adventure in an imaginary world. Public Knowledge Preprint Server'; private $dataStatement = [ - 'selectedStatements' => [ - 'Os dados de pesquisa estão disponíveis sob demanda, condição justificada no manuscrito' - ] + 'Os dados de pesquisa estão disponíveis sob demanda, condição justificada no manuscrito' ]; private $researchData = 'Linspector, Clarice; Iamarino, Atila, 2025, "Replication data for: An adventure in an imaginary world", https://doi.org/10.70122/FK2/9ET, Demo Dataverse, V1'; private $galleys = []; diff --git a/tests/TitlePageTest.php b/tests/TitlePageTest.php index e05c9b7..7199f54 100644 --- a/tests/TitlePageTest.php +++ b/tests/TitlePageTest.php @@ -219,6 +219,25 @@ public function testInsertingInExistingPdfStampsCitation(): void $this->assertTrue($this->searchForTextInPdf($pdf, $expectedText)); } + public function testInsertingInExistingPdfStampsDataStatement(): void + { + $titlePage = $this->getTitlePageForTests(); + $pdf = new Pdf($this->pathOfTestPdf); + + $titlePage->insertTitlePageFirstTime($pdf); + $expectedText = __('plugins.generic.titlePageForPreprint.dataStatement', [], $this->locale); + $this->assertTrue($this->searchForTextInPdf($pdf, $expectedText)); + + $firstStatement = $this->dataStatement[0]; + $this->assertTrue($this->searchForTextInPdf($pdf, $firstStatement)); + + $secondStatementMsg = $this->dataStatement[1]['message']; + $this->assertTrue($this->searchForTextInPdf($pdf, $secondStatementMsg)); + + $secondStatementReason = $this->dataStatement[1]['dataStatementReason']; + $this->assertTrue($this->searchForTextInPdf($pdf, $secondStatementReason)); + } + public function testInsertingInExistingPdfStampsHeader(): void { $titlePage = $this->getTitlePageForTests(); From 6f54ce7715aa2da3c11fc7e1086854cfa0e886bf Mon Sep 17 00:00:00 2001 From: Jhon Date: Thu, 23 Jan 2025 18:02:11 -0400 Subject: [PATCH 14/17] Adds back research data stamping to title page in unit tests Issue: documentacao-e-tarefas/scielo#738 Signed-off-by: Jhon --- tests/PdfHandlingTest.php | 5 +++-- tests/TitlePageTest.php | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/PdfHandlingTest.php b/tests/PdfHandlingTest.php index 3781365..794b7ba 100644 --- a/tests/PdfHandlingTest.php +++ b/tests/PdfHandlingTest.php @@ -43,7 +43,7 @@ class PdfHandlingTest extends PKPTestCase 'dataStatementReason' => 'Research data has sensitive data' ] ]; - + protected $researchData = 'Linspector, Clarice; Iamarino, Atila, 2025, "Replication data for: An adventure in an imaginary world", https://doi.org/10.70122/FK2/9ET, Demo Dataverse, V1'; protected function setUp(): void { @@ -91,7 +91,8 @@ protected function getSubmissionForTests(): SubmissionModel 'versionJustification' => $this->versionJustification, 'isTranslation' => $this->isTranslation, 'citation' => $this->citation, - 'dataStatement' => $this->dataStatement + 'dataStatement' => $this->dataStatement, + 'researchData' => $this->researchData ]); return $submission; diff --git a/tests/TitlePageTest.php b/tests/TitlePageTest.php index 7199f54..18b0a5e 100644 --- a/tests/TitlePageTest.php +++ b/tests/TitlePageTest.php @@ -238,6 +238,17 @@ public function testInsertingInExistingPdfStampsDataStatement(): void $this->assertTrue($this->searchForTextInPdf($pdf, $secondStatementReason)); } + public function testInsertingInExistingPdfStampsResearchData(): void + { + $titlePage = $this->getTitlePageForTests(); + $pdf = new Pdf($this->pathOfTestPdf); + + $titlePage->insertTitlePageFirstTime($pdf); + + $expectedText = __('plugins.generic.titlePageForPreprint.researchData', ['researchDataCitation' => $this->researchData], $this->locale); + $this->assertTrue($this->searchForTextInPdf($pdf, $expectedText)); + } + public function testInsertingInExistingPdfStampsHeader(): void { $titlePage = $this->getTitlePageForTests(); From 41415ae2b8e297a719d0348c8d238104e1b3d9ae Mon Sep 17 00:00:00 2001 From: Jhon Date: Thu, 23 Jan 2025 18:22:48 -0400 Subject: [PATCH 15/17] Updates submission press factory class Issue: documentacao-e-tarefas/scielo#738 Signed-off-by: Jhon --- classes/SubmissionPressFactory.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/classes/SubmissionPressFactory.php b/classes/SubmissionPressFactory.php index a2bc6b8..3a7aae1 100644 --- a/classes/SubmissionPressFactory.php +++ b/classes/SubmissionPressFactory.php @@ -93,9 +93,10 @@ private function getDataForPress($submission, $publication) $data['citation'] = ($data['isTranslation'] ? $this->getSubmissionCitation($submission) : ''); if ($publication->getData('dataStatementTypes')) { - $data['dataStatement'] = $this->getDataStatement($publication); + [$dataStatement, $hasResearchData] = $this->getDataStatement($publication); + $data['dataStatement'] = $dataStatement; - if ($data['dataStatement']['hasResearchData']) { + if ($hasResearchData) { $researchDataCitation = $this->getResearchDataCitation($submission); if ($researchDataCitation) { $data['researchData'] = $researchDataCitation; @@ -132,26 +133,33 @@ private function getDataStatement($publication) $dataStatementService::DATA_STATEMENT_TYPE_ON_DEMAND => 'plugins.generic.dataverse.dataStatement.onDemand', $dataStatementService::DATA_STATEMENT_TYPE_PUBLICLY_UNAVAILABLE => 'plugins.generic.dataverse.dataStatement.publiclyUnavailable' ]; - $dataStatement = ['selectedStatements' => [], 'hasResearchData' => false]; + $hasResearchData = false; + $dataStatement = []; foreach ($publication->getData('dataStatementTypes') as $selectedStatement) { if ($selectedStatement == $dataStatementService::DATA_STATEMENT_TYPE_DATAVERSE_SUBMITTED) { - $dataStatement['hasResearchData'] = true; + $hasResearchData = true; continue; } - $dataStatement['selectedStatements'][$selectedStatement] = $dataStatementTypes[$selectedStatement]; + $dataStatement[$selectedStatement] = $dataStatementTypes[$selectedStatement]; if ($selectedStatement == $dataStatementService::DATA_STATEMENT_TYPE_REPO_AVAILABLE) { - $dataStatement['dataStatementUrls'] = $publication->getData('dataStatementUrls'); + $dataStatement[$selectedStatement] = [ + 'message' => $dataStatementTypes[$selectedStatement], + 'dataStatementUrls' => $publication->getData('dataStatementUrls') + ]; } if ($selectedStatement == $dataStatementService::DATA_STATEMENT_TYPE_PUBLICLY_UNAVAILABLE) { - $dataStatement['dataStatementReason'] = $publication->getLocalizedData('dataStatementReason'); + $dataStatement[$selectedStatement] = [ + 'message' => $dataStatementTypes[$selectedStatement], + 'dataStatementReason' => $publication->getLocalizedData('dataStatementReason') + ]; } } - return $dataStatement; + return [$dataStatement, $hasResearchData]; } private function getResearchDataCitation($submission) From a54c9c578e9c3cba7e94bffb7d242cea2baada4e Mon Sep 17 00:00:00 2001 From: Jhon Date: Fri, 24 Jan 2025 15:22:59 -0400 Subject: [PATCH 16/17] Removes research data citation from title page code Issue: documentacao-e-tarefas/scielo#738 Signed-off-by: Jhon --- classes/SubmissionModel.php | 5 ----- classes/SubmissionPressFactory.php | 33 ++---------------------------- classes/TitlePage.php | 5 ----- locale/en/locale.po | 5 ----- locale/es/locale.po | 5 ----- locale/pt_BR/locale.po | 5 ----- tests/PdfHandlingTest.php | 2 -- tests/SubmissionTest.php | 8 -------- tests/TitlePageTest.php | 11 ---------- 9 files changed, 2 insertions(+), 77 deletions(-) diff --git a/classes/SubmissionModel.php b/classes/SubmissionModel.php index 2e77316..c976750 100644 --- a/classes/SubmissionModel.php +++ b/classes/SubmissionModel.php @@ -94,9 +94,4 @@ public function getDataStatement(): ?array { return $this->getData('dataStatement'); } - - public function getResearchData(): ?string - { - return $this->getData('researchData'); - } } diff --git a/classes/SubmissionPressFactory.php b/classes/SubmissionPressFactory.php index 3a7aae1..d705d64 100644 --- a/classes/SubmissionPressFactory.php +++ b/classes/SubmissionPressFactory.php @@ -93,15 +93,7 @@ private function getDataForPress($submission, $publication) $data['citation'] = ($data['isTranslation'] ? $this->getSubmissionCitation($submission) : ''); if ($publication->getData('dataStatementTypes')) { - [$dataStatement, $hasResearchData] = $this->getDataStatement($publication); - $data['dataStatement'] = $dataStatement; - - if ($hasResearchData) { - $researchDataCitation = $this->getResearchDataCitation($submission); - if ($researchDataCitation) { - $data['researchData'] = $researchDataCitation; - } - } + $data['dataStatement'] = $this->getDataStatement($publication); } $data['endorserName'] = $publication->getData('endorserName'); @@ -133,12 +125,10 @@ private function getDataStatement($publication) $dataStatementService::DATA_STATEMENT_TYPE_ON_DEMAND => 'plugins.generic.dataverse.dataStatement.onDemand', $dataStatementService::DATA_STATEMENT_TYPE_PUBLICLY_UNAVAILABLE => 'plugins.generic.dataverse.dataStatement.publiclyUnavailable' ]; - $hasResearchData = false; $dataStatement = []; foreach ($publication->getData('dataStatementTypes') as $selectedStatement) { if ($selectedStatement == $dataStatementService::DATA_STATEMENT_TYPE_DATAVERSE_SUBMITTED) { - $hasResearchData = true; continue; } @@ -159,25 +149,6 @@ private function getDataStatement($publication) } } - return [$dataStatement, $hasResearchData]; - } - - private function getResearchDataCitation($submission) - { - $dataverseRepo = new \APP\plugins\generic\dataverse\classes\facades\Repo(); - $dataverseStudy = $dataverseRepo::dataverseStudy()->getBySubmissionId($submission->getId()); - - if ($dataverseStudy) { - $dataverseClient = new \APP\plugins\generic\dataverse\dataverseAPI\DataverseClient(); - - try { - $citation = $dataverseClient->getDatasetActions()->getCitation($dataverseStudy->getPersistentId(), null); - return $citation; - } catch (\Exception $e) { - error_log('Error getting research data citation for title page: ' . $e->getMessage()); - } - } - - return null; + return $dataStatement; } } diff --git a/classes/TitlePage.php b/classes/TitlePage.php index 1516ea3..5a12c2d 100644 --- a/classes/TitlePage.php +++ b/classes/TitlePage.php @@ -143,11 +143,6 @@ private function generateTitlePage(): string $this->writeDataStatementOnTitlePage($titlePage); } - if ($this->submission->getResearchData()) { - $titlePage->Ln(5); - $titlePage->writeHTML(__('plugins.generic.titlePageForPreprint.researchData', ['researchDataCitation' => $this->submission->getResearchData()], $this->locale)); - } - $versionJustification = $this->submission->getVersionJustification(); if ($this->submission->getVersion() > 1 && !is_null($versionJustification)) { $versionJustification = __('plugins.generic.titlePageForPreprint.versionJustification', [], $this->locale) . ": " . $versionJustification; diff --git a/locale/en/locale.po b/locale/en/locale.po index e780d65..9ccb4e0 100644 --- a/locale/en/locale.po +++ b/locale/en/locale.po @@ -45,11 +45,6 @@ msgstr "" msgid "plugins.generic.titlePageForPreprint.dataStatement" msgstr "Data statement:" -msgid "plugins.generic.titlePageForPreprint.researchData" -msgstr "" -"Research data:
      " -"{$researchDataCitation}" - msgid "plugins.generic.titlePageForPreprint.versionJustification" msgstr "Version justification" diff --git a/locale/es/locale.po b/locale/es/locale.po index a5421c6..8560788 100644 --- a/locale/es/locale.po +++ b/locale/es/locale.po @@ -45,11 +45,6 @@ msgstr "" msgid "plugins.generic.titlePageForPreprint.dataStatement" msgstr "Declaración de datos:" -msgid "plugins.generic.titlePageForPreprint.researchData" -msgstr "" -"Datos de investigación:
      " -"{$researchDataCitation}" - msgid "plugins.generic.titlePageForPreprint.versionJustification" msgstr "Justificación de la versión" diff --git a/locale/pt_BR/locale.po b/locale/pt_BR/locale.po index 465f0ec..77dab5e 100644 --- a/locale/pt_BR/locale.po +++ b/locale/pt_BR/locale.po @@ -45,11 +45,6 @@ msgstr "" msgid "plugins.generic.titlePageForPreprint.dataStatement" msgstr "Declaração de dados:" -msgid "plugins.generic.titlePageForPreprint.researchData" -msgstr "" -"Dados de pesquisa:
      " -"{$researchDataCitation}" - msgid "plugins.generic.titlePageForPreprint.versionJustification" msgstr "Justificativa da versão" diff --git a/tests/PdfHandlingTest.php b/tests/PdfHandlingTest.php index 794b7ba..703da01 100644 --- a/tests/PdfHandlingTest.php +++ b/tests/PdfHandlingTest.php @@ -43,7 +43,6 @@ class PdfHandlingTest extends PKPTestCase 'dataStatementReason' => 'Research data has sensitive data' ] ]; - protected $researchData = 'Linspector, Clarice; Iamarino, Atila, 2025, "Replication data for: An adventure in an imaginary world", https://doi.org/10.70122/FK2/9ET, Demo Dataverse, V1'; protected function setUp(): void { @@ -92,7 +91,6 @@ protected function getSubmissionForTests(): SubmissionModel 'isTranslation' => $this->isTranslation, 'citation' => $this->citation, 'dataStatement' => $this->dataStatement, - 'researchData' => $this->researchData ]); return $submission; diff --git a/tests/SubmissionTest.php b/tests/SubmissionTest.php index c6a5d45..e4cabc5 100644 --- a/tests/SubmissionTest.php +++ b/tests/SubmissionTest.php @@ -22,7 +22,6 @@ class SubmissionTest extends PKPTestCase private $dataStatement = [ 'Os dados de pesquisa estão disponíveis sob demanda, condição justificada no manuscrito' ]; - private $researchData = 'Linspector, Clarice; Iamarino, Atila, 2025, "Replication data for: An adventure in an imaginary world", https://doi.org/10.70122/FK2/9ET, Demo Dataverse, V1'; private $galleys = []; private function getSubmissionForTests() @@ -46,7 +45,6 @@ private function getSubmissionForTests() 'isTranslation' => $this->isTranslation, 'citation' => $this->citation, 'dataStatement' => $this->dataStatement, - 'researchData' => $this->researchData, 'galleys' => $this->galleys ]); @@ -162,10 +160,4 @@ public function testHasDataStatement(): void $submission = $this->getSubmissionForTests(); $this->assertEquals($this->dataStatement, $submission->getDataStatement()); } - - public function testHasResearchData(): void - { - $submission = $this->getSubmissionForTests(); - $this->assertEquals($this->researchData, $submission->getResearchData()); - } } diff --git a/tests/TitlePageTest.php b/tests/TitlePageTest.php index 18b0a5e..7199f54 100644 --- a/tests/TitlePageTest.php +++ b/tests/TitlePageTest.php @@ -238,17 +238,6 @@ public function testInsertingInExistingPdfStampsDataStatement(): void $this->assertTrue($this->searchForTextInPdf($pdf, $secondStatementReason)); } - public function testInsertingInExistingPdfStampsResearchData(): void - { - $titlePage = $this->getTitlePageForTests(); - $pdf = new Pdf($this->pathOfTestPdf); - - $titlePage->insertTitlePageFirstTime($pdf); - - $expectedText = __('plugins.generic.titlePageForPreprint.researchData', ['researchDataCitation' => $this->researchData], $this->locale); - $this->assertTrue($this->searchForTextInPdf($pdf, $expectedText)); - } - public function testInsertingInExistingPdfStampsHeader(): void { $titlePage = $this->getTitlePageForTests(); From 999591fc8a71592d0205110867faadc9bc2a9ef0 Mon Sep 17 00:00:00 2001 From: Jhon Date: Fri, 24 Jan 2025 15:26:35 -0400 Subject: [PATCH 17/17] Updates version.xml Issue: documentacao-e-tarefas/scielo#738 Signed-off-by: Jhon --- version.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.xml b/version.xml index 4c49640..ebff5ce 100644 --- a/version.xml +++ b/version.xml @@ -13,8 +13,8 @@ titlePageForPreprint plugins.generic - 2.1.0.0 - 2024-12-17 + 2.2.0.0 + 2025-01-24 1 TitlePageForPreprintPlugin