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