Rev 1585 | Rev 1624 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1327 | jmachado | 1 | package pt.estgp.estgweb.services.questionarios.pedagogico; |
2 | |||
1333 | jmachado | 3 | import com.owlike.genson.TransformationException; |
1328 | jmachado | 4 | import org.apache.log4j.Logger; |
1327 | jmachado | 5 | import org.json.JSONArray; |
1328 | jmachado | 6 | import org.json.JSONException; |
1327 | jmachado | 7 | import pt.estgp.estgweb.domain.*; |
1328 | jmachado | 8 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
1333 | jmachado | 9 | import pt.estgp.estgweb.domain.dao.impl.CourseUnitDaoImpl; |
1327 | jmachado | 10 | import pt.estgp.estgweb.services.jobs.JobDeamon; |
11 | import pt.estgp.estgweb.services.jobs.ServiceJob; |
||
12 | import pt.estgp.estgweb.services.logresults.ILogMessages; |
||
1332 | jmachado | 13 | import pt.estgp.estgweb.services.logresults.LogMessageTypeEnum; |
14 | import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessage; |
||
1327 | jmachado | 15 | import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessages; |
1329 | jmachado | 16 | import pt.estgp.estgweb.services.questionarios.QuestionariosService; |
1336 | jmachado | 17 | import pt.estgp.estgweb.utils.ConfigProperties; |
1327 | jmachado | 18 | import pt.estgp.estgweb.web.exceptions.NotAuthorizedException; |
19 | import pt.utl.ist.berserk.logic.serviceManager.IService; |
||
20 | |||
1333 | jmachado | 21 | import java.io.IOException; |
22 | import java.util.*; |
||
1327 | jmachado | 23 | |
1328 | jmachado | 24 | |
1327 | jmachado | 25 | /** |
26 | * Created by jorgemachado on 22/03/16. |
||
27 | */ |
||
28 | public class UpdateCoursesAndUnitsJobService extends ServiceJob implements IService |
||
29 | { |
||
30 | |||
1328 | jmachado | 31 | public static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(UpdateCoursesAndUnitsJobService.class); |
32 | |||
1329 | jmachado | 33 | //return similar questionarios in same year, semestre and history category |
34 | public List<QuestionarioImpl> setAnoSemestre(1.5.0/docs/api/java/lang/String.html">String year, 1.5.0/docs/api/java/lang/String.html">String semestre, long questionarioId, UserSession userSession,QuestionarioImpl questionarioCleared) throws NotAuthorizedException |
||
35 | { |
||
36 | if(questionarioCleared.isClear((UserSessionImpl) userSession,QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_SET_ANO_SEMESTRE.name())) |
||
37 | { |
||
38 | questionarioCleared.setYear(year); |
||
39 | questionarioCleared.setSemestre(semestre); |
||
40 | questionarioCleared.setSubStatePedagogicoClass(QuestionarioImpl.SubStatePedagogico.YEAR_SEMESTRE_ASSIGNED); |
||
41 | List<QuestionarioImpl> similar = DaoFactory.getQuestionarioDaoImpl().findAnoSemestre(year, semestre, questionarioCleared.getQuestionarioHistoryDrive().getId()); |
||
42 | new QuestionariosService().loadInit(similar); |
||
43 | return similar; |
||
44 | } |
||
45 | else |
||
46 | throw new NotAuthorizedException("Não pode alterar o formulário porque o questionário está num estado avançado"); |
||
47 | } |
||
48 | |||
49 | |||
1328 | jmachado | 50 | public 1.5.0/docs/api/java/lang/String.html">String[] deserializeCoursesList(QuestionarioImpl questionario) |
51 | { |
||
52 | JobServiceTaskImpl job = questionario.getCourseSelectionTaskId() > 0 ? |
||
53 | (JobServiceTaskImpl) DaoFactory.getJobServiceTaskDaoImpl().load(questionario.getCourseSelectionTaskId()) : |
||
54 | null; |
||
55 | if(job == null) |
||
56 | return new 1.5.0/docs/api/java/lang/String.html">String[0]; |
||
57 | |||
58 | 1.5.0/docs/api/java/lang/String.html">String courses = job.getParameter(ServiceJob.JOB_questionario_courseList_KEY).getObject(); |
||
1332 | jmachado | 59 | return deserializeCoursesList(courses); |
60 | } |
||
1328 | jmachado | 61 | |
1332 | jmachado | 62 | public List<Course> getCoursesList(1.5.0/docs/api/java/lang/String.html">String coursesListJson) |
63 | { |
||
64 | List<Course> courses = new ArrayList<Course>(); |
||
65 | 1.5.0/docs/api/java/lang/String.html">String[] courseIds = deserializeCoursesList(coursesListJson); |
||
66 | for(1.5.0/docs/api/java/lang/String.html">String courseId: courseIds) |
||
67 | { |
||
68 | try |
||
69 | { |
||
70 | Course c = DaoFactory.getCourseDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(courseId)); |
||
71 | courses.add(c); |
||
72 | } |
||
73 | catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
74 | { |
||
75 | logger.info("Course not found in course list with id:" + courseId); |
||
76 | } |
||
77 | } |
||
78 | return courses; |
||
79 | } |
||
80 | |||
81 | public 1.5.0/docs/api/java/lang/String.html">String[] deserializeCoursesList(1.5.0/docs/api/java/lang/String.html">String json) |
||
82 | { |
||
1328 | jmachado | 83 | try { |
84 | |||
1332 | jmachado | 85 | JSONArray jsonArray = new JSONArray(json); |
1328 | jmachado | 86 | 1.5.0/docs/api/java/lang/String.html">String[] coursesList = new 1.5.0/docs/api/java/lang/String.html">String[jsonArray.length()]; |
87 | for(int i=0;i <jsonArray.length();i++) |
||
88 | { |
||
89 | coursesList[i] = ""+ jsonArray.get(i); |
||
90 | } |
||
91 | return coursesList; |
||
92 | } catch (JSONException e) { |
||
93 | logger.error(e,e); |
||
94 | } |
||
95 | return new 1.5.0/docs/api/java/lang/String.html">String[0]; |
||
96 | } |
||
1333 | jmachado | 97 | |
1404 | jmachado | 98 | /************* |
99 | * CRIAR O JOB PARA O RUNNER |
||
100 | * @param questionarioId |
||
101 | * @param coursesList |
||
102 | * @param session |
||
103 | * @param questionarioCleared |
||
104 | * @return |
||
105 | * @throws NotAuthorizedException |
||
106 | */ |
||
1327 | jmachado | 107 | public QuestionarioImpl runJobSelectCourses(long questionarioId,1.5.0/docs/api/java/lang/String.html">String[] coursesList,UserSession session,QuestionarioImpl questionarioCleared) throws NotAuthorizedException { |
108 | |||
109 | if(!questionarioCleared.isClear((UserSessionImpl) session,QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_SCHEDULLE_SELECT_COURSES.name())) |
||
110 | { |
||
111 | throw new NotAuthorizedException("Nao tem autorização para agendar atribuições de cursos"); |
||
112 | } |
||
1404 | jmachado | 113 | |
114 | /*******VERIFICACAO DE RESPOSTAS*********/ |
||
115 | long respostas = DaoFactory.getQuestionarioDaoImpl().getNumeroRespostas(questionarioId); |
||
116 | if(respostas == 0) |
||
117 | { |
||
118 | (questionarioCleared).setSubStatePedagogicoClass(QuestionarioImpl.SubStatePedagogico.ASSIGNING_COURSES); |
||
119 | } |
||
120 | else |
||
121 | { |
||
122 | logger.warn("Vai falhar no serviço, deixar falhar para visar o user"); |
||
123 | } |
||
124 | |||
1327 | jmachado | 125 | JSONArray jsonArray = new JSONArray(); |
126 | for(1.5.0/docs/api/java/lang/String.html">String sele: coursesList) |
||
127 | { |
||
128 | jsonArray.put(new 1.5.0/docs/api/java/lang/Long.html">Long(sele)); |
||
129 | } |
||
130 | |||
131 | Set<JobServiceTaskParameter> paramsJob = new HashSet<JobServiceTaskParameter>(); |
||
132 | |||
133 | JobServiceTaskParameterImpl paramJobL = DomainObjectFactory.createJobServiceTaskParameterImpl(); |
||
134 | paramJobL.setName(ServiceJob.JOB_questionario_courseList_KEY); |
||
135 | paramJobL.setDescription("lista de cursos a associar"); |
||
136 | paramJobL.setObject(jsonArray.toString()); |
||
137 | paramsJob.add(paramJobL); |
||
138 | |||
139 | |||
140 | JobServiceTaskParameterImpl paramJob = DomainObjectFactory.createJobServiceTaskParameterImpl(); |
||
141 | paramJob.setName(ServiceJob.JOB_questionario_id_KEY); |
||
142 | paramJob.setDescription("ID do questionário"); |
||
143 | paramJob.setObject("" + questionarioId); |
||
144 | paramsJob.add(paramJob); |
||
145 | |||
146 | JobServiceTask job = JobDeamon.createServiceJob(UpdateCoursesAndUnitsJobService.class, session.getUser(), paramsJob, |
||
147 | "Service: Atribuição de Cursos e Unidades a um questionário Pedagógico"); |
||
148 | questionarioCleared.setCourseSelectionTaskId(job.getId()); |
||
149 | return questionarioCleared; |
||
150 | } |
||
151 | |||
1332 | jmachado | 152 | |
1333 | jmachado | 153 | /** |
154 | * |
||
1336 | jmachado | 155 | * @param questionarioId |
156 | * @param session |
||
157 | * @param questionarioCleared |
||
158 | * @throws NotAuthorizedException |
||
159 | * |
||
160 | */ |
||
161 | public ILogMessages revertAllAssignments(long questionarioId, UserSession session,QuestionarioImpl questionarioCleared) throws NotAuthorizedException { |
||
162 | |||
163 | DefaultLogMessages logMessages = new DefaultLogMessages(); |
||
164 | if(!questionarioCleared.isClear((UserSessionImpl) session,QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_REVERT_ALL_ASSIGNEMENTS.name())) |
||
165 | { |
||
166 | throw new NotAuthorizedException("Nao tem autorização para agendar atribuições de cursos"); |
||
167 | } |
||
1404 | jmachado | 168 | long respostas = DaoFactory.getQuestionarioDaoImpl().getNumeroRespostas(questionarioId); |
169 | if(respostas > 0) |
||
170 | { |
||
171 | logMessages.addMessage(new DefaultLogMessage("error.questionario.com.respostas.nao.pode.efetuar.op", LogMessageTypeEnum.WARNING, |
||
172 | "Operação não permitida, Existem Respostas")); |
||
173 | logger.warn(logMessages.getLastMessage()); |
||
174 | serviceLogError(logMessages.getLastMessage()); |
||
175 | return logMessages; |
||
176 | } |
||
1336 | jmachado | 177 | for(QuestionarioPedagogicoCursoAfeto cu : DaoFactory.getQuestionarioPedagogicoCursoAfetoDaoImpl().find(questionarioId)) |
178 | { |
||
179 | int unidades = 0; |
||
180 | if(cu.getUnidadesAfetas() != null) |
||
181 | { |
||
182 | unidades = cu.getUnidadesAfetas().size(); |
||
183 | for(QuestionarioPedagogicoUnidadeCurricularAfeta unidadeCurricularAfeta: cu.getUnidadesAfetas()) |
||
184 | { |
||
1401 | jmachado | 185 | 1.5.0/docs/api/java/lang/String.html">String msg = "Reverting Unidade Curricular Afeta " + unidadeCurricularAfeta.getCodigoUnidade() + " - " + unidadeCurricularAfeta.getNome(); |
186 | logger.info(msg); |
||
187 | logMessages.addMessage(new DefaultLogMessage("questionario.courses.selection", LogMessageTypeEnum.WARNING,msg)); |
||
1336 | jmachado | 188 | if(unidadeCurricularAfeta.getTipologiasRequisitadas() != null && unidadeCurricularAfeta.getTipologiasRequisitadas().size() > 0) |
189 | { |
||
1401 | jmachado | 190 | msg = "A unidade " + unidadeCurricularAfeta.getCodigoUnidade() + " tem tipologias requisitadas que tem de ser removidas primeiro, iremos remover todas as tipologias e respostas candidatas associadas"; |
1336 | jmachado | 191 | logger.warn(msg); |
192 | logMessages.addMessage(new DefaultLogMessage("questionario.courses.selection", LogMessageTypeEnum.WARNING,msg)); |
||
193 | removeTipologiasERespostasCascade(unidadeCurricularAfeta); |
||
194 | } |
||
1401 | jmachado | 195 | unidadeCurricularAfeta.setCursoAfeto(null); |
196 | DaoFactory.getQuestionarioPedagogicoUnidadeCurricularAfetaDaoImpl().delete(unidadeCurricularAfeta); |
||
1336 | jmachado | 197 | } |
198 | } |
||
199 | 1.5.0/docs/api/java/lang/String.html">String msg = "Removendo curso afeto:" + cu.getNome() + " e " + unidades + " uniades afetas"; |
||
200 | logger.info(msg); |
||
201 | logMessages.addMessage(new DefaultLogMessage("questionario.courses.selection", LogMessageTypeEnum.INFO,msg)); |
||
202 | |||
203 | cu.setUnidadesAfetas(null); |
||
204 | DaoFactory.getQuestionarioPedagogicoCursoAfetoDaoImpl().delete(cu); |
||
205 | } |
||
206 | questionarioCleared.setSubStatePedagogicoClass(QuestionarioImpl.SubStatePedagogico.YEAR_SEMESTRE_ASSIGNED); |
||
207 | return logMessages; |
||
208 | } |
||
209 | |||
1387 | jmachado | 210 | |
1399 | jmachado | 211 | public static ILogMessages revertAllRespostasCandidatas(long questionarioId, ServiceJob serviceJob) throws NotAuthorizedException { |
1387 | jmachado | 212 | |
213 | DefaultLogMessages logMessages = new DefaultLogMessages(); |
||
1404 | jmachado | 214 | |
215 | long respostas = DaoFactory.getQuestionarioDaoImpl().getNumeroRespostas(questionarioId); |
||
216 | if(respostas > 0) |
||
217 | { |
||
218 | logMessages.addMessage(new DefaultLogMessage("error.questionario.com.respostas.nao.pode.efetuar.op", LogMessageTypeEnum.WARNING, |
||
219 | "Operação não permitida, Existem Respostas")); |
||
220 | logger.warn(logMessages.getLastMessage()); |
||
221 | serviceJob.serviceLogError(logMessages.getLastMessage()); |
||
222 | throw new NotAuthorizedException(logMessages.getLastMessage()); |
||
223 | } |
||
224 | |||
1387 | jmachado | 225 | 1.5.0/docs/api/java/lang/String.html">String msg = "Revertendo respostas candidatas do questionario " + questionarioId; |
1399 | jmachado | 226 | logger.info(msg); |
227 | serviceJob.serviceLogInfo(msg); |
||
1387 | jmachado | 228 | |
229 | for(QuestionarioPedagogicoCursoAfeto cu : DaoFactory.getQuestionarioPedagogicoCursoAfetoDaoImpl().find(questionarioId)) |
||
230 | { |
||
231 | msg = "Revertendo respostas do curso " + cu.getCodigoCurso() + " , iremos remover todas as tipologias e respostas candidatas associadas"; |
||
1399 | jmachado | 232 | logger.info(msg); |
233 | serviceJob.serviceLogInfo(msg); |
||
1394 | jmachado | 234 | ((QuestionarioPedagogicoCursoAfetoImpl)cu).resetAnswerStats(); |
1387 | jmachado | 235 | |
236 | int unidades = 0; |
||
237 | if(cu.getUnidadesAfetas() != null) |
||
238 | { |
||
239 | unidades = cu.getUnidadesAfetas().size(); |
||
240 | for(QuestionarioPedagogicoUnidadeCurricularAfeta unidadeCurricularAfeta: cu.getUnidadesAfetas()) |
||
241 | { |
||
1394 | jmachado | 242 | ((QuestionarioPedagogicoUnidadeCurricularAfetaImpl)unidadeCurricularAfeta).resetAnswerStats(); |
1387 | jmachado | 243 | logger.info("Reverting Respostas Unidade Curricular Afeta " + unidadeCurricularAfeta.getCodigoUnidade() + " - " + unidadeCurricularAfeta.getNome()); |
244 | if(unidadeCurricularAfeta.getTipologiasRequisitadas() != null && unidadeCurricularAfeta.getTipologiasRequisitadas().size() > 0) |
||
245 | { |
||
246 | msg = "A unidade " + unidadeCurricularAfeta.getCodigoUnidade() + " tem tipologias requisitadas que tem de ser removidas primeiro, iremos remover todas as tipologias e respostas candidatas associadas"; |
||
1399 | jmachado | 247 | logger.info(msg); |
248 | serviceJob.serviceLogWarn(msg); |
||
1387 | jmachado | 249 | logMessages.addMessage(new DefaultLogMessage("questionario.courses.selection", LogMessageTypeEnum.WARNING,msg)); |
250 | removeTipologiasERespostasCascade(unidadeCurricularAfeta); |
||
251 | } |
||
252 | } |
||
253 | } |
||
254 | logMessages.addMessage(new DefaultLogMessage("questionario.courses.selection", LogMessageTypeEnum.INFO,msg)); |
||
255 | } |
||
256 | return logMessages; |
||
257 | } |
||
258 | |||
1336 | jmachado | 259 | /** |
260 | * |
||
261 | */ |
||
1399 | jmachado | 262 | protected static void removeTipologiasERespostasCascade(QuestionarioPedagogicoUnidadeCurricularAfeta unidadeAfeta) |
1336 | jmachado | 263 | { |
264 | for(QuestionarioPedagogicoTipologiaRequisitada tr: unidadeAfeta.getTipologiasRequisitadas()) |
||
265 | { |
||
266 | logger.warn("deleting: " + tr); |
||
267 | if(tr.getAlunosRequisitados() != null) |
||
268 | { |
||
269 | for(QuestionarioPedagogicoAlunoRequisitado ar: tr.getAlunosRequisitados()) |
||
270 | { |
||
271 | logger.warn("deleting: " + ar); |
||
272 | if(ar.getRespostaRequisitada() != null) |
||
273 | { |
||
274 | logger.warn("deleting: Resposta Requisitada " + ar.getRespostaRequisitada().getId()); |
||
275 | if(ar.getRespostaRequisitada().getResposta() != null) |
||
276 | { |
||
277 | logger.warn("deleting resposta: " + ar.getRespostaRequisitada().getResposta()); |
||
278 | DaoFactory.getQuestionarioRespostaDaoImpl().delete(ar.getRespostaRequisitada().getResposta()); |
||
279 | ar.getRespostaRequisitada().setResposta(null); |
||
280 | } |
||
281 | DaoFactory.getQuestionarioRespostaRequisitadaDaoImplImpl().delete(ar.getRespostaRequisitada()); |
||
282 | ar.setRespostaRequisitada(null); |
||
283 | } |
||
284 | DaoFactory.getQuestionarioPedagogicoAlunoRequisitadoDaoImpl().delete(ar); |
||
285 | } |
||
286 | tr.setAlunosRequisitados(null); |
||
287 | } |
||
288 | DaoFactory.getQuestionarioPedagogicoTipologiaRequisitadaDaoImpl().delete(tr); |
||
289 | } |
||
290 | unidadeAfeta.setTipologiasRequisitadas(null); |
||
291 | } |
||
292 | |||
293 | /** |
||
294 | * |
||
1404 | jmachado | 295 | * ############# JOB TASK ############ |
296 | * ############# JOB TASK ############ |
||
1333 | jmachado | 297 | * @return |
298 | * @throws Throwable |
||
299 | */ |
||
1327 | jmachado | 300 | @1.5.0/docs/api/java/lang/Override.html">Override |
1329 | jmachado | 301 | protected ILogMessages runJobServiceTask() throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
302 | { |
||
1333 | jmachado | 303 | |
1332 | jmachado | 304 | DefaultLogMessages logMessages = new DefaultLogMessages(); |
1329 | jmachado | 305 | long questionarioId = 1.5.0/docs/api/java/lang/Long.html">Long.parseLong(getParametersMap().get(ServiceJob.JOB_questionario_id_KEY).getObject()); |
306 | QuestionarioImpl q = (QuestionarioImpl) DaoFactory.getQuestionarioDaoImpl().load(questionarioId); |
||
307 | |||
1404 | jmachado | 308 | /********VERIFICACAO DE RESPOSTAS***********/ |
309 | long respostas = DaoFactory.getQuestionarioDaoImpl().getNumeroRespostas(questionarioId); |
||
310 | if(respostas > 0) |
||
311 | { |
||
312 | logMessages.addMessage(new DefaultLogMessage("error.questionario.com.respostas.nao.pode.efetuar.op", LogMessageTypeEnum.WARNING, |
||
313 | "Operação não permitida, Existem Respostas")); |
||
314 | logger.warn(logMessages.getLastMessage()); |
||
315 | serviceLogError(logMessages.getLastMessage()); |
||
316 | throw new NotAuthorizedException("Nao tem autorização para agendar atribuições de cursos num questioário com respostas"); |
||
317 | } |
||
318 | |||
1585 | jmachado | 319 | //aqui sacamos os cursos seleccionados que sao serializados em JSON no Questionario e sao necessários como parametro ao serviço |
1332 | jmachado | 320 | 1.5.0/docs/api/java/lang/String.html">String[] coursesList = deserializeCoursesList(q); |
1329 | jmachado | 321 | //Colocamos já aqui o estado para nao se poder mudar o Ano e o Semestre |
322 | |||
1333 | jmachado | 323 | /**logging**/ |
324 | 1.5.0/docs/api/java/lang/String.html">String msg = "Starting running service for questionario: " + q.getId() + " - " + q.getiAnswersProcessorClass().getTitle(); |
||
325 | serviceLogInfo(msg); |
||
326 | logger.info(msg); |
||
327 | /**logging**/ |
||
1332 | jmachado | 328 | |
1399 | jmachado | 329 | revertAllRespostasCandidatas(questionarioId,this); |
1387 | jmachado | 330 | |
1333 | jmachado | 331 | List<String> newCourseCodesList = new ArrayList<String>(); |
1332 | jmachado | 332 | int count = 0; |
333 | int totalCourses = coursesList.length; |
||
334 | for(1.5.0/docs/api/java/lang/String.html">String courseStrId: coursesList) |
||
1328 | jmachado | 335 | { |
1332 | jmachado | 336 | count++; |
337 | try{ |
||
338 | 1.5.0/docs/api/java/lang/Long.html">Long courseLong = 1.5.0/docs/api/java/lang/Long.html">Long.parseLong(courseStrId); |
||
339 | /** logging **/ |
||
1333 | jmachado | 340 | msg = "Loading Course BACO ID: " + courseStrId; |
1332 | jmachado | 341 | serviceLogInfo(msg); |
342 | logger.info(msg); |
||
343 | /** logging **/ |
||
344 | |||
345 | Course c = DaoFactory.getCourseDaoImpl().load(courseLong); |
||
1333 | jmachado | 346 | newCourseCodesList.add(c.getCode()); |
1332 | jmachado | 347 | /** logging **/ |
348 | msg = "(" + count + " of " + totalCourses + ")-> Course loaded: " + c.getName() + "(" + c.getCode() + ")"; |
||
349 | serviceLogInfo(msg); |
||
350 | logger.info(msg); |
||
351 | /** logging **/ |
||
352 | |||
1333 | jmachado | 353 | createCursoAfeto(q, c, logMessages); |
1332 | jmachado | 354 | |
1333 | jmachado | 355 | /** COMMIT OPERATION **/ |
1332 | jmachado | 356 | setProgress((int)((((float)count)/((float)totalCourses))*100.0f)); |
357 | commitPartially(); |
||
1333 | jmachado | 358 | DaoFactory.getQuestionarioDaoImpl().update(q); |
359 | /** COMMIT OPERATION **/ |
||
1332 | jmachado | 360 | } |
361 | catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable t) |
||
362 | { |
||
363 | logger.error(t,t); |
||
364 | serviceLogError(t.toString(),t); |
||
365 | logMessages.addMessage(new DefaultLogMessage("questionario.courses.selection", LogMessageTypeEnum.ERROR,t.toString())); |
||
366 | } |
||
367 | |||
1328 | jmachado | 368 | } |
1333 | jmachado | 369 | |
370 | removeUnselectedCourses(q, newCourseCodesList); |
||
371 | |||
372 | /** COMMIT OPERATION **/ |
||
1328 | jmachado | 373 | setProgress(100); |
1332 | jmachado | 374 | commitPartially(); |
1333 | jmachado | 375 | DaoFactory.getQuestionarioDaoImpl().update(q); |
376 | /** COMMIT OPERATION **/ |
||
1328 | jmachado | 377 | |
1333 | jmachado | 378 | |
379 | msg = "Set courses state as " + QuestionarioImpl.SubStatePedagogico.COURSES_ASSIGNED.name(); |
||
1332 | jmachado | 380 | serviceLogInfo(msg); |
381 | logger.info(msg); |
||
1329 | jmachado | 382 | q.setSubStatePedagogicoClass(QuestionarioImpl.SubStatePedagogico.COURSES_ASSIGNED); |
383 | commitPartially(); |
||
1332 | jmachado | 384 | |
385 | return logMessages; |
||
1327 | jmachado | 386 | } |
1333 | jmachado | 387 | |
388 | /** |
||
389 | * |
||
390 | * @param q |
||
391 | * @param newCourseCodesList |
||
392 | */ |
||
393 | private void removeUnselectedCourses(QuestionarioImpl q, List<String> newCourseCodesList) { |
||
394 | /** logging **/ |
||
395 | 1.5.0/docs/api/java/lang/String.html">String msg = "Removing unselected courses "; |
||
396 | serviceLogInfo(msg); |
||
397 | logger.info(msg); |
||
398 | /** logging **/ |
||
399 | List<QuestionarioPedagogicoCursoAfeto> allCoursesInQuestionario = DaoFactory.getQuestionarioPedagogicoCursoAfetoDaoImpl().find(q.getId()); |
||
400 | for(QuestionarioPedagogicoCursoAfeto cursoAfeto: allCoursesInQuestionario) |
||
401 | { |
||
402 | if(!newCourseCodesList.contains(cursoAfeto.getCodigoCurso())) |
||
403 | { |
||
404 | removeCursoAfeto(cursoAfeto); |
||
405 | } |
||
406 | } |
||
407 | } |
||
408 | |||
409 | private void removeCursoAfeto(QuestionarioPedagogicoCursoAfeto cursoAfeto) { |
||
410 | 1.5.0/docs/api/java/lang/String.html">String msg; /** logging **/ |
||
411 | msg = "Deleting course: " + cursoAfeto.getCodigoCurso(); |
||
412 | serviceLogInfo(msg); |
||
413 | logger.info(msg); |
||
414 | /** logging **/ |
||
415 | for(QuestionarioPedagogicoUnidadeCurricularAfeta unidade: cursoAfeto.getUnidadesAfetas()) |
||
416 | { |
||
417 | /** logging **/ |
||
418 | msg = "--->Deleting unit from course: " + unidade.getCodigoUnidade(); |
||
419 | serviceLogInfo(msg); |
||
420 | logger.info(msg); |
||
421 | /** logging **/ |
||
422 | DaoFactory.getQuestionarioPedagogicoUnidadeCurricularAfetaDaoImpl().delete(unidade); |
||
423 | } |
||
424 | cursoAfeto.setUnidadesAfetas(null); |
||
425 | DaoFactory.getQuestionarioPedagogicoCursoAfetoDaoImpl().delete(cursoAfeto); |
||
426 | } |
||
427 | |||
1415 | jmachado | 428 | private void removeUnselectedUnits(QuestionarioPedagogicoCursoAfeto cursoAfetado, List<Long> newUnidadesCodesList) { |
1333 | jmachado | 429 | /** logging **/ |
430 | 1.5.0/docs/api/java/lang/String.html">String msg = "Removing unselected units from course: " + cursoAfetado.getCodigoCurso(); |
||
431 | serviceLogInfo(msg); |
||
432 | logger.info(msg); |
||
433 | /** logging **/ |
||
434 | Set<QuestionarioPedagogicoUnidadeCurricularAfeta> allUnidades = cursoAfetado.getUnidadesAfetas(); |
||
435 | for(QuestionarioPedagogicoUnidadeCurricularAfeta unidadeAfeta: allUnidades) |
||
436 | { |
||
1415 | jmachado | 437 | if(!newUnidadesCodesList.contains(unidadeAfeta.getCourseUnit().getId())) |
1333 | jmachado | 438 | { |
439 | /** logging **/ |
||
440 | msg = "--->Deleting unidade: " + unidadeAfeta.getCodigoUnidade(); |
||
441 | serviceLogInfo(msg); |
||
442 | logger.info(msg); |
||
443 | /** logging **/ |
||
444 | DaoFactory.getQuestionarioPedagogicoUnidadeCurricularAfetaDaoImpl().delete(unidadeAfeta); |
||
445 | } |
||
446 | } |
||
447 | } |
||
448 | |||
449 | |||
450 | /** |
||
451 | * |
||
452 | * @param q |
||
453 | * @param c |
||
454 | * @throws IOException |
||
455 | * @throws TransformationException |
||
456 | */ |
||
457 | private void createCursoAfeto(QuestionarioImpl q, Course c, DefaultLogMessages logMessages) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
||
458 | { |
||
459 | 1.5.0/docs/api/java/lang/String.html">String msg; |
||
460 | QuestionarioPedagogicoCursoAfetoImpl cursoAfeto = null; |
||
1585 | jmachado | 461 | //esta aqui um to_do mas foi revisto e nao aparenta haver problemas |
462 | // As unidades do curso sao carregadas mais abaixo e são adicionadas, |
||
463 | // Todas as não adicionadas são removidas seguidamente usando a lista de adicionadas. |
||
464 | // to_do antigo: fazer aqui um teste a ver se na lista de unidades found vem as unidades do curso afeto |
||
1335 | jmachado | 465 | //reativar o set e testar isso |
1585 | jmachado | 466 | |
467 | //isto serve para o caso do curso ter sido afeto mais que uma vez, tem de se remover as afetacoes e deixar apenas uma |
||
1333 | jmachado | 468 | List<QuestionarioPedagogicoCursoAfeto> cursosFound = DaoFactory.getQuestionarioPedagogicoCursoAfetoDaoImpl().find(q.getId(),c.getCode()); |
469 | if(cursosFound != null && cursosFound.size() > 1) |
||
470 | { |
||
471 | msg = "Encontrados mais que um curso nos mesmos códigos:" + c.getCode() + " apagando um"; |
||
472 | serviceLogWarn(msg); |
||
473 | logger.warn(msg); |
||
474 | logMessages.addMessage(new DefaultLogMessage("questionario.courses.selection", LogMessageTypeEnum.WARNING,msg)); |
||
475 | cursoAfeto = (QuestionarioPedagogicoCursoAfetoImpl) cursosFound.get(0); |
||
476 | cursosFound.remove(0); |
||
477 | for(QuestionarioPedagogicoCursoAfeto ca: cursosFound) |
||
478 | removeCursoAfeto(ca); |
||
479 | } |
||
480 | else if(cursosFound != null && cursosFound.size() == 1) |
||
481 | { |
||
482 | msg = "Curso " + c.getCode() + " encontrado, vai atualizar"; |
||
483 | serviceLogInfo(msg); |
||
484 | logger.info(msg); |
||
485 | cursoAfeto = (QuestionarioPedagogicoCursoAfetoImpl) cursosFound.get(0); |
||
486 | } |
||
487 | else |
||
488 | { |
||
489 | msg = "Criando novo curso para o código " + c.getCode(); |
||
490 | serviceLogInfo(msg); |
||
491 | logger.info(msg); |
||
492 | cursoAfeto = DomainObjectFactory.createQuestionarioPedagogicoCursoAfeto(); |
||
493 | DaoFactory.getQuestionarioPedagogicoCursoAfetoDaoImpl().save(cursoAfeto); |
||
1335 | jmachado | 494 | cursoAfeto.setUnidadesAfetas(new HashSet<QuestionarioPedagogicoUnidadeCurricularAfeta>()); |
1333 | jmachado | 495 | } |
496 | |||
497 | cursoAfeto.resetStats(); |
||
498 | |||
499 | cursoAfeto.setCourse(c); |
||
1336 | jmachado | 500 | cursoAfeto.setCodigoInstituicao(c.getInstitutionalCode()); |
501 | cursoAfeto.setNomeInstituicao(ConfigProperties.getProperty("institution.code."+c.getInstitutionalCode())); |
||
1333 | jmachado | 502 | cursoAfeto.setAno(q.getYear()); |
503 | cursoAfeto.setCodigoCurso(c.getCode()); |
||
504 | cursoAfeto.setNome(c.getName()); |
||
505 | cursoAfeto.setQuestionario(q); |
||
506 | cursoAfeto.setSemestre(q.getSemestre()); |
||
507 | |||
508 | |||
509 | |||
1335 | jmachado | 510 | |
1415 | jmachado | 511 | List<Long> newUnitCodesList = new ArrayList<Long>(); |
1333 | jmachado | 512 | int countUnits = 0; |
1585 | jmachado | 513 | //vai buscar todas as unidades da base de dados que fazem match as necessidades |
1333 | jmachado | 514 | List<CourseUnitDaoImpl.CourseUnitResult> results = DaoFactory.getCourseUnitDaoImpl().loadCourseUnits(c.getId(), q.getSemestre(), q.getYear()); |
515 | int totalUnits = results.size(); |
||
516 | for(CourseUnitDaoImpl.CourseUnitResult cur : results) |
||
517 | { |
||
518 | countUnits++; |
||
519 | CourseUnit cu = DaoFactory.getCourseUnitDaoImpl().load(cur.id); |
||
1415 | jmachado | 520 | newUnitCodesList.add(cu.getId()); |
1333 | jmachado | 521 | /** logging **/ |
522 | msg = "---->(" + countUnits + " of " + totalUnits +") CourseUnit loaded: " + cu.getName() + "(" + cu.getCode() + ")"; |
||
523 | serviceLogInfo(msg); |
||
524 | logger.info(msg); |
||
525 | /** logging **/ |
||
1585 | jmachado | 526 | //este metodo procura a unidade primeiro e apenas a cria se ela ainda nao existir como afeta |
1333 | jmachado | 527 | createUnidadeAfeta(cursoAfeto, cur,cu, logMessages); |
528 | DaoFactory.getCourseUnitDaoImpl().evict(cu); |
||
529 | } |
||
530 | |||
1585 | jmachado | 531 | //o problema poderia dar-se se uma unidade desaparece da base de dados, nesse caso ela já era afeta e o sistema nao a iria remover |
532 | //porque apesar de nao estar na nova lista de codigos, tb nao esta no curso afeto, mas o sistema |
||
533 | //o que faz é carregar todas as afetas e remover todas as que nao estejam na lista de novas |
||
1333 | jmachado | 534 | removeUnselectedUnits(cursoAfeto,newUnitCodesList); |
535 | } |
||
536 | |||
537 | /** |
||
538 | * |
||
539 | * @param cursoAfeto |
||
540 | * @param cur |
||
541 | * @throws IOException |
||
542 | * @throws TransformationException |
||
543 | */ |
||
544 | private void createUnidadeAfeta(QuestionarioPedagogicoCursoAfetoImpl cursoAfeto, CourseUnitDaoImpl.CourseUnitResult cur, CourseUnit cu, DefaultLogMessages logMessages) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException { |
||
545 | |||
546 | 1.5.0/docs/api/java/lang/String.html">String msg; |
||
547 | QuestionarioPedagogicoUnidadeCurricularAfetaImpl unidadeAfeta = null; |
||
1415 | jmachado | 548 | List<QuestionarioPedagogicoUnidadeCurricularAfeta> unidadesFound = DaoFactory.getQuestionarioPedagogicoUnidadeCurricularAfetaDaoImpl().find(cursoAfeto.getQuestionario().getId(), cursoAfeto.getCodigoCurso(), cu.getId()); |
1333 | jmachado | 549 | if(unidadesFound != null && unidadesFound.size() > 1) |
550 | { |
||
1415 | jmachado | 551 | msg = "Encontradas mais que uma unidade nos mesmos códigos: curso:" +cursoAfeto.getCodigoCurso() + ", unidade " + cu.getCode() + " com id sistema(" + cu.getId() + ") apagando um"; |
1333 | jmachado | 552 | serviceLogWarn(msg); |
553 | logger.warn(msg); |
||
554 | logMessages.addMessage(new DefaultLogMessage("questionario.courses.selection", LogMessageTypeEnum.WARNING,msg)); |
||
555 | unidadeAfeta = (QuestionarioPedagogicoUnidadeCurricularAfetaImpl) unidadesFound.get(0); |
||
556 | unidadesFound.remove(0); |
||
557 | DaoFactory.getQuestionarioPedagogicoUnidadeCurricularAfetaDaoImpl().delete(unidadesFound); |
||
558 | } |
||
559 | else if(unidadesFound != null && unidadesFound.size() == 1) |
||
560 | { |
||
561 | msg = "Unidade " + cu.getCode() + " encontrada, vai atualizar"; |
||
562 | serviceLogInfo(msg); |
||
563 | logger.info(msg); |
||
564 | unidadeAfeta = (QuestionarioPedagogicoUnidadeCurricularAfetaImpl) unidadesFound.get(0); |
||
565 | } |
||
566 | else |
||
567 | { |
||
568 | msg = "Criando nova unidade para o código " + cu.getCode(); |
||
569 | serviceLogInfo(msg); |
||
570 | logger.info(msg); |
||
571 | unidadeAfeta = DomainObjectFactory.createQuestionarioPedagogicoUnidadeCurricularAfeta(); |
||
1338 | jmachado | 572 | unidadeAfeta.setUsar(true); |
1572 | jmachado | 573 | unidadeAfeta.setUsarOlap(true); |
1338 | jmachado | 574 | unidadeAfeta.setVista(false); |
1333 | jmachado | 575 | DaoFactory.getQuestionarioPedagogicoUnidadeCurricularAfetaDaoImpl().save(unidadeAfeta); |
576 | } |
||
577 | |||
578 | unidadeAfeta.resetStats(); |
||
579 | unidadeAfeta.setCursoAfeto(cursoAfeto);//so metemos de um dos lados |
||
580 | unidadeAfeta.setCourseUnit(cu); |
||
581 | unidadeAfeta.setCodigoUnidade(cu.getCode()); |
||
1396 | jmachado | 582 | unidadeAfeta.addObs(""); |
1336 | jmachado | 583 | unidadeAfeta.setNome(cu.getName()); |
1333 | jmachado | 584 | |
585 | unidadeAfeta.setMarked(false); |
||
586 | |||
587 | ArrayList<CourseUnitImpl.Tipologia> mergedTipologias = copiarTipologias(cu, unidadeAfeta); |
||
588 | |||
589 | |||
590 | checkTurmaAndProfs(cu, unidadeAfeta, mergedTipologias); |
||
591 | checkProfs(cur, unidadeAfeta); |
||
592 | checkTurmas(cur, unidadeAfeta); |
||
593 | checkStudents(cur, unidadeAfeta); |
||
594 | |||
1338 | jmachado | 595 | |
1333 | jmachado | 596 | if(unidadeAfeta.isMarked()) |
597 | cursoAfeto.incMarcadas(); |
||
598 | |||
599 | |||
600 | } |
||
601 | |||
602 | /** |
||
603 | * |
||
604 | * @param cur |
||
605 | * @param unidadeAfeta |
||
606 | */ |
||
607 | private void checkTurmas(CourseUnitDaoImpl.CourseUnitResult cur, QuestionarioPedagogicoUnidadeCurricularAfetaImpl unidadeAfeta) { |
||
608 | if(cur.turmas == 0) |
||
609 | { |
||
610 | unidadeAfeta.setTurmas(0); |
||
611 | unidadeAfeta.setMarked(true); //WARNING |
||
612 | unidadeAfeta.addObs("Não tem turmas"); |
||
613 | } |
||
614 | else |
||
615 | unidadeAfeta.setTurmas(cur.turmas); |
||
616 | } |
||
617 | |||
618 | /** |
||
619 | * |
||
620 | * @param cur |
||
621 | * @param unidadeAfeta |
||
622 | */ |
||
623 | private void checkProfs(CourseUnitDaoImpl.CourseUnitResult cur, QuestionarioPedagogicoUnidadeCurricularAfetaImpl unidadeAfeta) { |
||
624 | if(cur.teachers == 0) |
||
625 | { |
||
626 | unidadeAfeta.setProfs(0); |
||
627 | unidadeAfeta.setMarked(true); //WARNING |
||
628 | unidadeAfeta.addObs("Não tem professores"); |
||
629 | } |
||
630 | else |
||
631 | unidadeAfeta.setProfs(cur.teachers); |
||
632 | } |
||
633 | |||
634 | /** |
||
635 | * |
||
636 | * @param cur |
||
637 | * @param unidadeAfeta |
||
638 | */ |
||
639 | private void checkStudents(CourseUnitDaoImpl.CourseUnitResult cur, QuestionarioPedagogicoUnidadeCurricularAfetaImpl unidadeAfeta) { |
||
640 | if(cur.students == 0) |
||
641 | { |
||
642 | unidadeAfeta.setStudents(0); |
||
643 | unidadeAfeta.setMarked(true); //WARNING |
||
644 | unidadeAfeta.addObs("Não tem estudantes"); |
||
645 | } |
||
646 | else |
||
647 | unidadeAfeta.setStudents(cur.students); |
||
648 | } |
||
649 | |||
650 | /** |
||
651 | * |
||
652 | * @param cu |
||
653 | * @param unidadeAfeta |
||
654 | * @return |
||
655 | * @throws IOException |
||
656 | * @throws TransformationException |
||
657 | */ |
||
658 | private ArrayList<CourseUnitImpl.Tipologia> copiarTipologias(CourseUnit cu, QuestionarioPedagogicoUnidadeCurricularAfetaImpl unidadeAfeta) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException { |
||
659 | try |
||
660 | { |
||
661 | CourseUnitImpl.Tipologias tipologias = ((CourseUnitImpl)cu).getTipologiasClass(); |
||
1623 | jmachado | 662 | //OBTEM-SE TODAS E DEPOIS QUANDO SE GERAREM AS RESPOSTAS VAO-SE OBTER ENTAO SIMPLES OU COMPLEXAS |
663 | if(cu.getCode().equals("100595")) |
||
664 | 1.5.0/docs/api/java/lang/System.html">System.out.println(); |
||
665 | |||
1333 | jmachado | 666 | ArrayList<CourseUnitImpl.Tipologia> mergedTipologias = tipologias.obtainMergeTipologias(); |
667 | unidadeAfeta.setTipologias(mergedTipologias.size()); |
||
668 | unidadeAfeta.setTipologiasJson(CourseUnitImpl.Tipologias.serializeMergedList(mergedTipologias)); |
||
669 | unidadeAfeta.setAddedTipologias(tipologias.getTipologiasExtraAdicionadas().size()); |
||
670 | return mergedTipologias; |
||
671 | } |
||
672 | catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
673 | { |
||
674 | ArrayList<CourseUnitImpl.Tipologia> tipologias = new ArrayList<CourseUnitImpl.Tipologia>(); |
||
675 | unidadeAfeta.setMarked(true); |
||
676 | unidadeAfeta.addObs("Erro a descodificar tipologias"); |
||
677 | unidadeAfeta.setTipologiasJson(CourseUnitImpl.Tipologias.serializeMergedList(tipologias)); |
||
678 | return tipologias; |
||
679 | } |
||
680 | } |
||
681 | |||
682 | /** |
||
683 | * |
||
684 | * @param cu |
||
685 | * @param unidadeAfeta |
||
686 | * @param mergedTipologias |
||
687 | */ |
||
688 | private void checkTurmaAndProfs(CourseUnit cu, QuestionarioPedagogicoUnidadeCurricularAfetaImpl unidadeAfeta, ArrayList<CourseUnitImpl.Tipologia> mergedTipologias) { |
||
689 | if(cu.getTeachers() != null) |
||
690 | { |
||
691 | HashMap<String,Boolean> turmaWithProfs = new HashMap<String, Boolean>(); |
||
692 | HashMap<String,Boolean> profsWithTurma = new HashMap<String, Boolean>(); |
||
693 | for(CourseUnitImpl.Tipologia t: mergedTipologias) |
||
694 | { |
||
695 | turmaWithProfs.put(t.getCdTurma(),true); |
||
696 | profsWithTurma.put(t.getCdDocente(),true); |
||
697 | } |
||
698 | for(Teacher t: cu.getTeachers()) |
||
699 | { |
||
700 | if(profsWithTurma.get(""+t.getSigesCode())==null) |
||
701 | { |
||
702 | unidadeAfeta.setProfsWithoutTurma(unidadeAfeta.getProfsWithoutTurma()+1); |
||
703 | unidadeAfeta.setMarked(true); |
||
704 | } |
||
705 | DaoFactory.getTeacherDaoImpl().evict(t); |
||
706 | } |
||
707 | |||
708 | for(CourseUnitTurma t: cu.getTurmas()) |
||
709 | { |
||
710 | if(turmaWithProfs.get(t.getTurma())==null) |
||
711 | { |
||
712 | unidadeAfeta.setTurmaWithoutProf(unidadeAfeta.getTurmaWithoutProf() + 1); |
||
713 | unidadeAfeta.setMarked(true); |
||
714 | } |
||
715 | DaoFactory.getCourseUnitTurmaDaoImpl().evict(t); |
||
716 | } |
||
717 | } |
||
718 | } |
||
1337 | jmachado | 719 | |
720 | |||
721 | /** |
||
722 | * SERVIÇO |
||
723 | * @param questionarioId |
||
724 | * @param cursosAfetos |
||
725 | * @param session |
||
726 | * @param questionarioCleared |
||
727 | * @throws IOException |
||
728 | * @throws TransformationException |
||
729 | * @throws NotAuthorizedException |
||
730 | */ |
||
731 | public void updateTipologiasPedagogico(long questionarioId, List<QuestionarioPedagogicoCursoAfeto> cursosAfetos, UserSession session,QuestionarioImpl questionarioCleared) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException, NotAuthorizedException { |
||
732 | |||
733 | if(!questionarioCleared.isClear((UserSessionImpl) session,QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_CHANGE_TIPOLOGIES.name())) |
||
734 | { |
||
735 | throw new NotAuthorizedException("Nao tem autorização para alterar as tipologias"); |
||
736 | } |
||
737 | for(QuestionarioPedagogicoCursoAfeto cursoAfeto: cursosAfetos) |
||
738 | { |
||
739 | QuestionarioPedagogicoCursoAfeto cuAfetoPersistent = DaoFactory.getQuestionarioPedagogicoCursoAfetoDaoImpl().load(cursoAfeto.getId()); |
||
740 | if(cuAfetoPersistent.getQuestionario().getId() == questionarioId) |
||
741 | { |
||
742 | cuAfetoPersistent.setUsarTipologias(cursoAfeto.isUsarTipologias()); |
||
743 | } |
||
744 | else |
||
745 | logger.warn("Curso pedido no serviço não faz parte do questionario requisitado: " + cursoAfeto.getId() + " " + cursoAfeto.getQuestionario().getId() + " != " + questionarioId); |
||
746 | |||
747 | } |
||
748 | |||
749 | } |
||
1338 | jmachado | 750 | |
751 | public void updateCheckVarPedagogico(long questionarioId,long unidadeAfetaId, 1.5.0/docs/api/java/lang/String.html">String op,1.5.0/docs/api/java/lang/String.html">String val,UserSession session, QuestionarioImpl questionarioCleared) throws NotAuthorizedException { |
||
752 | |||
1395 | jmachado | 753 | if(!questionarioCleared.isClear((UserSessionImpl) session,QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_CHANGE_ASSIGNEMENTS_USE_UNIT.name()) && |
754 | !questionarioCleared.isClear((UserSessionImpl) session,QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_CHANGE_ASSIGNEMENTS_CHECK_TEACHERS.name()) && |
||
1378 | jmachado | 755 | !questionarioCleared.isClear((UserSessionImpl) session,QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_CHANGE_ASSIGNEMENTS.name()) && |
756 | !questionarioCleared.isClear((UserSessionImpl) session,QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_CHANGE_TIPOLOGIES.name())) |
||
1338 | jmachado | 757 | { |
758 | throw new NotAuthorizedException("Nao tem autorização para alterar as tipologias"); |
||
759 | } |
||
760 | QuestionarioPedagogicoUnidadeCurricularAfetaImpl unidade = (QuestionarioPedagogicoUnidadeCurricularAfetaImpl) DaoFactory.getQuestionarioPedagogicoUnidadeCurricularAfetaDaoImpl().load(unidadeAfetaId); |
||
761 | if(op.equals("usar")) |
||
762 | { |
||
763 | unidade.setUsar(1.5.0/docs/api/java/lang/Boolean.html">Boolean.parseBoolean(val)); |
||
764 | } |
||
765 | else if(op.equals("vista")) |
||
766 | { |
||
767 | unidade.setVista(1.5.0/docs/api/java/lang/Boolean.html">Boolean.parseBoolean(val)); |
||
768 | } |
||
1378 | jmachado | 769 | else if(op.equals("vistaProfs")) |
770 | { |
||
771 | unidade.setVistaProfs(1.5.0/docs/api/java/lang/Boolean.html">Boolean.parseBoolean(val)); |
||
772 | } |
||
1338 | jmachado | 773 | else if(op.equals("observacoes")) |
774 | { |
||
775 | unidade.setObs(val); |
||
776 | } |
||
777 | } |
||
1378 | jmachado | 778 | |
1327 | jmachado | 779 | } |