Rev 1328 | Rev 1337 | 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.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 | |||
27 | public ActionForward selectCourses(ActionMapping mapping, |
||
28 | ActionForm form, |
||
29 | HttpServletRequest request, |
||
30 | HttpServletResponse response) |
||
31 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
||
32 | { |
||
33 | QuestionarioForm frm = (QuestionarioForm) form; |
||
34 | |||
35 | if(frm.getCoursesSelectedIds() == null) |
||
36 | { |
||
37 | addError(request,"questionario.no.courses.selected"); |
||
38 | return mapping.findForward("coursesSelection"); |
||
39 | } |
||
40 | |||
41 | |||
42 | |||
43 | IServiceManager sm = ServiceManager.getInstance(); |
||
44 | 1.5.0/docs/api/java/lang/String.html">String[] names = {"questionarioId","selectedCourses"}; |
||
45 | 5+0%2Fdocs%2Fapi+Object">Object[] args = {frm.getQuestionario().getId(),frm.getCoursesSelectedIds()}; |
||
46 | |||
47 | QuestionarioImpl q = (QuestionarioImpl) sm.execute(RequestUtils.getRequester(request, response),"RunJobSelectCourses",args,names); |
||
48 | |||
49 | frm.setQuestionario(q); |
||
50 | |||
51 | addMessage(request,"questionarios.courses.start"); |
||
1328 | jmachado | 52 | return mapping.findForward("coursesSelection"); |
1327 | jmachado | 53 | } |
54 | |||
1336 | jmachado | 55 | public ActionForward revertAssignements(ActionMapping mapping, |
56 | ActionForm form, |
||
57 | HttpServletRequest request, |
||
58 | HttpServletResponse response) |
||
59 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
||
60 | { |
||
61 | QuestionarioForm frm = (QuestionarioForm) form; |
||
1327 | jmachado | 62 | |
1336 | jmachado | 63 | IServiceManager sm = ServiceManager.getInstance(); |
64 | 1.5.0/docs/api/java/lang/String.html">String[] names = {"questionarioId"}; |
||
65 | 5+0%2Fdocs%2Fapi+Object">Object[] args = {frm.getQuestionario().getId()}; |
||
66 | |||
67 | ILogMessages logMessages = (ILogMessages) sm.execute(RequestUtils.getRequester(request, response),"QuestionarioRevertAllAssignmentsPedagogico",args,names); |
||
68 | |||
69 | for(ILogMessage log: logMessages.getLogMessages()) |
||
70 | { |
||
71 | if(log.getType() == LogMessageTypeEnum.ERROR || log.getType() == LogMessageTypeEnum.WARNING || log.getType() == LogMessageTypeEnum.FATAL) |
||
72 | addError(request,log.getMsg()); |
||
73 | else |
||
74 | addMessage(request,log.getMsg()); |
||
75 | } |
||
76 | return mapping.findForward("coursesSelection"); |
||
77 | } |
||
78 | |||
79 | |||
1327 | jmachado | 80 | } |