Rev 1379 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1327 | jmachado | 1 | package pt.estgp.estgweb.web.controllers.questionarios; |
2 | |||
3 | import org.apache.log4j.Logger; |
||
4 | import org.apache.struts.action.ActionForm; |
||
5 | import org.apache.struts.action.ActionForward; |
||
6 | import org.apache.struts.action.ActionMapping; |
||
7 | import pt.estgp.estgweb.domain.QuestionarioImpl; |
||
1336 | jmachado | 8 | import pt.estgp.estgweb.services.logresults.ILogMessage; |
9 | import pt.estgp.estgweb.services.logresults.ILogMessages; |
||
10 | import pt.estgp.estgweb.services.logresults.LogMessageTypeEnum; |
||
1327 | jmachado | 11 | import pt.estgp.estgweb.web.form.questionarios.QuestionarioForm; |
12 | import pt.estgp.estgweb.web.utils.RequestUtils; |
||
13 | import pt.utl.ist.berserk.logic.serviceManager.IServiceManager; |
||
14 | import pt.utl.ist.berserk.logic.serviceManager.ServiceManager; |
||
15 | |||
16 | import javax.servlet.http.HttpServletRequest; |
||
17 | import javax.servlet.http.HttpServletResponse; |
||
18 | |||
19 | /** |
||
20 | * Created by jorgemachado on 21/03/16. |
||
21 | */ |
||
22 | public class QuestionarioCourseSelectionController extends QuestionarioController |
||
23 | { |
||
24 | |||
25 | private 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(QuestionarioCourseSelectionController.class); |
||
26 | |||
1379 | jmachado | 27 | |
28 | |||
29 | public ActionForward assignAnswers(ActionMapping mapping, |
||
30 | ActionForm form, |
||
31 | HttpServletRequest request, |
||
32 | HttpServletResponse response) |
||
33 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
||
34 | { |
||
35 | QuestionarioForm frm = (QuestionarioForm) form; |
||
36 | |||
37 | IServiceManager sm = ServiceManager.getInstance(); |
||
38 | 1.5.0/docs/api/java/lang/String.html">String[] names = {"questionarioId"}; |
||
39 | 5+0%2Fdocs%2Fapi+Object">Object[] args = {frm.getQuestionario().getId()}; |
||
40 | |||
41 | QuestionarioImpl q = (QuestionarioImpl) sm.execute(RequestUtils.getRequester(request, response),"RunJobAssignAnswers",args,names); |
||
42 | |||
43 | frm.setQuestionario(q); |
||
44 | |||
45 | addMessage(request,"questionarios.answers.start"); |
||
46 | return mapping.findForward("assignAnswers"); |
||
47 | } |
||
48 | |||
1327 | jmachado | 49 | public ActionForward selectCourses(ActionMapping mapping, |
50 | ActionForm form, |
||
51 | HttpServletRequest request, |
||
52 | HttpServletResponse response) |
||
53 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
||
54 | { |
||
55 | QuestionarioForm frm = (QuestionarioForm) form; |
||
56 | |||
57 | if(frm.getCoursesSelectedIds() == null) |
||
58 | { |
||
59 | addError(request,"questionario.no.courses.selected"); |
||
60 | return mapping.findForward("coursesSelection"); |
||
61 | } |
||
62 | |||
63 | |||
64 | |||
65 | IServiceManager sm = ServiceManager.getInstance(); |
||
66 | 1.5.0/docs/api/java/lang/String.html">String[] names = {"questionarioId","selectedCourses"}; |
||
67 | 5+0%2Fdocs%2Fapi+Object">Object[] args = {frm.getQuestionario().getId(),frm.getCoursesSelectedIds()}; |
||
68 | |||
69 | QuestionarioImpl q = (QuestionarioImpl) sm.execute(RequestUtils.getRequester(request, response),"RunJobSelectCourses",args,names); |
||
70 | |||
71 | frm.setQuestionario(q); |
||
72 | |||
73 | addMessage(request,"questionarios.courses.start"); |
||
1328 | jmachado | 74 | return mapping.findForward("coursesSelection"); |
1327 | jmachado | 75 | } |
76 | |||
1336 | jmachado | 77 | public ActionForward revertAssignements(ActionMapping mapping, |
78 | ActionForm form, |
||
79 | HttpServletRequest request, |
||
80 | HttpServletResponse response) |
||
81 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
||
82 | { |
||
83 | QuestionarioForm frm = (QuestionarioForm) form; |
||
1327 | jmachado | 84 | |
1336 | jmachado | 85 | IServiceManager sm = ServiceManager.getInstance(); |
86 | 1.5.0/docs/api/java/lang/String.html">String[] names = {"questionarioId"}; |
||
87 | 5+0%2Fdocs%2Fapi+Object">Object[] args = {frm.getQuestionario().getId()}; |
||
88 | |||
89 | ILogMessages logMessages = (ILogMessages) sm.execute(RequestUtils.getRequester(request, response),"QuestionarioRevertAllAssignmentsPedagogico",args,names); |
||
90 | |||
91 | for(ILogMessage log: logMessages.getLogMessages()) |
||
92 | { |
||
93 | if(log.getType() == LogMessageTypeEnum.ERROR || log.getType() == LogMessageTypeEnum.WARNING || log.getType() == LogMessageTypeEnum.FATAL) |
||
1585 | jmachado | 94 | addErrorAsString(request, log.getMsg()); |
1336 | jmachado | 95 | else |
1337 | jmachado | 96 | addMessageAsString(request,log.getMsg()); |
1336 | jmachado | 97 | } |
1337 | jmachado | 98 | return mapping.findForward("admin"); |
1336 | jmachado | 99 | } |
100 | |||
1337 | jmachado | 101 | public ActionForward updateTipologias(ActionMapping mapping, |
102 | ActionForm form, |
||
103 | HttpServletRequest request, |
||
104 | HttpServletResponse response) |
||
105 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
||
106 | { |
||
107 | QuestionarioForm frm = (QuestionarioForm) form; |
||
1336 | jmachado | 108 | |
1337 | jmachado | 109 | IServiceManager sm = ServiceManager.getInstance(); |
110 | 1.5.0/docs/api/java/lang/String.html">String[] names = {"questionarioId","cursosAfetos"}; |
||
111 | 5+0%2Fdocs%2Fapi+Object">Object[] args = {frm.getQuestionario().getId(),frm.getCursosAfetos()}; |
||
112 | |||
113 | sm.execute(RequestUtils.getRequester(request, response),"QuestionarioUpdateTipologiasPedagogico",args,names); |
||
114 | |||
115 | addMessage(request,"questionario.tipologias.update.success"); |
||
116 | return mapping.findForward("coursesCheck"); |
||
117 | } |
||
118 | |||
1338 | jmachado | 119 | |
120 | |||
1327 | jmachado | 121 | } |