Rev 1380 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1380 | jmachado | 1 | package pt.estgp.estgweb.services.questionarios.pedagogico; |
2 | |||
3 | import org.apache.log4j.Logger; |
||
4 | import pt.estgp.estgweb.domain.QuestionarioImpl; |
||
5 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
||
6 | import pt.estgp.estgweb.services.jobs.ServiceJob; |
||
7 | import pt.estgp.estgweb.services.logresults.ILogMessages; |
||
8 | import pt.estgp.estgweb.services.logresults.LogMessageTypeEnum; |
||
9 | import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessage; |
||
10 | import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessages; |
||
11 | |||
12 | /** |
||
13 | * Created by jorgemachado on 28/05/16. |
||
14 | */ |
||
15 | public class TeachersAnswersProcessor extends ServiceJob { |
||
16 | |||
17 | private static 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(TeachersAnswersProcessor.class); |
||
18 | /** |
||
19 | * |
||
20 | * @return |
||
21 | * @throws Throwable |
||
22 | */ |
||
23 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
24 | protected ILogMessages runJobServiceTask() throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
||
25 | { |
||
26 | |||
27 | DefaultLogMessages logMessages = new DefaultLogMessages(); |
||
28 | long questionarioId = 1.5.0/docs/api/java/lang/Long.html">Long.parseLong(getParametersMap().get(ServiceJob.JOB_questionario_id_KEY).getObject()); |
||
29 | QuestionarioImpl q = (QuestionarioImpl) DaoFactory.getQuestionarioDaoImpl().load(questionarioId); |
||
30 | |||
31 | |||
32 | //Colocamos já aqui o estado para nao se poder mudar o Ano e o Semestre |
||
33 | |||
34 | /**logging**/ |
||
35 | 1.5.0/docs/api/java/lang/String.html">String msg = "Starting running service answers generation for questionario: " + q.getId() + " - " + q.getiAnswersProcessorClass().getTitle(); |
||
36 | serviceLogInfo(msg); |
||
37 | logger.info(msg); |
||
38 | /**logging**/ |
||
39 | |||
40 | /*List<String> newCourseCodesList = new ArrayList<String>(); |
||
41 | int count = 0; |
||
42 | int totalCourses = coursesList.length; |
||
43 | for(String courseStrId: coursesList) |
||
44 | { |
||
45 | count++;*/ |
||
46 | try{ |
||
47 | /*Long courseLong = Long.parseLong(courseStrId); |
||
48 | /** logging **/ |
||
49 | //msg = "Loading Course BACO ID: " + courseStrId; |
||
50 | //serviceLogInfo(msg); |
||
51 | //logger.info(msg); |
||
52 | /** logging **/ |
||
53 | |||
54 | |||
55 | |||
56 | /** COMMIT OPERATION **/ |
||
57 | //setProgress((int)((((float)count)/((float)totalCourses))*100.0f)); |
||
58 | //commitPartially(); |
||
59 | //DaoFactory.getQuestionarioDaoImpl().update(q); |
||
60 | /** COMMIT OPERATION **/ |
||
61 | } |
||
62 | catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable t) |
||
63 | { |
||
64 | logger.error(t,t); |
||
65 | serviceLogError(t.toString(),t); |
||
1387 | jmachado | 66 | logMessages.addMessage(new DefaultLogMessage("questionario.answers.assigning", LogMessageTypeEnum.ERROR,t.toString())); |
1380 | jmachado | 67 | } |
68 | |||
69 | //} |
||
70 | |||
71 | |||
72 | //removeUnselectedCourses(q, newCourseCodesList); |
||
73 | |||
74 | /** COMMIT OPERATION **/ |
||
75 | setProgress(100); |
||
76 | commitPartially(); |
||
77 | DaoFactory.getQuestionarioDaoImpl().update(q); |
||
78 | /** COMMIT OPERATION **/ |
||
79 | |||
80 | //TODO FALTA VERIFICAR SE HA COISAS DEPENDENTES DO COURSES_ASSIGNED TEM DE MUDAR PARA OU ANSWERS ASSIGNED |
||
81 | //OIU ENTAO SO DEPOIS DO REVERT E QUE PODEM VOLTAR A ATRIBUIR RESPOSTAS E ALTERAR SELECAO DE CURSOS |
||
82 | |||
83 | msg = "Set courses state as " + QuestionarioImpl.SubStatePedagogico.ANSWERS_ASSIGNED.name(); |
||
84 | serviceLogInfo(msg); |
||
85 | logger.info(msg); |
||
86 | q.setSubStatePedagogicoClass(QuestionarioImpl.SubStatePedagogico.ANSWERS_ASSIGNED); |
||
87 | commitPartially(); |
||
88 | |||
89 | return logMessages; |
||
90 | } |
||
91 | } |