On user profile show only non-deleted and latest versions of associated DMPs

This commit is contained in:
George Kalampokis 2020-02-06 13:06:47 +02:00
parent 286f556bfc
commit a9b87a5b9f
1 changed files with 5 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package eu.eudat.logic.managers;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
import eu.eudat.data.dao.entities.UserInfoDao;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.UserInfo;
@ -64,7 +65,10 @@ public class UserManager {
eu.eudat.data.entities.UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId);
UserProfile profile = new UserProfile().fromDataModel(user);
List<Integer> roles = new LinkedList<>();
List<DMP> dmps = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable(), userId, roles).take(5).toList();
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
criteria.setAllVersions(false);
QueryableList<DMP> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria);
List<DMP> dmps = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(items, userId, roles).take(5).toList();
profile.setAssociatedDmps(dmps.stream().map(x -> new DataManagementPlan().fromDataModel(x)).collect(Collectors.toList()));
return profile;
}