Rev 1606 | Rev 1656 | Go to most recent revision | 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 | { |
||
20 | Teacher t = (Teacher) userSession.getUser(); |
||
21 | int code = t.getSigesCode(); |
||
22 | |||
23 | QuestionarioReportDocenteFile q = |
||
1585 | jmachado | 24 | DaoFactory.getQuestionarioReportDocenteFileDaoImpl().findByRepository(identifier); |
1584 | jmachado | 25 | |
1606 | jmachado | 26 | if(q == null) |
27 | return false; |
||
28 | |||
1586 | jmachado | 29 | QuestionarioReportFileGroup questionarioReportFileGroup = q.getReportGroup(); |
30 | QuestionarioReportFileGroupDocentesAno questionarioReportFileGroupDocentesAno = (QuestionarioReportFileGroupDocentesAno) DaoFactory.getQuestionarioReportFileGroupDaoImpl().narrow(questionarioReportFileGroup); |
||
1585 | jmachado | 31 | |
1586 | jmachado | 32 | //DOCENTE SO VE SE ESTIVER ATIVO |
33 | if(q.isActive() && q.getEntityCode().equals(""+code)) |
||
1584 | jmachado | 34 | return true; |
1586 | jmachado | 35 | //BOARDS AND PEDAGOGICO |
36 | else if(super.canAccessResource(userSession,identifier)) |
||
1585 | jmachado | 37 | return true; |
1586 | jmachado | 38 | //PRESIDENTES DE ESCOLA SO VEEM SE ESTIVER ATIVO |
39 | else if(q.isActive()) |
||
1585 | jmachado | 40 | { |
1628 | jmachado | 41 | /* |
42 | DIRECAO DA ESCOLA SAI |
||
1585 | jmachado | 43 | //CHECK IF THERE IS ANY UNIT IN SCHOLL AND IF THIS USER IS FROM THE BOARD OF THAT SCHOOL |
44 | if(userSession.getUser().hasRole(Globals.ROLE_BOARD_SCHOOL_ESAE) || |
||
45 | userSession.getUser().hasRole(Globals.ROLE_BOARD_SCHOOL_ESAE) || |
||
46 | userSession.getUser().hasRole(Globals.ROLE_BOARD_SCHOOL_ESAE) || |
||
47 | userSession.getUser().hasRole(Globals.ROLE_BOARD_SCHOOL_ESAE)) |
||
48 | { |
||
49 | List <CourseUnit> courseUnitList = DaoFactory |
||
50 | .getCourseUnitDaoImpl() |
||
51 | .loadTeachedImportYearSemestreUnits(t.getId(), questionarioReportFileGroupDocentesAno.getImportYear()); |
||
52 | |||
53 | for(CourseUnit cu : courseUnitList) |
||
54 | { |
||
55 | String instituionCode = cu.getCourse().getInstitutionalCode(); |
||
56 | if(userSession.getUser().hasRole(Globals.ROLE_BOARD_SCHOOL(instituionCode))) |
||
57 | { |
||
58 | return true; |
||
59 | } |
||
60 | } |
||
61 | } |
||
1628 | jmachado | 62 | */ |
63 | |||
64 | |||
65 | //DEPARTAMENTO |
||
66 | //Carrega as unidades do Docente e confirma se alguma das unidades |
||
67 | //pertence a um departamento onde o user atual esteja ligado |
||
68 | List<CourseUnit> courseUnitList = DaoFactory |
||
69 | .getCourseUnitDaoImpl() |
||
70 | .loadTeachedImportYearSemestreUnits(t.getId(), questionarioReportFileGroupDocentesAno.getImportYear()); |
||
71 | |||
72 | for(CourseUnit cu : courseUnitList) |
||
73 | { |
||
74 | if(cu.getCourse().getDepartment() != null) |
||
75 | { |
||
76 | if(cu.getCourse().getDepartment().getBoardRole() != null) |
||
77 | if(userSession.getUser().hasRole(cu.getCourse().getDepartment().getBoardRole())) |
||
78 | return true; |
||
79 | |||
80 | if(cu.getCourse().getDepartment().getDirectorRole() != null) |
||
81 | if(userSession.getUser().hasRole(cu.getCourse().getDepartment().getDirectorRole())) |
||
82 | return true; |
||
83 | } |
||
84 | |||
85 | } |
||
86 | |||
1585 | jmachado | 87 | } |
88 | |||
1584 | jmachado | 89 | return false; |
90 | |||
91 | } |
||
92 | return false; |
||
93 | } |
||
94 | } |