Rev 1656 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1584 | jmachado | 1 | package pt.estgp.estgweb.filters.filters; |
2 | |||
1585 | jmachado | 3 | import pt.estgp.estgweb.domain.*; |
1584 | jmachado | 4 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
5 | |||
1585 | jmachado | 6 | import java.util.List; |
7 | |||
1584 | jmachado | 8 | /** |
9 | * @author Jorge Machado |
||
10 | * @date 4/Jun/2008 |
||
11 | * @see pt.estgp.estgweb.filters.filters |
||
12 | */ |
||
1586 | jmachado | 13 | public class ResourceAccessControlQuestionariosReportDocenteFilter extends ResourceAccessControlQuestionariosReportBoardsPedagogicoFilter |
1584 | jmachado | 14 | { |
15 | public boolean canAccessResource(UserSession userSession, 1.5.0/docs/api/java/lang/String.html">String identifier) |
||
16 | { |
||
1586 | jmachado | 17 | |
1584 | jmachado | 18 | if(userSession.getUser() != null && userSession.getUser() instanceof Teacher) |
19 | { |
||
1658 | jmachado | 20 | Teacher teacherInSession = (Teacher) userSession.getUser(); |
1584 | jmachado | 21 | |
1658 | jmachado | 22 | |
1584 | jmachado | 23 | QuestionarioReportDocenteFile q = |
1585 | jmachado | 24 | DaoFactory.getQuestionarioReportDocenteFileDaoImpl().findByRepository(identifier); |
1584 | jmachado | 25 | |
1606 | jmachado | 26 | if(q == null) |
27 | return false; |
||
28 | |||
1658 | jmachado | 29 | Teacher tDocenteDesteQuestionario = DaoFactory.getTeacherDaoImpl().loadBySigesCode(1.5.0/docs/api/java/lang/Integer.html">Integer.parseInt(q.getEntityCode())); |
1586 | jmachado | 30 | QuestionarioReportFileGroup questionarioReportFileGroup = q.getReportGroup(); |
31 | QuestionarioReportFileGroupDocentesAno questionarioReportFileGroupDocentesAno = (QuestionarioReportFileGroupDocentesAno) DaoFactory.getQuestionarioReportFileGroupDaoImpl().narrow(questionarioReportFileGroup); |
||
1585 | jmachado | 32 | |
1586 | jmachado | 33 | //DOCENTE SO VE SE ESTIVER ATIVO |
1658 | jmachado | 34 | |
35 | if(q.isActive() && tDocenteDesteQuestionario.getSigesCode() == teacherInSession.getSigesCode()) |
||
1584 | jmachado | 36 | return true; |
1586 | jmachado | 37 | //BOARDS AND PEDAGOGICO |
1658 | jmachado | 38 | else if(super.canAccessResource(userSession, identifier)) |
1585 | jmachado | 39 | return true; |
1586 | jmachado | 40 | //PRESIDENTES DE ESCOLA SO VEEM SE ESTIVER ATIVO |
41 | else if(q.isActive()) |
||
1585 | jmachado | 42 | { |
1628 | jmachado | 43 | /* |
44 | DIRECAO DA ESCOLA SAI |
||
1585 | jmachado | 45 | //CHECK IF THERE IS ANY UNIT IN SCHOLL AND IF THIS USER IS FROM THE BOARD OF THAT SCHOOL |
46 | if(userSession.getUser().hasRole(Globals.ROLE_BOARD_SCHOOL_ESAE) || |
||
47 | userSession.getUser().hasRole(Globals.ROLE_BOARD_SCHOOL_ESAE) || |
||
48 | userSession.getUser().hasRole(Globals.ROLE_BOARD_SCHOOL_ESAE) || |
||
49 | userSession.getUser().hasRole(Globals.ROLE_BOARD_SCHOOL_ESAE)) |
||
50 | { |
||
51 | List <CourseUnit> courseUnitList = DaoFactory |
||
52 | .getCourseUnitDaoImpl() |
||
53 | .loadTeachedImportYearSemestreUnits(t.getId(), questionarioReportFileGroupDocentesAno.getImportYear()); |
||
54 | |||
55 | for(CourseUnit cu : courseUnitList) |
||
56 | { |
||
57 | String instituionCode = cu.getCourse().getInstitutionalCode(); |
||
58 | if(userSession.getUser().hasRole(Globals.ROLE_BOARD_SCHOOL(instituionCode))) |
||
59 | { |
||
60 | return true; |
||
61 | } |
||
62 | } |
||
63 | } |
||
1628 | jmachado | 64 | */ |
65 | |||
66 | |||
67 | //DEPARTAMENTO |
||
68 | //Carrega as unidades do Docente e confirma se alguma das unidades |
||
69 | //pertence a um departamento onde o user atual esteja ligado |
||
1658 | jmachado | 70 | List<CourseUnit> courseUnitListDoDocenteDoQuestionario = DaoFactory |
1628 | jmachado | 71 | .getCourseUnitDaoImpl() |
1658 | jmachado | 72 | .loadTeachedImportYearSemestreUnits(tDocenteDesteQuestionario.getId(), questionarioReportFileGroupDocentesAno.getImportYear()); |
1628 | jmachado | 73 | |
1658 | jmachado | 74 | for(CourseUnit cuDoDocenteDoQuestionario : courseUnitListDoDocenteDoQuestionario) |
1628 | jmachado | 75 | { |
1658 | jmachado | 76 | if(cuDoDocenteDoQuestionario.getCourse() != null) |
1656 | jmachado | 77 | { |
1658 | jmachado | 78 | CourseImpl courseDoDocenteDoQuestionario = (CourseImpl) DaoFactory.getCourseDaoImpl().narrow(cuDoDocenteDoQuestionario.getCourse()); |
79 | if(courseDoDocenteDoQuestionario.isFromCourseCommission(userSession)) |
||
1656 | jmachado | 80 | { |
81 | return true; |
||
82 | } |
||
83 | } |
||
1658 | jmachado | 84 | if(cuDoDocenteDoQuestionario.getCourse().getDepartment() != null) |
1628 | jmachado | 85 | { |
1658 | jmachado | 86 | if(cuDoDocenteDoQuestionario.getCourse().getDepartment().getBoardRole() != null) |
87 | if(userSession.getUser().hasRole(cuDoDocenteDoQuestionario.getCourse().getDepartment().getBoardRole())) |
||
1628 | jmachado | 88 | return true; |
89 | |||
1658 | jmachado | 90 | if(cuDoDocenteDoQuestionario.getCourse().getDepartment().getDirectorRole() != null) |
91 | if(userSession.getUser().hasRole(cuDoDocenteDoQuestionario.getCourse().getDepartment().getDirectorRole())) |
||
1628 | jmachado | 92 | return true; |
93 | } |
||
94 | |||
95 | } |
||
96 | |||
1585 | jmachado | 97 | } |
98 | |||
1584 | jmachado | 99 | return false; |
100 | |||
101 | } |
||
102 | return false; |
||
103 | } |
||
104 | } |