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