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 004505fea..81e706cf8 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 @@ -84,6 +84,7 @@ import java.io.*; import java.math.BigInteger; import java.nio.file.Files; import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; @@ -359,7 +360,7 @@ public class DataManagementPlanManager { if (!isUserOwnerOfDmp(dmp1, principal)) { throw new Exception("User not being the creator is not authorized to edit this DMP."); } - if (dmp1.getModified().getTime() != dataManagementPlan.getModified().getTime()) { + if (Instant.ofEpochMilli(dmp1.getModified().getTime()).truncatedTo(ChronoUnit.SECONDS).toEpochMilli() != Instant.ofEpochMilli(dataManagementPlan.getModified().getTime()).truncatedTo(ChronoUnit.SECONDS).toEpochMilli()) { throw new Exception("Another user have already edit that DMP."); } List datasetList = new ArrayList<>(dmp1.getDataset()); @@ -481,7 +482,7 @@ public class DataManagementPlanManager { if (!isUserOwnerOfDmp(dmp1, principal)) { throw new Exception("User not being the creator is not authorized to edit this DMP."); } - if (dmp1.getModified().getTime() != dataManagementPlan.getModified().getTime()) { + if (Instant.ofEpochMilli(dmp1.getModified().getTime()).truncatedTo(ChronoUnit.SECONDS).toEpochMilli() != Instant.ofEpochMilli(dataManagementPlan.getModified().getTime()).truncatedTo(ChronoUnit.SECONDS).toEpochMilli()) { throw new Exception("Another user have already edit that DMP."); } for (DatasetWizardModel dataset : dataManagementPlan.getDatasets()) { diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts index 9caaa9a08..b9bbba867 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts @@ -33,7 +33,7 @@ import { ValidationErrorModel } from '@common/forms/validation/error-model/valid import { TranslateService } from '@ngx-translate/core'; import * as FileSaver from 'file-saver'; import { Observable, of as observableOf, interval } from 'rxjs'; -import { map, takeUntil } from 'rxjs/operators'; +import { delay, map, takeUntil } from 'rxjs/operators'; import { Principal } from "@app/core/model/auth/principal"; import { Role } from "@app/core/common/enum/role"; import { LockService } from '@app/core/services/lock/lock.service'; @@ -439,6 +439,8 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC .pipe(takeUntil(this._destroyed)) .subscribe( complete => { + this.formGroup.get('id').setValue(complete.id); + this.formGroup.get('modified').setValue(complete.modified); if (showAddDatasetDialog) { this.addDatasetOpenDialog(complete); } @@ -510,8 +512,8 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC onCallbackSuccessAddNew(dmp?: DmpModel) { // this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/datasets', 'new', dmp.id]); - // this.editDataset(dmp.id, true); + // this.router.navigate(['/datasets', 'new', dmp.id]); + this.editDataset(dmp.id, true); } public setErrorModel(validationErrorModel: ValidationErrorModel) {