Skip to content

Commit 00caf52

Browse files
Merge branch 'saveOnActivityLog#328' into 'main'
Salva no histórico de atividades os acontecimentos da verificação dos DOIs See merge request softwares-pkp/plugins_ojs/doiscielo!15
2 parents ea2d5ed + 2a45a7c commit 00caf52

6 files changed

Lines changed: 217 additions & 9 deletions

File tree

controllers/ScieloScreeningHandler.inc.php

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

33
import('classes.handler.Handler');
4+
import('classes.log.SubmissionEventLogEntry');
5+
import('lib.pkp.classes.log.SubmissionLog');
46
import('plugins.generic.scieloScreening.classes.DOIScreening');
57
import('plugins.generic.scieloScreening.classes.DOIScreeningDAO');
68
import('plugins.generic.scieloScreening.classes.ScreeningChecker');
@@ -31,16 +33,29 @@ function addDOIs($args, $request){
3133
return http_response_code(200);
3234
}
3335

36+
private function logDOIValidationEvent($request, $submission, $doi, $response) {
37+
if(array_key_exists('messageError', $response)) {
38+
SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_METADATA_UPDATE, 'plugins.generic.scieloScreening.log.doiNotValidated', ['doi' => $doi, 'errorMessage' => $response['messageError']]);
39+
} else if($response['doiConfirmedAuthorship']){
40+
SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_METADATA_UPDATE, 'plugins.generic.scieloScreening.log.doiValidatedAuthorshipConfirmed', ['doi' => $doi]);
41+
} else {
42+
SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_METADATA_UPDATE, 'plugins.generic.scieloScreening.log.doiValidatedAuthorshipNotConfirmed', ['doi' => $doi]);
43+
}
44+
}
45+
3446
public function validateDOI($args, $request){
3547
$checker = new ScreeningChecker();
3648
$responseCrossref = array();
49+
$submission = Services::get('submission')->get((int)$args['submissionId']);
3750

3851
$crossrefClient = new DOISystemClient('Crossref.org', 'https://api.crossref.org/works?filter=doi:');
3952
$crossrefService = new CrossrefService($args['doiString'], $crossrefClient);
4053

4154
if (!$crossrefService->DOIExists()) {
4255
$statusMessage = $crossrefService->getStatusResponseMessage();
4356
$response = $this->getDOIStatusResponseMessage($statusMessage);
57+
58+
$this->logDOIValidationEvent($request, $submission, $args['doiString'], $response);
4459
return json_encode($response);
4560
} else {
4661
$responseCrossref = $crossrefService->getResponseContent();
@@ -51,32 +66,36 @@ public function validateDOI($args, $request){
5166
$doiOrgService = new DOISystemService($args['doiString'], $doiOrgClient);
5267
$statusMessage = $doiOrgService->getStatusResponseMessage();
5368
$response = $this->getDOIStatusResponseMessage($statusMessage);
69+
70+
$this->logDOIValidationEvent($request, $submission, $args['doiString'], $response);
5471
return json_encode($response);
5572
}
5673

57-
$submission = Services::get('submission')->get((int)$args['submissionId']);
58-
$doiConfirmedAuthorship = $this->checkDOIAuthorship($submission, $responseCrossref);
59-
6074
$itemCrossref = $responseCrossref['message']['items'][0];
6175
if(!$checker->checkDOIArticle($itemCrossref)) {
6276
$response = [
6377
'statusValidate' => 0,
6478
'messageError' => __("plugins.generic.scieloScreening.doiFromJournal")
6579
];
80+
$this->logDOIValidationEvent($request, $submission, $args['doiString'], $response);
6681
return json_encode($response);
6782
}
6883

6984
$yearArticle = 0;
70-
if(isset($itemCrossref['published-print']))
85+
if(isset($itemCrossref['published-print'])){
7186
$yearArticle = $itemCrossref['published-print']['date-parts'][0][0];
72-
else
87+
} else {
7388
$yearArticle = $itemCrossref['published-online']['date-parts'][0][0];
89+
}
7490

75-
return json_encode([
91+
$response = [
7692
'statusValidate' => 1,
7793
'yearArticle' => $yearArticle,
78-
'doiConfirmedAuthorship' => $doiConfirmedAuthorship
79-
]);
94+
'doiConfirmedAuthorship' => $this->checkDOIAuthorship($submission, $responseCrossref)
95+
];
96+
97+
$this->logDOIValidationEvent($request, $submission, $args['doiString'], $response);
98+
return json_encode($response);
8099
}
81100

82101
public function checkDOIAuthorship($submission, $responseCrossref){
@@ -103,14 +122,24 @@ private function getDOIStatusResponseMessage($statusMessage) {
103122
];
104123
}
105124

125+
private function logDOIScreeningEvent($request, $submission, $doisImploded = null) {
126+
if(is_null($doisImploded)) {
127+
SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_METADATA_UPDATE, 'plugins.generic.scieloScreening.log.doiScreeningCompletedSuccess');
128+
} else {
129+
SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_METADATA_UPDATE, 'plugins.generic.scieloScreening.log.doiScreeningNotCompleted', ['doisImploded' => $doisImploded]);
130+
}
131+
}
132+
106133
public function validateDOIsFromScreening($args, $request){
107134
$checker = new ScreeningChecker();
108-
135+
$submission = Services::get('submission')->get((int)$args['submissionId']);
136+
109137
if($checker->checkDOIRepeated($args['dois'])){
110138
$response = [
111139
'statusValidateDOIs' => 0,
112140
'messageError' => __("plugins.generic.scieloScreening.doiDifferentRequirement")
113141
];
142+
$this->logDOIScreeningEvent($request, $submission, implode(", ", $args['dois']));
114143
return json_encode($response);
115144
}
116145

@@ -120,6 +149,7 @@ public function validateDOIsFromScreening($args, $request){
120149
'statusValidateDOIs' => 0,
121150
'messageError' => __("plugins.generic.scieloScreening.attentionRules")
122151
];
152+
$this->logDOIScreeningEvent($request, $submission, implode(", ", $args['dois']));
123153
return json_encode($response);
124154
}
125155
else if($countOkay == 2){
@@ -128,10 +158,12 @@ public function validateDOIsFromScreening($args, $request){
128158
'statusValidateDOIs' => 0,
129159
'messageError' => __("plugins.generic.scieloScreening.attentionRules")
130160
];
161+
$this->logDOIScreeningEvent($request, $submission, implode(", ", $args['dois']));
131162
return json_encode($response);
132163
}
133164
}
134165

166+
$this->logDOIScreeningEvent($request, $submission);
135167
return json_encode(['statusValidateDOIs' => 1]);
136168
}
137169

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
function loginAuthorUser() {
2+
cy.get('input[id=username]').clear();
3+
cy.get('input[id=username]').type(Cypress.env('OJSAuthorUsername'), { delay: 0 });
4+
cy.get('input[id=password]').type(Cypress.env('OJSAuthorPassword'), { delay: 0 });
5+
cy.get('button[class=submit]').click();
6+
}
7+
8+
function loginAdminUser() {
9+
cy.get('input[id=username]').clear();
10+
cy.get('input[id=username]').type(Cypress.env('OJSAdminUsername'), { delay: 0 });
11+
cy.get('input[id=password]').type(Cypress.env('OJSAdminPassword'), { delay: 0 });
12+
cy.get('button[class=submit]').click();
13+
}
14+
15+
function submissionStep1() {
16+
cy.get('#sectionId').select('1');
17+
cy.get('#pkp_submissionChecklist > ul > li > label > input').check();
18+
cy.get('#privacyConsent').check();
19+
20+
cy.get('#submissionStep1 > .formButtons > .submitFormButton').click();
21+
}
22+
23+
function submissionStep2() {
24+
cy.get('.pkp_linkaction_addGalley').click();
25+
cy.wait(2000);
26+
cy.get('input[name="label"]').type('PDF', { delay: 0 });
27+
cy.get('#articleGalleyForm > .formButtons > .submitFormButton').click();
28+
cy.get('#genreId').select('1');
29+
cy.fixture('dummy.pdf', 'base64').then(fileContent => {
30+
cy.get('input[type="file"]').upload({ fileContent, 'fileName': 'dummy_document.pdf', 'mimeType': 'application/pdf', 'encoding': 'base64' });
31+
});
32+
cy.get('#continueButton').click();
33+
cy.get('#continueButton').click();
34+
cy.get('#continueButton').click();
35+
cy.get('#submitStep2Form > .formButtons > .submitFormButton').click();
36+
}
37+
38+
function addContributor() {
39+
cy.get('a[id^="component-grid-users-author-authorgrid-addAuthor-button-"]').click();
40+
cy.wait(250);
41+
cy.get('input[id^="givenName-en_US-"]').type("Altigran S.", { delay: 0 });
42+
cy.get('input[id^="familyName-en_US-"]').type("da Silva", { delay: 0 });
43+
cy.get('select[id^="country"]').select("Brasil");
44+
cy.get('input[id^="email"]').type("altigran.silva@lepidus.com.br", { delay: 0 });
45+
cy.get('input[id^="orcid-"]').type("https://orcid.org/0000-0001-2345-6789", { delay: 0 });
46+
cy.get('input[id^="affiliation-en_US-"]').type("UFAM", { delay: 0 });
47+
cy.get('label').contains("Author").click();
48+
cy.get('#editAuthor > .formButtons > .submitFormButton').click();
49+
}
50+
51+
function performDOIScrening() {
52+
cy.get('#openDOIModal').click();
53+
cy.get('#firstDOI').type("10.1010/notARealDoi", { delay: 0 });
54+
cy.get('#firstDOILabel').click();
55+
cy.wait(5000);
56+
cy.get('#doiSubmit').click();
57+
58+
cy.get('#firstDOI').clear();
59+
cy.get('#firstDOI').type("10.1016/j.datak.2003.10.003", { delay: 0 });
60+
cy.get('#firstDOILabel').click();
61+
cy.wait(5000);
62+
cy.get('#secondDOI').type("10.34117/bjdv8n2-322", { delay: 0 });
63+
cy.get('#secondDOILabel').click();
64+
cy.wait(5000);
65+
cy.get('#thirdDOI').type("10.4025/actascianimsci.v42i1.44580", { delay: 0 });
66+
cy.get('#thirdDOILabel').click();
67+
cy.wait(5000);
68+
cy.get('#doiSubmit').click();
69+
}
70+
71+
function submissionStep3() {
72+
cy.get('input[name^="title"]').first().type("Submissions title", { delay: 0 });
73+
cy.get('label').contains('Title').click();
74+
cy.get('textarea[id^="abstract-en_US"]').type("Example of abstract");
75+
cy.get('.section > label:visible').first().click();
76+
cy.get('#inputNumberAuthors').type("2", { delay: 0 });
77+
addContributor();
78+
cy.get('ul[id^="en_US-keywords-"]').then(node => {
79+
node.tagit('createTag', "Dummy keyword");
80+
});
81+
performDOIScrening();
82+
cy.get('#submitStep3Form > .formButtons > .submitFormButton').click();
83+
}
84+
85+
function submissionStep4() {
86+
cy.get('#submitStep4Form > .formButtons > .submitFormButton').click();
87+
cy.get('.pkp_modal_confirmation > .footer > .ok').click();
88+
}
89+
90+
function userLogout() {
91+
cy.get(".pkpDropdown.app__headerAction > .pkpButton").click();
92+
cy.get("a.pkpDropdown__action").contains("Logout").click();
93+
}
94+
95+
function checkDOIScreeningOutputsHaveBeenLogged() {
96+
cy.get('.pkpButton').contains('Activity Log').click();
97+
cy.get('.gridCellContainer > span').should('contain', 'The DOI 10.1010/notARealDoi could not be validated. The returned message was:');
98+
cy.get('.gridCellContainer > span').should('contain', 'The submitter tried to complete the DOI screening without success. The DOIs informed were:')
99+
100+
cy.get('.gridCellContainer > span').should('contain', 'The DOI 10.1016/j.datak.2003.10.003 was successfully validated and its authorship has been confirmed.');
101+
cy.get('.gridCellContainer > span').should('contain', 'The DOI 10.34117/bjdv8n2-322 was successfully validated, but its authorship has not been confirmed.');
102+
cy.get('.gridCellContainer > span').should('contain', 'The DOI 10.4025/actascianimsci.v42i1.44580 was successfully validated, but its authorship has not been confirmed.');
103+
cy.get('.gridCellContainer > span').should('contain', 'The DOI screening was completed successfully.');
104+
}
105+
106+
describe("SciELO Screening Plugin - DOI Screening outputs are logged in submission's activity log", function() {
107+
it("Author user submits", function() {
108+
cy.visit(Cypress.env('baseUrl') + 'index.php/scielo/submissions');
109+
loginAuthorUser();
110+
111+
cy.get('.pkpHeader__actions:visible > a.pkpButton').click();
112+
submissionStep1();
113+
submissionStep2();
114+
submissionStep3();
115+
submissionStep4();
116+
userLogout();
117+
});
118+
it("Check if plugin has logged outputs of DOI screening in submission's activity log", function() {
119+
loginAdminUser();
120+
cy.get("#active-button").click();
121+
cy.get(".listPanel__itemActions:visible > a.pkpButton").first().click();
122+
checkDOIScreeningOutputsHaveBeenLogged();
123+
});
124+
});

locale/en_US/locale.po

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,23 @@ msgstr "No author had confirmed their ORCID"
191191
msgid "plugins.generic.scieloScreening.info.pdfsOkay"
192192
msgstr "Only one PDF document was submitted"
193193

194+
195+
msgid "plugins.generic.scieloScreening.log.doiValidatedAuthorshipConfirmed"
196+
msgstr "The DOI {$doi} was successfully validated and its authorship has been confirmed."
197+
198+
msgid "plugins.generic.scieloScreening.log.doiValidatedAuthorshipNotConfirmed"
199+
msgstr "The DOI {$doi} was successfully validated, but its authorship has not been confirmed."
200+
201+
msgid "plugins.generic.scieloScreening.log.doiNotValidated"
202+
msgstr "The DOI {$doi} could not be validated. The returned message was: {$errorMessage}"
203+
204+
msgid "plugins.generic.scieloScreening.log.doiScreeningCompletedSuccess"
205+
msgstr "The DOI screening was completed successfully."
206+
207+
msgid "plugins.generic.scieloScreening.log.doiScreeningNotCompleted"
208+
msgstr "The submitter tried to complete the DOI screening without success. The DOIs informed were: {$doisImploded}"
209+
210+
194211
msgid "plugins.generic.scieloScreening.httpDOINotFoundErrorCode"
195212
msgstr "The DOI entered is not registered. Confirm that it is correct and, if problem persists, check the source publication."
196213

locale/es_ES/locale.po

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,23 @@ msgstr "Ningún autor ha confirmado su ORCID"
191191
msgid "plugins.generic.scieloScreening.info.pdfsOkay"
192192
msgstr "Solo se envió un documento PDF"
193193

194+
195+
msgid "plugins.generic.scieloScreening.log.doiValidatedAuthorshipConfirmed"
196+
msgstr "El DOI {$doi} fue validado con éxito y se confirmó su autoría."
197+
198+
msgid "plugins.generic.scieloScreening.log.doiValidatedAuthorshipNotConfirmed"
199+
msgstr "El DOI {$doi} fue validado con éxito, pero no se confirmó su autoría."
200+
201+
msgid "plugins.generic.scieloScreening.log.doiNotValidated"
202+
msgstr "El DOI {$doi} no pudo ser validado. El mensaje que devolvió fue: {$errorMessage}"
203+
204+
msgid "plugins.generic.scieloScreening.log.doiScreeningCompletedSuccess"
205+
msgstr "La verificación de los DOI se completó con éxito."
206+
207+
msgid "plugins.generic.scieloScreening.log.doiScreeningNotCompleted"
208+
msgstr "El autor remitente intentó finalizar la verificación DOI, pero sin éxito. Los DOI informados fueron: {$doisImploded}"
209+
210+
194211
msgid "plugins.generic.scieloScreening.httpDOINotFoundErrorCode"
195212
msgstr "El DOI ingresado no está registrado. Confirme que sea correcto y, en caso de duda, consulte con la publicación fuente."
196213

locale/pt_BR/locale.po

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,23 @@ msgstr "Nenhum autor confirmou o seu ORCID"
191191
msgid "plugins.generic.scieloScreening.info.pdfsOkay"
192192
msgstr "Apenas um documento PDF foi submetido"
193193

194+
195+
msgid "plugins.generic.scieloScreening.log.doiValidatedAuthorshipConfirmed"
196+
msgstr "O DOI {$doi} foi validado com sucesso e sua autoria foi confirmada."
197+
198+
msgid "plugins.generic.scieloScreening.log.doiValidatedAuthorshipNotConfirmed"
199+
msgstr "O DOI {$doi} foi validado com sucesso, mas sua autoria não foi confirmada."
200+
201+
msgid "plugins.generic.scieloScreening.log.doiNotValidated"
202+
msgstr "O DOI {$doi} não pôde ser validado. A mensagem retornada foi: {$errorMessage}"
203+
204+
msgid "plugins.generic.scieloScreening.log.doiScreeningCompletedSuccess"
205+
msgstr "A verificação de DOIs foi finalizada com sucesso."
206+
207+
msgid "plugins.generic.scieloScreening.log.doiScreeningNotCompleted"
208+
msgstr "O autor submissor tentou finalizar a verificação de DOIs, mas sem sucesso. Os DOIs informados foram: {$doisImploded}"
209+
210+
194211
msgid "plugins.generic.scieloScreening.httpDOINotFoundErrorCode"
195212
msgstr "O DOI inserido não está registrado. Confirme se o mesmo está correto e, em caso de dúvida, verifique com a publicação de origem."
196213

templates/editDOIForm.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
{ldelim}
3737
doisOkay: doisOkay,
3838
doisYears: doisYears,
39+
submissionId: {$submissionId},
3940
dois: [$('#firstDOI').val(), $('#secondDOI').val(), $('#thirdDOI').val()]
4041
{rdelim},
4142
function (result){ldelim}

0 commit comments

Comments
 (0)