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);
}
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));
}
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();
}
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();
}
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;
}
Aggregations