source: src/main/java/service/impl/UniversityServiceImpl.java@ 1eb7a55

Last change on this file since 1eb7a55 was 1eb7a55, checked in by Elena Markovska <elena.elenamarkovska@…>, 12 days ago

Initial commit - Scholaris project code

  • Property mode set to 100644
File size: 1.9 KB
RevLine 
[1eb7a55]1package service.impl;
2
3import DAO.impl.UniversityDAOImpl;
4import model.University;
5import service.UniversityService;
6
7import java.sql.SQLException;
8import java.util.List;
9
10public 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}
Note: See TracBrowser for help on using the repository browser.