Search in sources :

Example 1 with RoleSchoolDataIdentifier

use of fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier in project muikku by otavanopisto.

the class RoleSchoolDataIdentifierDAO method findByDataSourceAndIdentifier.

public RoleSchoolDataIdentifier findByDataSourceAndIdentifier(SchoolDataSource dataSource, String identifier) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<RoleSchoolDataIdentifier> criteria = criteriaBuilder.createQuery(RoleSchoolDataIdentifier.class);
    Root<RoleSchoolDataIdentifier> root = criteria.from(RoleSchoolDataIdentifier.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(RoleSchoolDataIdentifier_.dataSource), dataSource), criteriaBuilder.equal(root.get(RoleSchoolDataIdentifier_.identifier), identifier)));
    return getSingleResult(entityManager.createQuery(criteria));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) RoleSchoolDataIdentifier(fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier) EntityManager(javax.persistence.EntityManager)

Example 2 with RoleSchoolDataIdentifier

use of fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier in project muikku by otavanopisto.

the class RoleSchoolDataIdentifierDAO method listByDataSource.

public List<RoleSchoolDataIdentifier> listByDataSource(SchoolDataSource schoolDataSource) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<RoleSchoolDataIdentifier> criteria = criteriaBuilder.createQuery(RoleSchoolDataIdentifier.class);
    Root<RoleSchoolDataIdentifier> root = criteria.from(RoleSchoolDataIdentifier.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.equal(root.get(RoleSchoolDataIdentifier_.dataSource), schoolDataSource));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) RoleSchoolDataIdentifier(fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier) EntityManager(javax.persistence.EntityManager)

Example 3 with RoleSchoolDataIdentifier

use of fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier in project muikku by otavanopisto.

the class RoleSchoolDataIdentifierDAO method findByDataSourceAndRoleEntity.

public RoleSchoolDataIdentifier findByDataSourceAndRoleEntity(SchoolDataSource dataSource, RoleEntity roleEntity) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<RoleSchoolDataIdentifier> criteria = criteriaBuilder.createQuery(RoleSchoolDataIdentifier.class);
    Root<RoleSchoolDataIdentifier> root = criteria.from(RoleSchoolDataIdentifier.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(RoleSchoolDataIdentifier_.dataSource), dataSource), criteriaBuilder.equal(root.get(RoleSchoolDataIdentifier_.roleEntity), roleEntity)));
    return getSingleResult(entityManager.createQuery(criteria));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) RoleSchoolDataIdentifier(fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier) EntityManager(javax.persistence.EntityManager)

Example 4 with RoleSchoolDataIdentifier

use of fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier in project muikku by otavanopisto.

the class WorkspaceRoleEntityController method findWorkspaceRoleEntityByDataSourceAndIdentifier.

public WorkspaceRoleEntity findWorkspaceRoleEntityByDataSourceAndIdentifier(String dataSource, String identifier) {
    SchoolDataSource schoolDataSource = schoolDataSourceDAO.findByIdentifier(dataSource);
    if (schoolDataSource == null) {
        logger.severe("Could not find datasource " + dataSource);
        return null;
    }
    RoleSchoolDataIdentifier roleIdentifier = roleSchoolDataIdentifierDAO.findByDataSourceAndIdentifier(schoolDataSource, identifier);
    if (roleIdentifier != null) {
        RoleEntity roleEntity = roleIdentifier.getRoleEntity();
        if (roleEntity != null && roleEntity.getType() == UserRoleType.WORKSPACE) {
            return (WorkspaceRoleEntity) roleEntity;
        }
    }
    return null;
}
Also used : WorkspaceRoleEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity) RoleEntity(fi.otavanopisto.muikku.model.users.RoleEntity) RoleSchoolDataIdentifier(fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier) SchoolDataSource(fi.otavanopisto.muikku.model.base.SchoolDataSource) WorkspaceRoleEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity)

Example 5 with RoleSchoolDataIdentifier

use of fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier in project muikku by otavanopisto.

the class EnvironmentRoleEntityController method findEnvironmentRoleEntity.

public EnvironmentRoleEntity findEnvironmentRoleEntity(String dataSource, String identifier) {
    SchoolDataSource schoolDataSource = schoolDataSourceDAO.findByIdentifier(dataSource);
    if (schoolDataSource == null) {
        logger.severe("Could not find datasource " + dataSource);
        return null;
    }
    RoleSchoolDataIdentifier roleIdentifier = roleSchoolDataIdentifierDAO.findByDataSourceAndIdentifier(schoolDataSource, identifier);
    if (roleIdentifier != null) {
        RoleEntity roleEntity = roleIdentifier.getRoleEntity();
        if (roleEntity != null && roleEntity.getType() == UserRoleType.ENVIRONMENT) {
            return (EnvironmentRoleEntity) roleEntity;
        }
    }
    return null;
}
Also used : RoleEntity(fi.otavanopisto.muikku.model.users.RoleEntity) EnvironmentRoleEntity(fi.otavanopisto.muikku.model.users.EnvironmentRoleEntity) RoleSchoolDataIdentifier(fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier) SchoolDataSource(fi.otavanopisto.muikku.model.base.SchoolDataSource) EnvironmentRoleEntity(fi.otavanopisto.muikku.model.users.EnvironmentRoleEntity)

Aggregations

RoleSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier)10 SchoolDataSource (fi.otavanopisto.muikku.model.base.SchoolDataSource)4 EntityManager (javax.persistence.EntityManager)4 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)4 RoleEntity (fi.otavanopisto.muikku.model.users.RoleEntity)3 WorkspaceRoleEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity)3 EnvironmentRoleEntity (fi.otavanopisto.muikku.model.users.EnvironmentRoleEntity)1 EnvironmentRole (fi.otavanopisto.muikku.schooldata.entity.EnvironmentRole)1 WorkspaceRole (fi.otavanopisto.muikku.schooldata.entity.WorkspaceRole)1 SchoolDataEnvironmentRoleDiscoveredEvent (fi.otavanopisto.muikku.schooldata.events.SchoolDataEnvironmentRoleDiscoveredEvent)1 SchoolDataEnvironmentRoleRemovedEvent (fi.otavanopisto.muikku.schooldata.events.SchoolDataEnvironmentRoleRemovedEvent)1 SchoolDataWorkspaceRoleDiscoveredEvent (fi.otavanopisto.muikku.schooldata.events.SchoolDataWorkspaceRoleDiscoveredEvent)1 SchoolDataWorkspaceRoleRemovedEvent (fi.otavanopisto.muikku.schooldata.events.SchoolDataWorkspaceRoleRemovedEvent)1 CourseStaffMemberRole (fi.otavanopisto.pyramus.rest.model.CourseStaffMemberRole)1 UserRole (fi.otavanopisto.pyramus.rest.model.UserRole)1 HashMap (java.util.HashMap)1