RoleDataView.java
1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package fi.codecrew.moya.web.cdiview.user;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.model.ListDataModel;
import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.RoleBeanLocal;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@RequestScoped
public class RoleDataView extends GenericCDIView {
private static final long serialVersionUID = -5165373936500592099L;
@EJB
private transient RoleBeanLocal rolebean;
private transient ListDataModel<Role> roles;
private static final Logger logger = LoggerFactory.getLogger(RoleDataView.class);
public List<Role> getRoleList()
{
return rolebean.listRoles();
}
public ListDataModel<Role> getRoles() {
if (roles == null) {
roles = new ListDataModel<Role>(rolebean.listRoles());
}
return roles;
}
public boolean isRoleReadPermission()
{
return super.hasPermission(UserPermission.READ_ROLES);
}
public Role getNoSelection()
{
return Role.EMPTY_ROLE;
}
public ListDataModel<Role> getRolesWithEmpty() {
if (roles == null) {
List<Role> list = rolebean.listRoles();
list.add(0, Role.EMPTY_ROLE);
roles = new ListDataModel<Role>(list);
logger.info("rolecount {}", roles.getRowCount());
}
return roles;
}
public List<Role> getUserSelectableRoles() {
return rolebean.listUserSelectableRoles();
}
}