Criteria crit = session.createCriteria(ProjectGroup.class)
.createCriteria("students").add( Restrictions.like("login", user.getLogin()) )
.createCriteria("project").add( Restrictions.like("id", project.getId()) );
List<ProjectGroup> grpAsStudent = crit.list();
for(int i = 0; i < grpAsStudent.size(); i++){
list.add(new ProjectRole(ProjectRole.AUTHORITY_STUDENT,grpAsStudent.get(i).getId(), null));
}
// We search the user in the project group as reporters
crit = session.createCriteria(ProjectGroup.class)
.createCriteria("reporters").add( Restrictions.like("login", user.getLogin()) )
.createCriteria("project").add( Restrictions.like("id", project.getId()));
List<ProjectGroup> grpAsReporter = crit.list();
for(int i = 0; i < grpAsReporter.size(); i++){
list.add(new ProjectRole(ProjectRole.AUTHORITY_REPORTER,grpAsReporter.get(i).getId(), null));
}
// We search the user in the project group as tutors
crit = session.createCriteria(ProjectCollection.class)
.createCriteria("tutors").add( Restrictions.like("login", user.getLogin()))
.createCriteria("project").add( Restrictions.like("id", project.getId()));
List<ProjectGroup> grpAsTutor = crit.list();
for(int i = 0; i < grpAsTutor.size(); i++){
list.add(new ProjectRole(ProjectRole.AUTHORITY_TUTOR, null, grpAsTutor.get(i).getId()));
}
return list;
}