2013-03-28 17:07:37 +01:00
|
|
|
package com.commafeed.backend.dao;
|
|
|
|
|
|
2013-03-30 09:22:49 +01:00
|
|
|
import java.util.List;
|
2013-03-29 12:59:21 +01:00
|
|
|
import java.util.Set;
|
2013-03-28 17:07:37 +01:00
|
|
|
|
|
|
|
|
import javax.ejb.Stateless;
|
|
|
|
|
|
|
|
|
|
import com.commafeed.backend.model.User;
|
|
|
|
|
import com.commafeed.backend.model.UserRole;
|
2013-03-30 19:06:32 +01:00
|
|
|
import com.commafeed.backend.model.UserRole.Role;
|
2013-04-12 10:44:41 +02:00
|
|
|
import com.commafeed.backend.model.UserRole_;
|
2013-03-29 12:59:21 +01:00
|
|
|
import com.google.common.collect.Sets;
|
2013-03-28 17:07:37 +01:00
|
|
|
|
|
|
|
|
@Stateless
|
2013-04-11 20:49:08 +02:00
|
|
|
public class UserRoleDAO extends GenericDAO<UserRole> {
|
2013-03-28 17:07:37 +01:00
|
|
|
|
2013-03-30 09:22:49 +01:00
|
|
|
public List<UserRole> findAll(User user) {
|
2013-04-12 10:44:41 +02:00
|
|
|
return findByField(UserRole_.user, user);
|
2013-03-30 09:22:49 +01:00
|
|
|
}
|
|
|
|
|
|
2013-04-11 20:49:08 +02:00
|
|
|
public Set<Role> findRoles(User user) {
|
2013-03-30 19:06:32 +01:00
|
|
|
Set<Role> list = Sets.newHashSet();
|
2013-04-12 10:44:41 +02:00
|
|
|
for (UserRole role : findByField(UserRole_.user, user)) {
|
2013-03-28 17:07:37 +01:00
|
|
|
list.add(role.getRole());
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
}
|