Search in sources :

Example 1 with WorkspaceRoleEntity

use of fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity in project muikku by otavanopisto.

the class WorkspaceRoleEntityDAO method create.

public WorkspaceRoleEntity create(WorkspaceRoleArchetype archetype, String name) {
    WorkspaceRoleEntity workspaceRoleEntity = new WorkspaceRoleEntity();
    workspaceRoleEntity.setArchetype(archetype);
    workspaceRoleEntity.setName(name);
    return persist(workspaceRoleEntity);
}
Also used : WorkspaceRoleEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity)

Example 2 with WorkspaceRoleEntity

use of fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity in project muikku by otavanopisto.

the class WorkspaceRoleEntityDAO method findByName.

public WorkspaceRoleEntity findByName(String roleName) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<WorkspaceRoleEntity> criteria = criteriaBuilder.createQuery(WorkspaceRoleEntity.class);
    Root<WorkspaceRoleEntity> root = criteria.from(WorkspaceRoleEntity.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.equal(root.get(WorkspaceRoleEntity_.name), roleName));
    return getSingleResult(entityManager.createQuery(criteria));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) WorkspaceRoleEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity)

Example 3 with WorkspaceRoleEntity

use of fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity in project muikku by otavanopisto.

the class WorkspaceUserEntityDAO method listByWorkspaceEntityAndRoleArchetypeAndActiveAndArchived.

public List<WorkspaceUserEntity> listByWorkspaceEntityAndRoleArchetypeAndActiveAndArchived(WorkspaceEntity workspaceEntity, WorkspaceRoleArchetype archetype, Boolean active, Boolean archived) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<WorkspaceUserEntity> criteria = criteriaBuilder.createQuery(WorkspaceUserEntity.class);
    Root<WorkspaceUserEntity> root = criteria.from(WorkspaceUserEntity.class);
    Join<WorkspaceUserEntity, WorkspaceRoleEntity> join = root.join(WorkspaceUserEntity_.workspaceUserRole);
    criteria.select(root);
    criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(WorkspaceUserEntity_.active), active), criteriaBuilder.equal(root.get(WorkspaceUserEntity_.archived), archived), criteriaBuilder.equal(root.get(WorkspaceUserEntity_.workspaceEntity), workspaceEntity), criteriaBuilder.equal(join.get(WorkspaceRoleEntity_.archetype), archetype)));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) WorkspaceRoleEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity)

Example 4 with WorkspaceRoleEntity

use of fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity in project muikku by otavanopisto.

the class WorkspaceUserEntityDAO method listByWorkspaceEntityAndRoleArchetypeAndArchived.

public List<WorkspaceUserEntity> listByWorkspaceEntityAndRoleArchetypeAndArchived(WorkspaceEntity workspaceEntity, WorkspaceRoleArchetype archetype, Boolean archived) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<WorkspaceUserEntity> criteria = criteriaBuilder.createQuery(WorkspaceUserEntity.class);
    Root<WorkspaceUserEntity> root = criteria.from(WorkspaceUserEntity.class);
    Join<WorkspaceUserEntity, WorkspaceRoleEntity> join = root.join(WorkspaceUserEntity_.workspaceUserRole);
    criteria.select(root);
    criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(WorkspaceUserEntity_.archived), archived), criteriaBuilder.equal(root.get(WorkspaceUserEntity_.workspaceEntity), workspaceEntity), criteriaBuilder.equal(join.get(WorkspaceRoleEntity_.archetype), archetype)));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) WorkspaceRoleEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity)

Example 5 with WorkspaceRoleEntity

use of fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity 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)

Aggregations

WorkspaceRoleEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity)17 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)6 RoleEntity (fi.otavanopisto.muikku.model.users.RoleEntity)5 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)5 UserSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier)4 EntityManager (javax.persistence.EntityManager)4 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)4 SchoolDataSource (fi.otavanopisto.muikku.model.base.SchoolDataSource)3 Permission (fi.otavanopisto.muikku.model.security.Permission)3 EnvironmentRoleEntity (fi.otavanopisto.muikku.model.users.EnvironmentRoleEntity)3 RoleSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier)3 WorkspaceRoleArchetype (fi.otavanopisto.muikku.model.workspace.WorkspaceRoleArchetype)3 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)3 ArrayList (java.util.ArrayList)3 RolePermission (fi.otavanopisto.muikku.model.security.RolePermission)2 EnvironmentRoleArchetype (fi.otavanopisto.muikku.model.users.EnvironmentRoleArchetype)2 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)2 MuikkuPermissionCollection (fi.otavanopisto.muikku.security.MuikkuPermissionCollection)2 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)2 Path (javax.ws.rs.Path)2