Search in sources :

Example 1 with Department

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;
}
Also used : Department(amu.zhcet.data.department.Department) Student(amu.zhcet.data.user.student.Student)

Example 2 with Department

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";
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) PathChain(amu.zhcet.common.page.PathChain) Department(amu.zhcet.data.department.Department) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Controller(org.springframework.stereotype.Controller) CourseService(amu.zhcet.data.course.CourseService) Course(amu.zhcet.data.course.Course) ErrorUtils(amu.zhcet.core.error.ErrorUtils) Slf4j(lombok.extern.slf4j.Slf4j) Model(org.springframework.ui.Model) List(java.util.List) FloatedCourse(amu.zhcet.data.course.floated.FloatedCourse) Stream(java.util.stream.Stream) Path(amu.zhcet.common.page.Path) GetMapping(org.springframework.web.bind.annotation.GetMapping) DepartmentController(amu.zhcet.core.admin.department.DepartmentController) Comparator(java.util.Comparator) FloatedCourseService(amu.zhcet.data.course.floated.FloatedCourseService) FloatedCourse(amu.zhcet.data.course.floated.FloatedCourse) Course(amu.zhcet.data.course.Course) FloatedCourse(amu.zhcet.data.course.floated.FloatedCourse) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 3 with Department

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);
}
Also used : Department(amu.zhcet.data.department.Department) Transactional(javax.transaction.Transactional)

Example 4 with Department

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);
}
Also used : Department(amu.zhcet.data.department.Department) Transactional(javax.transaction.Transactional)

Example 5 with Department

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";
}
Also used : Department(amu.zhcet.data.department.Department) UpdateException(amu.zhcet.common.error.UpdateException)

Aggregations

Department (amu.zhcet.data.department.Department)6 Transactional (javax.transaction.Transactional)2 UpdateException (amu.zhcet.common.error.UpdateException)1 Path (amu.zhcet.common.page.Path)1 PathChain (amu.zhcet.common.page.PathChain)1 DepartmentController (amu.zhcet.core.admin.department.DepartmentController)1 ErrorUtils (amu.zhcet.core.error.ErrorUtils)1 Course (amu.zhcet.data.course.Course)1 CourseService (amu.zhcet.data.course.CourseService)1 FloatedCourse (amu.zhcet.data.course.floated.FloatedCourse)1 FloatedCourseService (amu.zhcet.data.course.floated.FloatedCourseService)1 Student (amu.zhcet.data.user.student.Student)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Stream (java.util.stream.Stream)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Controller (org.springframework.stereotype.Controller)1 Model (org.springframework.ui.Model)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1