|
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
|
| Line | |
|---|
| 1 | package service.impl;
|
|---|
| 2 |
|
|---|
| 3 | import DAO.impl.ProfessorSubjectDAOImpl;
|
|---|
| 4 | import model.Professor;
|
|---|
| 5 | import model.Subject;
|
|---|
| 6 | import service.ProfessorSubjectService;
|
|---|
| 7 | import java.sql.SQLException;
|
|---|
| 8 | import java.util.List;
|
|---|
| 9 |
|
|---|
| 10 | public class ProfessorSubjectServiceImpl implements ProfessorSubjectService {
|
|---|
| 11 |
|
|---|
| 12 | private final ProfessorSubjectDAOImpl dao = new ProfessorSubjectDAOImpl();
|
|---|
| 13 |
|
|---|
| 14 | @Override
|
|---|
| 15 | public void assignProfessorToSubject(Long professor_id, Long subject_id) throws SQLException {
|
|---|
| 16 | List<Subject> currentSubjects = dao.getSubjectsByProfessor(professor_id);
|
|---|
| 17 | for (Subject s : currentSubjects) {
|
|---|
| 18 | if (s.getId().equals(subject_id)) {
|
|---|
| 19 | return;
|
|---|
| 20 | }
|
|---|
| 21 | }
|
|---|
| 22 | dao.assign(professor_id, subject_id);
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | @Override
|
|---|
| 26 | public void removeProfessorFromSubject(Long professor_id, Long subject_id) throws SQLException {
|
|---|
| 27 | dao.remove(professor_id, subject_id);
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | @Override
|
|---|
| 31 | public List<Professor> getProfessorsForSubject(Long subject_id) throws SQLException {
|
|---|
| 32 | return dao.getProfessorsBySubject(subject_id);
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | @Override
|
|---|
| 36 | public List<Subject> getSubjectsForProfessor(Long professor_id) throws SQLException {
|
|---|
| 37 | return dao.getSubjectsByProfessor(professor_id);
|
|---|
| 38 | }
|
|---|
| 39 | } |
|---|
Note:
See
TracBrowser
for help on using the repository browser.