Fixes bug where one could edit Finalized DMP.

This commit is contained in:
gkolokythas 2019-06-21 17:47:06 +03:00
parent ab63ea34d1
commit b2a407d90e
1 changed files with 5 additions and 2 deletions

View File

@ -397,6 +397,11 @@ public class DataManagementPlanManager {
public void createOrUpdate(ApiContext apiContext, DataManagementPlanEditorModel dataManagementPlan, Principal principal) throws Exception {
DMP dmp1 = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(dataManagementPlan.getId());
if (dmp1.getStatus().equals(DMP.DMPStatus.FINALISED.getValue())) {
throw new Exception("DMP is finalized, therefore cannot be edited.");
}
DMP newDmp = dataManagementPlan.toDataModel();
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
@ -406,8 +411,6 @@ public class DataManagementPlanManager {
try {
DMP dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(dataManagementPlan.getId());
if (dmp.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()))
newDmp.setStatus(DMP.DMPStatus.FINALISED.getValue());
newDmp.setCreated(dmp.getCreated());
if (dmp.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId())
.collect(Collectors.toList()).size() == 0) {