Fixes DMP invitation bug not properly saving the information.

This commit is contained in:
gkolokythas 2019-05-14 16:40:25 +03:00
parent aedc23a037
commit 0ee3299d79
2 changed files with 4 additions and 1 deletions

View File

@ -229,7 +229,7 @@ public class DataManagementPlanManager {
public eu.eudat.models.data.dmp.DataManagementPlan getSingle(String id, Principal principal, DynamicProjectConfiguration dynamicProjectConfiguration) throws InstantiationException, IllegalAccessException {
DMP dataManagementPlanEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
if (dataManagementPlanEntity.getCreator().getId() != principal.getId() && dataManagementPlanEntity.getUsers().stream().filter(userInfo -> userInfo.getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
if (dataManagementPlanEntity.getCreator().getId() != principal.getId() && dataManagementPlanEntity.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
throw new UnauthorisedException();
eu.eudat.models.data.dmp.DataManagementPlan datamanagementPlan = new eu.eudat.models.data.dmp.DataManagementPlan();
datamanagementPlan.fromDataModel(dataManagementPlanEntity);

View File

@ -58,7 +58,10 @@ public class InvitationsManager {
UserInfo invitedUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
UserDMP userDMP = new UserDMP();
userDMP.setUser(invitedUser);
userDMP.setDmp(invitation.getDmp());
userDMP.setRole(UserDMP.UserDMPRoles.USER.getValue());
DMP datamanagementPlan = invitation.getDmp();
apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(userDMP);
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), userDMP, datamanagementPlan);
invitation.setAcceptedInvitation(true);
apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao().createOrUpdate(invitation);