From 37a5c49cc84781bf6e50bc2b7fe7012ba7f1c879 Mon Sep 17 00:00:00 2001 From: amentis Date: Tue, 14 May 2024 13:39:57 +0300 Subject: [PATCH] fix update other plan version status while deleting one plan --- .../org/opencdmp/service/dmp/DmpServiceImpl.java | 16 ++++++++-------- .../ui/dmp/overview/dmp-overview.component.ts | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java index 97e207adb..1c302e8df 100644 --- a/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java @@ -335,19 +335,19 @@ public class DmpServiceImpl implements DmpService { EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).disableTracking().authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).types(EntityType.DMP).entityIds(data.getId()); if (entityDoiQuery.count() > 0) throw new MyApplicationException("DMP is deposited can not deleted"); - DmpEntity previousFinalized = null; - if (data.getVersionStatus().equals(DmpVersionStatus.Current)){ + DmpEntity previousDmp = null; + if (!data.getVersionStatus().equals(DmpVersionStatus.Previous)){ DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class) - .statuses(DmpStatus.Finalized) .excludedIds(data.getId()) .isActive(IsActive.Active) .groupIds(data.getGroupId()); dmpQuery.setOrder(new Ordering().addDescending(Dmp._version)); - previousFinalized = dmpQuery.first(); - if (previousFinalized != null){ - previousFinalized.setVersionStatus(DmpVersionStatus.Current); - this.entityManager.merge(previousFinalized); + previousDmp = dmpQuery.first(); + if (previousDmp != null){ + if (previousDmp.getStatus().equals(DmpStatus.Finalized)) previousDmp.setVersionStatus(DmpVersionStatus.Current); + else previousDmp.setVersionStatus(DmpVersionStatus.NotFinalized); + this.entityManager.merge(previousDmp); } data.setVersionStatus(DmpVersionStatus.NotFinalized); this.entityManager.merge(data); @@ -355,7 +355,7 @@ public class DmpServiceImpl implements DmpService { } this.deleterFactory.deleter(DmpDeleter.class).deleteAndSaveByIds(List.of(id), false); - if (previousFinalized != null) this.elasticService.persistDmp(previousFinalized); + if (previousDmp != null) this.elasticService.persistDmp(previousDmp); this.annotationEntityRemovalIntegrationEventHandler.handleDmp(data.getId()); } 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 d663a7c9c..5fca4b832 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 @@ -409,7 +409,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { } onUpdateCallbackError(error) { - this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('DATASET-UPLOAD.SNACK-BAR.UNSUCCESSFUL'), SnackBarNotificationLevel.Error); + this.uiNotificationService.snackBarNotification(error.error.error ? error.error.error : this.language.instant('DATASET-UPLOAD.SNACK-BAR.UNSUCCESSFUL'), SnackBarNotificationLevel.Error); } downloadXml(id: string) {