Search in sources :

Example 1 with SystemRoleEntity

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));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) SystemRoleEntity(fi.otavanopisto.muikku.model.users.SystemRoleEntity)

Example 2 with SystemRoleEntity

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;
}
Also used : EnvironmentRoleEntity(fi.otavanopisto.muikku.model.users.EnvironmentRoleEntity) SystemRoleEntity(fi.otavanopisto.muikku.model.users.SystemRoleEntity) WorkspaceRoleEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity) SystemRoleEntity(fi.otavanopisto.muikku.model.users.SystemRoleEntity) RoleEntity(fi.otavanopisto.muikku.model.users.RoleEntity) EnvironmentRoleEntity(fi.otavanopisto.muikku.model.users.EnvironmentRoleEntity) WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) WorkspaceRoleEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity) Permission(fi.otavanopisto.muikku.model.security.Permission) RequestAction(org.ocpsoft.rewrite.annotation.RequestAction)

Example 3 with SystemRoleEntity

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);
}
Also used : SystemRoleEntity(fi.otavanopisto.muikku.model.users.SystemRoleEntity)

Example 4 with 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;
}
Also used : RoleEntity(fi.otavanopisto.muikku.model.users.RoleEntity) SystemRoleEntity(fi.otavanopisto.muikku.model.users.SystemRoleEntity) EnvironmentRoleEntity(fi.otavanopisto.muikku.model.users.EnvironmentRoleEntity) EnvironmentRoleEntity(fi.otavanopisto.muikku.model.users.EnvironmentRoleEntity) Permission(fi.otavanopisto.muikku.model.security.Permission) SystemRoleEntity(fi.otavanopisto.muikku.model.users.SystemRoleEntity) RequestAction(org.ocpsoft.rewrite.annotation.RequestAction)

Aggregations

SystemRoleEntity (fi.otavanopisto.muikku.model.users.SystemRoleEntity)4 Permission (fi.otavanopisto.muikku.model.security.Permission)2 EnvironmentRoleEntity (fi.otavanopisto.muikku.model.users.EnvironmentRoleEntity)2 RoleEntity (fi.otavanopisto.muikku.model.users.RoleEntity)2 RequestAction (org.ocpsoft.rewrite.annotation.RequestAction)2 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)1 WorkspaceRoleEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity)1 EntityManager (javax.persistence.EntityManager)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1