Rev 1541 | Rev 1699 | 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; |
||
1516 | jmachado | 7 | import pt.estgp.estgweb.domain.CourseStudiesPlanImpl; |
376 | jmachado | 8 | import pt.estgp.estgweb.domain.views.CourseView; |
9 | import pt.estgp.estgweb.filters.exceptions.NotFoundException; |
||
1516 | jmachado | 10 | import pt.estgp.estgweb.services.courses.CoursesService; |
1534 | jmachado | 11 | import pt.estgp.estgweb.services.courses.StudiesPlanImporter; |
1507 | jmachado | 12 | import pt.estgp.estgweb.services.courses.xsd.Curso; |
1516 | jmachado | 13 | import pt.estgp.estgweb.services.courses.xsd.PerfilImpl; |
14 | import pt.estgp.estgweb.services.courses.xsd.SemestreImpl; |
||
1507 | jmachado | 15 | import pt.estgp.estgweb.services.courses.xsd.UnidadeImpl; |
376 | jmachado | 16 | import pt.estgp.estgweb.services.courseunits.DirectedCoordinatedCourses; |
17 | import pt.estgp.estgweb.services.courseunits.DirectedCoordinatedUnitsService; |
||
444 | jmachado | 18 | import pt.estgp.estgweb.services.expceptions.AlreadyExistsException; |
214 | jmachado | 19 | import pt.estgp.estgweb.web.controllers.courseunits.CourseUnitsController; |
376 | jmachado | 20 | import pt.estgp.estgweb.web.exceptions.NoCookiesException; |
214 | jmachado | 21 | import pt.estgp.estgweb.web.form.courses.CourseForm; |
1505 | jmachado | 22 | import pt.estgp.estgweb.web.form.courses.CourseStudiesPlansAdminForm; |
214 | jmachado | 23 | import pt.estgp.estgweb.web.utils.RequestUtils; |
376 | jmachado | 24 | import pt.utl.ist.berserk.logic.filterManager.exceptions.FilterRetrieveException; |
25 | import pt.utl.ist.berserk.logic.filterManager.exceptions.IncompatibleFilterException; |
||
26 | import pt.utl.ist.berserk.logic.filterManager.exceptions.InvalidFilterException; |
||
27 | import pt.utl.ist.berserk.logic.filterManager.exceptions.InvalidFilterExpressionException; |
||
214 | jmachado | 28 | import pt.utl.ist.berserk.logic.serviceManager.IServiceManager; |
29 | import pt.utl.ist.berserk.logic.serviceManager.ServiceManager; |
||
30 | import pt.utl.ist.berserk.logic.serviceManager.exceptions.FilterChainFailedException; |
||
31 | import pt.utl.ist.berserk.logic.serviceManager.exceptions.ServiceManagerException; |
||
32 | |||
376 | jmachado | 33 | import javax.servlet.ServletException; |
214 | jmachado | 34 | import javax.servlet.http.HttpServletRequest; |
35 | import javax.servlet.http.HttpServletResponse; |
||
1516 | jmachado | 36 | import java.util.Iterator; |
214 | jmachado | 37 | |
38 | /** |
||
39 | * @author Jorge Machado |
||
40 | * @author Fabio Velez |
||
41 | * @date 26/Fev/2008 |
||
42 | * @time 18:01:54 |
||
43 | * @see pt.estgp.estgweb.web |
||
44 | */ |
||
45 | public class CoursesController extends CourseUnitsController |
||
46 | { |
||
47 | |||
48 | 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); |
||
49 | |||
50 | |||
51 | public ActionForward startNew(ActionMapping mapping, |
||
52 | ActionForm form, |
||
53 | HttpServletRequest request, |
||
54 | HttpServletResponse response) |
||
55 | throws ServletException |
||
56 | { |
||
57 | CourseForm cF = (CourseForm) form; |
||
58 | CourseView cV = cF.getCourseView(); |
||
59 | request.setAttribute("CourseView",cV); |
||
60 | cF.setCourseView(cV); |
||
61 | return mapping.findForward("submit"); |
||
62 | } |
||
1505 | jmachado | 63 | private void loadOnlyCourseAndPlans(CourseForm cF, HttpServletRequest request, HttpServletResponse response) |
64 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable, InvalidFilterException, ServiceManagerException, InvalidFilterExpressionException, IncompatibleFilterException, FilterRetrieveException, NoCookiesException |
||
65 | { |
||
66 | load(cF,request,response,false,true); |
||
214 | jmachado | 67 | |
1505 | jmachado | 68 | } |
69 | |||
214 | jmachado | 70 | private void load(CourseForm cF, HttpServletRequest request, HttpServletResponse response) |
71 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable, InvalidFilterException, ServiceManagerException, InvalidFilterExpressionException, IncompatibleFilterException, FilterRetrieveException, NoCookiesException |
||
72 | { |
||
1505 | jmachado | 73 | load(cF,request,response,true,true); |
74 | } |
||
75 | private void load(CourseForm cF, HttpServletRequest request, HttpServletResponse response,boolean loadUnits,boolean loadStudiesPlans) |
||
76 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable, InvalidFilterException, ServiceManagerException, InvalidFilterExpressionException, IncompatibleFilterException, FilterRetrieveException, NoCookiesException |
||
77 | { |
||
214 | jmachado | 78 | 1.5.0/docs/api/java/lang/String.html">String code = cF.getCourseView().getCode(); |
79 | long id = cF.getCourseView().getId(); |
||
376 | jmachado | 80 | |
214 | jmachado | 81 | IServiceManager sm = ServiceManager.getInstance(); |
82 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{"serializable"}; |
||
83 | 5+0%2Fdocs%2Fapi+Object">Object[] args; |
||
84 | 1.5.0/docs/api/java/lang/String.html">String serviceName; |
||
85 | if(code != null) |
||
86 | { |
||
1505 | jmachado | 87 | args = new 5+0%2Fdocs%2Fapi+Object">Object[]{code,loadUnits}; |
88 | if(loadStudiesPlans) |
||
89 | serviceName = "LoadCourseByCodeAndStudiesPlans"; |
||
90 | else |
||
91 | serviceName = "LoadCourseByCode"; |
||
214 | jmachado | 92 | } |
93 | else |
||
94 | { |
||
1505 | jmachado | 95 | args = new 5+0%2Fdocs%2Fapi+Object">Object[]{id,loadUnits}; |
96 | if(loadStudiesPlans) |
||
97 | serviceName = "LoadCourseAndStudiesPlans"; |
||
98 | else |
||
99 | serviceName = "LoadCourse"; |
||
214 | jmachado | 100 | } |
101 | CourseView cV = (CourseView) sm.execute(RequestUtils.getRequester(request, response), serviceName, args, names); |
||
102 | request.setAttribute("CourseView",cV); |
||
103 | cF.setCourseView(cV); |
||
104 | } |
||
105 | |||
1486 | jmachado | 106 | private void loadForPublic(CourseForm cF, HttpServletRequest request, HttpServletResponse response) |
107 | throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable, InvalidFilterException, ServiceManagerException, InvalidFilterExpressionException, IncompatibleFilterException, FilterRetrieveException, NoCookiesException |
||
108 | { |
||
1505 | jmachado | 109 | load(cF,request,response,false,false); |
110 | /* String code = cF.getCourseView().getCode(); |
||
1486 | jmachado | 111 | long id = cF.getCourseView().getId(); |
112 | |||
113 | IServiceManager sm = ServiceManager.getInstance(); |
||
114 | String[] names = new String[]{"serializable"}; |
||
115 | Object[] args; |
||
116 | String serviceName; |
||
117 | if(code != null) |
||
118 | { |
||
119 | args = new Object[]{code,false}; |
||
120 | serviceName = "LoadCourseByCode"; |
||
121 | } |
||
122 | else |
||
123 | { |
||
1487 | jmachado | 124 | args = new Object[]{id,false}; |
1486 | jmachado | 125 | serviceName = "LoadCourse"; |
126 | } |
||
127 | CourseView cV = (CourseView) sm.execute(RequestUtils.getRequester(request, response), serviceName, args, names); |
||
128 | request.setAttribute("CourseView",cV); |
||
1505 | jmachado | 129 | cF.setCourseView(cV);*/ |
1486 | jmachado | 130 | } |
131 | |||
649 | jmachado | 132 | public ActionForward loadPlan(ActionMapping mapping, |
133 | ActionForm form, |
||
134 | HttpServletRequest request, |
||
135 | HttpServletResponse response) |
||
136 | throws ServletException |
||
137 | { |
||
138 | try |
||
139 | { |
||
140 | load((CourseForm) form,request,response); |
||
141 | return mapping.findForward("loadPlan"); |
||
142 | } |
||
143 | catch (FilterChainFailedException e) |
||
144 | { |
||
145 | return mapping.findForward("error401"); |
||
146 | } |
||
147 | catch (NotFoundException e) |
||
148 | { |
||
149 | return mapping.findForward("error404"); |
||
150 | } |
||
151 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
152 | { |
||
153 | logger.error(e, e); |
||
154 | return mapping.findForward("error500"); |
||
155 | } |
||
156 | } |
||
157 | |||
214 | jmachado | 158 | public ActionForward load(ActionMapping mapping, |
159 | ActionForm form, |
||
160 | HttpServletRequest request, |
||
161 | HttpServletResponse response) |
||
162 | throws ServletException |
||
163 | { |
||
164 | try |
||
165 | { |
||
166 | load((CourseForm) form,request,response); |
||
167 | return mapping.findForward("load"); |
||
168 | } |
||
169 | catch (FilterChainFailedException e) |
||
170 | { |
||
171 | return mapping.findForward("error401"); |
||
172 | } |
||
173 | catch (NotFoundException e) |
||
174 | { |
||
175 | return mapping.findForward("error404"); |
||
176 | } |
||
177 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
178 | { |
||
179 | logger.error(e, e); |
||
180 | return mapping.findForward("error500"); |
||
181 | } |
||
182 | } |
||
183 | |||
641 | jmachado | 184 | |
185 | public ActionForward loadSeparators(ActionMapping mapping, |
||
186 | ActionForm form, |
||
187 | HttpServletRequest request, |
||
188 | HttpServletResponse response) |
||
189 | throws ServletException |
||
190 | { |
||
191 | try |
||
192 | { |
||
1486 | jmachado | 193 | loadForPublic((CourseForm) form,request,response); |
641 | jmachado | 194 | return mapping.findForward("loadSeparators"); |
195 | } |
||
196 | catch (FilterChainFailedException e) |
||
197 | { |
||
198 | return mapping.findForward("error401"); |
||
199 | } |
||
200 | catch (NotFoundException e) |
||
201 | { |
||
202 | return mapping.findForward("error404"); |
||
203 | } |
||
204 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
205 | { |
||
206 | logger.error(e, e); |
||
207 | return mapping.findForward("error500"); |
||
208 | } |
||
209 | } |
||
210 | |||
649 | jmachado | 211 | |
212 | public ActionForward loadMenu(ActionMapping mapping, |
||
213 | ActionForm form, |
||
214 | HttpServletRequest request, |
||
215 | HttpServletResponse response) |
||
216 | throws ServletException |
||
217 | { |
||
218 | try |
||
219 | { |
||
220 | load((CourseForm) form,request,response); |
||
221 | return mapping.findForward("loadMenu"); |
||
222 | } |
||
223 | catch (FilterChainFailedException e) |
||
224 | { |
||
225 | return mapping.findForward("error401"); |
||
226 | } |
||
227 | catch (NotFoundException e) |
||
228 | { |
||
229 | return mapping.findForward("error404"); |
||
230 | } |
||
231 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
232 | { |
||
233 | logger.error(e, e); |
||
234 | return mapping.findForward("error500"); |
||
235 | } |
||
236 | } |
||
237 | |||
238 | |||
214 | jmachado | 239 | public ActionForward edit(ActionMapping mapping, |
240 | ActionForm form, |
||
241 | HttpServletRequest request, |
||
242 | HttpServletResponse response) |
||
243 | throws ServletException |
||
244 | { |
||
245 | try |
||
246 | { |
||
247 | load((CourseForm) form,request,response); |
||
248 | return mapping.findForward("submit"); |
||
249 | } |
||
250 | catch (FilterChainFailedException e) |
||
251 | { |
||
252 | return mapping.findForward("error401"); |
||
253 | } |
||
254 | catch (NotFoundException e) |
||
255 | { |
||
256 | return mapping.findForward("error404"); |
||
257 | } |
||
258 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
259 | { |
||
260 | logger.error(e, e); |
||
261 | return mapping.findForward("error500"); |
||
262 | } |
||
263 | } |
||
264 | |||
1505 | jmachado | 265 | public ActionForward editAdmin(ActionMapping mapping, |
266 | ActionForm form, |
||
267 | HttpServletRequest request, |
||
268 | HttpServletResponse response) |
||
269 | throws ServletException |
||
270 | { |
||
271 | try |
||
272 | { |
||
273 | loadOnlyCourseAndPlans((CourseForm) form, request, response); |
||
274 | return mapping.findForward("submit"); |
||
275 | } |
||
276 | catch (FilterChainFailedException e) |
||
277 | { |
||
278 | return mapping.findForward("error401"); |
||
279 | } |
||
280 | catch (NotFoundException e) |
||
281 | { |
||
282 | return mapping.findForward("error404"); |
||
283 | } |
||
284 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
285 | { |
||
286 | logger.error(e, e); |
||
287 | return mapping.findForward("error500"); |
||
288 | } |
||
289 | } |
||
290 | |||
1540 | jmachado | 291 | public ActionForward submitAndAdminStudyPlan(ActionMapping mapping, |
292 | ActionForm form, |
||
293 | HttpServletRequest request, |
||
294 | HttpServletResponse response) |
||
295 | throws ServletException |
||
296 | { |
||
297 | ActionForward forward = submit(mapping,form,request,response); |
||
298 | if(forward.getPath() == mapping.getInputForward().getPath()) |
||
299 | { |
||
300 | CourseForm cF = (CourseForm) form; |
||
301 | long id = cF.getCourseView().getId(); |
||
302 | request.setAttribute("courseId",id); |
||
303 | return mapping.findForward("adminStudiesPlans"); |
||
304 | } |
||
305 | return forward; |
||
306 | |||
307 | } |
||
308 | |||
214 | jmachado | 309 | public ActionForward submit(ActionMapping mapping, |
310 | ActionForm form, |
||
311 | HttpServletRequest request, |
||
312 | HttpServletResponse response) |
||
313 | throws ServletException |
||
314 | { |
||
315 | try |
||
316 | { |
||
317 | CourseForm cF = (CourseForm) form; |
||
318 | IServiceManager sm = ServiceManager.getInstance(); |
||
319 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{"object"}; |
||
320 | 5+0%2Fdocs%2Fapi+Object">Object[] args; |
||
321 | |||
322 | if(cF.getStudiesPlan() == null || cF.getStudiesPlan().getFileSize() <= 0) |
||
323 | args = new 5+0%2Fdocs%2Fapi+Object">Object[]{cF.getCourseView(),null,null,0,null}; |
||
324 | else //ring name, int size, String contentType, String extensio |
||
325 | args = new 5+0%2Fdocs%2Fapi+Object">Object[]{cF.getCourseView(),cF.getStudiesPlan().getInputStream(),cF.getStudiesPlan().getFileName(),cF.getStudiesPlan().getFileSize(),cF.getStudiesPlan().getContentType()}; |
||
326 | |||
327 | long id = cF.getCourseView().getId(); |
||
328 | CourseView cV = (CourseView) sm.execute(RequestUtils.getRequester(request, response), "SubmitCourse", args, names); |
||
329 | request.setAttribute("CourseView",cV); |
||
248 | jmachado | 330 | if(cV.getHtmlResult() != null) |
331 | { |
||
376 | jmachado | 332 | return mapping.findForward("submit"); |
248 | jmachado | 333 | } |
334 | |||
214 | jmachado | 335 | cF.setCourseView(cV); |
336 | if(id > 0) |
||
337 | addMessage(request,"course.updated.success","" + cV.getCode()); |
||
338 | else |
||
339 | addMessage(request,"course.created.success","" + cV.getCode()); |
||
340 | return mapping.getInputForward(); |
||
341 | } |
||
444 | jmachado | 342 | catch (AlreadyExistsException e) |
343 | { |
||
344 | addErrorWithKeys(request,"course.exists",e.getMessage()); |
||
345 | try |
||
346 | { |
||
347 | load((CourseForm) form,request,response); |
||
348 | return mapping.findForward("submit"); |
||
349 | } |
||
350 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable throwable) |
||
351 | { |
||
352 | logger.error(e, e); |
||
353 | return mapping.findForward("error500"); |
||
354 | } |
||
355 | } |
||
214 | jmachado | 356 | catch (FilterChainFailedException e) |
357 | { |
||
358 | return mapping.findForward("error401"); |
||
359 | } |
||
360 | catch (NotFoundException e) |
||
361 | { |
||
362 | return mapping.findForward("error404"); |
||
363 | } |
||
364 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
365 | { |
||
366 | logger.error(e, e); |
||
367 | return mapping.findForward("error500"); |
||
368 | } |
||
369 | } |
||
343 | jmachado | 370 | |
371 | |||
1506 | jmachado | 372 | |
373 | |||
344 | jmachado | 374 | public ActionForward loadCoursesPrograms(ActionMapping mapping, |
376 | jmachado | 375 | ActionForm form, |
376 | HttpServletRequest request, |
||
377 | HttpServletResponse response) |
||
344 | jmachado | 378 | throws ServletException |
379 | { |
||
380 | try |
||
381 | { |
||
382 | CourseForm cF = (CourseForm) form; |
||
345 | jmachado | 383 | 1.5.0/docs/api/java/lang/String.html">String importYear = cF.getImportYear(); |
376 | jmachado | 384 | long courseId = cF.getCourseId(); |
1039 | jmachado | 385 | if(courseId <= 0) |
386 | { |
||
387 | addError(request,"courses.fill.course"); |
||
388 | return mapping.findForward("load.courses.programs"); |
||
389 | } |
||
376 | jmachado | 390 | 1.5.0/docs/api/java/lang/String.html">String semestre = cF.getSemestre(); |
391 | 1.5.0/docs/api/java/lang/String.html">String area = cF.getArea(); |
||
392 | DirectedCoordinatedUnitsService.TeachersSituationEnum teachersSituationEnum = cF.getTeacherSituationEnum(); |
||
1312 | jmachado | 393 | 1.5.0/docs/api/java/lang/String.html">String institutionCode = cF.getInstitutionCode(); |
376 | jmachado | 394 | |
344 | jmachado | 395 | IServiceManager sm = ServiceManager.getInstance(); |
1312 | jmachado | 396 | 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"}; |
397 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{importYear,courseId,semestre,area,teachersSituationEnum,institutionCode}; |
||
344 | jmachado | 398 | DirectedCoordinatedCourses directedCoordinatedCourses = (DirectedCoordinatedCourses) sm.execute(RequestUtils.getRequester(request, response), "LoadCoursesProgramsForServices", args, names); |
399 | cF.setDirectedCoordinatedCourses(directedCoordinatedCourses); |
||
376 | jmachado | 400 | cF.setArea(directedCoordinatedCourses.getArea()); |
401 | cF.setCourseId(directedCoordinatedCourses.getCourseId()); |
||
344 | jmachado | 402 | return mapping.findForward("load.courses.programs"); |
403 | } |
||
404 | catch (FilterChainFailedException e) |
||
405 | { |
||
406 | return mapping.findForward("error401"); |
||
407 | } |
||
408 | catch (NotFoundException e) |
||
409 | { |
||
410 | return mapping.findForward("error404"); |
||
411 | } |
||
412 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
413 | { |
||
414 | logger.error(e, e); |
||
415 | return mapping.findForward("error500"); |
||
416 | } |
||
417 | } |
||
418 | |||
343 | jmachado | 419 | public ActionForward loadDirectedCoordininatedCourses(ActionMapping mapping, |
376 | jmachado | 420 | ActionForm form, |
421 | HttpServletRequest request, |
||
422 | HttpServletResponse response) |
||
343 | jmachado | 423 | throws ServletException |
424 | { |
||
425 | try |
||
426 | { |
||
345 | jmachado | 427 | |
343 | jmachado | 428 | CourseForm cF = (CourseForm) form; |
345 | jmachado | 429 | 1.5.0/docs/api/java/lang/String.html">String importYear = cF.getImportYear(); |
343 | jmachado | 430 | IServiceManager sm = ServiceManager.getInstance(); |
345 | jmachado | 431 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{"importYear"}; |
432 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 1.5.0/docs/api/java/lang/String.html">String[]{importYear}; |
||
343 | jmachado | 433 | DirectedCoordinatedCourses directedCoordinatedCourses = (DirectedCoordinatedCourses) sm.execute(RequestUtils.getRequester(request, response), "LoadDirectedCoordinatedCoursesForUserInSession", args, names); |
434 | cF.setDirectedCoordinatedCourses(directedCoordinatedCourses); |
||
435 | return mapping.findForward("load.directed.coordinated.courses"); |
||
436 | } |
||
437 | catch (FilterChainFailedException e) |
||
438 | { |
||
439 | return mapping.findForward("error401"); |
||
440 | } |
||
441 | catch (NotFoundException e) |
||
442 | { |
||
443 | return mapping.findForward("error404"); |
||
444 | } |
||
445 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
446 | { |
||
447 | logger.error(e, e); |
||
448 | return mapping.findForward("error500"); |
||
449 | } |
||
450 | } |
||
451 | |||
452 | public ActionForward updateDirectedCoordininatedCourses(ActionMapping mapping, |
||
376 | jmachado | 453 | ActionForm form, |
454 | HttpServletRequest request, |
||
455 | HttpServletResponse response) |
||
343 | jmachado | 456 | throws ServletException |
457 | { |
||
458 | try |
||
459 | { |
||
460 | CourseForm cF = (CourseForm) form; |
||
461 | IServiceManager sm = ServiceManager.getInstance(); |
||
462 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{"directedCoordinatedCourses"}; |
||
463 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{cF.getDirectedCoordinatedCourses()}; |
||
464 | DirectedCoordinatedCourses directedCoordinatedCourses = (DirectedCoordinatedCourses) sm.execute(RequestUtils.getRequester(request, response), "UpdateDirectedCoordinatedCoursesForUserInSession", args, names); |
||
465 | cF.setDirectedCoordinatedCourses(directedCoordinatedCourses); |
||
466 | addMessage(request,"course.directed.coordinated.courses.updated.success",""+directedCoordinatedCourses.getUpdated()); |
||
345 | jmachado | 467 | return mapping.findForward("confirm.courses.programs"); |
343 | jmachado | 468 | } |
469 | catch (FilterChainFailedException e) |
||
470 | { |
||
471 | return mapping.findForward("error401"); |
||
472 | } |
||
473 | catch (NotFoundException e) |
||
474 | { |
||
475 | return mapping.findForward("error404"); |
||
476 | } |
||
477 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
478 | { |
||
479 | logger.error(e, e); |
||
480 | return mapping.findForward("error500"); |
||
481 | } |
||
482 | } |
||
1505 | jmachado | 483 | |
484 | |||
485 | /** |
||
486 | * StudiesPlans Controller Functions |
||
487 | * @param mapping |
||
488 | * @param form |
||
489 | * @param request |
||
490 | * @param response |
||
491 | * @return |
||
492 | * @throws ServletException |
||
493 | */ |
||
494 | public ActionForward addNewVersion(ActionMapping mapping, |
||
495 | ActionForm form, |
||
496 | HttpServletRequest request, |
||
497 | HttpServletResponse response) |
||
498 | throws ServletException |
||
499 | { |
||
500 | try |
||
501 | { |
||
502 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
503 | long courseId = frm.getCourseId(); |
||
504 | |||
505 | IServiceManager sm = ServiceManager.getInstance(); |
||
506 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{}; |
||
507 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{courseId,frm.getCourseStudiesPlan()}; |
||
508 | sm.execute(RequestUtils.getRequester(request, response), "AddNewStudiesPlan", args, names); |
||
509 | addMessage(request, "course.studies.plan.added"); |
||
510 | return mapping.findForward("loadstudyplans"); |
||
511 | } |
||
512 | catch (FilterChainFailedException e) |
||
513 | { |
||
514 | return mapping.findForward("error401"); |
||
515 | } |
||
516 | catch (NotFoundException e) |
||
517 | { |
||
518 | return mapping.findForward("error404"); |
||
519 | } |
||
520 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
521 | { |
||
522 | logger.error(e, e); |
||
523 | return mapping.findForward("error500"); |
||
524 | } |
||
525 | } |
||
526 | |||
527 | public ActionForward savePlano(ActionMapping mapping, |
||
528 | ActionForm form, |
||
529 | HttpServletRequest request, |
||
530 | HttpServletResponse response) |
||
531 | throws ServletException |
||
532 | { |
||
533 | try |
||
534 | { |
||
535 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
536 | long courseId = frm.getCourseId(); |
||
537 | |||
538 | IServiceManager sm = ServiceManager.getInstance(); |
||
539 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{}; |
||
540 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{courseId,frm.getCourseStudiesPlan().getId(),frm.getPlanoEstudos(),frm.getCourseStudiesPlan()}; |
||
541 | sm.execute(RequestUtils.getRequester(request, response), "SavePlanoEstudos", args, names); |
||
542 | addMessage(request, "course.studies.plan.saved"); |
||
543 | request.setAttribute("courseId",courseId); |
||
544 | return mapping.findForward("adminStudyPlans"); |
||
545 | } |
||
546 | catch (FilterChainFailedException e) |
||
547 | { |
||
548 | return mapping.findForward("error401"); |
||
549 | } |
||
550 | catch (NotFoundException e) |
||
551 | { |
||
552 | return mapping.findForward("error404"); |
||
553 | } |
||
554 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
555 | { |
||
556 | logger.error(e, e); |
||
557 | return mapping.findForward("error500"); |
||
558 | } |
||
559 | } |
||
560 | |||
1507 | jmachado | 561 | public ActionForward addUnidadePerfil(ActionMapping mapping, |
562 | ActionForm form, |
||
563 | HttpServletRequest request, |
||
564 | HttpServletResponse response) |
||
565 | throws ServletException |
||
566 | { |
||
567 | try |
||
568 | { |
||
569 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
570 | 1.5.0/docs/api/java/lang/String.html">String perfilId = frm.getPerfilId(); |
||
571 | for(Curso.Semestre semestre: frm.getPlanoEstudos().getSemestre()){ |
||
572 | for(Curso.Semestre.Perfil perfil: semestre.getPerfil()) |
||
573 | { |
||
574 | if(perfil.getPerfilId().equals(perfilId)) |
||
575 | { |
||
576 | perfil.getUnidade().add(new UnidadeImpl()); |
||
577 | break; |
||
578 | } |
||
579 | } |
||
580 | } |
||
581 | return mapping.findForward("editStudyPlan"); |
||
582 | } |
||
583 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
584 | { |
||
585 | logger.error(e, e); |
||
586 | return mapping.findForward("error500"); |
||
587 | } |
||
588 | } |
||
1516 | jmachado | 589 | public ActionForward removePerfil(ActionMapping mapping, |
590 | ActionForm form, |
||
591 | HttpServletRequest request, |
||
592 | HttpServletResponse response) |
||
593 | throws ServletException |
||
594 | { |
||
595 | try |
||
596 | { |
||
597 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
598 | 1.5.0/docs/api/java/lang/String.html">String perfilId = frm.getPerfilId(); |
||
599 | for(Curso.Semestre semestre: frm.getPlanoEstudos().getSemestre()){ |
||
600 | Iterator<Curso.Semestre.Perfil> iterPerfil = semestre.getPerfil().iterator(); |
||
601 | while(iterPerfil.hasNext()) |
||
602 | { |
||
603 | Curso.Semestre.Perfil perfil = iterPerfil.next(); |
||
604 | if(perfil.getPerfilId().equals(perfilId)) |
||
605 | { |
||
606 | iterPerfil.remove(); |
||
607 | break; |
||
608 | } |
||
609 | } |
||
610 | } |
||
611 | return mapping.findForward("editStudyPlan"); |
||
612 | } |
||
613 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
614 | { |
||
615 | logger.error(e, e); |
||
616 | return mapping.findForward("error500"); |
||
617 | } |
||
618 | } |
||
1507 | jmachado | 619 | public ActionForward addUnidadeSemestre(ActionMapping mapping, |
620 | ActionForm form, |
||
621 | HttpServletRequest request, |
||
622 | HttpServletResponse response) |
||
623 | throws ServletException |
||
624 | { |
||
625 | try |
||
626 | { |
||
627 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
628 | 1.5.0/docs/api/java/lang/String.html">String semestreId = frm.getSemestreId(); |
||
629 | for(Curso.Semestre semestre: frm.getPlanoEstudos().getSemestre()) |
||
630 | { |
||
631 | if(semestre.getSemestreId().equals(semestreId)) |
||
632 | { |
||
633 | semestre.getUnidade().add(new UnidadeImpl()); |
||
634 | break; |
||
635 | } |
||
636 | } |
||
637 | return mapping.findForward("editStudyPlan"); |
||
638 | } |
||
639 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
640 | { |
||
641 | logger.error(e, e); |
||
642 | return mapping.findForward("error500"); |
||
643 | } |
||
644 | } |
||
1505 | jmachado | 645 | |
1516 | jmachado | 646 | public ActionForward removeSemestre(ActionMapping mapping, |
647 | ActionForm form, |
||
648 | HttpServletRequest request, |
||
649 | HttpServletResponse response) |
||
650 | throws ServletException |
||
651 | { |
||
652 | try |
||
653 | { |
||
654 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
655 | 1.5.0/docs/api/java/lang/String.html">String semestreId = frm.getSemestreId(); |
||
656 | Iterator<Curso.Semestre> iteSem = frm.getPlanoEstudos().getSemestre().iterator(); |
||
657 | while(iteSem.hasNext()) |
||
658 | { |
||
659 | Curso.Semestre semestre = iteSem.next(); |
||
660 | if(semestre.getSemestreId().equals(semestreId)) |
||
661 | { |
||
662 | iteSem.remove(); |
||
663 | break; |
||
664 | } |
||
665 | } |
||
666 | return mapping.findForward("editStudyPlan"); |
||
667 | } |
||
668 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
669 | { |
||
670 | logger.error(e, e); |
||
671 | return mapping.findForward("error500"); |
||
672 | } |
||
673 | } |
||
1505 | jmachado | 674 | |
1516 | jmachado | 675 | public ActionForward addNewSemestre(ActionMapping mapping, |
676 | ActionForm form, |
||
677 | HttpServletRequest request, |
||
678 | HttpServletResponse response) |
||
679 | throws ServletException |
||
680 | { |
||
681 | try |
||
682 | { |
||
683 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
684 | frm.getPlanoEstudos().getSemestre().add(new SemestreImpl()); |
||
685 | return mapping.findForward("editStudyPlan"); |
||
686 | } |
||
687 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
688 | { |
||
689 | logger.error(e, e); |
||
690 | return mapping.findForward("error500"); |
||
691 | } |
||
692 | } |
||
1505 | jmachado | 693 | |
1516 | jmachado | 694 | public ActionForward addPerfilSemestre(ActionMapping mapping, |
695 | ActionForm form, |
||
696 | HttpServletRequest request, |
||
697 | HttpServletResponse response) |
||
698 | throws ServletException |
||
699 | { |
||
700 | try |
||
701 | { |
||
702 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
703 | 1.5.0/docs/api/java/lang/String.html">String semestreId = frm.getSemestreId(); |
||
704 | for(Curso.Semestre semestre: frm.getPlanoEstudos().getSemestre()) |
||
705 | { |
||
706 | if(semestre.getSemestreId().equals(semestreId)) |
||
707 | { |
||
708 | semestre.getPerfil().add(new PerfilImpl()); |
||
709 | break; |
||
710 | } |
||
711 | } |
||
712 | return mapping.findForward("editStudyPlan"); |
||
713 | } |
||
714 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
715 | { |
||
716 | logger.error(e, e); |
||
717 | return mapping.findForward("error500"); |
||
718 | } |
||
719 | } |
||
1505 | jmachado | 720 | |
1517 | jmachado | 721 | public ActionForward sendUpSemestre(ActionMapping mapping, |
722 | ActionForm form, |
||
723 | HttpServletRequest request, |
||
724 | HttpServletResponse response) |
||
725 | throws ServletException |
||
726 | { |
||
727 | try |
||
728 | { |
||
729 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
730 | 1.5.0/docs/api/java/lang/String.html">String semestreId = frm.getSemestreId(); |
||
731 | for(int i = 0; i < frm.getPlanoEstudos().getSemestre().size();i++) |
||
732 | { |
||
733 | Curso.Semestre semestre = frm.getPlanoEstudos().getSemestre().get(i); |
||
734 | if(semestre.getSemestreId().equals(semestreId)) |
||
735 | { |
||
736 | int nextPos = i-1; |
||
737 | frm.getPlanoEstudos().getSemestre().remove(i); |
||
738 | if(nextPos < 0) |
||
739 | nextPos = 0; |
||
740 | frm.getPlanoEstudos().getSemestre().add(nextPos,semestre); |
||
741 | break; |
||
742 | } |
||
743 | } |
||
744 | return mapping.findForward("editStudyPlan"); |
||
745 | } |
||
746 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
747 | { |
||
748 | logger.error(e, e); |
||
749 | return mapping.findForward("error500"); |
||
750 | } |
||
751 | } |
||
752 | public ActionForward sendDownSemestre(ActionMapping mapping, |
||
753 | ActionForm form, |
||
754 | HttpServletRequest request, |
||
755 | HttpServletResponse response) |
||
756 | throws ServletException |
||
757 | { |
||
758 | try |
||
759 | { |
||
760 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
761 | 1.5.0/docs/api/java/lang/String.html">String semestreId = frm.getSemestreId(); |
||
762 | for(int i = 0; i < frm.getPlanoEstudos().getSemestre().size();i++) |
||
763 | { |
||
764 | Curso.Semestre semestre = frm.getPlanoEstudos().getSemestre().get(i); |
||
765 | if(semestre.getSemestreId().equals(semestreId)) |
||
766 | { |
||
767 | int nextPos = i+1; |
||
768 | frm.getPlanoEstudos().getSemestre().remove(i); |
||
769 | if(nextPos >= frm.getPlanoEstudos().getSemestre().size()) |
||
770 | frm.getPlanoEstudos().getSemestre().add(semestre); |
||
771 | else |
||
772 | frm.getPlanoEstudos().getSemestre().add(nextPos,semestre); |
||
773 | break; |
||
774 | } |
||
775 | } |
||
776 | return mapping.findForward("editStudyPlan"); |
||
777 | } |
||
778 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
779 | { |
||
780 | logger.error(e, e); |
||
781 | return mapping.findForward("error500"); |
||
782 | } |
||
783 | } |
||
784 | |||
785 | public ActionForward sendUpPerfil(ActionMapping mapping, |
||
786 | ActionForm form, |
||
787 | HttpServletRequest request, |
||
788 | HttpServletResponse response) |
||
789 | throws ServletException |
||
790 | { |
||
791 | try |
||
792 | { |
||
793 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
794 | 1.5.0/docs/api/java/lang/String.html">String perfilId = frm.getPerfilId(); |
||
795 | |||
796 | for(Curso.Semestre semestre: frm.getPlanoEstudos().getSemestre()) |
||
797 | { |
||
798 | for(int i = 0; i < semestre.getPerfil().size();i++) |
||
799 | { |
||
800 | Curso.Semestre.Perfil perfil = semestre.getPerfil().get(i); |
||
801 | if(perfil.getPerfilId().equals(perfilId)) |
||
802 | { |
||
803 | int nextPos = i-1; |
||
804 | semestre.getPerfil().remove(i); |
||
805 | if(nextPos < 0) |
||
806 | nextPos = 0; |
||
807 | semestre.getPerfil().add(nextPos,perfil); |
||
808 | break; |
||
809 | } |
||
810 | } |
||
811 | } |
||
812 | return mapping.findForward("editStudyPlan"); |
||
813 | } |
||
814 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
815 | { |
||
816 | logger.error(e, e); |
||
817 | return mapping.findForward("error500"); |
||
818 | } |
||
819 | } |
||
820 | public ActionForward sendDownPerfil(ActionMapping mapping, |
||
821 | ActionForm form, |
||
822 | HttpServletRequest request, |
||
823 | HttpServletResponse response) |
||
824 | throws ServletException |
||
825 | { |
||
826 | try |
||
827 | { |
||
828 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
829 | 1.5.0/docs/api/java/lang/String.html">String perfilId = frm.getPerfilId(); |
||
830 | |||
831 | for(Curso.Semestre semestre: frm.getPlanoEstudos().getSemestre()) |
||
832 | { |
||
833 | for(int i = 0; i < semestre.getPerfil().size();i++) |
||
834 | { |
||
835 | Curso.Semestre.Perfil perfil = semestre.getPerfil().get(i); |
||
836 | if(perfil.getPerfilId().equals(perfilId)) |
||
837 | { |
||
838 | int nextPos = i+1; |
||
839 | semestre.getPerfil().remove(i); |
||
840 | if(nextPos >= semestre.getPerfil().size()) |
||
841 | semestre.getPerfil().add(perfil); |
||
842 | else |
||
843 | semestre.getPerfil().add(nextPos,perfil); |
||
844 | break; |
||
845 | } |
||
846 | } |
||
847 | } |
||
848 | return mapping.findForward("editStudyPlan"); |
||
849 | } |
||
850 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
851 | { |
||
852 | logger.error(e, e); |
||
853 | return mapping.findForward("error500"); |
||
854 | } |
||
855 | } |
||
856 | |||
1516 | jmachado | 857 | public ActionForward clonarPlano(ActionMapping mapping, |
858 | ActionForm form, |
||
859 | HttpServletRequest request, |
||
860 | HttpServletResponse response) |
||
861 | throws ServletException |
||
862 | { |
||
863 | try |
||
864 | { |
||
865 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
866 | long planId = frm.getCourseStudiesPlan().getId(); |
||
867 | long sourcePlanId = frm.getSourcePlanId(); |
||
1507 | jmachado | 868 | |
1516 | jmachado | 869 | IServiceManager sm = ServiceManager.getInstance(); |
870 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{}; |
||
871 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{sourcePlanId,planId,frm.getCourseId()}; |
||
872 | CourseStudiesPlanImpl novoPlano = (CourseStudiesPlanImpl) sm.execute(RequestUtils.getRequester(request, response), "CloneStudiesPlanVersionFrom", args, names); |
||
873 | frm.setCourseStudiesPlan(novoPlano); |
||
874 | frm.setPlanoEstudos(new CoursesService().loadCursoPlanoFromXml(novoPlano.getXml())); |
||
875 | addMessage(request, "course.studies.plan.cloned"); |
||
876 | return mapping.findForward("editStudyPlan"); |
||
877 | } |
||
878 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
879 | { |
||
880 | logger.error(e, e); |
||
881 | return mapping.findForward("error500"); |
||
882 | } |
||
883 | } |
||
884 | |||
885 | |||
1534 | jmachado | 886 | public ActionForward importarPlano(ActionMapping mapping, |
887 | ActionForm form, |
||
888 | HttpServletRequest request, |
||
889 | HttpServletResponse response) |
||
890 | throws ServletException |
||
891 | { |
||
892 | try |
||
893 | { |
||
894 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
895 | long planId = frm.getCourseStudiesPlan().getId(); |
||
1516 | jmachado | 896 | |
897 | |||
1534 | jmachado | 898 | IServiceManager sm = ServiceManager.getInstance(); |
899 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{}; |
||
1535 | jmachado | 900 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{frm.getFormFileImport().getInputStream(),planId}; |
1534 | jmachado | 901 | StudiesPlanImporter importer = (StudiesPlanImporter) sm.execute(RequestUtils.getRequester(request, response), "ImportStudiesPlanVersionFromFile", args, names); |
902 | frm.setPlanoEstudos(importer.getPlanoEstudosCurso()); |
||
903 | addMessage(request, "course.studies.plan.imported"); |
||
1535 | jmachado | 904 | frm.getCourseStudiesPlan().setImportLog(importer.getLog()); |
1534 | jmachado | 905 | return mapping.findForward("editStudyPlan"); |
906 | } |
||
907 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
908 | { |
||
909 | logger.error(e, e); |
||
910 | return mapping.findForward("error500"); |
||
911 | } |
||
912 | } |
||
1516 | jmachado | 913 | |
1541 | jmachado | 914 | public ActionForward mergePlano(ActionMapping mapping, |
915 | ActionForm form, |
||
916 | HttpServletRequest request, |
||
917 | HttpServletResponse response) |
||
918 | throws ServletException |
||
919 | { |
||
920 | try |
||
921 | { |
||
922 | CourseStudiesPlansAdminForm frm = (CourseStudiesPlansAdminForm) form; |
||
923 | long planId = frm.getCourseStudiesPlan().getId(); |
||
1534 | jmachado | 924 | |
925 | |||
1541 | jmachado | 926 | IServiceManager sm = ServiceManager.getInstance(); |
927 | 1.5.0/docs/api/java/lang/String.html">String[] names = new 1.5.0/docs/api/java/lang/String.html">String[]{}; |
||
1542 | jmachado | 928 | 5+0%2Fdocs%2Fapi+Object">Object[] args = new 5+0%2Fdocs%2Fapi+Object">Object[]{frm.getFormFileImport2().getInputStream(),planId}; |
1541 | jmachado | 929 | StudiesPlanImporter importer = (StudiesPlanImporter) sm.execute(RequestUtils.getRequester(request, response), "MergeStudiesPlanVersionFromFile", args, names); |
930 | frm.setPlanoEstudos(importer.mergePlanoEstudosCurso(frm.getPlanoEstudos())); |
||
931 | addMessage(request, "course.studies.plan.merged"); |
||
932 | frm.getCourseStudiesPlan().setImportLog(importer.getLog()); |
||
933 | return mapping.findForward("editStudyPlan"); |
||
934 | } |
||
935 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
936 | { |
||
937 | logger.error(e, e); |
||
938 | return mapping.findForward("error500"); |
||
939 | } |
||
940 | } |
||
1534 | jmachado | 941 | |
942 | |||
1541 | jmachado | 943 | |
944 | |||
945 | |||
214 | jmachado | 946 | } |