diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java index 62ff0fe59..abe8c4f20 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java @@ -266,6 +266,17 @@ public class DMPs extends BaseController { } } + @Transactional + @RequestMapping(method = RequestMethod.POST, value = {"/unfinalize/{id}"}) + public ResponseEntity> undoFinalize(@PathVariable String id, Principal principal) { + try { + this.dataManagementPlanManager.undoFinalize(UUID.fromString(id), principal); + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Data Datamanagement Plan made active.")); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage())); + } + } + /* * DOI Generation * */ diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 62f173179..56bb8e41d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -794,7 +794,9 @@ public class DataManagementPlanManager { }); UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId()); sendNotification(dmp, user, NotificationType.DMP_PUBLISH); - this.createZenodoDoi(dmp.getId(), principal, null, true); + if (dmp.getDoi() != null && !dmp.getDoi().isEmpty()) { + this.createZenodoDoi(dmp.getId(), principal, null, true); + } } public void makeFinalize(UUID id, Principal principal, DatasetsToBeFinalized datasetsToBeFinalized) throws Exception { @@ -850,6 +852,17 @@ public class DataManagementPlanManager { this.updateDatasetsIndex(indexDatasets); } + public void undoFinalize(UUID id, Principal principal) throws Exception { + DMP dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(id); + if (!isUserOwnerOfDmp(dmp, principal)) + throw new Exception("User does not have the privilege to do this action."); + if (dmp.getStatus().equals(DMP.DMPStatus.ACTIVE.getValue())) + throw new Exception("DMP is already Active"); + dmp.setStatus(DMP.DMPStatus.ACTIVE.getValue()); + apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp); + this.updateIndex(dmp); + } + /* * Export Data * */ diff --git a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts index fff823d5d..7d6e8d33e 100644 --- a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts +++ b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts @@ -92,6 +92,10 @@ export class DmpService { return this.http.post(this.actionUrl + 'finalize/' + id, datasetsToBeFinalized, { headers: this.headers }); } + unfinalize( id: String): Observable { + return this.http.post(this.actionUrl + 'unfinalize/' + id, { headers: this.headers }); + } + getDoi(id: string): Observable { return this.http.post(this.actionUrl + 'createZenodoDoi/' + id, { headers: this.headers }); } diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html index 5151ecd9b..072c3db51 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html @@ -33,6 +33,7 @@
+ diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts index c363c8595..fc26664d8 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts @@ -528,6 +528,17 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { return this.configurationService.doiLink + id; } + reverse() { + this.dmpService.unfinalize(this.dmp.id).pipe(takeUntil(this._destroyed)) + .subscribe( + complete => { + this.dmp.status = DmpStatus.Draft; + this.onCallbackSuccess() + }, + error => this.onFinalizeCallbackError(error) + );; + } + // advancedClicked() { // const dialogRef = this.dialog.open(ExportMethodDialogComponent, { // maxWidth: '500px', diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index e94c124dc..ee4d7bbb6 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -412,6 +412,7 @@ "EXPORT": "Export", "PUBLISH": "Publish", "FINALIZE": "Finalize", + "UNFINALIZE": "Undo Finalization", "ADV-EXP": "Advanced Export", "EXP-AS": "Export As", "DOWNLOAD-XML": "Download XML", diff --git a/dmp-frontend/src/assets/i18n/es.json b/dmp-frontend/src/assets/i18n/es.json index 72cce5e49..c00b54876 100644 --- a/dmp-frontend/src/assets/i18n/es.json +++ b/dmp-frontend/src/assets/i18n/es.json @@ -412,6 +412,7 @@ "EXPORT": "Expertar", "PUBLISH": "Publicar", "FINALIZE": "Finalizar", + "UNFINALIZE": "Undo Finalization", "ADV-EXP": "Exportar avanzado", "EXP-AS": "Exportar como", "DOWNLOAD-XML": "Descargar XML", diff --git a/dmp-frontend/src/assets/i18n/gr.json b/dmp-frontend/src/assets/i18n/gr.json index 9fe15ff49..29cdcf64b 100644 --- a/dmp-frontend/src/assets/i18n/gr.json +++ b/dmp-frontend/src/assets/i18n/gr.json @@ -412,6 +412,7 @@ "EXPORT": "Εξαγωγή", "PUBLISH": "Δημοσίευση", "FINALIZE": "Οριστικοποίηση", + "UNFINALIZE": "Undo Finalization", "ADV-EXP": "Προχωρημένη Εξαγωγή", "EXP-AS": "Εξαγωγή ως", "DOWNLOAD-XML": "Λήψη XML",