fix update other plan version status while deleting one plan
This commit is contained in:
parent
fb0a8b07be
commit
37a5c49cc8
|
@ -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());
|
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");
|
if (entityDoiQuery.count() > 0) throw new MyApplicationException("DMP is deposited can not deleted");
|
||||||
|
|
||||||
DmpEntity previousFinalized = null;
|
DmpEntity previousDmp = null;
|
||||||
if (data.getVersionStatus().equals(DmpVersionStatus.Current)){
|
if (!data.getVersionStatus().equals(DmpVersionStatus.Previous)){
|
||||||
DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class)
|
DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class)
|
||||||
.statuses(DmpStatus.Finalized)
|
|
||||||
.excludedIds(data.getId())
|
.excludedIds(data.getId())
|
||||||
.isActive(IsActive.Active)
|
.isActive(IsActive.Active)
|
||||||
.groupIds(data.getGroupId());
|
.groupIds(data.getGroupId());
|
||||||
|
|
||||||
dmpQuery.setOrder(new Ordering().addDescending(Dmp._version));
|
dmpQuery.setOrder(new Ordering().addDescending(Dmp._version));
|
||||||
previousFinalized = dmpQuery.first();
|
previousDmp = dmpQuery.first();
|
||||||
if (previousFinalized != null){
|
if (previousDmp != null){
|
||||||
previousFinalized.setVersionStatus(DmpVersionStatus.Current);
|
if (previousDmp.getStatus().equals(DmpStatus.Finalized)) previousDmp.setVersionStatus(DmpVersionStatus.Current);
|
||||||
this.entityManager.merge(previousFinalized);
|
else previousDmp.setVersionStatus(DmpVersionStatus.NotFinalized);
|
||||||
|
this.entityManager.merge(previousDmp);
|
||||||
}
|
}
|
||||||
data.setVersionStatus(DmpVersionStatus.NotFinalized);
|
data.setVersionStatus(DmpVersionStatus.NotFinalized);
|
||||||
this.entityManager.merge(data);
|
this.entityManager.merge(data);
|
||||||
|
@ -355,7 +355,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.deleterFactory.deleter(DmpDeleter.class).deleteAndSaveByIds(List.of(id), false);
|
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());
|
this.annotationEntityRemovalIntegrationEventHandler.handleDmp(data.getId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -409,7 +409,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdateCallbackError(error) {
|
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) {
|
downloadXml(id: string) {
|
||||||
|
|
Loading…
Reference in New Issue