use of fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent in project pyramus by otavanopisto.
the class GradingService method getCourseAssessmentByCourseStudentId.
public CourseAssessmentEntity getCourseAssessmentByCourseStudentId(@WebParam(name = "courseStudentId") Long courseStudentId) {
CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
CourseAssessmentDAO courseAssessmentDAO = DAOFactory.getInstance().getCourseAssessmentDAO();
CourseStudent courseStudent = courseStudentDAO.findById(courseStudentId);
CourseAssessment courseAssessment = courseAssessmentDAO.findLatestByCourseStudentAndArchived(courseStudent, Boolean.FALSE);
return EntityFactoryVault.buildFromDomainObject(courseAssessment);
}
use of fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent in project pyramus by otavanopisto.
the class BillingDetailsDAO method listByStudent.
public List<BillingDetails> listByStudent(Student student) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<BillingDetails> criteria = criteriaBuilder.createQuery(BillingDetails.class);
Root<CourseStudent> root = criteria.from(CourseStudent.class);
criteria.select(root.get(CourseStudent_.billingDetails));
criteria.where(criteriaBuilder.equal(root.get(CourseStudent_.student), student));
criteria.groupBy(root.get(CourseStudent_.billingDetails));
return entityManager.createQuery(criteria).getResultList();
}
use of fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent in project pyramus by otavanopisto.
the class StudentRESTService method listCourseStudents.
@Path("/students/{STUDENTID:[0-9]*}/courses")
@GET
@RESTPermit(StudentPermissions.LIST_COURSESTUDENTSBYSTUDENT)
public Response listCourseStudents(@PathParam("STUDENTID") Long studentId) {
Student student = studentController.findStudentById(studentId);
Status studentStatus = checkStudent(student);
if (studentStatus != Status.OK)
return Response.status(studentStatus).build();
List<fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent> courseStudents = courseController.listCourseStudentsByStudent(student);
if (courseStudents.isEmpty()) {
return Response.status(Status.NO_CONTENT).build();
}
List<fi.otavanopisto.pyramus.domainmodel.courses.Course> courses = new ArrayList<>();
for (fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent courseStudent : courseStudents) {
courses.add(courseStudent.getCourse());
}
return Response.status(Status.OK).entity(objectFactory.createModel(courses)).build();
}
use of fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent in project pyramus by otavanopisto.
the class StudentRESTService method getStudentStudyActivity.
@Path("/students/{STUDENTID:[0-9]*}/courseActivity")
@GET
@RESTPermit(handling = Handling.INLINE)
public Response getStudentStudyActivity(@PathParam("STUDENTID") Long studentId, @QueryParam("courseIds") String courseIds, @QueryParam("includeTransferCredits") boolean includeTransferCredits) {
// Access check
Student student = studentController.findStudentById(studentId);
if (student == null || student.getArchived()) {
return Response.status(Status.NOT_FOUND).build();
}
if (!restSecurity.hasPermission(new String[] { StudentPermissions.GET_STUDENT_COURSEACTIVITY, UserPermissions.USER_OWNER }, student, Style.OR)) {
return Response.status(Status.FORBIDDEN).build();
}
if (!sessionController.hasEnvironmentPermission(OrganizationPermissions.ACCESS_ALL_ORGANIZATIONS)) {
if (!UserUtils.isMemberOf(sessionController.getUser(), student.getOrganization())) {
return Response.status(Status.FORBIDDEN).build();
}
}
// Get courses of the student (all or those specified with courseIds)
List<CourseStudent> courseStudents;
if (StringUtils.isEmpty(courseIds)) {
courseStudents = courseController.listByStudent(student);
} else {
courseStudents = new ArrayList<>();
String[] courseIdArray = courseIds.split(",");
for (int i = 0; i < courseIdArray.length; i++) {
Course course = courseController.findCourseById(new Long(courseIdArray[i]));
if (course != null) {
CourseStudent courseStudent = courseController.findCourseStudentByCourseAndStudent(course, student);
if (courseStudent != null) {
courseStudents.add(courseStudent);
} else {
logger.warning(String.format("Course student not found asking activity for student %d in course %d", student.getId(), course.getId()));
}
}
}
}
// Serve data
List<CourseActivity> courseActivities = studentController.listCourseActivities(courseStudents, includeTransferCredits);
return Response.ok(courseActivities).build();
}
use of fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent in project pyramus by otavanopisto.
the class StudentRESTService method createCourseAssessmentRequest.
@Path("/students/{STUDENTID:[0-9]*}/courses/{COURSEID:[0-9]*}/assessmentRequests/")
@POST
@RESTPermit(handling = Handling.INLINE)
public Response createCourseAssessmentRequest(@PathParam("STUDENTID") Long studentId, @PathParam("COURSEID") Long courseId, fi.otavanopisto.pyramus.rest.model.CourseAssessmentRequest entity) {
if (entity == null) {
return Response.status(Status.BAD_REQUEST).build();
}
Student student = studentController.findStudentById(studentId);
Status studentStatus = checkStudent(student);
if (studentStatus != Status.OK)
return Response.status(studentStatus).build();
Course course = courseController.findCourseById(courseId);
if (course == null) {
return Response.status(Status.NOT_FOUND).entity("Could not find course").build();
}
if (course.getArchived()) {
return Response.status(Status.NOT_FOUND).entity("Course is archived").build();
}
if (!restSecurity.hasPermission(new String[] { CourseAssessmentPermissions.CREATE_COURSEASSESSMENTREQUEST, StudentPermissions.STUDENT_OWNER }, student, Style.OR)) {
return Response.status(Status.FORBIDDEN).build();
}
CourseStudent courseStudent = courseController.findCourseStudentById(entity.getCourseStudentId());
if (courseStudent == null) {
return Response.status(Status.BAD_REQUEST).entity("Could not find coursestudent").build();
}
if (courseStudent.getArchived()) {
return Response.status(Status.BAD_REQUEST).entity("Coursestudent is archived").build();
}
if (!courseStudent.getStudent().getId().equals(student.getId())) {
return Response.status(Status.BAD_REQUEST).entity("Coursestudent doesnt match student").build();
}
if (!courseStudent.getCourse().getId().equals(course.getId())) {
return Response.status(Status.BAD_REQUEST).entity("Coursestudent doesnt match course").build();
}
CourseAssessmentRequest courseAssessmentRequest = assessmentController.createCourseAssessmentRequest(courseStudent, Date.from(entity.getCreated().toInstant()), entity.getRequestText());
return Response.ok(objectFactory.createModel(courseAssessmentRequest)).build();
}
Aggregations