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;
|
|
|
|
|
import com.commafeed.frontend.utils.ModelFactory.MF;
|
2013-03-29 12:59:21 +01:00
|
|
|
import com.google.common.collect.Sets;
|
2013-03-28 17:07:37 +01:00
|
|
|
|
|
|
|
|
@SuppressWarnings("serial")
|
|
|
|
|
@Stateless
|
2013-03-30 11:37:57 +01:00
|
|
|
public class UserRoleService 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) {
|
|
|
|
|
return findByField(MF.i(MF.p(UserRole.class).getUser()), user);
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-29 12:59:21 +01:00
|
|
|
public Set<String> getRoles(User user) {
|
|
|
|
|
Set<String> list = Sets.newHashSet();
|
2013-03-28 17:07:37 +01:00
|
|
|
for (UserRole role : findByField(MF.i(proxy().getUser()), user)) {
|
|
|
|
|
list.add(role.getRole());
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
}
|