Rev 1586 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1579 | jmachado | 1 | package pt.estgp.estgweb.web.controllers.questionarios.reports; |
2 | |||
3 | import jomm.dao.impl.AbstractDao; |
||
4 | import org.apache.log4j.Logger; |
||
5 | import org.apache.struts.action.ActionErrors; |
||
6 | import org.apache.struts.action.ActionForm; |
||
7 | import org.apache.struts.action.ActionForward; |
||
8 | import org.apache.struts.action.ActionMapping; |
||
9 | import org.json.JSONException; |
||
10 | import org.json.JSONObject; |
||
11 | import pt.estgp.estgweb.domain.QuestionarioReportFileGroup; |
||
12 | import pt.estgp.estgweb.domain.QuestionarioReportFileGroupImpl; |
||
13 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
||
14 | import pt.estgp.estgweb.web.controllers.utils.AbstractWidgetAjaxController; |
||
15 | import pt.estgp.estgweb.web.form.questionarios.QuestionarioReportGroupForm; |
||
16 | import pt.estgp.estgweb.web.utils.RequestUtils; |
||
17 | import pt.utl.ist.berserk.logic.serviceManager.IServiceManager; |
||
18 | import pt.utl.ist.berserk.logic.serviceManager.ServiceManager; |
||
19 | |||
20 | import javax.servlet.http.HttpServletRequest; |
||
21 | import javax.servlet.http.HttpServletResponse; |
||
22 | |||
23 | /** |
||
24 | * @author Jorge Machado |
||
25 | * @date 26/Fev/2008 |
||
26 | * @time 18:01:54 |
||
27 | * @see pt.estgp.estgweb.web |
||
28 | */ |
||
29 | public class QuestionarioReportsController extends AbstractWidgetAjaxController |
||
30 | { |
||
31 | |||
32 | 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(QuestionarioReportsController.class); |
||
33 | |||
34 | |||
1586 | jmachado | 35 | public ActionForward updateReportGroup(ActionMapping mapping, |
1580 | jmachado | 36 | ActionForm form, |
37 | HttpServletRequest request, |
||
38 | HttpServletResponse response) |
||
39 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
||
40 | { |
||
1586 | jmachado | 41 | updateReportGroup(form,request,response); |
42 | return mapping.findForward("reportAdmin"); |
||
43 | } |
||
1580 | jmachado | 44 | |
1586 | jmachado | 45 | /**Accao para widget**/ |
46 | public 1.5.0/docs/api/java/lang/Boolean.html">Boolean updateReportGroup(ActionForm form, |
||
47 | HttpServletRequest request, |
||
48 | HttpServletResponse response) |
||
49 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
||
50 | { |
||
51 | |||
1580 | jmachado | 52 | QuestionarioReportGroupForm frm = (QuestionarioReportGroupForm) form; |
53 | IServiceManager sm = ServiceManager.getInstance(); |
||
54 | 1.5.0/docs/api/java/lang/String.html">String[] names = {}; |
||
1586 | jmachado | 55 | 5+0%2Fdocs%2Fapi+Object">Object[] args = {frm.getQuestionarioReportFileGroup().getId(),frm.getQuestionarioReportFileGroup().getTitle(),frm.getQuestionarioReportFileGroup().isActive()}; |
1580 | jmachado | 56 | |
57 | sm.execute(RequestUtils.getRequester(request, response),"UpdateReportGroup",args,names); |
||
1586 | jmachado | 58 | addMessage(request,"questionarios.report.parameters.saved"); |
59 | return true; |
||
60 | } |
||
1580 | jmachado | 61 | |
1586 | jmachado | 62 | |
63 | /**Accao para widget**/ |
||
64 | public 1.5.0/docs/api/java/lang/Boolean.html">Boolean updateReport(ActionForm form, |
||
65 | HttpServletRequest request, |
||
66 | HttpServletResponse response) |
||
67 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
||
68 | { |
||
69 | |||
70 | QuestionarioReportGroupForm frm = (QuestionarioReportGroupForm) form; |
||
71 | IServiceManager sm = ServiceManager.getInstance(); |
||
72 | 1.5.0/docs/api/java/lang/String.html">String[] names = {}; |
||
73 | 5+0%2Fdocs%2Fapi+Object">Object[] args = {frm.getQuestionarioReportFile().getId(),frm.getQuestionarioReportFile().isActive()}; |
||
74 | |||
75 | sm.execute(RequestUtils.getRequester(request, response),"UpdateReportFile",args,names); |
||
76 | addMessage(request,"questionarios.report.parameters.saved"); |
||
77 | return true; |
||
1580 | jmachado | 78 | } |
79 | |||
1579 | jmachado | 80 | public ActionForward saveReportGroup(ActionMapping mapping, |
81 | ActionForm form, |
||
82 | HttpServletRequest request, |
||
83 | HttpServletResponse response) |
||
84 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
||
85 | { |
||
86 | |||
87 | QuestionarioReportGroupForm frm = (QuestionarioReportGroupForm) form; |
||
88 | IServiceManager sm = ServiceManager.getInstance(); |
||
89 | 1.5.0/docs/api/java/lang/String.html">String[] names = {"title","classType"}; |
||
90 | 5+0%2Fdocs%2Fapi+Object">Object[] args = {frm.getTitle(),frm.getReportFileGroupClass()}; |
||
91 | |||
92 | sm.execute(RequestUtils.getRequester(request, response),"SaveReportGroup",args,names); |
||
93 | |||
94 | return mapping.findForward("list"); |
||
95 | } |
||
96 | |||
97 | public JSONObject reloadInputs(ActionForm form, HttpServletRequest request,HttpServletResponse response) throws JSONException |
||
98 | { |
||
99 | QuestionarioReportGroupForm frm = (QuestionarioReportGroupForm) form; |
||
100 | AbstractDao.getCurrentSession().beginTransaction(); |
||
101 | QuestionarioReportFileGroupImpl q = (QuestionarioReportFileGroupImpl) DaoFactory.getQuestionarioReportFileGroupDaoImpl().load(frm.getQuestionarioReportFileGroup().getId()); |
||
102 | JSONObject jsonObject = new JSONObject(); |
||
103 | jsonObject.put("jsonInputs", q.getInputsJsonArray()); |
||
104 | AbstractDao.getCurrentSession().getTransaction().commit(); |
||
105 | return jsonObject; |
||
106 | } |
||
107 | |||
108 | public ActionForward runJobGenerate(ActionMapping mapping, |
||
109 | ActionForm form, |
||
110 | HttpServletRequest request, |
||
111 | HttpServletResponse response) |
||
112 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
||
113 | { |
||
114 | QuestionarioReportGroupForm frm = (QuestionarioReportGroupForm) form; |
||
115 | |||
116 | ActionErrors errors = frm.validateForGenerate(mapping,request); |
||
117 | if(!errors.isEmpty()) |
||
118 | { |
||
119 | saveErrors(request,errors); |
||
120 | return mapping.findForward("reportAdmin"); |
||
121 | } |
||
122 | |||
123 | IServiceManager sm = ServiceManager.getInstance(); |
||
124 | 1.5.0/docs/api/java/lang/String.html">String[] names = {}; |
||
1830 | jmachado | 125 | 5+0%2Fdocs%2Fapi+Object">Object[] args = {frm.getQuestionarioReportFileGroup().getId(), |
126 | frm.getQuestionarioReportFileGroup().getTitle(), |
||
127 | frm.getQuestionarioReportFileGroup().isActive(), |
||
128 | frm.getProcessSigesCode() |
||
129 | }; |
||
1579 | jmachado | 130 | |
131 | QuestionarioReportFileGroup group = (QuestionarioReportFileGroup) sm.execute(RequestUtils.getRequester(request, response), "GenerateReportGroup", args, names); |
||
132 | ((QuestionarioReportGroupForm) form).setQuestionarioReportFileGroup(group); |
||
133 | |||
134 | return mapping.findForward("reportAdmin"); |
||
135 | } |
||
136 | |||
137 | } |