Rev 1326 | Rev 1404 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1314 | 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; |
||
1325 | jmachado | 7 | import pt.estgp.estgweb.domain.DomainObjectFactory; |
1315 | jmachado | 8 | import pt.estgp.estgweb.domain.QuestionarioImpl; |
1326 | jmachado | 9 | import pt.estgp.estgweb.domain.UserSessionImpl; |
10 | import pt.estgp.estgweb.domain.utils.SimpleClearanceRuledSupport; |
||
11 | import pt.estgp.estgweb.web.UserSessionProxy; |
||
1314 | jmachado | 12 | import pt.estgp.estgweb.web.controllers.ApplicationDispatchController; |
1315 | jmachado | 13 | import pt.estgp.estgweb.web.form.questionarios.QuestionarioForm; |
1326 | jmachado | 14 | import pt.estgp.estgweb.web.utils.RequestUtils; |
15 | import pt.utl.ist.berserk.logic.serviceManager.IServiceManager; |
||
16 | import pt.utl.ist.berserk.logic.serviceManager.ServiceManager; |
||
1314 | jmachado | 17 | |
18 | import javax.servlet.ServletException; |
||
19 | import javax.servlet.http.HttpServletRequest; |
||
20 | import javax.servlet.http.HttpServletResponse; |
||
21 | |||
22 | /** |
||
23 | * @author Jorge Machado |
||
24 | * @date 26/Fev/2008 |
||
25 | * @time 18:01:54 |
||
26 | * @see pt.estgp.estgweb.web |
||
27 | */ |
||
28 | public class QuestionarioController extends ApplicationDispatchController |
||
29 | { |
||
30 | |||
31 | 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(QuestionarioController.class); |
||
32 | |||
1326 | jmachado | 33 | public ActionForward startNew(ActionMapping mapping, |
34 | ActionForm form, |
||
35 | HttpServletRequest request, |
||
36 | HttpServletResponse response) |
||
37 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
||
38 | { |
||
1314 | jmachado | 39 | |
1326 | jmachado | 40 | QuestionarioForm frm = (QuestionarioForm) form; |
41 | frm.getQuestionario().setClearanceRuledSupport(new SimpleClearanceRuledSupport()); |
||
42 | frm.getQuestionario().getClearanceRuledSupport().addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_SAVE_FORM.name(), (UserSessionImpl) UserSessionProxy.loadUserSessionFromRequest(request)); |
||
43 | frm.getQuestionario().getClearanceRuledSupport().addClearance(QuestionarioImpl.QuestionarioClearancesOperation.QUESTIONARIO_SAVE_ANSWER_PROCESSOR.name(), (UserSessionImpl) UserSessionProxy.loadUserSessionFromRequest(request)); |
||
44 | return mapping.findForward("newEdit"); |
||
45 | } |
||
1314 | jmachado | 46 | |
1325 | jmachado | 47 | public ActionForward save(ActionMapping mapping, |
1314 | jmachado | 48 | ActionForm form, |
49 | HttpServletRequest request, |
||
50 | HttpServletResponse response) |
||
1326 | jmachado | 51 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
1314 | jmachado | 52 | { |
53 | |||
1315 | jmachado | 54 | QuestionarioForm frm = (QuestionarioForm) form; |
1326 | jmachado | 55 | IServiceManager sm = ServiceManager.getInstance(); |
56 | 1.5.0/docs/api/java/lang/String.html">String[] names = {"questionario"}; |
||
57 | 5+0%2Fdocs%2Fapi+Object">Object[] args = {frm.getQuestionario()}; |
||
1325 | jmachado | 58 | |
1326 | jmachado | 59 | 1.5.0/docs/api/java/lang/String.html">String service = frm.getQuestionario().getId() <= 0 ? "NewQuestionarioForm": "saveQuestionarioForm"; |
60 | QuestionarioImpl affected = (QuestionarioImpl) sm.execute(RequestUtils.getRequester(request, response),service,args,names); |
||
61 | frm.setQuestionario(affected); |
||
1325 | jmachado | 62 | |
1315 | jmachado | 63 | return mapping.findForward("list"); |
1314 | jmachado | 64 | } |
65 | |||
1315 | jmachado | 66 | public ActionForward refresh(ActionMapping mapping, |
67 | ActionForm form, |
||
68 | HttpServletRequest request, |
||
69 | HttpServletResponse response) |
||
70 | throws ServletException |
||
71 | { |
||
1314 | jmachado | 72 | |
1315 | jmachado | 73 | QuestionarioForm frm = (QuestionarioForm) form; |
74 | frm.setShowQuestionarioForm(true); |
||
1325 | jmachado | 75 | return mapping.findForward("newEdit"); |
1315 | jmachado | 76 | } |
1314 | jmachado | 77 | |
1315 | jmachado | 78 | public ActionForward form(ActionMapping mapping, |
79 | ActionForm form, |
||
80 | HttpServletRequest request, |
||
81 | HttpServletResponse response) |
||
1326 | jmachado | 82 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
1315 | jmachado | 83 | { |
84 | |||
85 | QuestionarioForm frm = (QuestionarioForm) form; |
||
86 | |||
1326 | jmachado | 87 | IServiceManager sm = ServiceManager.getInstance(); |
88 | 1.5.0/docs/api/java/lang/String.html">String[] names = {"questionarioId"}; |
||
89 | 5+0%2Fdocs%2Fapi+Object">Object[] args = {frm.getQuestionario().getId()}; |
||
90 | |||
91 | QuestionarioImpl q = (QuestionarioImpl) sm.execute(RequestUtils.getRequester(request, response),"loadQuestionarioAdmin",args,names); |
||
92 | |||
1315 | jmachado | 93 | frm.setQuestionario(q); |
94 | |||
1325 | jmachado | 95 | if(q.getQuestionarioHistoryDrive() == null) |
96 | { |
||
97 | q.setQuestionarioHistoryDrive(DomainObjectFactory.createQuestionarioHistoryDriveImpl()); |
||
98 | } |
||
1315 | jmachado | 99 | frm.setShowQuestionarioForm(true); |
1325 | jmachado | 100 | return mapping.findForward("newEdit"); |
1315 | jmachado | 101 | } |
102 | |||
1325 | jmachado | 103 | public ActionForward startAfetacoes(ActionMapping mapping, |
104 | ActionForm form, |
||
105 | HttpServletRequest request, |
||
106 | HttpServletResponse response) |
||
1326 | jmachado | 107 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
1325 | jmachado | 108 | { |
1326 | jmachado | 109 | QuestionarioForm frm = (QuestionarioForm) form; |
1315 | jmachado | 110 | |
1326 | jmachado | 111 | IServiceManager sm = ServiceManager.getInstance(); |
112 | 1.5.0/docs/api/java/lang/String.html">String[] names = {"questionarioId"}; |
||
113 | 5+0%2Fdocs%2Fapi+Object">Object[] args = {frm.getQuestionario().getId()}; |
||
114 | |||
115 | QuestionarioImpl affected = (QuestionarioImpl) sm.execute(RequestUtils.getRequester(request, response),"SetQuestionarioAssignDetailsState",args,names); |
||
116 | |||
117 | frm.setQuestionario(affected); |
||
118 | |||
119 | return mapping.findForward("admin"); |
||
120 | } |
||
121 | |||
122 | public ActionForward deleteQuestionario(ActionMapping mapping, |
||
123 | ActionForm form, |
||
124 | HttpServletRequest request, |
||
125 | HttpServletResponse response) |
||
126 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
||
127 | { |
||
128 | |||
129 | |||
1325 | jmachado | 130 | QuestionarioForm frm = (QuestionarioForm) form; |
1326 | jmachado | 131 | |
132 | IServiceManager sm = ServiceManager.getInstance(); |
||
133 | 1.5.0/docs/api/java/lang/String.html">String[] names = {"questionarioId"}; |
||
134 | 5+0%2Fdocs%2Fapi+Object">Object[] args = {frm.getQuestionario().getId()}; |
||
135 | |||
136 | QuestionarioImpl affected = (QuestionarioImpl) sm.execute(RequestUtils.getRequester(request, response),"DeleteQuestionario",args,names); |
||
137 | |||
138 | frm.setQuestionario(affected); |
||
139 | |||
140 | return mapping.findForward("list"); |
||
1325 | jmachado | 141 | } |
1315 | jmachado | 142 | |
1325 | jmachado | 143 | |
1403 | jmachado | 144 | public ActionForward putInAssignedAnwsers(ActionMapping mapping, |
145 | ActionForm form, |
||
146 | HttpServletRequest request, |
||
147 | HttpServletResponse response) |
||
148 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
||
149 | { |
||
1325 | jmachado | 150 | |
1403 | jmachado | 151 | |
152 | QuestionarioForm frm = (QuestionarioForm) form; |
||
153 | |||
154 | long questionarioId; |
||
155 | if(request.getParameter("questionarioId")!=null) |
||
156 | questionarioId = 1.5.0/docs/api/java/lang/Long.html">Long.parseLong(request.getParameter("questionarioId")); |
||
157 | else |
||
158 | questionarioId = frm.getQuestionario().getId(); |
||
159 | |||
160 | |||
161 | IServiceManager sm = ServiceManager.getInstance(); |
||
162 | 1.5.0/docs/api/java/lang/String.html">String[] names = {"questionarioId"}; |
||
163 | 5+0%2Fdocs%2Fapi+Object">Object[] args = {questionarioId}; |
||
164 | |||
165 | QuestionarioImpl affected = (QuestionarioImpl) sm.execute(RequestUtils.getRequester(request, response),"QuestionarioPutAssignedAnswers",args,names); |
||
166 | |||
167 | frm.setQuestionario(affected); |
||
168 | |||
169 | return mapping.findForward("admin"); |
||
170 | } |
||
171 | |||
172 | public ActionForward startProcessement(ActionMapping mapping, |
||
173 | ActionForm form, |
||
174 | HttpServletRequest request, |
||
175 | HttpServletResponse response) |
||
176 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
||
177 | { |
||
178 | |||
179 | |||
180 | QuestionarioForm frm = (QuestionarioForm) form; |
||
181 | |||
182 | long questionarioId; |
||
183 | if(request.getParameter("questionarioId")!=null) |
||
184 | questionarioId = 1.5.0/docs/api/java/lang/Long.html">Long.parseLong(request.getParameter("questionarioId")); |
||
185 | else |
||
186 | questionarioId = frm.getQuestionario().getId(); |
||
187 | |||
188 | |||
189 | IServiceManager sm = ServiceManager.getInstance(); |
||
190 | 1.5.0/docs/api/java/lang/String.html">String[] names = {"questionarioId"}; |
||
191 | 5+0%2Fdocs%2Fapi+Object">Object[] args = {questionarioId}; |
||
192 | |||
193 | QuestionarioImpl affected = (QuestionarioImpl) sm.execute(RequestUtils.getRequester(request, response),"QuestionarioStartProcessement",args,names); |
||
194 | |||
195 | frm.setQuestionario(affected); |
||
196 | |||
197 | return mapping.findForward("admin"); |
||
198 | } |
||
199 | |||
200 | |||
201 | |||
202 | |||
203 | |||
1314 | jmachado | 204 | } |