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