Rev 1404 | Rev 1544 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1325 | jmachado | 1 | package pt.estgp.estgweb.services.questionarios; |
2 | |||
1346 | jmachado | 3 | import pt.estgp.estgweb.Globals; |
1325 | jmachado | 4 | import pt.estgp.estgweb.domain.IAnswersProcessor; |
1329 | jmachado | 5 | import pt.estgp.estgweb.domain.JobServiceTask; |
1328 | jmachado | 6 | import pt.estgp.estgweb.domain.QuestionarioImpl; |
1329 | jmachado | 7 | import pt.estgp.estgweb.domain.UserSessionImpl; |
8 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
||
9 | import pt.estgp.estgweb.domain.utils.SimpleClearanceRuledSupport; |
||
1380 | jmachado | 10 | import pt.estgp.estgweb.services.questionarios.pedagogico.AnswersAlunosProcessor; |
1328 | jmachado | 11 | import pt.estgp.estgweb.services.questionarios.pedagogico.UpdateCoursesAndUnitsJobService; |
1325 | jmachado | 12 | import pt.estgp.estgweb.utils.ConfigProperties; |
13 | |||
14 | /** |
||
15 | * Created by jorgemachado on 20/03/16. |
||
16 | */ |
||
17 | public class PedagogicoAlunosProcessor implements IAnswersProcessor |
||
18 | { |
||
19 | |||
20 | static 1.5.0/docs/api/java/lang/String.html">String title = ConfigProperties.getProperty("pt.estgp.estgweb.services.questionarios.PedagogicoAlunosProcessor.title"); |
||
1328 | jmachado | 21 | static 1.5.0/docs/api/java/lang/String.html">String jsp = ConfigProperties.getProperty("pt.estgp.estgweb.services.questionarios.PedagogicoAlunosProcessor.jsp"); |
1325 | jmachado | 22 | |
23 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
24 | public 1.5.0/docs/api/java/lang/String.html">String getHistoryDriveConstraint() { |
||
25 | return "QuestionarioAvaliacaoUnidadesCurricularesEstudantes"; |
||
26 | } |
||
27 | |||
28 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
29 | public 1.5.0/docs/api/java/lang/String.html">String getTitle() { |
||
30 | return title; |
||
31 | } |
||
32 | |||
33 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
34 | public 1.5.0/docs/api/java/lang/String.html">String getAfetacoesManagementForward() |
||
35 | { |
||
1328 | jmachado | 36 | return jsp; |
1325 | jmachado | 37 | } |
1328 | jmachado | 38 | |
39 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
40 | public void initQuestionarioAfetacoesVariables(QuestionarioImpl questionario) |
||
41 | { |
||
42 | questionario.setAfetacoesVarCoursesSelectionForJob(new UpdateCoursesAndUnitsJobService().deserializeCoursesList(questionario)); |
||
43 | } |
||
1329 | jmachado | 44 | |
45 | public void startAfetacoes(QuestionarioImpl questionario) |
||
46 | { |
||
47 | questionario.setSubStatePedagogicoClass(QuestionarioImpl.SubStatePedagogico.START); |
||
48 | } |
||
49 | |||
1409 | jmachado | 50 | |
51 | |||
1329 | jmachado | 52 | public void initClearances(QuestionarioImpl q, UserSessionImpl usession, SimpleClearanceRuledSupport s) |
53 | { |
||
1409 | jmachado | 54 | if(q.getStateEnum() == QuestionarioImpl.1.5.0/docs/api/org/omg/PortableServer/POAManagerPackage/State.html">State.ASSIGNATION_DETAILS) |
55 | assignationDetailsClearances(q, usession, s); |
||
56 | |||
57 | if(q.getStateEnum() == QuestionarioImpl.1.5.0/docs/api/org/omg/PortableServer/POAManagerPackage/State.html">State.STOPED_WITH_ANSWERS || q.getStateEnum() == QuestionarioImpl.1.5.0/docs/api/org/omg/PortableServer/POAManagerPackage/State.html">State.PROCESSING || q.getStateEnum() == QuestionarioImpl.1.5.0/docs/api/org/omg/PortableServer/POAManagerPackage/State.html">State.PROCESSING_WITH_ANSWERS) |
||
1346 | jmachado | 58 | { |
1409 | jmachado | 59 | if(usession.getUser().hasRole(Globals.ROLE_PRESIDENTE_CONCELHO_PEDAGOGICO)) |
60 | { |
||
61 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_SEE_DASHBOARD.name(),usession); |
||
62 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_SEE_FORM.name(),usession); |
||
63 | } |
||
1346 | jmachado | 64 | } |
1379 | jmachado | 65 | |
1409 | jmachado | 66 | } |
1379 | jmachado | 67 | |
1409 | jmachado | 68 | private void assignationDetailsClearances(QuestionarioImpl q, UserSessionImpl usession, SimpleClearanceRuledSupport s) { |
69 | if(q.getStateEnum() == QuestionarioImpl.1.5.0/docs/api/org/omg/PortableServer/POAManagerPackage/State.html">State.ASSIGNATION_DETAILS) |
||
1329 | jmachado | 70 | { |
1346 | jmachado | 71 | if((usession.getUser().isSuperuserOrAdmin() |
72 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_ADMIN))) |
||
1329 | jmachado | 73 | { |
1409 | jmachado | 74 | if(q.getSubStatePedagodigoEnum() == QuestionarioImpl.SubStatePedagogico.START || |
75 | q.getSubStatePedagodigoEnum() == QuestionarioImpl.SubStatePedagogico.YEAR_SEMESTRE_ASSIGNED) |
||
76 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_SET_ANO_SEMESTRE.name(),usession); |
||
77 | } |
||
78 | |||
79 | |||
80 | if(q.getSubStatePedagodigoEnum().getPosition() >= QuestionarioImpl.SubStatePedagogico.YEAR_SEMESTRE_ASSIGNED.getPosition() && |
||
81 | q.getSubStatePedagodigoEnum().getPosition() < QuestionarioImpl.SubStatePedagogico.FINNISHED_ANSWERS_GENERATING.getPosition()) |
||
82 | { |
||
83 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_SCHEDULLE_SEE_SELECT_COURSES.name(),usession); |
||
84 | |||
85 | if((usession.getUser().isSuperuserOrAdmin() |
||
86 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_ADMIN))) |
||
1329 | jmachado | 87 | { |
1409 | jmachado | 88 | if(q.getCourseSelectionTaskId() <= 0 || q.getSubStatePedagodigoEnum().getPosition() == QuestionarioImpl.SubStatePedagogico.COURSES_ASSIGNED.getPosition()) |
89 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_SCHEDULLE_SELECT_COURSES.name(),usession); |
||
90 | else |
||
1329 | jmachado | 91 | { |
1409 | jmachado | 92 | JobServiceTask task = DaoFactory.getJobServiceTaskDaoImpl().load(q.getCourseSelectionTaskId()); |
93 | if(task.isExecuted() || (task.getSaveDate() != null && |
||
94 | 1.5.0/docs/api/java/lang/System.html">System.currentTimeMillis()-task.getSaveDate().getTime()>1800000)) //half hour blocked, 30 minutos |
||
1346 | jmachado | 95 | { |
1409 | jmachado | 96 | if(!task.isExecuted() && 1.5.0/docs/api/java/lang/System.html">System.currentTimeMillis()-task.getSaveDate().getTime()>1800000) |
97 | { |
||
98 | q.setSubStatePedagogicoClass(QuestionarioImpl.SubStatePedagogico.YEAR_SEMESTRE_ASSIGNED);//rolling back to year semestre assigned |
||
99 | } |
||
100 | task.setExecuted(true); |
||
101 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_SCHEDULLE_SELECT_COURSES.name(),usession); |
||
1346 | jmachado | 102 | } |
1329 | jmachado | 103 | } |
104 | } |
||
105 | } |
||
106 | |||
1379 | jmachado | 107 | |
108 | |||
1409 | jmachado | 109 | if(q.getSubStatePedagodigoEnum().getPosition() >= QuestionarioImpl.SubStatePedagogico.COURSES_ASSIGNED.getPosition() && |
110 | q.getSubStatePedagodigoEnum().getPosition() < QuestionarioImpl.SubStatePedagogico.FINNISHED_ANSWERS_GENERATING.getPosition()) |
||
111 | { |
||
1346 | jmachado | 112 | |
1387 | jmachado | 113 | |
1409 | jmachado | 114 | if((usession.getUser().isSuperuserOrAdmin() |
115 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_ADMIN)) |
||
116 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_TIPOLOGIAS_ADMIN)) |
||
117 | { |
||
118 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_CHANGE_TIPOLOGIES.name(),usession); |
||
119 | } |
||
1346 | jmachado | 120 | |
1409 | jmachado | 121 | if((usession.getUser().isSuperuserOrAdmin() |
122 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_ADMIN)) |
||
123 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_ASSIGNEMENTS_CHECK_STUDENTS_ADMIN)) |
||
124 | { |
||
125 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_CHANGE_ASSIGNEMENTS.name(),usession); |
||
126 | //s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_CHANGE_ASSIGNEMENTS_USE_UNIT.name(),usession); |
||
127 | } |
||
1346 | jmachado | 128 | |
1409 | jmachado | 129 | if((usession.getUser().isSuperuserOrAdmin() |
130 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_ADMIN)) |
||
131 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_ASSIGNEMENTS_CHECK_TEACHERS_ADMIN)) |
||
132 | { |
||
133 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_CHANGE_ASSIGNEMENTS_CHECK_TEACHERS.name(),usession); |
||
134 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_CHANGE_ASSIGNEMENTS_USE_UNIT.name(),usession); |
||
135 | } |
||
1378 | jmachado | 136 | |
1409 | jmachado | 137 | if((usession.getUser().isSuperuserOrAdmin() |
138 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_ADMIN))) |
||
139 | { |
||
1379 | jmachado | 140 | |
1409 | jmachado | 141 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_SEE_START_ASSIGN_ANSWERS.name(),usession); |
142 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_REVERT_ALL_ASSIGNEMENTS.name(),usession); |
||
1379 | jmachado | 143 | |
1409 | jmachado | 144 | //ATRIBUIR RESPOSTAS MAS SO DEPOIS DE CURSOS ATRIBUIDOS |
145 | if(q.getAnswerGenerationTaskId() <= 0 || q.getSubStatePedagodigoEnum().getPosition() == QuestionarioImpl.SubStatePedagogico.ANSWERS_ASSIGNED.getPosition()) |
||
146 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_START_ASSIGN_ANSWERS.name(),usession); |
||
147 | else |
||
1379 | jmachado | 148 | { |
1409 | jmachado | 149 | JobServiceTask task = DaoFactory.getJobServiceTaskDaoImpl().load(q.getAnswerGenerationTaskId()); |
150 | if(task.isExecuted() || (task.getSaveDate() != null && |
||
151 | 1.5.0/docs/api/java/lang/System.html">System.currentTimeMillis()-task.getSaveDate().getTime()>1800000)) //half hour blocked, 30 minutos |
||
1379 | jmachado | 152 | { |
1409 | jmachado | 153 | if(!task.isExecuted() && 1.5.0/docs/api/java/lang/System.html">System.currentTimeMillis()-task.getSaveDate().getTime()>1800000) |
154 | { |
||
155 | q.setSubStatePedagogicoClass(QuestionarioImpl.SubStatePedagogico.COURSES_ASSIGNED);//rolling back to courses assigned |
||
156 | } |
||
157 | task.setExecuted(true); |
||
158 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_START_ASSIGN_ANSWERS.name(),usession); |
||
1379 | jmachado | 159 | } |
160 | } |
||
161 | } |
||
1346 | jmachado | 162 | } |
1379 | jmachado | 163 | |
1409 | jmachado | 164 | if(q.getSubStatePedagodigoEnum().getPosition() == QuestionarioImpl.SubStatePedagogico.ANSWERS_ASSIGNED.getPosition()) |
1379 | jmachado | 165 | { |
1409 | jmachado | 166 | if((usession.getUser().isSuperuserOrAdmin() |
167 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_ADMIN))) |
||
168 | { |
||
169 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_PUT_ANSWERS_ASSIGNED.name(),usession); |
||
170 | } |
||
1379 | jmachado | 171 | } |
172 | } |
||
1329 | jmachado | 173 | } |
1380 | jmachado | 174 | |
175 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
176 | public 1.5.0/docs/api/java/lang/Class.html">Class getJobServiceTaskAnswersProcessor() { |
||
177 | return AnswersAlunosProcessor.class; |
||
178 | } |
||
179 | |||
180 | |||
1325 | jmachado | 181 | } |