Rev 1771 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
214 | jmachado | 1 | package pt.estgp.estgweb.web.controllers.courses; |
2 | |||
376 | jmachado | 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; |
||
1667 | jmachado | 7 | import org.json.JSONObject; |
1516 | jmachado | 8 | import pt.estgp.estgweb.domain.CourseStudiesPlanImpl; |
1667 | jmachado | 9 | import pt.estgp.estgweb.domain.Teacher; |
376 | jmachado | 10 | import pt.estgp.estgweb.domain.views.CourseView; |
11 | import pt.estgp.estgweb.filters.exceptions.NotFoundException; |
||
1516 | jmachado | 12 | import pt.estgp.estgweb.services.courses.CoursesService; |
1534 | jmachado | 13 | import pt.estgp.estgweb.services.courses.StudiesPlanImporter; |
1771 | jmachado | 14 | import pt.estgp.estgweb.services.courses.xsd.CursoImpl; |
376 | jmachado | 15 | import pt.estgp.estgweb.services.courseunits.DirectedCoordinatedCourses; |
16 | import pt.estgp.estgweb.services.courseunits.DirectedCoordinatedUnitsService; |
||
444 | jmachado | 17 | import pt.estgp.estgweb.services.expceptions.AlreadyExistsException; |
1791 | jmachado | 18 | import pt.estgp.estgweb.services.users.ReplaceRoleResult; |
1700 | jmachado | 19 | import pt.estgp.estgweb.web.controllers.configuration.UserRolesController; |
214 | jmachado | 20 | import pt.estgp.estgweb.web.controllers.courseunits.CourseUnitsController; |
1667 | jmachado | 21 | import pt.estgp.estgweb.web.controllers.widgetmodel.ModelWidgetController; |
376 | jmachado | 22 | import pt.estgp.estgweb.web.exceptions.NoCookiesException; |
1699 | jmachado | 23 | import pt.estgp.estgweb.web.filters.UserRoleProxy; |
214 | jmachado | 24 | import pt.estgp.estgweb.web.form.courses.CourseForm; |
1505 | jmachado | 25 | import pt.estgp.estgweb.web.form.courses.CourseStudiesPlansAdminForm; |
214 | jmachado | 26 | import pt.estgp.estgweb.web.utils.RequestUtils; |
376 | jmachado | 27 | import pt.utl.ist.berserk.logic.filterManager.exceptions.FilterRetrieveException; |
28 | import pt.utl.ist.berserk.logic.filterManager.exceptions.IncompatibleFilterException; |
||
29 | import pt.utl.ist.berserk.logic.filterManager.exceptions.InvalidFilterException; |
||
30 | import pt.utl.ist.berserk.logic.filterManager.exceptions.InvalidFilterExpressionException; |
||
214 | jmachado | 31 | import pt.utl.ist.berserk.logic.serviceManager.IServiceManager; |
32 | import pt.utl.ist.berserk.logic.serviceManager.ServiceManager; |
||
33 | import pt.utl.ist.berserk.logic.serviceManager.exceptions.FilterChainFailedException; |
||
34 | import pt.utl.ist.berserk.logic.serviceManager.exceptions.ServiceManagerException; |
||
35 | |||
376 | jmachado | 36 | import javax.servlet.ServletException; |
214 | jmachado | 37 | import javax.servlet.http.HttpServletRequest; |
38 | import javax.servlet.http.HttpServletResponse; |
||
39 | |||
40 | /** |
||
41 | * @author Jorge Machado |
||
42 | * @author Fabio Velez |
||
43 | * @date 26/Fev/2008 |
||
44 | * @time 18:01:54 |
||
45 | * @see pt.estgp.estgweb.web |
||
46 | */ |
||
47 | public class CoursesController extends CourseUnitsController |
||
48 | { |
||
49 | |||
50 | 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(CoursesController.class); |
||
51 | |||
52 | |||
53 | public ActionForward startNew(ActionMapping mapping, |
||
54 | ActionForm form, |
||
55 | HttpServletRequest request, |
||
56 | HttpServletResponse response) |
||
57 | throws ServletException |
||
58 | { |
||
59 | CourseForm cF = (CourseForm) form; |
||
60 | CourseView cV = cF.getCourseView(); |
||
61 | request.setAttribute("CourseView",cV); |
||
62 | cF.setCourseView(cV); |
||
63 | return mapping.findForward("submit"); |
||
64 | } |
||
1505 | jmachado | 65 | private void loadOnlyCourseAndPlans(CourseForm cF, HttpServletRequest request, HttpServletResponse response) |
66 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable, InvalidFilterException, ServiceManagerException, InvalidFilterExpressionException, IncompatibleFilterException, FilterRetrieveException, NoCookiesException |
||
67 | { |
||
68 | load(cF,request,response,false,true); |
||
214 | jmachado | 69 | |
1505 | jmachado | 70 | } |
71 | |||
214 | jmachado | 72 | private void load(CourseForm cF, HttpServletRequest request, HttpServletResponse response) |
73 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable, InvalidFilterException, ServiceManagerException, InvalidFilterExpressionException, IncompatibleFilterException, FilterRetrieveException, NoCookiesException |
||
74 | { |
||
1505 | jmachado | 75 | load(cF,request,response,true,true); |
76 | } |
||
77 | private void load(CourseForm cF, HttpServletRequest request, HttpServletResponse response,boolean loadUnits,boolean loadStudiesPlans) |
||
78 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable, InvalidFilterException, ServiceManagerException, InvalidFilterExpressionException, IncompatibleFilterException, FilterRetrieveException, NoCookiesException |
||
79 | { |
||
214 | jmachado | 80 | 1.5.0/docs/api/java/lang/String.html">String code = cF.getCourseView().getCode(); |
81 | long id = cF.getCourseView().getId(); |
||
376 | jmachado | 82 | |
214 | jmachado | 83 | IServiceManager sm = ServiceManager.getInstance(); |
84 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{"serializable"}; |
||
85 | 5+0%2Fdocs%2Fapi+Object">Object[] args; |
||
86 | 1.5.0/docs/api/java/lang/String.html">String serviceName; |
||
87 | if(code != null) |
||
88 | { |
||
1505 | jmachado | 89 | args = new 5+0%2Fdocs%2Fapi+Object">Object[]{code,loadUnits}; |
90 | if(loadStudiesPlans) |
||
91 | serviceName = "LoadCourseByCodeAndStudiesPlans"; |
||
92 | else |
||
93 | serviceName = "LoadCourseByCode"; |
||
214 | jmachado | 94 | } |
95 | else |
||
96 | { |
||
1505 | jmachado | 97 | args = new 5+0%2Fdocs%2Fapi+Object">Object[]{id,loadUnits}; |
98 | if(loadStudiesPlans) |
||
99 | serviceName = "LoadCourseAndStudiesPlans"; |
||
100 | else |
||
101 | serviceName = "LoadCourse"; |
||
214 | jmachado | 102 | } |
103 | CourseView cV = (CourseView) sm.execute(RequestUtils.getRequester(request, response), serviceName, args, names); |
||
104 | request.setAttribute("CourseView",cV); |
||
105 | cF.setCourseView(cV); |
||
106 | } |
||
107 | |||
1486 | jmachado | 108 | private void loadForPublic(CourseForm cF, HttpServletRequest request, HttpServletResponse response) |
109 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable, InvalidFilterException, ServiceManagerException, InvalidFilterExpressionException, IncompatibleFilterException, FilterRetrieveException, NoCookiesException |
||
110 | { |
||
1505 | jmachado | 111 | load(cF,request,response,false,false); |
112 | /* String code = cF.getCourseView().getCode(); |
||
1486 | jmachado | 113 | long id = cF.getCourseView().getId(); |
114 | |||
115 | IServiceManager sm = ServiceManager.getInstance(); |
||
116 | String[] names = new String[]{"serializable"}; |
||
117 | Object[] args; |
||
118 | String serviceName; |
||
119 | if(code != null) |
||
120 | { |
||
121 | args = new Object[]{code,false}; |
||
122 | serviceName = "LoadCourseByCode"; |
||
123 | } |
||
124 | else |
||
125 | { |
||
1487 | jmachado | 126 | args = new Object[]{id,false}; |
1486 | jmachado | 127 | serviceName = "LoadCourse"; |
128 | } |
||
129 | CourseView cV = (CourseView) sm.execute(RequestUtils.getRequester(request, response), serviceName, args, names); |
||
130 | request.setAttribute("CourseView",cV); |
||
1505 | jmachado | 131 | cF.setCourseView(cV);*/ |
1486 | jmachado | 132 | } |
133 | |||
649 | jmachado | 134 | public ActionForward loadPlan(ActionMapping mapping, |
135 | ActionForm form, |
||
136 | HttpServletRequest request, |
||
137 | HttpServletResponse response) |
||
138 | throws ServletException |
||
139 | { |
||
140 | try |
||
141 | { |
||
142 | load((CourseForm) form,request,response); |
||
143 | return mapping.findForward("loadPlan"); |
||
144 | } |
||
145 | catch (FilterChainFailedException e) |
||
146 | { |
||
147 | return mapping.findForward("error401"); |
||
148 | } |
||
149 | catch (NotFoundException e) |
||
150 | { |
||
151 | return mapping.findForward("error404"); |
||
152 | } |
||
153 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
154 | { |
||
155 | logger.error(e, e); |
||
156 | return mapping.findForward("error500"); |
||
157 | } |
||
158 | } |
||
159 | |||
214 | jmachado | 160 | public ActionForward load(ActionMapping mapping, |
161 | ActionForm form, |
||
162 | HttpServletRequest request, |
||
163 | HttpServletResponse response) |
||
164 | throws ServletException |
||
165 | { |
||
166 | try |
||
167 | { |
||
168 | load((CourseForm) form,request,response); |
||
169 | return mapping.findForward("load"); |
||
170 | } |
||
171 | catch (FilterChainFailedException e) |
||
172 | { |
||
173 | return mapping.findForward("error401"); |
||
174 | } |
||
175 | catch (NotFoundException e) |
||
176 | { |
||
177 | return mapping.findForward("error404"); |
||
178 | } |
||
179 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
180 | { |
||
181 | logger.error(e, e); |
||
182 | return mapping.findForward("error500"); |
||
183 | } |
||
184 | } |
||
185 | |||
641 | jmachado | 186 | |
187 | public ActionForward loadSeparators(ActionMapping mapping, |
||
188 | ActionForm form, |
||
189 | HttpServletRequest request, |
||
190 | HttpServletResponse response) |
||
191 | throws ServletException |
||
192 | { |
||
193 | try |
||
194 | { |
||
1486 | jmachado | 195 | loadForPublic((CourseForm) form,request,response); |
641 | jmachado | 196 | return mapping.findForward("loadSeparators"); |
197 | } |
||
198 | catch (FilterChainFailedException e) |
||
199 | { |
||
200 | return mapping.findForward("error401"); |
||
201 | } |
||
202 | catch (NotFoundException e) |
||
203 | { |
||
204 | return mapping.findForward("error404"); |
||
205 | } |
||
206 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
207 | { |
||
208 | logger.error(e, e); |
||
209 | return mapping.findForward("error500"); |
||
210 | } |
||
211 | } |
||
212 | |||
649 | jmachado | 213 | |
214 | public ActionForward loadMenu(ActionMapping mapping, |
||
215 | ActionForm form, |
||
216 | HttpServletRequest request, |
||
217 | HttpServletResponse response) |
||
218 | throws ServletException |
||
219 | { |
||
220 | try |
||
221 | { |
||
222 | load((CourseForm) form,request,response); |
||
223 | return mapping.findForward("loadMenu"); |
||
224 | } |
||
225 | catch (FilterChainFailedException e) |
||
226 | { |
||
227 | return mapping.findForward("error401"); |
||
228 | } |
||
229 | catch (NotFoundException e) |
||
230 | { |
||
231 | return mapping.findForward("error404"); |
||
232 | } |
||
233 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
234 | { |
||
235 | logger.error(e, e); |
||
236 | return mapping.findForward("error500"); |
||
237 | } |
||
238 | } |
||
239 | |||
240 | |||
214 | jmachado | 241 | public ActionForward edit(ActionMapping mapping, |
242 | ActionForm form, |
||
243 | HttpServletRequest request, |
||
244 | HttpServletResponse response) |
||
245 | throws ServletException |
||
246 | { |
||
247 | try |
||
248 | { |
||
249 | load((CourseForm) form,request,response); |
||
250 | return mapping.findForward("submit"); |
||
251 | } |
||
252 | catch (FilterChainFailedException e) |
||
253 | { |
||
254 | return mapping.findForward("error401"); |
||
255 | } |
||
256 | catch (NotFoundException e) |
||
257 | { |
||
258 | return mapping.findForward("error404"); |
||
259 | } |
||
260 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
261 | { |
||
262 | logger.error(e, e); |
||
263 | return mapping.findForward("error500"); |
||
264 | } |
||
265 | } |
||
266 | |||
1505 | jmachado | 267 | public ActionForward editAdmin(ActionMapping mapping, |
268 | ActionForm form, |
||
269 | HttpServletRequest request, |
||
270 | HttpServletResponse response) |
||
271 | throws ServletException |
||
272 | { |
||
273 | try |
||
274 | { |
||
275 | loadOnlyCourseAndPlans((CourseForm) form, request, response); |
||
276 | return mapping.findForward("submit"); |
||
277 | } |
||
278 | catch (FilterChainFailedException e) |
||
279 | { |
||
280 | return mapping.findForward("error401"); |
||
281 | } |
||
282 | catch (NotFoundException e) |
||
283 | { |
||
284 | return mapping.findForward("error404"); |
||
285 | } |
||
286 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
287 | { |
||
288 | logger.error(e, e); |
||
289 | return mapping.findForward("error500"); |
||
290 | } |
||
291 | } |
||
292 | |||
1540 | jmachado | 293 | public ActionForward submitAndAdminStudyPlan(ActionMapping mapping, |
294 | ActionForm form, |
||
295 | HttpServletRequest request, |
||
296 | HttpServletResponse response) |
||
297 | throws ServletException |
||
298 | { |
||
299 | ActionForward forward = submit(mapping,form,request,response); |
||
300 | if(forward.getPath() == mapping.getInputForward().getPath()) |
||
301 | { |
||
302 | CourseForm cF = (CourseForm) form; |
||
303 | long id = cF.getCourseView().getId(); |
||
304 | request.setAttribute("courseId",id); |
||
305 | return mapping.findForward("adminStudiesPlans"); |
||
306 | } |
||
307 | return forward; |
||
308 | |||
309 | } |
||
310 | |||
214 | jmachado | 311 | public ActionForward submit(ActionMapping mapping, |
312 | ActionForm form, |
||
313 | HttpServletRequest request, |
||
314 | HttpServletResponse response) |
||
315 | throws ServletException |
||
316 | { |
||
317 | try |
||
318 | { |
||
319 | CourseForm cF = (CourseForm) form; |
||
320 | IServiceManager sm = ServiceManager.getInstance(); |
||
321 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{"object"}; |
||
322 | 5+0%2Fdocs%2Fapi+Object">Object[] args; |
||
323 | |||
324 | if(cF.getStudiesPlan() == null || cF.getStudiesPlan().getFileSize() <= 0) |
||
325 | args = new 5+0%2Fdocs%2Fapi+Object">Object[]{cF.getCourseView(),null,null,0,null}; |
||
326 | else //ring name, int size, String contentType, String extensio |
||
327 | args = new 5+0%2Fdocs%2Fapi+Object">Object[]{cF.getCourseView(),cF.getStudiesPlan().getInputStream(),cF.getStudiesPlan().getFileName(),cF.getStudiesPlan().getFileSize(),cF.getStudiesPlan().getContentType()}; |
||
328 | |||
329 | long id = cF.getCourseView().getId(); |
||
330 | CourseView cV = (CourseView) sm.execute(RequestUtils.getRequester(request, response), "SubmitCourse", args, names); |
||
331 | request.setAttribute("CourseView",cV); |
||
248 | jmachado | 332 | if(cV.getHtmlResult() != null) |
333 | { |
||
376 | jmachado | 334 | return mapping.findForward("submit"); |
248 | jmachado | 335 | } |
336 | |||
214 | jmachado | 337 | cF.setCourseView(cV); |
338 | if(id > 0) |
||
339 | addMessage(request,"course.updated.success","" + cV.getCode()); |
||
340 | else |
||
341 | addMessage(request,"course.created.success","" + cV.getCode()); |
||
342 | return mapping.getInputForward(); |
||
343 | } |
||
444 | jmachado | 344 | catch (AlreadyExistsException e) |
345 | { |
||
346 | addErrorWithKeys(request,"course.exists",e.getMessage()); |
||
347 | try |
||
348 | { |
||
349 | load((CourseForm) form,request,response); |
||
350 | return mapping.findForward("submit"); |
||
351 | } |
||
352 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable throwable) |
||
353 | { |
||
354 | logger.error(e, e); |
||
355 | return mapping.findForward("error500"); |
||
356 | } |
||
357 | } |
||
214 | jmachado | 358 | catch (FilterChainFailedException e) |
359 | { |
||
360 | return mapping.findForward("error401"); |
||
361 | } |
||
362 | catch (NotFoundException e) |
||
363 | { |
||
364 | return mapping.findForward("error404"); |
||
365 | } |
||
366 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
367 | { |
||
368 | logger.error(e, e); |
||
369 | return mapping.findForward("error500"); |
||
370 | } |
||
371 | } |
||
343 | jmachado | 372 | |
373 | |||
1506 | jmachado | 374 | |
375 | |||
344 | jmachado | 376 | public ActionForward loadCoursesPrograms(ActionMapping mapping, |
376 | jmachado | 377 | ActionForm form, |
378 | HttpServletRequest request, |
||
379 | HttpServletResponse response) |
||
344 | jmachado | 380 | throws ServletException |
381 | { |
||
382 | try |
||
383 | { |
||
384 | CourseForm cF = (CourseForm) form; |
||
345 | jmachado | 385 | 1.5.0/docs/api/java/lang/String.html">String importYear = cF.getImportYear(); |
376 | jmachado | 386 | long courseId = cF.getCourseId(); |
1039 | jmachado | 387 | if(courseId <= 0) |
388 | { |
||
389 | addError(request,"courses.fill.course"); |
||
390 | return mapping.findForward("load.courses.programs"); |
||
391 | } |
||
376 | jmachado | 392 | 1.5.0/docs/api/java/lang/String.html">String semestre = cF.getSemestre(); |
393 | 1.5.0/docs/api/java/lang/String.html">String area = cF.getArea(); |
||
394 | DirectedCoordinatedUnitsService.TeachersSituationEnum teachersSituationEnum = cF.getTeacherSituationEnum(); |
||
1312 | jmachado | 395 | 1.5.0/docs/api/java/lang/String.html">String institutionCode = cF.getInstitutionCode(); |
376 | jmachado | 396 | |
344 | jmachado | 397 | IServiceManager sm = ServiceManager.getInstance(); |
1312 | jmachado | 398 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{"importYear","courseId","semestre","area","teachersSituationEnum","institutionCode"}; |
399 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{importYear,courseId,semestre,area,teachersSituationEnum,institutionCode}; |
||
344 | jmachado | 400 | DirectedCoordinatedCourses directedCoordinatedCourses = (DirectedCoordinatedCourses) sm.execute(RequestUtils.getRequester(request, response), "LoadCoursesProgramsForServices", args, names); |
401 | cF.setDirectedCoordinatedCourses(directedCoordinatedCourses); |
||
376 | jmachado | 402 | cF.setArea(directedCoordinatedCourses.getArea()); |
403 | cF.setCourseId(directedCoordinatedCourses.getCourseId()); |
||
344 | jmachado | 404 | return mapping.findForward("load.courses.programs"); |
405 | } |
||
406 | catch (FilterChainFailedException e) |
||
407 | { |
||
408 | return mapping.findForward("error401"); |
||
409 | } |
||
410 | catch (NotFoundException e) |
||
411 | { |
||
412 | return mapping.findForward("error404"); |
||
413 | } |
||
414 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
415 | { |
||
416 | logger.error(e, e); |
||
417 | return mapping.findForward("error500"); |
||
418 | } |
||
419 | } |
||
420 | |||
343 | jmachado | 421 | public ActionForward loadDirectedCoordininatedCourses(ActionMapping mapping, |
376 | jmachado | 422 | ActionForm form, |
423 | HttpServletRequest request, |
||
424 | HttpServletResponse response) |
||
343 | jmachado | 425 | throws ServletException |
426 | { |
||
427 | try |
||
428 | { |
||
345 | jmachado | 429 | |
343 | jmachado | 430 | CourseForm cF = (CourseForm) form; |
345 | jmachado | 431 | 1.5.0/docs/api/java/lang/String.html">String importYear = cF.getImportYear(); |
343 | jmachado | 432 | IServiceManager sm = ServiceManager.getInstance(); |
345 | jmachado | 433 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{"importYear"}; |
434 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 1.5.0/docs/api/java/lang/String.html">String[]{importYear}; |
||
343 | jmachado | 435 | DirectedCoordinatedCourses directedCoordinatedCourses = (DirectedCoordinatedCourses) sm.execute(RequestUtils.getRequester(request, response), "LoadDirectedCoordinatedCoursesForUserInSession", args, names); |
436 | cF.setDirectedCoordinatedCourses(directedCoordinatedCourses); |
||
437 | return mapping.findForward("load.directed.coordinated.courses"); |
||
438 | } |
||
439 | catch (FilterChainFailedException e) |
||
440 | { |
||
441 | return mapping.findForward("error401"); |
||
442 | } |
||
443 | catch (NotFoundException e) |
||
444 | { |
||
445 | return mapping.findForward("error404"); |
||
446 | } |
||
447 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
448 | { |
||
449 | logger.error(e, e); |
||
450 | return mapping.findForward("error500"); |
||
451 | } |
||
452 | } |
||
453 | |||
454 | public ActionForward updateDirectedCoordininatedCourses(ActionMapping mapping, |
||
376 | jmachado | 455 | ActionForm form, |
456 | HttpServletRequest request, |
||
457 | HttpServletResponse response) |
||
343 | jmachado | 458 | throws ServletException |
459 | { |
||
460 | try |
||
461 | { |
||
462 | CourseForm cF = (CourseForm) form; |
||
463 | IServiceManager sm = ServiceManager.getInstance(); |
||
464 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{"directedCoordinatedCourses"}; |
||
465 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{cF.getDirectedCoordinatedCourses()}; |
||
466 | DirectedCoordinatedCourses directedCoordinatedCourses = (DirectedCoordinatedCourses) sm.execute(RequestUtils.getRequester(request, response), "UpdateDirectedCoordinatedCoursesForUserInSession", args, names); |
||
467 | cF.setDirectedCoordinatedCourses(directedCoordinatedCourses); |
||
468 | addMessage(request,"course.directed.coordinated.courses.updated.success",""+directedCoordinatedCourses.getUpdated()); |
||
1699 | jmachado | 469 | //return mapping.findForward("confirm.courses.programs"); |
470 | //return mapping.findForward("load.directed.coordinated.courses"); |
||
471 | return loadCoursesPrograms(mapping,form,request,response); |
||
472 | |||
343 | jmachado | 473 | } |
474 | catch (FilterChainFailedException e) |
||
475 | { |
||
476 | return mapping.findForward("error401"); |
||
477 | } |
||
478 | catch (NotFoundException e) |
||
479 | { |
||
480 | return mapping.findForward("error404"); |
||
481 | } |
||
482 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
483 | { |
||
484 | logger.error(e, e); |
||
485 | return mapping.findForward("error500"); |
||
486 | } |
||
487 | } |
||
1505 | jmachado | 488 | |
489 | |||
490 | /** |
||
491 | * StudiesPlans Controller Functions |
||
492 | * @param mapping |
||
493 | * @param form |
||
494 | * @param request |
||
495 | * @param response |
||
496 | * @return |
||
497 | * @throws ServletException |
||
498 | */ |
||
499 | public ActionForward addNewVersion(ActionMapping mapping, |
||
500 | ActionForm form, |
||
501 | HttpServletRequest request, |
||
502 | HttpServletResponse response) |
||
503 | throws ServletException |
||
504 | { |
||
505 | try |
||
506 | { |
||
507 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
508 | long courseId = frm.getCourseId(); |
||
509 | |||
510 | IServiceManager sm = ServiceManager.getInstance(); |
||
511 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{}; |
||
512 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{courseId,frm.getCourseStudiesPlan()}; |
||
513 | sm.execute(RequestUtils.getRequester(request, response), "AddNewStudiesPlan", args, names); |
||
514 | addMessage(request, "course.studies.plan.added"); |
||
515 | return mapping.findForward("loadstudyplans"); |
||
516 | } |
||
517 | catch (FilterChainFailedException e) |
||
518 | { |
||
519 | return mapping.findForward("error401"); |
||
520 | } |
||
521 | catch (NotFoundException e) |
||
522 | { |
||
523 | return mapping.findForward("error404"); |
||
524 | } |
||
525 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
526 | { |
||
527 | logger.error(e, e); |
||
528 | return mapping.findForward("error500"); |
||
529 | } |
||
530 | } |
||
531 | |||
532 | public ActionForward savePlano(ActionMapping mapping, |
||
533 | ActionForm form, |
||
534 | HttpServletRequest request, |
||
535 | HttpServletResponse response) |
||
536 | throws ServletException |
||
537 | { |
||
538 | try |
||
539 | { |
||
540 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
541 | long courseId = frm.getCourseId(); |
||
542 | |||
1771 | jmachado | 543 | //FEITO aqui neste ponto apanhar o plano Curso em JSON e criar a classe colocar a classe como argumento em vez de frm.getPlanoEstudos() |
544 | //FEITO criar um campo de texto para colocar o JSON do plano no form |
||
545 | CursoImpl c = CursoImpl.loadFromJson(frm.getPlanoEstudosJsonInterface()); |
||
546 | frm.setPlanoEstudos(c); |
||
547 | |||
1505 | jmachado | 548 | IServiceManager sm = ServiceManager.getInstance(); |
549 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{}; |
||
550 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{courseId,frm.getCourseStudiesPlan().getId(),frm.getPlanoEstudos(),frm.getCourseStudiesPlan()}; |
||
1771 | jmachado | 551 | |
552 | |||
1505 | jmachado | 553 | sm.execute(RequestUtils.getRequester(request, response), "SavePlanoEstudos", args, names); |
554 | addMessage(request, "course.studies.plan.saved"); |
||
555 | request.setAttribute("courseId",courseId); |
||
556 | return mapping.findForward("adminStudyPlans"); |
||
557 | } |
||
558 | catch (FilterChainFailedException e) |
||
559 | { |
||
560 | return mapping.findForward("error401"); |
||
561 | } |
||
562 | catch (NotFoundException e) |
||
563 | { |
||
564 | return mapping.findForward("error404"); |
||
565 | } |
||
566 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
567 | { |
||
568 | logger.error(e, e); |
||
569 | return mapping.findForward("error500"); |
||
570 | } |
||
571 | } |
||
572 | |||
573 | |||
574 | |||
1516 | jmachado | 575 | public ActionForward clonarPlano(ActionMapping mapping, |
576 | ActionForm form, |
||
577 | HttpServletRequest request, |
||
578 | HttpServletResponse response) |
||
579 | throws ServletException |
||
580 | { |
||
581 | try |
||
582 | { |
||
583 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
584 | long planId = frm.getCourseStudiesPlan().getId(); |
||
585 | long sourcePlanId = frm.getSourcePlanId(); |
||
1507 | jmachado | 586 | |
1516 | jmachado | 587 | IServiceManager sm = ServiceManager.getInstance(); |
588 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{}; |
||
589 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{sourcePlanId,planId,frm.getCourseId()}; |
||
590 | CourseStudiesPlanImpl novoPlano = (CourseStudiesPlanImpl) sm.execute(RequestUtils.getRequester(request, response), "CloneStudiesPlanVersionFrom", args, names); |
||
591 | frm.setCourseStudiesPlan(novoPlano); |
||
592 | frm.setPlanoEstudos(new CoursesService().loadCursoPlanoFromXml(novoPlano.getXml())); |
||
1771 | jmachado | 593 | |
1516 | jmachado | 594 | addMessage(request, "course.studies.plan.cloned"); |
595 | return mapping.findForward("editStudyPlan"); |
||
596 | } |
||
597 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
598 | { |
||
599 | logger.error(e, e); |
||
600 | return mapping.findForward("error500"); |
||
601 | } |
||
602 | } |
||
603 | |||
604 | |||
1534 | jmachado | 605 | public ActionForward importarPlano(ActionMapping mapping, |
606 | ActionForm form, |
||
607 | HttpServletRequest request, |
||
608 | HttpServletResponse response) |
||
609 | throws ServletException |
||
610 | { |
||
611 | try |
||
612 | { |
||
613 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
614 | long planId = frm.getCourseStudiesPlan().getId(); |
||
1516 | jmachado | 615 | |
1771 | jmachado | 616 | //FEITO aqui neste ponto apanhar o plano Curso em JSON e criar a classe colocar a classe como argumento em vez de frm.getPlanoEstudos() |
617 | //FEITO criar um campo de texto para colocar o JSON do plano no form |
||
618 | //NAO E USADO MAS SE VIER A SER JA ESTAMOS A GARANTIR QUE O PLANO VEM CERTO |
||
619 | CursoImpl c = CursoImpl.loadFromJson(frm.getPlanoEstudosJsonInterface()); |
||
620 | frm.setPlanoEstudos(c); |
||
1516 | jmachado | 621 | |
1534 | jmachado | 622 | IServiceManager sm = ServiceManager.getInstance(); |
623 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{}; |
||
1535 | jmachado | 624 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{frm.getFormFileImport().getInputStream(),planId}; |
1534 | jmachado | 625 | StudiesPlanImporter importer = (StudiesPlanImporter) sm.execute(RequestUtils.getRequester(request, response), "ImportStudiesPlanVersionFromFile", args, names); |
626 | frm.setPlanoEstudos(importer.getPlanoEstudosCurso()); |
||
627 | addMessage(request, "course.studies.plan.imported"); |
||
1535 | jmachado | 628 | frm.getCourseStudiesPlan().setImportLog(importer.getLog()); |
1534 | jmachado | 629 | return mapping.findForward("editStudyPlan"); |
630 | } |
||
631 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
632 | { |
||
633 | logger.error(e, e); |
||
634 | return mapping.findForward("error500"); |
||
635 | } |
||
636 | } |
||
1516 | jmachado | 637 | |
1541 | jmachado | 638 | public ActionForward mergePlano(ActionMapping mapping, |
639 | ActionForm form, |
||
640 | HttpServletRequest request, |
||
641 | HttpServletResponse response) |
||
642 | throws ServletException |
||
643 | { |
||
644 | try |
||
645 | { |
||
646 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
647 | long planId = frm.getCourseStudiesPlan().getId(); |
||
1534 | jmachado | 648 | |
1771 | jmachado | 649 | //FEITO aqui neste ponto apanhar o plano Curso em JSON e criar a classe colocar a classe como argumento em vez de frm.getPlanoEstudos() |
650 | //FEITO criar um campo de texto para colocar o JSON do plano no form |
||
651 | CursoImpl c = CursoImpl.loadFromJson(frm.getPlanoEstudosJsonInterface()); |
||
652 | frm.setPlanoEstudos(c); |
||
1534 | jmachado | 653 | |
1771 | jmachado | 654 | |
1541 | jmachado | 655 | IServiceManager sm = ServiceManager.getInstance(); |
656 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{}; |
||
1542 | jmachado | 657 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{frm.getFormFileImport2().getInputStream(),planId}; |
1541 | jmachado | 658 | StudiesPlanImporter importer = (StudiesPlanImporter) sm.execute(RequestUtils.getRequester(request, response), "MergeStudiesPlanVersionFromFile", args, names); |
659 | frm.setPlanoEstudos(importer.mergePlanoEstudosCurso(frm.getPlanoEstudos())); |
||
660 | addMessage(request, "course.studies.plan.merged"); |
||
661 | frm.getCourseStudiesPlan().setImportLog(importer.getLog()); |
||
662 | return mapping.findForward("editStudyPlan"); |
||
663 | } |
||
664 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
665 | { |
||
666 | logger.error(e, e); |
||
667 | return mapping.findForward("error500"); |
||
668 | } |
||
669 | } |
||
1534 | jmachado | 670 | |
671 | |||
1541 | jmachado | 672 | |
1667 | jmachado | 673 | /**Widget Controller*/ |
674 | public 1.5.0/docs/api/java/lang/Boolean.html">Boolean addCourseComissionRole(ActionForm form,HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable { |
||
675 | 1.5.0/docs/api/java/lang/String.html">String courseId = request.getParameter("courseId"); |
||
1541 | jmachado | 676 | |
1667 | jmachado | 677 | IServiceManager sm = ServiceManager.getInstance(); |
678 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{}; |
||
679 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{1.5.0/docs/api/java/lang/Long.html">Long.parseLong(courseId)}; |
||
1791 | jmachado | 680 | ReplaceRoleResult result = (ReplaceRoleResult) sm.execute(RequestUtils.getRequester(request, response), "CreateRoleCourseComission", args, names); |
1700 | jmachado | 681 | UserRolesController.evaluateUpdateRoleResult(this,request,result); |
1699 | jmachado | 682 | UserRoleProxy.setDirty(); |
1667 | jmachado | 683 | return true; |
684 | } |
||
1541 | jmachado | 685 | |
1667 | jmachado | 686 | public JSONObject changeCoordinator(ActionForm form,HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable { |
687 | 1.5.0/docs/api/java/lang/String.html">String courseId = request.getParameter("courseId"); |
||
688 | 1.5.0/docs/api/java/lang/String.html">String teacherId = request.getParameter("teacherId"); |
||
689 | |||
690 | IServiceManager sm = ServiceManager.getInstance(); |
||
691 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{}; |
||
692 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{1.5.0/docs/api/java/lang/Long.html">Long.parseLong(teacherId),1.5.0/docs/api/java/lang/Long.html">Long.parseLong(courseId)}; |
||
693 | Teacher t = (Teacher) sm.execute(RequestUtils.getRequester(request, response), "ChangeCourseCoordinator", args, names); |
||
694 | JSONObject tJson = ModelWidgetController.getJsonUser(t); |
||
695 | addMessage(request,"course.coordinator.added.success"); |
||
696 | return tJson; |
||
697 | } |
||
698 | |||
699 | |||
700 | |||
701 | |||
702 | |||
214 | jmachado | 703 | } |