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())))
|
.stream().map(x -> UUID.fromString(x.getId())).collect(Collectors.toList())))
|
||||||
.update(root -> root.<Integer>get("status"), Dataset.Status.FINALISED.getValue());
|
.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);
|
assignUser(newDmp, user, apiContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class QuickWizardManager {
|
||||||
eu.eudat.data.entities.Project projectEntity = project.toDataModel();
|
eu.eudat.data.entities.Project projectEntity = project.toDataModel();
|
||||||
projectEntity.setType(eu.eudat.data.entities.Project.ProjectType.INTERNAL.getValue());
|
projectEntity.setType(eu.eudat.data.entities.Project.ProjectType.INTERNAL.getValue());
|
||||||
projectEntity.setCreationUser(databaseRepository.getUserInfoDao().find(principal.getId()));
|
projectEntity.setCreationUser(databaseRepository.getUserInfoDao().find(principal.getId()));
|
||||||
Project projectEntityRet = databaseRepository.getProjectDao().createOrUpdate(projectEntity);
|
Project projectEntityRet = databaseRepository.getProjectDao().createOrUpdate(projectEntity);
|
||||||
return projectEntityRet;
|
return projectEntityRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,9 +44,18 @@ public class QuickWizardManager {
|
||||||
createProjectIfItDoesntExist(newDmp, user);
|
createProjectIfItDoesntExist(newDmp, user);
|
||||||
newDmp.setCreator(user);
|
newDmp.setCreator(user);
|
||||||
DMP dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
|
DMP dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
|
||||||
|
if (dataManagementPlan.getAssociatedUsers().size() == 0)
|
||||||
|
assignUser(newDmp, user, apiContext);
|
||||||
return dmpret;
|
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) {
|
private void createProjectIfItDoesntExist(DMP newDmp, UserInfo userInfo) {
|
||||||
if (newDmp.getProject() != null) {
|
if (newDmp.getProject() != null) {
|
||||||
|
@ -61,6 +70,4 @@ public class QuickWizardManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue