use of amu.zhcet.data.department.Department in project zhcet-web by zhcet-amu.
the class StudentRegistrationAdapter method fromStudentUpload.
private static Student fromStudentUpload(StudentUpload studentUpload) {
Student student = new Student();
student.setEnrolmentNumber(studentUpload.getEnrolmentNumber());
student.setFacultyNumber(studentUpload.getFacultyNumber());
student.getUser().setName(studentUpload.getName());
Department department = Department.builder().name(StringUtils.capitalizeFirst(studentUpload.getDepartment())).build();
student.getUser().setDepartment(department);
student.setSection(studentUpload.getSection());
student.setHallCode(studentUpload.getHall());
student.setRegistrationYear(studentUpload.getRegistrationYear());
student.setStatus(studentUpload.getStatus());
student.getUser().getDetails().setGender(studentUpload.getGender());
return student;
}
use of amu.zhcet.data.department.Department in project zhcet-web by zhcet-amu.
the class CoursesController method getCourses.
@GetMapping
public String getCourses(Model model, @PathVariable Department department, @RequestParam(value = "all", required = false) Boolean all) {
ErrorUtils.requireNonNullDepartment(department);
// Determine if only active courses have to be should
boolean active = !(all != null && all);
model.addAttribute("page_description", "View and manage courses for the Department");
model.addAttribute("department", department);
model.addAttribute("page_title", "Courses : " + department.getName() + " Department");
model.addAttribute("page_subtitle", "Course Management");
model.addAttribute("page_path", getPath(department));
model.addAttribute("all", !active);
List<FloatedCourse> floatedCourses = floatedCourseService.getCurrentFloatedCourses(department);
List<Course> courses = courseService.getAllActiveCourse(department, active);
// Add meta tag and no of registrations to each course
for (FloatedCourse floatedCourse : floatedCourses) {
Stream.of(floatedCourse).map(FloatedCourse::getCourse).map(courses::indexOf).filter(index -> index != -1).map(courses::get).findFirst().ifPresent(course -> {
course.setMeta("Floated");
course.setRegistrations(floatedCourse.getCourseRegistrations().size());
});
}
courses.sort(Comparator.comparing(Course::getCode));
model.addAttribute("courses", courses);
return "department/courses";
}
use of amu.zhcet.data.department.Department in project zhcet-web by zhcet-amu.
the class FacultyEditService method saveFacultyMember.
@Transactional
public void saveFacultyMember(FacultyMember facultyMember, FacultyEditModel facultyEditModel) {
String departmentName = facultyEditModel.getUserDepartmentName();
Department department = ModelEditUtils.verifyDepartment(departmentName, departmentService::findByName);
facultyEditModel.setUserEmail(ModelEditUtils.verifyNewEmail(facultyMember::getUser, facultyEditModel::getUserEmail, userService::checkDuplicateEmail));
facultyMember.getUser().setDepartment(department);
modelMapper.map(facultyEditModel, facultyMember);
facultyService.save(facultyMember);
}
use of amu.zhcet.data.department.Department in project zhcet-web by zhcet-amu.
the class StudentEditService method saveStudent.
@Transactional
public void saveStudent(Student student, StudentEditModel studentEditModel) {
Department department = ModelEditUtils.verifyDepartment(studentEditModel.getUserDepartmentName(), departmentService::findByName);
checkFacultyNumber(student, studentEditModel);
studentEditModel.setUserEmail(ModelEditUtils.verifyNewEmail(student::getUser, studentEditModel::getUserEmail, userService::checkDuplicateEmail));
checkHallCode(studentEditModel);
checkStatus(studentEditModel);
student.getUser().setDepartment(department);
modelMapper.map(studentEditModel, student);
studentService.save(student);
}
use of amu.zhcet.data.department.Department in project zhcet-web by zhcet-amu.
the class CourseEditController method postCourse.
@PostMapping("/edit")
public String postCourse(@PathVariable Course course, @ModelAttribute("course") @Valid Course newCourse, BindingResult result, RedirectAttributes redirectAttributes) {
ErrorUtils.requireNonNullCourse(course);
Department department = course.getDepartment();
if (result.hasErrors()) {
redirectAttributes.addFlashAttribute("course", newCourse);
redirectAttributes.addFlashAttribute("org.springframework.validation.BindingResult.course", result);
} else {
try {
newCourse.setDepartment(department);
courseService.updateCourse(course, newCourse);
redirectAttributes.addFlashAttribute("course_success", "Course saved successfully!");
} catch (UpdateException e) {
log.warn("Course Save Error", e);
newCourse.setCode(course.getCode());
redirectAttributes.addFlashAttribute("course", newCourse);
redirectAttributes.addFlashAttribute("course_errors", e.getMessage());
}
}
return "redirect:/admin/department/courses/{course}/edit";
}
Aggregations