@Override public boolean check(UserContext user, Department source) { if (!permissionDepartment.check(user, source)) return false; if (source.getSolverGroup() != null) return false; int nrOffered = ((Number) DepartmentDAO.getInstance() .getSession() .createQuery( "select count(io) from CourseOffering co inner join co.instructionalOffering io " + "where co.subjectArea.department.uniqueId=:deptId and io.notOffered = 0") .setLong("deptId", source.getUniqueId()) .setCacheable(true) .uniqueResult()) .intValue(); return nrOffered == 0; }