Fixes bugs on creating and updating DMPs releated to the user refactor.

This commit is contained in:
gkolokythas 2019-05-17 13:19:30 +03:00
parent 6b13f191b0
commit 4b47ce75e1
2 changed files with 11 additions and 4 deletions

View File

@ -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);
}

View File

@ -34,7 +34,7 @@ public class QuickWizardManager {
eu.eudat.data.entities.Project projectEntity = project.toDataModel();
projectEntity.setType(eu.eudat.data.entities.Project.ProjectType.INTERNAL.getValue());
projectEntity.setCreationUser(databaseRepository.getUserInfoDao().find(principal.getId()));
Project projectEntityRet = databaseRepository.getProjectDao().createOrUpdate(projectEntity);
Project projectEntityRet = databaseRepository.getProjectDao().createOrUpdate(projectEntity);
return projectEntityRet;
}
@ -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 {
}
}
}
}