From 39b0ca01406441d6598df1db227ee503fe67c5ae Mon Sep 17 00:00:00 2001 From: gkolokythas Date: Fri, 26 Jul 2019 11:37:26 +0300 Subject: [PATCH] Fixes bug on showing deleted Dataset Descriptions and fixes language on Dataset Description Template version update. --- .../data/dao/entities/DatasetDaoImpl.java | 6 ++-- .../controllers/DatasetWizardController.java | 1 + .../dataset-wizard.component.ts | 35 +++++++++++-------- dmp-frontend/src/assets/i18n/en.json | 4 +++ 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java index 17c51f2c8..3983bca9b 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java @@ -65,12 +65,14 @@ public class DatasetDaoImpl extends DatabaseAccess implements DatasetDa @Override public Dataset find(UUID id) { - return getDatabaseService().getQueryable(Dataset.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle(); + return getDatabaseService().getQueryable(Dataset.class) + .where((builder, root) -> builder.and(builder.notEqual(root.get("status"),Dataset.Status.DELETED.getValue()), builder.notEqual(root.get("status"),Dataset.Status.CANCELED.getValue()), builder.equal((root.get("id")), id))).getSingle(); } @Override public Dataset find(UUID id, String hint) { - return getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class).withHint(hint).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle(); + return getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class).withHint(hint) + .where((builder, root) -> builder.and(builder.notEqual(root.get("status"),Dataset.Status.DELETED.getValue()), builder.notEqual(root.get("status"),Dataset.Status.CANCELED.getValue()), builder.equal((root.get("id")), id))).getSingle(); } @Override diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetWizardController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetWizardController.java index 4836d3ca7..c94fd9c89 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetWizardController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetWizardController.java @@ -71,6 +71,7 @@ public class DatasetWizardController extends BaseController { return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlans)); } + @Transactional @RequestMapping(method = RequestMethod.GET, value = {"{id}"}, produces = "application/json") public @ResponseBody ResponseEntity getSingle(@PathVariable String id, @RequestHeader("Content-Type") String contentType, @ClaimedAuthorities(claims = {ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException { diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts index c4631fade..9c0ba6aab 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts @@ -135,6 +135,11 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr if (this.formGroup.get('dmp').value.status == DmpStatus.Draft && this.formGroup.get('status').value == DatasetStatus.Finalized) { this.hasReversableStatus = true; } + }, + error => { + this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.MESSAGES.DATAESET-NOT-FOUND'), SnackBarNotificationLevel.Error); + this.router.navigate(['/plans']); + return Observable.of(null); }); } else if (dmpId != null) { this.isNew = true; @@ -383,7 +388,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr public isSemiFormValid(formGroup: FormGroup): boolean { var isValid: boolean = true; - Object.keys(formGroup.controls).forEach( controlName => { + Object.keys(formGroup.controls).forEach(controlName => { if (controlName != 'datasetProfileDefinition' && formGroup.get(controlName).invalid) { isValid = false; } @@ -395,17 +400,17 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr this.datasetWizardService.createDataset(this.formGroup.value) .pipe(takeUntil(this._destroyed)) .subscribe( - complete => { - this.datasetWizardService.getSingle(complete.id) - .pipe(takeUntil(this._destroyed)) - .subscribe( - result => { - this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(result); - } - ); - this.onCallbackSuccess(); - }, - error => this.onCallbackError(error) + complete => { + this.datasetWizardService.getSingle(complete.id) + .pipe(takeUntil(this._destroyed)) + .subscribe( + result => { + this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(result); + } + ); + this.onCallbackSuccess(); + }, + error => this.onCallbackError(error) ); } @@ -588,8 +593,8 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr this.datasetWizardService.delete(id) .pipe(takeUntil(this._destroyed)) .subscribe( - complete => { this.onCallbackSuccess(); this.router.navigateByUrl('/datasets') }, - error => this.onCallbackError(error) + complete => { this.onCallbackSuccess(); this.router.navigateByUrl('/datasets') }, + error => this.onCallbackError(error) ); } }); @@ -639,7 +644,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { if (result) { this.profileUpdateId = this.itemId; - this.uiNotificationService.snackBarNotification("Profile changed, WOW!", SnackBarNotificationLevel.Success); + this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.MESSAGES.SUCCESS-UPDATE-DATASET-PROFILE'), SnackBarNotificationLevel.Success); this.router.navigate(['/datasets/profileupdate/' + this.profileUpdateId]); } }); diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index bb7b267bb..1f57ea5cb 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -367,6 +367,10 @@ "COPY-DATASET": "Copy Dataset Description", "UPDATE-DATASET-PROFILE": "Update Template" }, + "MESSAGES": { + "DATAESET-NOT-FOUND": "Dataset Description does not exist", + "SUCCESS-UPDATE-DATASET-PROFILE": "Dataset Template updated successfully" + }, "UPLOAD": { "UPLOAD-XML": "Import", "UPLOAD-XML-FILE-TITLE": "Import Dataset Template",