From 5819257cad918844cab9d5081103e937b21b54b4 Mon Sep 17 00:00:00 2001 From: Jhon Date: Wed, 25 Sep 2024 17:50:58 -0400 Subject: [PATCH 01/18] Creates new handler for dataverse related requests Issue: documentacao-e-tarefas/scielo#700 Signed-off-by: Jhon --- api/v1/datasets/DatasetHandler.php | 6 +- api/v1/dataverse/DataverseHandler.php | 92 +++++++++++++++++++ .../dispatchers/DataverseEventsDispatcher.php | 3 + 3 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 api/v1/dataverse/DataverseHandler.php diff --git a/api/v1/datasets/DatasetHandler.php b/api/v1/datasets/DatasetHandler.php index b54c681d..1988cb3e 100644 --- a/api/v1/datasets/DatasetHandler.php +++ b/api/v1/datasets/DatasetHandler.php @@ -113,8 +113,10 @@ public function get($slimRequest, $response, $args) $dataverseClient = new DataverseClient(); $dataset = $dataverseClient->getDatasetActions()->get($study->getPersistentId()); } catch (DataverseException $e) { - $request = $this->getRequest(); - $submission = Repo::submission()->get($study->getSubmissionId()); + if ($e->getCode() === 404) { + DAORegistry::getDAO('DataverseStudyDAO')->deleteStudy($study); + } + $error = $e->getMessage(); $message = 'plugins.generic.dataverse.error.getFailed'; diff --git a/api/v1/dataverse/DataverseHandler.php b/api/v1/dataverse/DataverseHandler.php new file mode 100644 index 00000000..aedeb461 --- /dev/null +++ b/api/v1/dataverse/DataverseHandler.php @@ -0,0 +1,92 @@ +_handlerPath = 'dataverse'; + $roles = [Role::ROLE_ID_MANAGER, Role::ROLE_ID_SUB_EDITOR, Role::ROLE_ID_AUTHOR]; + $this->_endpoints = [ + 'GET' => [ + [ + 'pattern' => $this->getEndpointPattern() . '/dataverseName', + 'handler' => [$this, 'getDataverseName'], + 'roles' => $roles + ], + [ + 'pattern' => $this->getEndpointPattern() . '/rootDataverseName', + 'handler' => [$this, 'getRootDataverseName'], + 'roles' => $roles + ], + [ + 'pattern' => $this->getEndpointPattern() . '/licenses', + 'handler' => [$this, 'getDataverseLicenses'], + 'roles' => $roles + ], + ], + ]; + parent::__construct(); + } + + public function authorize($request, &$args, $roleAssignments) + { + $rolePolicy = new PolicySet(PolicySet::COMBINING_PERMIT_OVERRIDES); + + foreach ($roleAssignments as $role => $operations) { + $rolePolicy->addPolicy(new RoleBasedHandlerOperationPolicy($request, $role, $operations)); + } + $this->addPolicy($rolePolicy); + + return parent::authorize($request, $args, $roleAssignments); + } + + public function getDataverseName($slimRequest, $response, $args) + { + try { + $dataverseClient = new DataverseClient(); + $dataverseCollection = $dataverseClient->getDataverseCollectionActions()->get(); + $dataverseName = $dataverseCollection->getName(); + + return $response->withJson(['dataverseName' => $dataverseName], 200); + } catch (DataverseException $e) { + error_log('Dataverse API error while getting dataverse name: ' . $e->getMessage()); + return $response->withStatus($e->getCode()); + } + } + + public function getRootDataverseName($slimRequest, $response, $args) + { + try { + $dataverseClient = new DataverseClient(); + $rootDataverseCollection = $dataverseClient->getDataverseCollectionActions()->getRoot(); + $rootDataverseName = $rootDataverseCollection->getName(); + + return $response->withJson(['rootDataverseName' => $rootDataverseName], 200); + } catch (DataverseException $e) { + error_log('Dataverse API error while getting root name: ' . $e->getMessage()); + return $response->withStatus($e->getCode()); + } + } + + public function getDataverseLicenses($slimRequest, $response, $args) + { + try { + $dataverseClient = new DataverseClient(); + $dataverseLicenses = $dataverseClient->getDataverseCollectionActions()->getLicenses(); + + return $response->withJson(['licenses' => $dataverseLicenses], 200); + } catch (DataverseException $e) { + error_log('Dataverse API error while getting licenses: ' . $e->getMessage()); + return $response->withStatus($e->getCode()); + } + } +} diff --git a/classes/dispatchers/DataverseEventsDispatcher.php b/classes/dispatchers/DataverseEventsDispatcher.php index 2c527a5e..e7c63a96 100644 --- a/classes/dispatchers/DataverseEventsDispatcher.php +++ b/classes/dispatchers/DataverseEventsDispatcher.php @@ -10,6 +10,7 @@ use PKP\components\forms\FormComponent; use Illuminate\Support\Facades\Event; use APP\plugins\generic\dataverse\api\v1\datasets\DatasetHandler; +use APP\plugins\generic\dataverse\api\v1\dataverse\DataverseHandler; use APP\plugins\generic\dataverse\api\v1\draftDatasetFiles\DraftDatasetFileHandler; use APP\plugins\generic\dataverse\classes\APACitation; use APP\plugins\generic\dataverse\classes\components\forms\SelectDataFilesForReviewForm; @@ -292,6 +293,8 @@ public function setupDataverseAPIHandlers(string $hookname, array $params): void if (str_contains($request->getRequestPath(), 'api/v1/datasets')) { $handler = new DatasetHandler(); + } elseif (str_contains($request->getRequestPath(), 'api/v1/dataverse')) { + $handler = new DataverseHandler(); } elseif (str_contains($request->getRequestPath(), 'api/v1/draftDatasetFiles')) { $handler = new DraftDatasetFileHandler(); } From 9f8644952d43288331b3840511777194b814fbe4 Mon Sep 17 00:00:00 2001 From: Jhon Date: Thu, 26 Sep 2024 16:16:34 -0400 Subject: [PATCH 02/18] Creates caching for dataverse common requested data Issue: documentacao-e-tarefas/scielo#700 Signed-off-by: Jhon --- classes/entities/DataverseCollection.php | 8 +++ dataverseAPI/actions/DataverseActions.php | 15 +++- .../actions/DataverseCollectionActions.php | 68 +++++++++++++++++-- 3 files changed, 83 insertions(+), 8 deletions(-) diff --git a/classes/entities/DataverseCollection.php b/classes/entities/DataverseCollection.php index fa53748b..c434cc86 100644 --- a/classes/entities/DataverseCollection.php +++ b/classes/entities/DataverseCollection.php @@ -95,4 +95,12 @@ public function setCreationDate(string $creationDate): void { $this->setData('creationDate', $creationDate); } + + public static function __set_state($dump) + { + $collectionObj = new DataverseCollection(); + $collectionObj->setAllData($dump['_data']); + + return $collectionObj; + } } diff --git a/dataverseAPI/actions/DataverseActions.php b/dataverseAPI/actions/DataverseActions.php index 1e931fe0..d81c5e94 100644 --- a/dataverseAPI/actions/DataverseActions.php +++ b/dataverseAPI/actions/DataverseActions.php @@ -4,6 +4,7 @@ use APP\core\Application; use PKP\db\DAORegistry; +use PKP\cache\CacheManager; use GuzzleHttp\Exception\TransferException; use APP\plugins\generic\dataverse\classes\entities\DataverseResponse; use APP\plugins\generic\dataverse\classes\exception\DataverseException; @@ -11,18 +12,22 @@ abstract class DataverseActions { + protected $contextId; protected $serverURL; protected $apiToken; protected $dataverseAlias; protected $client; + protected $cacheManager; + + protected const ONE_DAY_SECONDS = 24 * 60 * 60; public function __construct( DataverseConfiguration $configuration = null, \GuzzleHttp\Client $client = null ) { if (is_null($configuration)) { - $contextId = Application::get()->getRequest()->getContext()->getId(); - $configuration = DAORegistry::getDAO('DataverseConfigurationDAO')->get($contextId); + $this->contextId = Application::get()->getRequest()->getContext()->getId(); + $configuration = DAORegistry::getDAO('DataverseConfigurationDAO')->get($this->contextId); } if (is_null($client)) { @@ -33,6 +38,7 @@ public function __construct( $this->apiToken = $configuration->getAPIToken(); $this->dataverseAlias = $configuration->getDataverseCollection(); $this->client = $client; + $this->cacheManager = CacheManager::getManager(); } public function createNativeAPIURI(string ...$pathParams): string @@ -112,4 +118,9 @@ public function swordAPIRequest(string $method, string $uri, array $options = [] $response->getBody() ); } + + public function cacheDismiss() + { + return null; + } } diff --git a/dataverseAPI/actions/DataverseCollectionActions.php b/dataverseAPI/actions/DataverseCollectionActions.php index 2162b93f..51cd0f01 100644 --- a/dataverseAPI/actions/DataverseCollectionActions.php +++ b/dataverseAPI/actions/DataverseCollectionActions.php @@ -11,18 +11,74 @@ class DataverseCollectionActions extends DataverseActions implements DataverseCo { public function get(): DataverseCollection { - $uri = $this->getCurrentDataverseURI(); - $response = $this->nativeAPIRequest('GET', $uri); + $cache = $this->cacheManager->getFileCache( + $this->contextId, + 'dataverse_collection', + [$this, 'cacheDismiss'] + ); - return $this->createDataverseCollection($response); + $dataverseCollection = $cache->getContents(); + $currentCacheTime = time() - $cache->getCacheTime(); + + if (is_null($dataverseCollection) || $currentCacheTime > self::ONE_DAY_SECONDS) { + $cache->flush(); + + $uri = $this->getCurrentDataverseURI(); + $response = $this->nativeAPIRequest('GET', $uri); + $dataverseCollection = $this->createDataverseCollection($response); + + $cache->setEntireCache($dataverseCollection); + } + + return $dataverseCollection; } public function getRoot(): DataverseCollection { - $uri = $this->getRootDataverseURI(); - $response = $this->nativeAPIRequest('GET', $uri); + $cache = $this->cacheManager->getFileCache( + $this->contextId, + 'root_dataverse_collection', + [$this, 'cacheDismiss'] + ); + + $rootDataverseCollection = $cache->getContents(); + $currentCacheTime = time() - $cache->getCacheTime(); + + if (is_null($rootDataverseCollection) || $currentCacheTime > self::ONE_DAY_SECONDS) { + $cache->flush(); + + $uri = $this->getRootDataverseURI(); + $response = $this->nativeAPIRequest('GET', $uri); + $rootDataverseCollection = $this->createDataverseCollection($response); + + $cache->setEntireCache($rootDataverseCollection); + } + + return $rootDataverseCollection; + } + + public function getLicenses(): array + { + $cache = $this->cacheManager->getFileCache( + $this->contextId, + 'dataverse_licenses', + [$this, 'cacheDismiss'] + ); + + $dataverseLicenses = $cache->getContents(); + $currentCacheTime = time() - $cache->getCacheTime(); + + if (is_null($dataverseLicenses) || $currentCacheTime > self::ONE_DAY_SECONDS) { + $cache->flush(); + + $uri = $this->createNativeAPIURI('licenses'); + $response = $this->nativeAPIRequest('GET', $uri); + $dataverseLicenses = json_decode($response->getBody(), true); + + $cache->setEntireCache($dataverseLicenses); + } - return $this->createDataverseCollection($response); + return $dataverseLicenses['data'] ?? []; } public function publish(): void From 83240bd5a2549bbb69ea6e3ae502677349d65e17 Mon Sep 17 00:00:00 2001 From: Jhon Date: Thu, 26 Sep 2024 16:21:06 -0400 Subject: [PATCH 03/18] Retrieving of dataverse licenses receives error handling Issue: documentacao-e-tarefas/scielo#700 Signed-off-by: Jhon --- classes/DataverseMetadata.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/classes/DataverseMetadata.php b/classes/DataverseMetadata.php index b0b4bb66..17bde0df 100644 --- a/classes/DataverseMetadata.php +++ b/classes/DataverseMetadata.php @@ -5,6 +5,7 @@ use APP\core\Application; use PKP\db\DAORegistry; use APP\plugins\generic\dataverse\classes\dataverseConfiguration\DataverseConfiguration; +use APP\plugins\generic\dataverse\dataverseAPI\DataverseClient; class DataverseMetadata { @@ -74,12 +75,15 @@ public function getDataverseSubjects(): array public function getDataverseLicenses(): ?array { - $configuration = $this->getDataverseConfiguration(); - $licensesUrl = $configuration->getDataverseServerUrl() . '/api/licenses'; - $response = json_decode(file_get_contents($licensesUrl), true); - $this->dataverseLicenses = $response['data'] ?? []; + try { + $dataverseClient = new DataverseClient(); + $this->dataverseLicenses = $dataverseClient->getDataverseCollectionActions()->getLicenses(); - return $this->dataverseLicenses; + return $this->dataverseLicenses; + } catch (DataverseException $e) { + error_log('Dataverse API error (licenses): ' . $e->getMessage()); + return []; + } } public function getDefaultLicense(): ?string From 96aadbb1bed9a80930c81a1883beaf64a8002c5f Mon Sep 17 00:00:00 2001 From: Jhon Date: Thu, 26 Sep 2024 17:39:22 -0400 Subject: [PATCH 04/18] Data statement tab in workflow gets dataverse name by itself Issue: documentacao-e-tarefas/scielo#700 Signed-off-by: Jhon --- .../components/forms/DataStatementForm.php | 27 +++++++--- classes/services/DataStatementService.php | 10 ++-- js/ui/components/DataStatementForm.js | 53 +++++++++++++++++++ templates/dataStatementTab.tpl | 2 +- 4 files changed, 81 insertions(+), 11 deletions(-) diff --git a/classes/components/forms/DataStatementForm.php b/classes/components/forms/DataStatementForm.php index a8492410..2f1162eb 100644 --- a/classes/components/forms/DataStatementForm.php +++ b/classes/components/forms/DataStatementForm.php @@ -26,10 +26,9 @@ public function __construct($action, $publication, $page) $this->action = $action; $this->locales = $this->getFormLocales($context); - $dataStatementService = new DataStatementService(); - $dataStatementOptions = $this->getDataStatementOptions($dataStatementService, $page); - $dataverseName = $dataStatementService->getDataverseName(); + $dataStatementOptions = $this->getDataStatementOptions($page); + $this->dataversePluginApiUrl = $request->getDispatcher()->url($request, Application::ROUTE_API, $context->getPath(), 'dataverse'); $vocabApiUrl = $request->getDispatcher()->url($request, Application::ROUTE_API, $context->getPath(), 'vocabs'); $this->addField(new FieldOptions('dataStatementTypes', [ @@ -61,7 +60,7 @@ public function __construct($action, $publication, $page) [ 'value' => true, 'label' => __('plugins.generic.dataverse.dataStatement.researchDataSubmitted', [ - 'dataverseName' => $dataverseName, + 'dataverseName' => '', ]), 'disabled' => true, ], @@ -71,6 +70,20 @@ public function __construct($action, $publication, $page) } } + public function getConfig() + { + $config = parent::getConfig(); + + $config = array_merge( + $config, + [ + 'dataversePluginApiUrl' => $this->dataversePluginApiUrl + ] + ); + + return $config; + } + private function getFormLocales($context): array { $supportedFormLocales = $context->getSupportedFormLocales(); @@ -83,9 +96,11 @@ private function getFormLocales($context): array return $formLocales; } - private function getDataStatementOptions($dataStatementService, $page): array + private function getDataStatementOptions($page): array { - $dataStatementTypes = $dataStatementService->getDataStatementTypes(); + $dataStatementService = new DataStatementService(); + $includeSubmittedType = ($page == 'submission'); + $dataStatementTypes = $dataStatementService->getDataStatementTypes($includeSubmittedType); if ($page == 'workflow') { unset($dataStatementTypes[DataStatementService::DATA_STATEMENT_TYPE_DATAVERSE_SUBMITTED]); diff --git a/classes/services/DataStatementService.php b/classes/services/DataStatementService.php index 95136e2b..f5eb5613 100644 --- a/classes/services/DataStatementService.php +++ b/classes/services/DataStatementService.php @@ -15,9 +15,8 @@ class DataStatementService private $dataverseName; - public function getDataStatementTypes(): array + public function getDataStatementTypes($includeSubmittedType = true): array { - $dataverseName = $this->getDataverseName(); $types = [ self::DATA_STATEMENT_TYPE_IN_MANUSCRIPT => __('plugins.generic.dataverse.dataStatement.inManuscript'), self::DATA_STATEMENT_TYPE_REPO_AVAILABLE => __('plugins.generic.dataverse.dataStatement.repoAvailable'), @@ -25,8 +24,11 @@ public function getDataStatementTypes(): array self::DATA_STATEMENT_TYPE_PUBLICLY_UNAVAILABLE => __('plugins.generic.dataverse.dataStatement.publiclyUnavailable') ]; - if (!is_null($dataverseName)) { - $types[self::DATA_STATEMENT_TYPE_DATAVERSE_SUBMITTED] = __('plugins.generic.dataverse.dataStatement.submissionDeposit', ['dataverseName' => $dataverseName]); + if ($includeSubmittedType) { + $this->getDataverseName(); + if (!is_null($this->dataverseName)) { + $types[self::DATA_STATEMENT_TYPE_DATAVERSE_SUBMITTED] = __('plugins.generic.dataverse.dataStatement.submissionDeposit', ['dataverseName' => $this->dataverseName]); + } } return $types; diff --git a/js/ui/components/DataStatementForm.js b/js/ui/components/DataStatementForm.js index b958e2ce..70ca4b1d 100644 --- a/js/ui/components/DataStatementForm.js +++ b/js/ui/components/DataStatementForm.js @@ -1,3 +1,56 @@ +pkp.Vue.component('data-statement-form', { + name: 'DataStatementForm', + extends: pkp.controllers.Container.components.PkpForm, + data() { + return { + flagMounted: false + }; + }, + props: { + dataversePluginApiUrl: { + type: String + } + }, + methods: { + updateDataSubmittedField() { + let self = this; + $.ajax({ + url: self.dataversePluginApiUrl + '/dataverseName', + type: 'GET', + error: function (r) { + return; + }, + success: function (r) { + let dataverseName = r.dataverseName; + let researchDataSubmittedField = null; + + for (let field of self.fields) { + if (field.name == 'researchDataSubmitted') { + researchDataSubmittedField = field; + break; + } + } + + let newFieldLabel = researchDataSubmittedField.options[0].label; + newFieldLabel = newFieldLabel.replace(/<\/strong>/, `${dataverseName}`); + + researchDataSubmittedField.options[0].label = newFieldLabel; + }, + }); + } + }, + mounted() { + setTimeout(() => { + this.flagMounted = true; + }, 2500); + }, + watch: { + flagMounted(newVal, oldVal) { + this.updateDataSubmittedField(); + } + } +}); + function addEventListeners() { let checkRepoAvailable = document.querySelectorAll('input[name="dataStatementTypes"][value="' + pkp.const.DATA_STATEMENT_TYPE_REPO_AVAILABLE + '"]')[0]; let checkPublicUnavailable = document.querySelectorAll('input[name="dataStatementTypes"][value="' + pkp.const.DATA_STATEMENT_TYPE_PUBLICLY_UNAVAILABLE + '"]')[0]; diff --git a/templates/dataStatementTab.tpl b/templates/dataStatementTab.tpl index 9a385eed..616da221 100644 --- a/templates/dataStatementTab.tpl +++ b/templates/dataStatementTab.tpl @@ -1,3 +1,3 @@ - + \ No newline at end of file From bd052312c841a1bcef9e044c6b94881bc2f9f3b9 Mon Sep 17 00:00:00 2001 From: Jhon Date: Thu, 26 Sep 2024 18:33:34 -0400 Subject: [PATCH 05/18] Dataset tab page loads its data by itself However, still not getting dataset files Issue: documentacao-e-tarefas/scielo#700 Signed-off-by: Jhon --- .../components/forms/DatasetMetadataForm.php | 42 +++-- classes/dispatchers/DatasetTabDispatcher.php | 144 ++++++++---------- js/DataverseWorkflowPage.js | 105 +++++++++++-- templates/datasetTab/datasetData.tpl | 6 +- 4 files changed, 190 insertions(+), 107 deletions(-) diff --git a/classes/components/forms/DatasetMetadataForm.php b/classes/components/forms/DatasetMetadataForm.php index 88d2964d..5fd8f8af 100644 --- a/classes/components/forms/DatasetMetadataForm.php +++ b/classes/components/forms/DatasetMetadataForm.php @@ -21,16 +21,14 @@ public function __construct($action, $method, $dataset, $page) $this->locales = $this->mapCurrentLocale(); $dataverseMetadata = new DataverseMetadata(); - $dataverseLicenses = $dataverseMetadata->getDataverseLicenses(); + $dataverseLicenses = ($page == 'submission' ? $dataverseMetadata->getDataverseLicenses() : []); + $datasetMetadata = $this->getDatasetMetadata($dataset); if ($page == 'workflow') { - $mappedKeywords = (array) $dataset->getKeywords() ?? []; - $mappedKeywords = [Locale::getLocale() => $mappedKeywords]; - $this->addField(new FieldText('datasetTitle', [ 'label' => __('plugins.generic.dataverse.metadataForm.title'), 'isRequired' => true, - 'value' => $dataset->getTitle(), + 'value' => $datasetMetadata['title'], 'size' => 'large', ])) ->addField(new FieldRichTextarea('datasetDescription', [ @@ -38,7 +36,7 @@ public function __construct($action, $method, $dataset, $page) 'isRequired' => true, 'toolbar' => 'bold italic superscript subscript | link | blockquote bullist numlist | image | code', 'plugins' => 'paste,link,lists,image,code', - 'value' => $dataset->getDescription() + 'value' => $datasetMetadata['description'] ])) ->addField(new FieldControlledVocab('datasetKeywords', [ 'label' => __('plugins.generic.dataverse.metadataForm.keyword'), @@ -46,28 +44,50 @@ public function __construct($action, $method, $dataset, $page) 'apiUrl' => $this->getVocabSuggestionUrlBase(), 'isMultilingual' => true, 'locales' => $this->locales, - 'value' => $mappedKeywords + 'value' => $datasetMetadata['keywords'] ])); } - $selectedLicense = $dataset->getLicense() ?? $dataverseMetadata->getDefaultLicense(); - $this->addField(new FieldSelect('datasetSubject', [ 'label' => __('plugins.generic.dataverse.metadataForm.subject.label'), 'description' => ($page == 'submission' ? __('plugins.generic.dataverse.metadataForm.subject.description') : ''), 'isRequired' => true, 'options' => $dataverseMetadata->getDataverseSubjects(), - 'value' => $dataset->getSubject(), + 'value' => $datasetMetadata['subject'], ])) ->addField(new FieldSelect('datasetLicense', [ 'label' => __('plugins.generic.dataverse.metadataForm.license.label'), 'description' => ($page == 'submission' ? __('plugins.generic.dataverse.metadataForm.license.description') : ''), 'isRequired' => true, 'options' => $this->mapLicensesForDisplay($dataverseLicenses), - 'value' => $selectedLicense, + 'value' => $datasetMetadata['license'], ])); } + private function getDatasetMetadata($dataset) + { + if (is_null($dataset)) { + return [ + 'title' => '', + 'description' => '', + 'keywords' => [], + 'subject' => '', + 'license' => '' + ]; + } + + $mappedKeywords = (array) $dataset->getKeywords() ?? []; + $mappedKeywords = [Locale::getLocale() => $mappedKeywords]; + + return [ + 'title' => $dataset->getTitle(), + 'description' => $dataset->getDescription(), + 'keywords' => $mappedKeywords, + 'subject' => $dataset->getSubject(), + 'license' => $dataset->getLicense() + ]; + } + private function getVocabSuggestionUrlBase() { $request = Application::get()->getRequest(); diff --git a/classes/dispatchers/DatasetTabDispatcher.php b/classes/dispatchers/DatasetTabDispatcher.php index 9640df52..e7f52901 100644 --- a/classes/dispatchers/DatasetTabDispatcher.php +++ b/classes/dispatchers/DatasetTabDispatcher.php @@ -59,21 +59,7 @@ private function getDatasetTabContent(Submission $submission): string return $this->plugin->getTemplateResource('datasetTab/noResearchData.tpl'); } - $dataverseClient = new DataverseClient(); - try { - $dataset = $dataverseClient->getDatasetActions()->get($study->getPersistentId()); - return $this->plugin->getTemplateResource('datasetTab/datasetData.tpl'); - } catch (DataverseException $e) { - if ($e->getCode() === 404) { - Repo::dataverseStudy()->delete($study); - } - - error_log('Dataverse API error: ' . $e->getMessage()); - - $templateMgr = TemplateManager::getManager(Application::get()->getRequest()); - $templateMgr->assign('errorMessage', $e->getMessage()); - return $this->plugin->getTemplateResource('datasetTab/researchDataError.tpl'); - } + return $this->plugin->getTemplateResource('datasetTab/datasetData.tpl'); } public function loadResourcesToWorkflow(string $hookName, array $params): bool @@ -127,6 +113,7 @@ private function setupResearchDataDeposit(Submission $submission): void $context = $request->getContext(); $user = $request->getUser(); + $dataversePluginApiUrl = $request->getDispatcher()->url($request, Application::ROUTE_API, $context->getPath(), 'dataverse'); $metadataFormAction = $request->getDispatcher()->url($request, Application::ROUTE_API, $context->getPath(), 'datasets', null, null, ['submissionId' => $submission->getId()]); $fileListApiUrl = $request ->getDispatcher() @@ -148,6 +135,11 @@ private function setupResearchDataDeposit(Submission $submission): void $this->initDatasetMetadataForm($templateMgr, $metadataFormAction, 'POST', $dataset); $this->initDatasetFilesList($templateMgr, $submission, $fileListApiUrl, $fileActionApiUrl, $datasetFiles); + + $templateMgr->setState([ + 'dataversePluginApiUrl' => $dataversePluginApiUrl, + 'hasDepositedDataset' => false + ]); } private function setupResearchDataUpdate(Submission $submission, DataverseStudy $study): void @@ -160,72 +152,63 @@ private function setupResearchDataUpdate(Submission $submission, DataverseStudy $userRoles = (array) $router->getHandler()->getAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES); $configuration = DAORegistry::getDAO('DataverseConfigurationDAO')->get($context->getId()); - try { - $dataverseClient = new DataverseClient(); - $dataset = $dataverseClient->getDatasetActions()->get($study->getPersistentId()); - $rootDataverseCollection = $dataverseClient->getDataverseCollectionActions()->getRoot(); - $dataverseCollection = $dataverseClient->getDataverseCollectionActions()->get(); - - $datasetApiUrl = $dispatcher->url( - $request, - Application::ROUTE_API, - $context->getPath(), - 'datasets/' . $study->getId() - ); - $fileListApiUrl = $dispatcher->url( - $request, - Application::ROUTE_API, - $context->getPath(), - 'datasets/' . $study->getId() . '/files' - ); - $fileActionApiUrl = $dispatcher->url( - $request, - Application::ROUTE_API, - $context->getPath(), - 'datasets/' . $study->getId() . '/file' - ); - $datasetStatementUrl = $dispatcher->url( - $request, - Application::ROUTE_PAGE, - null, - 'authorDashboard', - 'submission', - $submission->getId(), - null, - '#publication/dataStatement' - ); - - $datasetFiles = array_map(function ($datasetFile) use ($fileActionApiUrl) { - $fileVars = $datasetFile->getVars(); - $fileVars['downloadUrl'] = $fileActionApiUrl . '?fileId=' . $datasetFile->getId() . '&fileName=' . $datasetFile->getFileName(); - return $fileVars; - }, $dataset->getFiles()); - - $this->initDatasetMetadataForm($templateMgr, $datasetApiUrl, 'PUT', $dataset); - $this->initDatasetFilesList($templateMgr, $submission, $fileListApiUrl, $fileActionApiUrl, $datasetFiles); - - $defaultEmailBody = $this->getDeleteDatasetEmailBody($submission, $dataverseCollection, $datasetStatementUrl); - $deleteDatasetForm = $this->getDeleteDatasetForm($context, $datasetApiUrl, $defaultEmailBody); - $this->addComponent($templateMgr, $deleteDatasetForm); - - $templateMgr->setState([ - 'dataset' => $dataset->getAllData(), - 'deleteDatasetLabel' => __('plugins.generic.dataverse.researchData.delete'), - 'confirmDeleteDatasetMessage' => __('plugins.generic.dataverse.modal.confirmDatasetDelete'), - 'publishDatasetLabel' => __('plugins.generic.dataverse.researchData.publish'), - 'confirmPublishDatasetMessage' => __('plugins.generic.dataverse.modal.confirmDatasetPublish', [ - 'serverName' => $rootDataverseCollection->getName(), - 'serverUrl' => $configuration->getDataverseServerUrl(), - ]), - 'datasetCitationUrl' => $dispatcher->url($request, Application::ROUTE_API, $context->getPath(), 'datasets/' . $study->getId() . '/citation'), - 'canSendEmail' => in_array(Role::ROLE_ID_MANAGER, $userRoles) - ]); - } catch (DataverseException $e) { - error_log('Dataverse API error: ' . $e->getMessage()); - } + $dataversePluginApiUrl = $dispatcher->url( + $request, + Application::ROUTE_API, + $context->getPath(), + 'dataverse' + ); + $datasetApiUrl = $dispatcher->url( + $request, + Application::ROUTE_API, + $context->getPath(), + 'datasets/' . $study->getId() + ); + $fileListApiUrl = $dispatcher->url( + $request, + Application::ROUTE_API, + $context->getPath(), + 'datasets/' . $study->getId() . '/files' + ); + $fileActionApiUrl = $dispatcher->url( + $request, + Application::ROUTE_API, + $context->getPath(), + 'datasets/' . $study->getId() . '/file' + ); + $datasetStatementUrl = $dispatcher->url( + $request, + Application::ROUTE_PAGE, + null, + 'authorDashboard', + 'submission', + $submission->getId(), + null, + '#publication/dataStatement' + ); + + $this->initDatasetMetadataForm($templateMgr, $datasetApiUrl, 'PUT'); + $this->initDatasetFilesList($templateMgr, $submission, $fileListApiUrl, $fileActionApiUrl, []); + + $defaultEmailBody = $this->getDeleteDatasetEmailBody($submission, $datasetStatementUrl); + $deleteDatasetForm = $this->getDeleteDatasetForm($context, $datasetApiUrl, $defaultEmailBody); + $this->addComponent($templateMgr, $deleteDatasetForm); + + $templateMgr->setState([ + 'dataversePluginApiUrl' => $dataversePluginApiUrl, + 'deleteDatasetLabel' => __('plugins.generic.dataverse.researchData.delete'), + 'confirmDeleteDatasetMessage' => __('plugins.generic.dataverse.modal.confirmDatasetDelete'), + 'publishDatasetLabel' => __('plugins.generic.dataverse.researchData.publish'), + 'confirmPublishDatasetMessage' => __('plugins.generic.dataverse.modal.confirmDatasetPublish', [ + 'serverUrl' => $configuration->getDataverseServerUrl(), + ]), + 'datasetCitationUrl' => $dispatcher->url($request, Application::ROUTE_API, $context->getPath(), 'datasets/' . $study->getId() . '/citation'), + 'canSendEmail' => in_array(Role::ROLE_ID_MANAGER, $userRoles), + 'hasDepositedDataset' => true + ]); } - private function initDatasetMetadataForm(TemplateManager $templateMgr, string $action, string $method, Dataset $dataset): void + private function initDatasetMetadataForm(TemplateManager $templateMgr, string $action, string $method, ?Dataset $dataset = null): void { $datasetMetadataForm = new DatasetMetadataForm($action, $method, $dataset, 'workflow'); $this->addComponent($templateMgr, $datasetMetadataForm); @@ -259,13 +242,12 @@ private function initDatasetFilesList($templateMgr, $submission, $fileListApiUrl $this->addComponent($templateMgr, $datasetFilesListPanel); } - private function getDeleteDatasetEmailBody($submission, $dataverseCollection, $datasetStatementUrl): string + private function getDeleteDatasetEmailBody($submission, $datasetStatementUrl): string { return __( 'emails.datasetDeleteNotification.body', [ 'submissionTitle' => htmlspecialchars($submission->getLocalizedFullTitle()), - 'dataverseName' => $dataverseCollection->getName(), 'dataStatementUrl' => $datasetStatementUrl, ] ); diff --git a/js/DataverseWorkflowPage.js b/js/DataverseWorkflowPage.js index 568d060e..8e345495 100644 --- a/js/DataverseWorkflowPage.js +++ b/js/DataverseWorkflowPage.js @@ -2,12 +2,19 @@ var DataverseWorkflowPage = $.extend(true, {}, pkp.controllers.WorkflowPage, { name: 'DataverseWorkflowPage', data() { return { + dataversePluginApiUrl: null, + rootDataverseName: '', + dataverseName: '', + dataverseLicenses: [], dataset: null, datasetCitation: '', datasetCitationUrl: null, fileFormErrors: [], + hasDepositedDataset: false, + datasetIsLoading: true, isLoading: false, latestGetRequest: '', + flagMounted: false }; }, computed: { @@ -112,22 +119,84 @@ var DataverseWorkflowPage = $.extend(true, {}, pkp.controllers.WorkflowPage, { }); }, + getRootDataverseName() { + let self = this; + $.ajax({ + url: self.dataversePluginApiUrl + '/rootDataverseName', + type: 'GET', + success: function (r) { + self.rootDataverseName = r.rootDataverseName; + self.confirmPublishDatasetMessage = self.confirmPublishDatasetMessage.replace('{$serverName}', self.rootDataverseName); + }, + }); + }, + + getDataverseName() { + let self = this; + $.ajax({ + url: self.dataversePluginApiUrl + '/dataverseName', + type: 'GET', + success: function (r) { + self.dataverseName = r.dataverseName; + + if (self.hasDepositedDataset) { + let deleteDatasetForm = self.components.deleteDataset; + let deleteMessageField = deleteDatasetForm.fields[0]; + deleteMessageField.value = deleteMessageField.value.replace('{$dataverseName}', self.dataverseName); + } + }, + }); + }, + + getDataverseLicenses() { + let self = this; + $.ajax({ + url: self.dataversePluginApiUrl + '/licenses', + type: 'GET', + success: function (r) { + let datasetMetadataForm = self.components.datasetMetadata; + + for (let license of r.licenses) { + self.dataverseLicenses.push({'label': license.name, 'value': license.name}); + } + + datasetMetadataForm.fields[4].options = self.dataverseLicenses; + }, + }); + }, + refreshDataset() { const self = this; + this.datasetIsLoading = true; $.ajax({ url: this.components.datasetMetadata.action, type: 'GET', success(r) { self.dataset = r; - }, - error(r) { - self.ajaxErrorCallback(r); + self.datasetIsLoading = false; } }); }, - setDatasetForms(dataset) { + updateDatasetMetadataForm(dataset) { let form = { ...this.components.datasetMetadata }; + + for (let field of form.fields) { + let datasetFieldName = field.name.replace(/^dataset/, '').toLowerCase(); + + if (this.dataset.hasOwnProperty(datasetFieldName)) { + field.value = this.dataset[datasetFieldName]; + + if (datasetFieldName == 'keywords') { + let selectedKeywords = []; + for (let keyword of this.dataset[datasetFieldName]) { + selectedKeywords.push({'label': keyword, 'value': keyword}); + } + field.selected = selectedKeywords; + } + } + } + form.canSubmit = this.canEditPublication && dataset.versionState !== 'RELEASED'; @@ -146,12 +215,12 @@ var DataverseWorkflowPage = $.extend(true, {}, pkp.controllers.WorkflowPage, { this.components.datasetFiles = filesPanel; }, - setDatasetCitation() { + updateDatasetCitation() { if (!this.datasetCitationUrl) { return; } var self = this; - this.datasetCitation = 'loading...'; + this.datasetCitation = this.__('common.loading') + '...'; $.ajax({ url: self.datasetCitationUrl, type: 'GET', @@ -181,18 +250,26 @@ var DataverseWorkflowPage = $.extend(true, {}, pkp.controllers.WorkflowPage, { }, 2500); } }); - - this.setDatasetCitation(); - if (this.dataset) { - this.setDatasetForms(this.dataset); - this.setDatasetFilesPanel(this.dataset); - } + }, + mounted() { + setTimeout(() => { + this.flagMounted = true; + }, 2500); }, watch: { dataset(newVal, oldVal) { - this.setDatasetForms(newVal); + this.updateDatasetMetadataForm(newVal); this.setDatasetFilesPanel(newVal); - this.setDatasetCitation(); + this.updateDatasetCitation(); + }, + flagMounted(newVal, oldVal) { + this.getDataverseName(); + this.getDataverseLicenses(); + + if (this.hasDepositedDataset) { + this.getRootDataverseName(); + this.refreshDataset(); + } } }, }); diff --git a/templates/datasetTab/datasetData.tpl b/templates/datasetTab/datasetData.tpl index fbb8772e..f12b46a3 100644 --- a/templates/datasetTab/datasetData.tpl +++ b/templates/datasetTab/datasetData.tpl @@ -1,4 +1,8 @@ -
+ + + {{ __('common.loading')}} ... + +

{translate key="plugins.generic.dataverse.researchData"} From 3e6d48393d5ade0bfe19592ec6716da578d55a6f Mon Sep 17 00:00:00 2001 From: Jhon Date: Thu, 26 Sep 2024 18:39:35 -0400 Subject: [PATCH 06/18] List panel gets dataset files by itself Issue: documentacao-e-tarefas/scielo#700 Signed-off-by: Jhon --- js/ui/components/DatasetFilesListPanel.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/js/ui/components/DatasetFilesListPanel.js b/js/ui/components/DatasetFilesListPanel.js index ee14121d..852a71d2 100644 --- a/js/ui/components/DatasetFilesListPanel.js +++ b/js/ui/components/DatasetFilesListPanel.js @@ -79,7 +79,8 @@ pkp.Vue.component('dataset-files-list-panel', { mixins: [ajaxError, dialog], data() { return { - isLoading: false, + flagMounted: false, + isLoading: false } }, props: { @@ -207,5 +208,15 @@ pkp.Vue.component('dataset-files-list-panel', { }, render: function (h) { return datasetFilesListTemplate.render.call(this, h); + }, + mounted() { + setTimeout(() => { + this.flagMounted = true; + }, 2500); + }, + watch: { + flagMounted(newVal, oldVal) { + this.refreshItems(); + } } }); \ No newline at end of file From 1bbd44b36637a57151e45a2ecd2b7503d6bc9a8c Mon Sep 17 00:00:00 2001 From: Jhon Date: Fri, 27 Sep 2024 15:27:40 -0400 Subject: [PATCH 07/18] Removes getting of dataverse name from list panel instancing Issue: documentacao-e-tarefas/scielo#700 Signed-off-by: Jhon --- classes/components/forms/DataStatementForm.php | 4 ---- classes/components/forms/DraftDatasetFileForm.php | 13 ++----------- classes/services/DatasetService.php | 3 --- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/classes/components/forms/DataStatementForm.php b/classes/components/forms/DataStatementForm.php index 2f1162eb..26692933 100644 --- a/classes/components/forms/DataStatementForm.php +++ b/classes/components/forms/DataStatementForm.php @@ -102,10 +102,6 @@ private function getDataStatementOptions($page): array $includeSubmittedType = ($page == 'submission'); $dataStatementTypes = $dataStatementService->getDataStatementTypes($includeSubmittedType); - if ($page == 'workflow') { - unset($dataStatementTypes[DataStatementService::DATA_STATEMENT_TYPE_DATAVERSE_SUBMITTED]); - } - return array_map(function ($value, $label) { return [ 'value' => $value, diff --git a/classes/components/forms/DraftDatasetFileForm.php b/classes/components/forms/DraftDatasetFileForm.php index 4aea26b0..6ac165b6 100644 --- a/classes/components/forms/DraftDatasetFileForm.php +++ b/classes/components/forms/DraftDatasetFileForm.php @@ -51,17 +51,8 @@ private function getTermsOfUseData($contextId) $locale = Locale::getLocale(); $dataverseClient = new DataverseClient(); $configuration = DAORegistry::getDAO('DataverseConfigurationDAO')->get($contextId); + $termsOfUse = $configuration->getLocalizedData('termsOfUse', $locale); - try { - $dataverseCollection = $dataverseClient->getDataverseCollectionActions()->get(); - $termsOfUse = $configuration->getLocalizedData('termsOfUse', $locale); - return [ - 'dataverseName' => $dataverseCollection->getName(), - 'termsOfUseURL' => $termsOfUse - ]; - } catch (DataverseException $e) { - error_log('Dataverse API error: ' . $e->getMessage()); - return []; - } + return ['termsOfUserUrl' => $termsOfUse]; } } diff --git a/classes/services/DatasetService.php b/classes/services/DatasetService.php index 2f294a2f..bddb54f8 100644 --- a/classes/services/DatasetService.php +++ b/classes/services/DatasetService.php @@ -120,10 +120,7 @@ public function delete(DataverseStudy $study, ?string $deleteMessage): void try { $dataverseClient = new DataverseClient(); - $dataset = $dataverseClient->getDatasetActions()->get($study->getPersistentId()); - $dataverseName = $dataverseClient->getDataverseCollectionActions()->get()->getName(); - $dataverseClient->getDatasetActions()->delete($dataset->getPersistentId()); } catch (DataverseException $e) { $this->registerAndNotifyError( From ec38719d2755e7cf9d7670d4f37e71c46fe3768b Mon Sep 17 00:00:00 2001 From: Jhon Date: Fri, 27 Sep 2024 15:54:56 -0400 Subject: [PATCH 08/18] Dataset files list panel can load dataverse name by itself Issue: documentacao-e-tarefas/scielo#700 Signed-off-by: Jhon --- .../listPanel/DatasetFilesListPanel.php | 2 ++ classes/dispatchers/DatasetTabDispatcher.php | 23 ++++++++++++++----- .../DraftDatasetFilesDispatcher.php | 9 ++++++-- js/ui/components/DatasetFilesListPanel.js | 16 +++++++++++++ 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/classes/components/listPanel/DatasetFilesListPanel.php b/classes/components/listPanel/DatasetFilesListPanel.php index 4c566e17..f477539e 100644 --- a/classes/components/listPanel/DatasetFilesListPanel.php +++ b/classes/components/listPanel/DatasetFilesListPanel.php @@ -9,6 +9,7 @@ class DatasetFilesListPanel extends ListPanel { public $addFileLabel = ''; + public $dataversePluginApiUrl = ''; public $fileListUrl = ''; public $fileActionUrl = ''; public $isLoading = false; @@ -32,6 +33,7 @@ public function getConfig() $config, [ 'addFileLabel' => $this->addFileLabel, + 'dataversePluginApiUrl' => $this->dataversePluginApiUrl, 'fileListUrl' => $this->fileListUrl, 'fileActionUrl' => $this->fileActionUrl, 'addFileModalTitle' => $this->addFileModalTitle, diff --git a/classes/dispatchers/DatasetTabDispatcher.php b/classes/dispatchers/DatasetTabDispatcher.php index e7f52901..081c68bc 100644 --- a/classes/dispatchers/DatasetTabDispatcher.php +++ b/classes/dispatchers/DatasetTabDispatcher.php @@ -134,7 +134,12 @@ private function setupResearchDataDeposit(Submission $submission): void ksort($datasetFiles); $this->initDatasetMetadataForm($templateMgr, $metadataFormAction, 'POST', $dataset); - $this->initDatasetFilesList($templateMgr, $submission, $fileListApiUrl, $fileActionApiUrl, $datasetFiles); + $this->initDatasetFilesList($templateMgr, $submission, [ + 'dataversePluginApiUrl' => $dataversePluginApiUrl, + 'fileListApiUrl' => $fileListApiUrl, + 'fileActionApiUrl' => $fileActionApiUrl, + 'files' => $datasetFiles + ]); $templateMgr->setState([ 'dataversePluginApiUrl' => $dataversePluginApiUrl, @@ -188,7 +193,12 @@ private function setupResearchDataUpdate(Submission $submission, DataverseStudy ); $this->initDatasetMetadataForm($templateMgr, $datasetApiUrl, 'PUT'); - $this->initDatasetFilesList($templateMgr, $submission, $fileListApiUrl, $fileActionApiUrl, []); + $this->initDatasetFilesList($templateMgr, $submission, [ + 'dataversePluginApiUrl' => $dataversePluginApiUrl, + 'fileListApiUrl' => $fileListApiUrl, + 'fileActionApiUrl' => $fileActionApiUrl, + 'files' => [] + ]); $defaultEmailBody = $this->getDeleteDatasetEmailBody($submission, $datasetStatementUrl); $deleteDatasetForm = $this->getDeleteDatasetForm($context, $datasetApiUrl, $defaultEmailBody); @@ -214,7 +224,7 @@ private function initDatasetMetadataForm(TemplateManager $templateMgr, string $a $this->addComponent($templateMgr, $datasetMetadataForm); } - private function initDatasetFilesList($templateMgr, $submission, $fileListApiUrl, $fileActionApiUrl, $datasetFiles): void + private function initDatasetFilesList($templateMgr, $submission, $args): void { $templateMgr->addJavaScript( 'dataset-files-list-panel', @@ -231,9 +241,10 @@ private function initDatasetFilesList($templateMgr, $submission, $fileListApiUrl $submission, [ 'addFileLabel' => __('plugins.generic.dataverse.addResearchData'), - 'fileListUrl' => $fileListApiUrl, - 'fileActionUrl' => $fileActionApiUrl, - 'items' => $datasetFiles, + 'dataversePluginApiUrl' => $args['dataversePluginApiUrl'], + 'fileListUrl' => $args['fileListApiUrl'], + 'fileActionUrl' => $args['fileActionApiUrl'], + 'items' => $args['files'], 'modalTitle' => __('plugins.generic.dataverse.modal.addFile.title'), 'title' => __('plugins.generic.dataverse.researchData'), ] diff --git a/classes/dispatchers/DraftDatasetFilesDispatcher.php b/classes/dispatchers/DraftDatasetFilesDispatcher.php index 35430010..b9c6bda4 100644 --- a/classes/dispatchers/DraftDatasetFilesDispatcher.php +++ b/classes/dispatchers/DraftDatasetFilesDispatcher.php @@ -74,12 +74,16 @@ public function addToFilesStep(string $hookName, array $params) private function addDatasetFilesList($templateMgr, $request, $submission): void { $items = $this->getDatasetFiles($request, $submission->getId()); + $context = $request->getContext(); + $dataversePluginApiUrl = $request + ->getDispatcher() + ->url($request, Application::ROUTE_API, $context->getPath(), 'dataverse'); $fileListApiUrl = $request ->getDispatcher() - ->url($request, Application::ROUTE_API, $request->getContext()->getPath(), 'draftDatasetFiles', null, null, ['submissionId' => $submission->getId()]); + ->url($request, Application::ROUTE_API, $context->getPath(), 'draftDatasetFiles', null, null, ['submissionId' => $submission->getId()]); $fileActionApiUrl = $request ->getDispatcher() - ->url($request, Application::ROUTE_API, $request->getContext()->getPath(), 'draftDatasetFiles'); + ->url($request, Application::ROUTE_API, $context->getPath(), 'draftDatasetFiles'); $datasetFilesListPanel = new DatasetFilesListPanel( 'datasetFiles', @@ -87,6 +91,7 @@ private function addDatasetFilesList($templateMgr, $request, $submission): void $submission, [ 'addFileLabel' => __('plugins.generic.dataverse.addResearchData'), + 'dataversePluginApiUrl' => $dataversePluginApiUrl, 'fileListUrl' => $fileListApiUrl, 'fileActionUrl' => $fileActionApiUrl, 'items' => $items, diff --git a/js/ui/components/DatasetFilesListPanel.js b/js/ui/components/DatasetFilesListPanel.js index 852a71d2..fcdadb6d 100644 --- a/js/ui/components/DatasetFilesListPanel.js +++ b/js/ui/components/DatasetFilesListPanel.js @@ -90,6 +90,9 @@ pkp.Vue.component('dataset-files-list-panel', { addFileModalTitle: { type: String, }, + dataversePluginApiUrl: { + type: String, + }, fileListUrl: { type: String, }, @@ -205,6 +208,18 @@ pkp.Vue.component('dataset-files-list-panel', { }, }); }, + getDataverseName() { + let self = this; + $.ajax({ + url: self.dataversePluginApiUrl + '/dataverseName', + type: 'GET', + success: function (r) { + let datasetFileForm = self.form; + let termsOfUseFieldOption = datasetFileForm.fields[1].options[0]; + termsOfUseFieldOption.label = termsOfUseFieldOption.label.replace('{$dataverseName}', r.dataverseName); + }, + }); + } }, render: function (h) { return datasetFilesListTemplate.render.call(this, h); @@ -217,6 +232,7 @@ pkp.Vue.component('dataset-files-list-panel', { watch: { flagMounted(newVal, oldVal) { this.refreshItems(); + this.getDataverseName(); } } }); \ No newline at end of file From 85b201f298500a5c4d7f54d4ea5a6ae82b4ab337 Mon Sep 17 00:00:00 2001 From: Jhon Date: Fri, 27 Sep 2024 17:01:50 -0400 Subject: [PATCH 09/18] Handler receives dataset published info when getting citation Issue: documentacao-e-tarefas/scielo#700 Signed-off-by: Jhon --- api/v1/datasets/DatasetHandler.php | 5 ++++- classes/dispatchers/DatasetInformationDispatcher.php | 2 +- dataverseAPI/actions/DatasetActions.php | 9 ++++++--- js/DataverseWorkflowPage.js | 4 ++++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/api/v1/datasets/DatasetHandler.php b/api/v1/datasets/DatasetHandler.php index 1988cb3e..07de5173 100644 --- a/api/v1/datasets/DatasetHandler.php +++ b/api/v1/datasets/DatasetHandler.php @@ -283,9 +283,12 @@ public function getCitation($slimRequest, $response, $args) return $response->withStatus(404)->withJsonError('api.404.resourceNotFound'); } + $queryParams = $slimRequest->getQueryParams(); + $datasetIsPublished = (bool) $queryParams['datasetIsPublished']; + try { $dataverseClient = new DataverseClient(); - $citation = $dataverseClient->getDatasetActions()->getCitation($study->getPersistentId()); + $citation = $dataverseClient->getDatasetActions()->getCitation($study->getPersistentId(), $datasetIsPublished); } catch (DataverseException $e) { error_log('Error getting citation: ' . $e->getMessage()); return $response->withStatus($e->getCode())->withJsonError('api.error.researchDataCitationNotFound'); diff --git a/classes/dispatchers/DatasetInformationDispatcher.php b/classes/dispatchers/DatasetInformationDispatcher.php index e6c905b9..bcea92c5 100644 --- a/classes/dispatchers/DatasetInformationDispatcher.php +++ b/classes/dispatchers/DatasetInformationDispatcher.php @@ -28,7 +28,7 @@ public function addDatasetInformation(string $hookName, array $params): bool $dataverseClient = new DataverseClient(); try { - $citation = $dataverseClient->getDatasetActions()->getCitation($study->getPersistentId()); + $citation = $dataverseClient->getDatasetActions()->getCitation($study->getPersistentId(), null); $templateMgr->assign('datasetInfo', $citation); $output .= $templateMgr->fetch($this->plugin->getTemplateResource('dataCitation.tpl')); } catch (DataverseException $e) { diff --git a/dataverseAPI/actions/DatasetActions.php b/dataverseAPI/actions/DatasetActions.php index 7b65e369..ff8f170a 100644 --- a/dataverseAPI/actions/DatasetActions.php +++ b/dataverseAPI/actions/DatasetActions.php @@ -23,11 +23,14 @@ public function get(string $persistentId): Dataset return $datasetFactory->getDataset(); } - public function getCitation(string $persistentId): string + public function getCitation(string $persistentId, ?bool $datasetIsPublished): string { - $dataset = $this->get($persistentId); + if (is_null($datasetIsPublished)) { + $dataset = $this->get($persistentId); + $datasetIsPublished = $dataset->isPublished(); + } - if ($dataset->isPublished()) { + if ($datasetIsPublished) { $args = '?exporter=dataverse_json&persistentId=' . $persistentId; $uri = $this->createNativeAPIURI('datasets', 'export' . $args); $response = $this->nativeAPIRequest('GET', $uri); diff --git a/js/DataverseWorkflowPage.js b/js/DataverseWorkflowPage.js index 8e345495..ff9fc277 100644 --- a/js/DataverseWorkflowPage.js +++ b/js/DataverseWorkflowPage.js @@ -223,6 +223,9 @@ var DataverseWorkflowPage = $.extend(true, {}, pkp.controllers.WorkflowPage, { this.datasetCitation = this.__('common.loading') + '...'; $.ajax({ url: self.datasetCitationUrl, + data: { + datasetIsPublished: (self.datasetIsPublished ? 1 : 0) + }, type: 'GET', error: self.ajaxErrorCallback, success: (r) => { @@ -258,6 +261,7 @@ var DataverseWorkflowPage = $.extend(true, {}, pkp.controllers.WorkflowPage, { }, watch: { dataset(newVal, oldVal) { + console.log('banzai'); this.updateDatasetMetadataForm(newVal); this.setDatasetFilesPanel(newVal); this.updateDatasetCitation(); From bc47431d3842c5ddfb2703a93b364b57a63f5792 Mon Sep 17 00:00:00 2001 From: Jhon Date: Fri, 27 Sep 2024 18:28:54 -0400 Subject: [PATCH 10/18] Selects default dataset license during submission process Issue: documentacao-e-tarefas/scielo#700 Signed-off-by: Jhon --- classes/components/forms/DatasetMetadataForm.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/classes/components/forms/DatasetMetadataForm.php b/classes/components/forms/DatasetMetadataForm.php index 5fd8f8af..8bbdec6b 100644 --- a/classes/components/forms/DatasetMetadataForm.php +++ b/classes/components/forms/DatasetMetadataForm.php @@ -20,10 +20,18 @@ public function __construct($action, $method, $dataset, $page) $this->method = $method; $this->locales = $this->mapCurrentLocale(); - $dataverseMetadata = new DataverseMetadata(); - $dataverseLicenses = ($page == 'submission' ? $dataverseMetadata->getDataverseLicenses() : []); + $dataverseLicenses = []; $datasetMetadata = $this->getDatasetMetadata($dataset); + if ($page == 'submission') { + $dataverseMetadata = new DataverseMetadata(); + $dataverseLicenses = $dataverseMetadata->getDataverseLicenses(); + + if (empty($datasetMetadata['license'])) { + $datasetMetadata['license'] = $dataverseMetadata->getDefaultLicense(); + } + } + if ($page == 'workflow') { $this->addField(new FieldText('datasetTitle', [ 'label' => __('plugins.generic.dataverse.metadataForm.title'), From 683eabf9ee92a6c9ea78fe62041f0435d9d1e3ac Mon Sep 17 00:00:00 2001 From: Jhon Date: Fri, 27 Sep 2024 19:01:32 -0400 Subject: [PATCH 11/18] Adds commands to wait for dataset loading in integration tests Issue: documentacao-e-tarefas/scielo#700 Signed-off-by: Jhon --- classes/components/forms/DatasetMetadataForm.php | 2 +- cypress/support/commands.js | 10 ++++++++++ cypress/tests/Test2_workflowFeatures.cy.js | 4 ++++ js/DataverseWorkflowPage.js | 1 - 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/classes/components/forms/DatasetMetadataForm.php b/classes/components/forms/DatasetMetadataForm.php index 8bbdec6b..c014833b 100644 --- a/classes/components/forms/DatasetMetadataForm.php +++ b/classes/components/forms/DatasetMetadataForm.php @@ -20,11 +20,11 @@ public function __construct($action, $method, $dataset, $page) $this->method = $method; $this->locales = $this->mapCurrentLocale(); + $dataverseMetadata = new DataverseMetadata(); $dataverseLicenses = []; $datasetMetadata = $this->getDatasetMetadata($dataset); if ($page == 'submission') { - $dataverseMetadata = new DataverseMetadata(); $dataverseLicenses = $dataverseMetadata->getDataverseLicenses(); if (empty($datasetMetadata['license'])) { diff --git a/cypress/support/commands.js b/cypress/support/commands.js index d8ed06f1..9b06d408 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -22,4 +22,14 @@ Cypress.Commands.add('findSubmission', function(tab, title) { .parent().parent().within(() => { cy.get('.pkpButton:contains("View")').click(); }); +}); + +Cypress.Commands.add('waitDataStatementTabLoading', function () { + cy.intercept('GET', '**/api/v1/dataverse/dataverseName*').as('getDataverseNameRequest'); + cy.wait('@getDataverseNameRequest'); +}); + +Cypress.Commands.add('waitDatasetTabLoading', function () { + cy.intercept('GET', /\/api\/v1\/datasets\/\d+\/citation/).as('getDatasetRequest'); + cy.wait('@getDatasetRequest'); }); \ No newline at end of file diff --git a/cypress/tests/Test2_workflowFeatures.cy.js b/cypress/tests/Test2_workflowFeatures.cy.js index 3946fa98..c76eefb4 100644 --- a/cypress/tests/Test2_workflowFeatures.cy.js +++ b/cypress/tests/Test2_workflowFeatures.cy.js @@ -23,6 +23,8 @@ describe('Dataverse Plugin - Workflow features', function () { cy.login('eostrom', null, 'publicknowledge'); cy.findSubmission('myQueue', submissionData.title); + cy.waitDataStatementTabLoading(); + cy.get('#publication-button').click(); cy.contains('button', 'Data statement').click(); @@ -58,6 +60,8 @@ describe('Dataverse Plugin - Workflow features', function () { cy.login('eostrom', null, 'publicknowledge'); cy.findSubmission('myQueue', submissionData.title); + cy.waitDatasetTabLoading(); + cy.get('#publication-button').click(); cy.get('#datasetTab-button').click(); diff --git a/js/DataverseWorkflowPage.js b/js/DataverseWorkflowPage.js index ff9fc277..669c786e 100644 --- a/js/DataverseWorkflowPage.js +++ b/js/DataverseWorkflowPage.js @@ -261,7 +261,6 @@ var DataverseWorkflowPage = $.extend(true, {}, pkp.controllers.WorkflowPage, { }, watch: { dataset(newVal, oldVal) { - console.log('banzai'); this.updateDatasetMetadataForm(newVal); this.setDatasetFilesPanel(newVal); this.updateDatasetCitation(); From 2b5485d9d67cf8aed664631f655d8c3b9dd63590 Mon Sep 17 00:00:00 2001 From: Jhon Date: Mon, 30 Sep 2024 12:23:19 -0400 Subject: [PATCH 12/18] Fixes dataset keywords field in workflow page Issue: documentacao-e-tarefas/scielo#700 Signed-off-by: Jhon --- classes/components/forms/DatasetMetadataForm.php | 2 +- js/DataverseWorkflowPage.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/classes/components/forms/DatasetMetadataForm.php b/classes/components/forms/DatasetMetadataForm.php index c014833b..7a572d1b 100644 --- a/classes/components/forms/DatasetMetadataForm.php +++ b/classes/components/forms/DatasetMetadataForm.php @@ -78,7 +78,7 @@ private function getDatasetMetadata($dataset) return [ 'title' => '', 'description' => '', - 'keywords' => [], + 'keywords' => [Locale::getLocale() => []], 'subject' => '', 'license' => '' ]; diff --git a/js/DataverseWorkflowPage.js b/js/DataverseWorkflowPage.js index 669c786e..d55a8178 100644 --- a/js/DataverseWorkflowPage.js +++ b/js/DataverseWorkflowPage.js @@ -183,16 +183,21 @@ var DataverseWorkflowPage = $.extend(true, {}, pkp.controllers.WorkflowPage, { for (let field of form.fields) { let datasetFieldName = field.name.replace(/^dataset/, '').toLowerCase(); - + if (this.dataset.hasOwnProperty(datasetFieldName)) { field.value = this.dataset[datasetFieldName]; - + if (datasetFieldName == 'keywords') { let selectedKeywords = []; + for (let keyword of this.dataset[datasetFieldName]) { selectedKeywords.push({'label': keyword, 'value': keyword}); } - field.selected = selectedKeywords; + + field.selected = {}; + field.selected[form.primaryLocale] = selectedKeywords; + field.value = {}; + field.value[form.primaryLocale] = this.dataset[datasetFieldName]; } } } From c49cb1001d4ff106d6d47a57f589b1ce08112b8b Mon Sep 17 00:00:00 2001 From: Jhon Date: Mon, 30 Sep 2024 14:02:09 -0400 Subject: [PATCH 13/18] Atempts fixing of workflow features integration test Issue: documentacao-e-tarefas/scielo#700 Signed-off-by: Jhon --- cypress/support/commands.js | 4 +-- cypress/tests/Test2_workflowFeatures.cy.js | 41 +++++++++++++++++----- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 9b06d408..00ac86a6 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -26,10 +26,10 @@ Cypress.Commands.add('findSubmission', function(tab, title) { Cypress.Commands.add('waitDataStatementTabLoading', function () { cy.intercept('GET', '**/api/v1/dataverse/dataverseName*').as('getDataverseNameRequest'); - cy.wait('@getDataverseNameRequest'); + cy.wait('@getDataverseNameRequest', {timeout:10000}); }); Cypress.Commands.add('waitDatasetTabLoading', function () { cy.intercept('GET', /\/api\/v1\/datasets\/\d+\/citation/).as('getDatasetRequest'); - cy.wait('@getDatasetRequest'); + cy.wait('@getDatasetRequest', {timeout:10000}); }); \ No newline at end of file diff --git a/cypress/tests/Test2_workflowFeatures.cy.js b/cypress/tests/Test2_workflowFeatures.cy.js index c76eefb4..fef42648 100644 --- a/cypress/tests/Test2_workflowFeatures.cy.js +++ b/cypress/tests/Test2_workflowFeatures.cy.js @@ -102,7 +102,9 @@ describe('Dataverse Plugin - Workflow features', function () { it('Research data files editing in workflow', function () { cy.login('eostrom', null, 'publicknowledge'); cy.findSubmission('myQueue', submissionData.title); - + + cy.waitDatasetTabLoading(); + cy.get('#publication-button').click(); cy.get('#datasetTab-button').click(); cy.get('#dataset_files-button').click(); @@ -137,6 +139,8 @@ describe('Dataverse Plugin - Workflow features', function () { cy.login('eostrom', null, 'publicknowledge'); cy.findSubmission('myQueue', submissionData.title); + cy.waitDatasetTabLoading(); + cy.get('#publication-button').click(); cy.get('#datasetTab-button').click(); @@ -152,6 +156,8 @@ describe('Dataverse Plugin - Workflow features', function () { cy.login('eostrom', null, 'publicknowledge'); cy.findSubmission('myQueue', submissionData.title); + cy.waitDataStatementTabLoading(); + cy.get('#publication-button').click(); cy.get('#datasetTab-button').click(); @@ -172,8 +178,9 @@ describe('Dataverse Plugin - Workflow features', function () { cy.get('#datasetMetadata-datasetSubject-control').select('Earth and Environmental Sciences'); cy.get('#datasetMetadata-datasetLicense-control').select('CC BY 4.0'); cy.get('button:visible:contains("Save")').click(); - cy.wait(3000); + cy.wait(7000); + cy.waitDatasetTabLoading(); cy.contains('h1', 'Research data'); }); it('Check author actions were registered in activity log', function () { @@ -200,6 +207,8 @@ describe('Dataverse Plugin - Workflow features', function () { cy.login('eostrom', null, 'publicknowledge'); cy.findSubmission('myQueue', submissionData.title); + cy.waitDatasetTabLoading(); + cy.get('#publication-button').click(); cy.get('#datasetTab-button').click(); @@ -214,7 +223,9 @@ describe('Dataverse Plugin - Workflow features', function () { it('Editor can delete research data in workflow', function () { cy.login('dbarnes', null, 'publicknowledge'); cy.findSubmission('active', submissionData.title); - + + cy.waitDatasetTabLoading(); + cy.get('#publication-button').click(); cy.get('#datasetTab-button').click(); @@ -222,7 +233,7 @@ describe('Dataverse Plugin - Workflow features', function () { cy.getTinyMceContent('deleteDataset-deleteMessage-control') .should('include', 'The research data from the manuscript submission "' + submissionData.title + '" has been removed'); cy.get('.modal__panel button:contains("Delete and send email")').click(); - cy.wait(3000); + cy.wait(5000); cy.contains('No research data transferred.'); cy.get('#dataStatement-button').click(); @@ -231,7 +242,9 @@ describe('Dataverse Plugin - Workflow features', function () { it('Editor can upload research data in workflow', function () { cy.login('dbarnes', null, 'publicknowledge'); cy.findSubmission('active', submissionData.title); - + + cy.waitDataStatementTabLoading(); + cy.get('#publication-button').click(); cy.get('#datasetTab-button').click(); @@ -252,14 +265,17 @@ describe('Dataverse Plugin - Workflow features', function () { cy.get('#datasetMetadata-datasetSubject-control').select('Earth and Environmental Sciences'); cy.get('#datasetMetadata-datasetLicense-control').select('CC BY 4.0'); cy.get('button:visible:contains("Save")').click(); - cy.wait(3000); + cy.wait(7000); + cy.waitDatasetTabLoading(); cy.contains('h1', 'Research data'); }); it('Editor can publish dataset on submission publishing', function () { cy.login('dbarnes', null, 'publicknowledge'); cy.findSubmission('active', submissionData.title); + cy.waitDatasetTabLoading(); + if (Cypress.env('contextTitles').en !== 'Public Knowledge Preprint Server') { cy.get('#workflow-button').click(); @@ -282,7 +298,10 @@ describe('Dataverse Plugin - Workflow features', function () { cy.wait(1000); cy.get('select[id="assignToIssue-issueId-control"]').select('1'); cy.get('div[id^="assign-"] button:contains("Save")').click(); - cy.wait(500); + cy.wait(1000); + cy.get('div[id^="assign-"] [role="status"]').contains('Saved'); + cy.reload(); + cy.get('div#publication button:contains("Schedule For Publication")').click(); cy.contains('All publication requirements have been met. This will be published immediately in Vol. 1 No. 2 (2014). Are you sure you want to publish this?'); } else { cy.get('#publication-button').click(); @@ -309,6 +328,8 @@ describe('Dataverse Plugin - Workflow features', function () { cy.login('dbarnes', null, 'publicknowledge'); cy.findSubmission('archive', submissionData.title); + cy.waitDatasetTabLoading(); + cy.get('#publication-button').click(); cy.get('#datasetTab-button').click(); @@ -318,7 +339,9 @@ describe('Dataverse Plugin - Workflow features', function () { + 'Before proceeding, make sure they are suitable for publication in '; cy.get('div[data-modal="publishDataset"]').contains(publishMsg); cy.get('div[data-modal="publishDataset"] button:contains("Yes")').click(); - cy.wait(1000); + cy.wait(3000); + + cy.waitDatasetTabLoading(); cy.get('.value > p').contains('V1'); cy.contains('Publish research data').should('not.exist'); @@ -330,6 +353,8 @@ describe('Dataverse Plugin - Workflow features', function () { cy.login('dbarnes', null, 'publicknowledge'); cy.findSubmission('archive', submissionData.title); + cy.waitDatasetTabLoading(); + cy.get('#publication-button').click(); cy.contains('button', 'Create New Version').click(); cy.get('.modal__panel button:contains("Yes")').click(); From fa1308d3d55264ae14375512e3101e1063a1070a Mon Sep 17 00:00:00 2001 From: Jhon Date: Mon, 30 Sep 2024 14:43:09 -0400 Subject: [PATCH 14/18] Changes checking of dataset loading after uploading Issue: documentacao-e-tarefas/scielo#700 Signed-off-by: Jhon --- cypress/tests/Test2_workflowFeatures.cy.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cypress/tests/Test2_workflowFeatures.cy.js b/cypress/tests/Test2_workflowFeatures.cy.js index fef42648..d2095c59 100644 --- a/cypress/tests/Test2_workflowFeatures.cy.js +++ b/cypress/tests/Test2_workflowFeatures.cy.js @@ -180,8 +180,7 @@ describe('Dataverse Plugin - Workflow features', function () { cy.get('button:visible:contains("Save")').click(); cy.wait(7000); - cy.waitDatasetTabLoading(); - cy.contains('h1', 'Research data'); + cy.contains('h1', 'Research data', {timeout:10000}); }); it('Check author actions were registered in activity log', function () { cy.login('dbarnes', null, 'publicknowledge'); @@ -267,8 +266,7 @@ describe('Dataverse Plugin - Workflow features', function () { cy.get('button:visible:contains("Save")').click(); cy.wait(7000); - cy.waitDatasetTabLoading(); - cy.contains('h1', 'Research data'); + cy.contains('h1', 'Research data', {timeout:10000}); }); it('Editor can publish dataset on submission publishing', function () { cy.login('dbarnes', null, 'publicknowledge'); From 2f108bf564e0535d31fae0999cf7ae71f2a9629c Mon Sep 17 00:00:00 2001 From: Jhon Date: Mon, 30 Sep 2024 15:15:03 -0400 Subject: [PATCH 15/18] Fixes two last integration tests Issue: documentacao-e-tarefas/scielo#700 Signed-off-by: Jhon --- cypress/tests/Test3_reviewStage.cy.js | 4 ++++ cypress/tests/Test4_publicSiteInfo.cy.js | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cypress/tests/Test3_reviewStage.cy.js b/cypress/tests/Test3_reviewStage.cy.js index 94e8f8e3..95300ca6 100644 --- a/cypress/tests/Test3_reviewStage.cy.js +++ b/cypress/tests/Test3_reviewStage.cy.js @@ -143,6 +143,8 @@ describe('Dataverse Plugin - Features around review stage', function () { cy.login('dbarnes', null, 'publicknowledge'); cy.findSubmission('myQueue', submissionData.title); + cy.waitDatasetTabLoading(); + cy.get('#workflow-button').click(); cy.clickDecision('Accept Submission'); @@ -164,6 +166,8 @@ describe('Dataverse Plugin - Features around review stage', function () { cy.get('a.pkpButton').contains('View All Submissions').click(); cy.findSubmission('myQueue', submissionData.title); + cy.waitDatasetTabLoading(); + cy.get('#publication-button').click(); cy.get('#datasetTab-button').click(); diff --git a/cypress/tests/Test4_publicSiteInfo.cy.js b/cypress/tests/Test4_publicSiteInfo.cy.js index 05ba9401..ed2b8de5 100644 --- a/cypress/tests/Test4_publicSiteInfo.cy.js +++ b/cypress/tests/Test4_publicSiteInfo.cy.js @@ -25,7 +25,9 @@ describe('Dataverse Plugin - Information displayed in public site', function () it('Data statement is not displayed if only submitted to Dataverse', function () { cy.login('dbarnes', null, 'publicknowledge'); cy.findSubmission('myQueue', secondSubmissionTitle); - + + cy.waitDataStatementTabLoading(); + cy.get('#workflow-button').click(); cy.clickDecision('Send To Production'); cy.recordDecisionSendToProduction(['Catherine Kwantes'], []); @@ -36,8 +38,12 @@ describe('Dataverse Plugin - Information displayed in public site', function () cy.wait(1000); cy.get('select[id="assignToIssue-issueId-control"]').select('1'); cy.get('div[id^="assign-"] button:contains("Save")').click(); - cy.get('.pkpWorkflow__publishModal button:contains("Publish")').click(); cy.wait(1000); + cy.get('div[id^="assign-"] [role="status"]').contains('Saved'); + cy.reload(); + cy.get('div#publication button:contains("Schedule For Publication")').click(); + cy.get('.pkpWorkflow__publishModal button:contains("Publish")').click(); + cy.wait(3000); cy.get('.pkpHeader__actions a:contains("View")').click(); From 50838d40a9ae1b1c578bda9788c6852ca0b40172 Mon Sep 17 00:00:00 2001 From: Jhon Date: Mon, 30 Sep 2024 15:28:24 -0400 Subject: [PATCH 16/18] Trying to focus, in order to gain information Signed-off-by: Jhon --- cypress/tests/Test3_reviewStage.cy.js | 2 ++ cypress/tests/Test4_publicSiteInfo.cy.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cypress/tests/Test3_reviewStage.cy.js b/cypress/tests/Test3_reviewStage.cy.js index 95300ca6..e319e800 100644 --- a/cypress/tests/Test3_reviewStage.cy.js +++ b/cypress/tests/Test3_reviewStage.cy.js @@ -170,6 +170,8 @@ describe('Dataverse Plugin - Features around review stage', function () { cy.get('#publication-button').click(); cy.get('#datasetTab-button').click(); + + cy.get('#publication-button').focus(); cy.get('p:contains("Demo Dataverse, V1")'); }); diff --git a/cypress/tests/Test4_publicSiteInfo.cy.js b/cypress/tests/Test4_publicSiteInfo.cy.js index ed2b8de5..5d560de7 100644 --- a/cypress/tests/Test4_publicSiteInfo.cy.js +++ b/cypress/tests/Test4_publicSiteInfo.cy.js @@ -48,7 +48,7 @@ describe('Dataverse Plugin - Information displayed in public site', function () cy.get('.pkpHeader__actions a:contains("View")').click(); cy.contains('h2', 'Data statement').should('not.exist'); - cy.contains('h2', 'Research data'); + cy.contains('h2', 'Research data').focus(); cy.contains('"Replication data for: ' + secondSubmissionTitle + '"'); cy.contains('a', /https:\/\/doi\.org\/10\.[^\/]*\/FK2\//); cy.contains('Demo Dataverse, V1'); From d8e85a02cb178898578da17ec27384a1235fe527 Mon Sep 17 00:00:00 2001 From: Jhon Date: Mon, 30 Sep 2024 16:01:34 -0400 Subject: [PATCH 17/18] Tries to improve third integration test Signed-off-by: Jhon --- cypress/tests/Test3_reviewStage.cy.js | 4 ++-- cypress/tests/Test4_publicSiteInfo.cy.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cypress/tests/Test3_reviewStage.cy.js b/cypress/tests/Test3_reviewStage.cy.js index e319e800..335b2652 100644 --- a/cypress/tests/Test3_reviewStage.cy.js +++ b/cypress/tests/Test3_reviewStage.cy.js @@ -163,6 +163,8 @@ describe('Dataverse Plugin - Features around review stage', function () { }); cy.contains('button', 'Record Decision').click(); + cy.wait(1000); + cy.contains('has been accepted for publication and sent to the copyediting stage'); cy.get('a.pkpButton').contains('View All Submissions').click(); cy.findSubmission('myQueue', submissionData.title); @@ -171,8 +173,6 @@ describe('Dataverse Plugin - Features around review stage', function () { cy.get('#publication-button').click(); cy.get('#datasetTab-button').click(); - cy.get('#publication-button').focus(); - cy.get('p:contains("Demo Dataverse, V1")'); }); }); \ No newline at end of file diff --git a/cypress/tests/Test4_publicSiteInfo.cy.js b/cypress/tests/Test4_publicSiteInfo.cy.js index 5d560de7..ed2b8de5 100644 --- a/cypress/tests/Test4_publicSiteInfo.cy.js +++ b/cypress/tests/Test4_publicSiteInfo.cy.js @@ -48,7 +48,7 @@ describe('Dataverse Plugin - Information displayed in public site', function () cy.get('.pkpHeader__actions a:contains("View")').click(); cy.contains('h2', 'Data statement').should('not.exist'); - cy.contains('h2', 'Research data').focus(); + cy.contains('h2', 'Research data'); cy.contains('"Replication data for: ' + secondSubmissionTitle + '"'); cy.contains('a', /https:\/\/doi\.org\/10\.[^\/]*\/FK2\//); cy.contains('Demo Dataverse, V1'); From 99c544ba8af246c4c06e8edccf6c760fd413da48 Mon Sep 17 00:00:00 2001 From: Jhon Date: Mon, 30 Sep 2024 16:30:24 -0400 Subject: [PATCH 18/18] Updates version.xml Issue: documentacao-e-tarefas/scielo#700 Signed-off-by: Jhon --- version.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.xml b/version.xml index de6b4784..7323f3f5 100644 --- a/version.xml +++ b/version.xml @@ -13,8 +13,8 @@ dataverse plugins.generic - 3.0.2.0 - 2024-08-16 + 3.1.0.0 + 2024-09-30 1 DataversePlugin