use of fi.otavanopisto.muikku.model.users.SystemRoleEntity in project muikku by otavanopisto.
the class SystemRoleEntityDAO method findByRoleType.
public SystemRoleEntity findByRoleType(SystemRoleType roleType) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<SystemRoleEntity> criteria = criteriaBuilder.createQuery(SystemRoleEntity.class);
Root<SystemRoleEntity> root = criteria.from(SystemRoleEntity.class);
criteria.select(root);
criteria.where(criteriaBuilder.equal(root.get(SystemRoleEntity_.roleType), roleType));
return getSingleResult(entityManager.createQuery(criteria));
}
use of fi.otavanopisto.muikku.model.users.SystemRoleEntity in project muikku by otavanopisto.
the class WorkspacePermissionsRoleManagementBackingBean method init.
@RequestAction
public String init() {
String urlName = getWorkspaceUrlName();
if (StringUtils.isBlank(urlName)) {
return NavigationRules.NOT_FOUND;
}
WorkspaceEntity workspaceEntity = workspaceController.findWorkspaceEntityByUrlName(urlName);
if (workspaceEntity == null) {
return NavigationRules.NOT_FOUND;
}
if (!sessionController.hasWorkspacePermission(MuikkuPermissions.WORKSPACE_MANAGEWORKSPACESETTINGS, workspaceEntity)) {
return NavigationRules.ACCESS_DENIED;
}
workspaceEntityId = workspaceEntity.getId();
workspaceBackingBean.setWorkspaceUrlName(urlName);
workspaceName = workspaceBackingBean.getWorkspaceName();
/**
* View data
*/
permissions = permissionController.listPermissionsByScope(PermissionScope.WORKSPACE);
Collections.sort(permissions, new Comparator<Permission>() {
@Override
public int compare(Permission o1, Permission o2) {
return o1.getName().compareTo(o2.getName());
}
});
roleEntities = new ArrayList<RoleEntity>();
List<SystemRoleEntity> systemRoleEntities = roleController.listSystemRoleEntities();
List<EnvironmentRoleEntity> environmentRoleEnties = roleController.listEnvironmentRoleEntities();
List<WorkspaceRoleEntity> workspaceRoleEntities = roleController.listWorkspaceRoleEntities();
Collections.sort(environmentRoleEnties, new Comparator<EnvironmentRoleEntity>() {
@Override
public int compare(EnvironmentRoleEntity o1, EnvironmentRoleEntity o2) {
return o1.getArchetype().compareTo(o2.getArchetype());
}
});
Collections.sort(workspaceRoleEntities, new Comparator<WorkspaceRoleEntity>() {
@Override
public int compare(WorkspaceRoleEntity o1, WorkspaceRoleEntity o2) {
return o1.getArchetype().compareTo(o2.getArchetype());
}
});
for (SystemRoleEntity systemRoleEntity : systemRoleEntities) {
roleEntities.add(systemRoleEntity);
}
for (EnvironmentRoleEntity environmentRoleEntity : environmentRoleEnties) {
roleEntities.add(environmentRoleEntity);
}
for (WorkspaceRoleEntity workspaceRoleEntity : workspaceRoleEntities) {
roleEntities.add(workspaceRoleEntity);
}
return null;
}
use of fi.otavanopisto.muikku.model.users.SystemRoleEntity in project muikku by otavanopisto.
the class SystemRoleEntityDAO method create.
public SystemRoleEntity create(String name, SystemRoleType roleType) {
SystemRoleEntity systemRoleEntity = new SystemRoleEntity();
systemRoleEntity.setName(name);
systemRoleEntity.setRoleType(roleType);
return persist(systemRoleEntity);
}
use of fi.otavanopisto.muikku.model.users.SystemRoleEntity in project muikku by otavanopisto.
the class EnvironmentPermissionsManagementBackingBean method init.
@RequestAction
public String init() {
if (!sessionController.hasEnvironmentPermission(MuikkuPermissions.MANAGE_PERMISSIONS)) {
return NavigationRules.ACCESS_DENIED;
}
permissions = permissionController.listPermissionsByScope(PermissionScope.ENVIRONMENT);
Collections.sort(permissions, new Comparator<Permission>() {
@Override
public int compare(Permission o1, Permission o2) {
return o1.getName().compareTo(o2.getName());
}
});
roleEntities = new ArrayList<RoleEntity>();
List<SystemRoleEntity> systemRoleEntities = roleController.listSystemRoleEntities();
List<EnvironmentRoleEntity> environmentRoleEntities = roleController.listEnvironmentRoleEntities();
Collections.sort(environmentRoleEntities, new Comparator<EnvironmentRoleEntity>() {
@Override
public int compare(EnvironmentRoleEntity o1, EnvironmentRoleEntity o2) {
return o1.getArchetype().compareTo(o2.getArchetype());
}
});
for (SystemRoleEntity systemRoleEntity : systemRoleEntities) {
roleEntities.add(systemRoleEntity);
}
for (EnvironmentRoleEntity environmentRoleEntity : environmentRoleEntities) {
roleEntities.add(environmentRoleEntity);
}
return null;
}
Aggregations