|
Last change
on this file since 1eb7a55 was 1eb7a55, checked in by Elena Markovska <elena.elenamarkovska@…>, 11 days ago |
|
Initial commit - Scholaris project code
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Rev | Line | |
|---|
| [1eb7a55] | 1 | package service.impl;
|
|---|
| 2 |
|
|---|
| 3 | import DAO.impl.StudentSubjectDAOImpl;
|
|---|
| 4 | import model.StudentSubject;
|
|---|
| 5 | import java.sql.SQLException;
|
|---|
| 6 | import java.util.List;
|
|---|
| 7 |
|
|---|
| 8 | public class StudentSubjectServiceImpl {
|
|---|
| 9 | private final StudentSubjectDAOImpl dao = new StudentSubjectDAOImpl();
|
|---|
| 10 |
|
|---|
| 11 | public void enrollStudent(StudentSubject ss) throws SQLException {
|
|---|
| 12 | // Business Logic: New enrollments should always start with 0 absences
|
|---|
| 13 | ss.setAbsences_count(0);
|
|---|
| 14 | dao.save(ss);
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | public List<StudentSubject> getAllEnrollments() throws SQLException {
|
|---|
| 18 | return dao.getAll();
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | public void updateResult(StudentSubject ss) throws SQLException {
|
|---|
| 22 | // Business Validation: Ensure grade is valid before calling DB
|
|---|
| 23 | if (ss.getFinal_grade() != null) {
|
|---|
| 24 | if (ss.getFinal_grade() < 5 || ss.getFinal_grade() > 10) {
|
|---|
| 25 | throw new IllegalArgumentException("Grade must be between 5 and 10.");
|
|---|
| 26 | }
|
|---|
| 27 | }
|
|---|
| 28 | dao.update(ss);
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | public void removeEnrollment(Long ss_id) throws SQLException {
|
|---|
| 32 | dao.delete(ss_id);
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | public StudentSubject getEnrollment(Long ss_id) throws SQLException {
|
|---|
| 36 | return dao.getById(ss_id);
|
|---|
| 37 | }
|
|---|
| 38 | } |
|---|
Note:
See
TracBrowser
for help on using the repository browser.