| [1eb7a55] | 1 | package service.impl;
|
|---|
| 2 |
|
|---|
| 3 | import DAO.impl.UniversityDAOImpl;
|
|---|
| 4 | import model.University;
|
|---|
| 5 | import service.UniversityService;
|
|---|
| 6 |
|
|---|
| 7 | import java.sql.SQLException;
|
|---|
| 8 | import java.util.List;
|
|---|
| 9 |
|
|---|
| 10 | public class UniversityServiceImpl implements UniversityService {
|
|---|
| 11 |
|
|---|
| 12 | UniversityDAOImpl universityDAO = new UniversityDAOImpl();
|
|---|
| 13 |
|
|---|
| 14 | @Override
|
|---|
| 15 | public List<University> getAllFaculty() throws SQLException {
|
|---|
| 16 | List<University> university = universityDAO.getAll();
|
|---|
| 17 | return university;
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | @Override
|
|---|
| 21 | public List<University> getAllUniversities() throws SQLException {
|
|---|
| 22 | return universityDAO.getAll();
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | @Override
|
|---|
| 26 | public University getById(Long id) throws SQLException {
|
|---|
| 27 | try {
|
|---|
| 28 | return universityDAO.getByID(id);
|
|---|
| 29 | } catch (SQLException e) {
|
|---|
| 30 | System.out.println("Error fetching university with ID " + id + ": " + e.getMessage());
|
|---|
| 31 | throw e;
|
|---|
| 32 | }
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | @Override
|
|---|
| 36 | public void update(University university) {
|
|---|
| 37 | try {
|
|---|
| 38 | universityDAO.update(university);
|
|---|
| 39 | System.out.println("Successfully updated university: " + university);
|
|---|
| 40 | } catch (SQLException e) {
|
|---|
| 41 | System.out.println("Error updating university: " + university + ". " + e.getMessage());
|
|---|
| 42 | throw new RuntimeException("Failed to update university", e);
|
|---|
| 43 | }
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | @Override
|
|---|
| 47 | public void delete(Long id) throws SQLException {
|
|---|
| 48 | universityDAO.delete(id);
|
|---|
| 49 | System.out.println("Successfully deleted university with ID: " + id);
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | @Override
|
|---|
| 53 | public void save(University university) {
|
|---|
| 54 | try {
|
|---|
| 55 | universityDAO.save(university);
|
|---|
| 56 | System.out.println("Successfully saved university: " + university);
|
|---|
| 57 | } catch (SQLException e) {
|
|---|
| 58 | System.out.println("Error saving university: " + university + ". " + e.getMessage());
|
|---|
| 59 | throw new RuntimeException("Failed to save university", e);
|
|---|
| 60 | }
|
|---|
| 61 | }
|
|---|
| 62 | }
|
|---|