Fixes bugs on creating and updating DMPs releated to the user refactor.
This commit is contained in:
parent
6b13f191b0
commit
4b47ce75e1
|
@ -353,7 +353,7 @@ public class DataManagementPlanManager {
|
|||
.stream().map(x -> UUID.fromString(x.getId())).collect(Collectors.toList())))
|
||||
.update(root -> root.<Integer>get("status"), Dataset.Status.FINALISED.getValue());
|
||||
}
|
||||
if (dataManagementPlan.getAssociatedUsers().stream().filter(item -> item.getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
|
||||
if (dataManagementPlan.getAssociatedUsers().size() == 0)
|
||||
assignUser(newDmp, user, apiContext);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,9 +44,18 @@ public class QuickWizardManager {
|
|||
createProjectIfItDoesntExist(newDmp, user);
|
||||
newDmp.setCreator(user);
|
||||
DMP dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
|
||||
if (dataManagementPlan.getAssociatedUsers().size() == 0)
|
||||
assignUser(newDmp, user, apiContext);
|
||||
return dmpret;
|
||||
}
|
||||
|
||||
private void assignUser(DMP dmp, UserInfo userInfo, ApiContext apiContext) {
|
||||
UserDMP userDMP = new UserDMP();
|
||||
userDMP.setDmp(dmp);
|
||||
userDMP.setUser(userInfo);
|
||||
userDMP.setRole(UserDMP.UserDMPRoles.OWNER.getValue());
|
||||
apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(userDMP);
|
||||
}
|
||||
|
||||
private void createProjectIfItDoesntExist(DMP newDmp, UserInfo userInfo) {
|
||||
if (newDmp.getProject() != null) {
|
||||
|
@ -61,6 +70,4 @@ public class QuickWizardManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue