Rev 1395 | Rev 1404 | 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 | |||
50 | public void initClearances(QuestionarioImpl q, UserSessionImpl usession, SimpleClearanceRuledSupport s) |
||
51 | { |
||
1346 | jmachado | 52 | if((usession.getUser().isSuperuserOrAdmin() |
53 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_ADMIN))) |
||
54 | { |
||
55 | if(q.getSubStatePedagodigoEnum() == QuestionarioImpl.SubStatePedagogico.START || |
||
56 | q.getSubStatePedagodigoEnum() == QuestionarioImpl.SubStatePedagogico.YEAR_SEMESTRE_ASSIGNED) |
||
57 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_SET_ANO_SEMESTRE.name(),usession); |
||
58 | } |
||
1379 | jmachado | 59 | |
60 | |||
1329 | jmachado | 61 | if(q.getSubStatePedagodigoEnum().getPosition() >= QuestionarioImpl.SubStatePedagogico.YEAR_SEMESTRE_ASSIGNED.getPosition() && |
62 | q.getSubStatePedagodigoEnum().getPosition() < QuestionarioImpl.SubStatePedagogico.FINNISHED_ANSWERS_GENERATING.getPosition()) |
||
63 | { |
||
64 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_SCHEDULLE_SEE_SELECT_COURSES.name(),usession); |
||
1346 | jmachado | 65 | |
66 | if((usession.getUser().isSuperuserOrAdmin() |
||
67 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_ADMIN))) |
||
1329 | jmachado | 68 | { |
1379 | jmachado | 69 | if(q.getCourseSelectionTaskId() <= 0 || q.getSubStatePedagodigoEnum().getPosition() == QuestionarioImpl.SubStatePedagogico.COURSES_ASSIGNED.getPosition()) |
1346 | jmachado | 70 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_SCHEDULLE_SELECT_COURSES.name(),usession); |
71 | else |
||
1329 | jmachado | 72 | { |
1346 | jmachado | 73 | JobServiceTask task = DaoFactory.getJobServiceTaskDaoImpl().load(q.getCourseSelectionTaskId()); |
74 | if(task.isExecuted() || (task.getSaveDate() != null && |
||
1379 | jmachado | 75 | 1.5.0/docs/api/java/lang/System.html">System.currentTimeMillis()-task.getSaveDate().getTime()>1800000)) //half hour blocked, 30 minutos |
1329 | jmachado | 76 | { |
1346 | jmachado | 77 | if(!task.isExecuted() && 1.5.0/docs/api/java/lang/System.html">System.currentTimeMillis()-task.getSaveDate().getTime()>1800000) |
78 | { |
||
79 | q.setSubStatePedagogicoClass(QuestionarioImpl.SubStatePedagogico.YEAR_SEMESTRE_ASSIGNED);//rolling back to year semestre assigned |
||
80 | } |
||
81 | task.setExecuted(true); |
||
82 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_SCHEDULLE_SELECT_COURSES.name(),usession); |
||
1329 | jmachado | 83 | } |
84 | } |
||
85 | } |
||
86 | } |
||
87 | |||
1379 | jmachado | 88 | |
89 | |||
1329 | jmachado | 90 | if(q.getSubStatePedagodigoEnum().getPosition() >= QuestionarioImpl.SubStatePedagogico.COURSES_ASSIGNED.getPosition() && |
91 | q.getSubStatePedagodigoEnum().getPosition() < QuestionarioImpl.SubStatePedagogico.FINNISHED_ANSWERS_GENERATING.getPosition()) |
||
92 | { |
||
1346 | jmachado | 93 | |
1387 | jmachado | 94 | |
1346 | jmachado | 95 | if((usession.getUser().isSuperuserOrAdmin() |
96 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_ADMIN)) |
||
97 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_TIPOLOGIAS_ADMIN)) |
||
98 | { |
||
99 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_CHANGE_TIPOLOGIES.name(),usession); |
||
100 | } |
||
101 | |||
102 | if((usession.getUser().isSuperuserOrAdmin() |
||
103 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_ADMIN)) |
||
1403 | jmachado | 104 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_ASSIGNEMENTS_CHECK_STUDENTS_ADMIN)) |
1346 | jmachado | 105 | { |
106 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_CHANGE_ASSIGNEMENTS.name(),usession); |
||
1403 | jmachado | 107 | //s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_CHANGE_ASSIGNEMENTS_USE_UNIT.name(),usession); |
1346 | jmachado | 108 | } |
109 | |||
110 | if((usession.getUser().isSuperuserOrAdmin() |
||
1378 | jmachado | 111 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_ADMIN)) |
112 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_ASSIGNEMENTS_CHECK_TEACHERS_ADMIN)) |
||
113 | { |
||
114 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_CHANGE_ASSIGNEMENTS_CHECK_TEACHERS.name(),usession); |
||
1395 | jmachado | 115 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_CHANGE_ASSIGNEMENTS_USE_UNIT.name(),usession); |
1378 | jmachado | 116 | } |
117 | |||
118 | if((usession.getUser().isSuperuserOrAdmin() |
||
1346 | jmachado | 119 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_ADMIN))) |
120 | { |
||
1379 | jmachado | 121 | |
1387 | jmachado | 122 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_SEE_START_ASSIGN_ANSWERS.name(),usession); |
1346 | jmachado | 123 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_REVERT_ALL_ASSIGNEMENTS.name(),usession); |
1379 | jmachado | 124 | |
125 | //ATRIBUIR RESPOSTAS MAS SO DEPOIS DE CURSOS ATRIBUIDOS |
||
126 | if(q.getAnswerGenerationTaskId() <= 0 || q.getSubStatePedagodigoEnum().getPosition() == QuestionarioImpl.SubStatePedagogico.ANSWERS_ASSIGNED.getPosition()) |
||
127 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_START_ASSIGN_ANSWERS.name(),usession); |
||
128 | else |
||
129 | { |
||
130 | JobServiceTask task = DaoFactory.getJobServiceTaskDaoImpl().load(q.getAnswerGenerationTaskId()); |
||
131 | if(task.isExecuted() || (task.getSaveDate() != null && |
||
132 | 1.5.0/docs/api/java/lang/System.html">System.currentTimeMillis()-task.getSaveDate().getTime()>1800000)) //half hour blocked, 30 minutos |
||
133 | { |
||
134 | if(!task.isExecuted() && 1.5.0/docs/api/java/lang/System.html">System.currentTimeMillis()-task.getSaveDate().getTime()>1800000) |
||
135 | { |
||
136 | q.setSubStatePedagogicoClass(QuestionarioImpl.SubStatePedagogico.COURSES_ASSIGNED);//rolling back to courses assigned |
||
137 | } |
||
138 | task.setExecuted(true); |
||
139 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_START_ASSIGN_ANSWERS.name(),usession); |
||
140 | } |
||
141 | } |
||
1346 | jmachado | 142 | } |
1329 | jmachado | 143 | } |
1379 | jmachado | 144 | |
145 | if(q.getSubStatePedagodigoEnum().getPosition() == QuestionarioImpl.SubStatePedagogico.ANSWERS_ASSIGNED.getPosition()) |
||
146 | { |
||
147 | if((usession.getUser().isSuperuserOrAdmin() |
||
148 | || usession.getUser().hasRole(Globals.QUESTIONARIOS_ADMIN))) |
||
149 | { |
||
150 | s.addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_FINNISH_ASSIGNEMENTS.name(),usession); |
||
151 | } |
||
152 | } |
||
153 | |||
1329 | jmachado | 154 | } |
1380 | jmachado | 155 | |
156 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
157 | public 1.5.0/docs/api/java/lang/Class.html">Class getJobServiceTaskAnswersProcessor() { |
||
158 | return AnswersAlunosProcessor.class; |
||
159 | } |
||
160 | |||
161 | |||
1325 | jmachado | 162 | } |