From bca715d52becd63de88522d171ef434880d4afdd Mon Sep 17 00:00:00 2001 From: gkolokythas Date: Tue, 27 Aug 2019 17:00:09 +0300 Subject: [PATCH] Fixes bug on not storing Funder Id on Grant table. --- .../data/src/main/java/eu/eudat/data/entities/Funder.java | 6 ++++-- .../eudat/logic/managers/DataManagementPlanManager.java | 7 +++++-- .../models/data/dmp/DataManagementPlanEditorModel.java | 2 +- .../src/main/java/eu/eudat/models/data/grant/Grant.java | 2 +- .../main/java/eu/eudat/models/data/project/Project.java | 8 ++++---- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/entities/Funder.java b/dmp-backend/data/src/main/java/eu/eudat/data/entities/Funder.java index d66162494..2b6bce8b1 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/entities/Funder.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/entities/Funder.java @@ -154,10 +154,12 @@ public class Funder implements DataEntity { @Override public void update(Funder entity) { this.label = entity.getLabel(); - this.created = entity.getCreated(); + this.reference = entity.getReference(); this.definition = entity.getDefinition(); - this.modified = new Date(); this.status = entity.getStatus(); + this.created = entity.getCreated(); + this.modified = new Date(); + this.type = entity.getType(); } @Override 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 c9890d1c0..b52a44429 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 @@ -457,11 +457,14 @@ public class DataManagementPlanManager { if (newDmp.getGrant().getId() != null) { Grant grant = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().find(newDmp.getGrant().getId()); - if ( !grant.getFunder().getId().equals(newDmp.getGrant().getFunder().getId()) && !newDmp.getGrant().getCreationUser().getId().equals(user.getId())){ - throw new Exception("User is not the owner of the Grant therefore, cannot edit it"); + if (grant.getFunder() != null + && !grant.getFunder().getId().equals(newDmp.getGrant().getFunder().getId()) + && !grant.getCreationUser().getId().equals(user.getId())){ + throw new Exception("User is not the owner of the Grant, therefore, cannot edit it"); } } + apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant()); newDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp); // Dataset manipulation for when the DMP is set to be finalized. diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java index 30ac3a10a..a0d73dc83 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java @@ -293,7 +293,7 @@ public class DataManagementPlanEditorModel implements DataModel { entity.setStatus(this.status != null ? this.getStatus() : eu.eudat.data.entities.Grant.Status.ACTIVE.getValue()); entity.setModified(new Date()); entity.setDescription(this.description); - entity.setFunder(new Funder()); if (this.funderId != null) { + entity.setFunder(new Funder()); entity.getFunder().setId(this.funderId); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/project/Project.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/project/Project.java index 7b238e0db..61474faaa 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/project/Project.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/project/Project.java @@ -22,7 +22,7 @@ public class Project implements DataModel