Rev 1925 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1892 | grupo2 | 1 | package pt.estgp.estgweb.web.controllers.courses; |
2 | |||
1925 | grupo2 | 3 | import jomm.dao.impl.AbstractDao; |
1892 | grupo2 | 4 | import org.apache.struts.action.ActionForm; |
1925 | grupo2 | 5 | import org.apache.struts.action.ActionForward; |
6 | import org.apache.struts.action.ActionMapping; |
||
1892 | grupo2 | 7 | import org.json.JSONObject; |
1925 | grupo2 | 8 | import pt.estgp.estgweb.domain.CourseImpl; |
9 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
||
1934 | grupo2 | 10 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.CourseReportDocument; |
1892 | grupo2 | 11 | import pt.estgp.estgweb.web.controllers.utils.AbstractWidgetAjaxController; |
1925 | grupo2 | 12 | import pt.estgp.estgweb.web.exceptions.NoCookiesException; |
1892 | grupo2 | 13 | import pt.estgp.estgweb.web.utils.RequestUtils; |
14 | import pt.utl.ist.berserk.logic.serviceManager.IServiceManager; |
||
15 | import pt.utl.ist.berserk.logic.serviceManager.ServiceManager; |
||
16 | |||
17 | import javax.servlet.http.HttpServletRequest; |
||
18 | import javax.servlet.http.HttpServletResponse; |
||
19 | |||
20 | /** |
||
21 | * Created by jorgemachado on 06/01/17. |
||
22 | */ |
||
23 | public class CoursesServicesController extends AbstractWidgetAjaxController |
||
24 | { |
||
25 | /** |
||
26 | * See also CoursesServicesWidgetController for WS-API services |
||
27 | */ |
||
28 | |||
29 | /** |
||
30 | * |
||
31 | * @param form |
||
32 | * @param request |
||
33 | * @param response |
||
34 | * @return |
||
35 | * @throws Throwable |
||
36 | */ |
||
37 | |||
1925 | grupo2 | 38 | public JSONObject generateGlobalLearningResultsChartImg(ActionForm form, HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable { |
1892 | grupo2 | 39 | 1.5.0/docs/api/java/lang/String.html">String courseReportDocument = request.getParameter("courseReportDocument"); |
1934 | grupo2 | 40 | CourseReportDocument reportDocument = CourseReportDocument.fromJson(courseReportDocument); |
1892 | grupo2 | 41 | |
42 | IServiceManager sm = ServiceManager.getInstance(); |
||
43 | 1.5.0/docs/api/java/lang/String.html">String json = (1.5.0/docs/api/java/lang/String.html">String) sm.execute(RequestUtils.getRequester(request, response), |
||
44 | "CourseReportGenerateGlobalLearningResultsChartImg", |
||
1934 | grupo2 | 45 | new 5+0%2Fdocs%2Fapi+Object">Object[]{reportDocument}, |
46 | new 1.5.0/docs/api/java/lang/String.html">String[]{"reportDocument"}); |
||
1892 | grupo2 | 47 | return new JSONObject(json); |
48 | } |
||
49 | |||
1925 | grupo2 | 50 | public JSONObject generateGlobalLearningResultsChartYearImg(ActionForm form, HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable { |
1898 | grupo2 | 51 | 1.5.0/docs/api/java/lang/String.html">String courseReportDocument = request.getParameter("courseReportDocument"); |
1934 | grupo2 | 52 | CourseReportDocument reportDocument = CourseReportDocument.fromJson(courseReportDocument); |
1892 | grupo2 | 53 | |
1898 | grupo2 | 54 | IServiceManager sm = ServiceManager.getInstance(); |
55 | 1.5.0/docs/api/java/lang/String.html">String json = (1.5.0/docs/api/java/lang/String.html">String) sm.execute(RequestUtils.getRequester(request, response), |
||
56 | "CourseReportGenerateGlobalLearningResultsChartYearImg", |
||
1934 | grupo2 | 57 | new 5+0%2Fdocs%2Fapi+Object">Object[]{reportDocument}, |
58 | new 1.5.0/docs/api/java/lang/String.html">String[]{"reportDocument"}); |
||
1898 | grupo2 | 59 | return new JSONObject(json); |
60 | } |
||
1914 | grupo2 | 61 | |
1925 | grupo2 | 62 | public JSONObject generateGenerateGlobalLearningResultsChartSem(ActionForm form, HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable { |
1914 | grupo2 | 63 | 1.5.0/docs/api/java/lang/String.html">String courseReportDocument = request.getParameter("courseReportDocument"); |
1934 | grupo2 | 64 | CourseReportDocument reportDocument = CourseReportDocument.fromJson(courseReportDocument); |
1925 | grupo2 | 65 | 1.5.0/docs/api/java/lang/String.html">String semesterCode = request.getParameter("semesterCode"); |
1914 | grupo2 | 66 | |
67 | IServiceManager sm = ServiceManager.getInstance(); |
||
68 | 1.5.0/docs/api/java/lang/String.html">String json = (1.5.0/docs/api/java/lang/String.html">String) sm.execute(RequestUtils.getRequester(request, response), |
||
1925 | grupo2 | 69 | "CourseReportGenerateLearningResultsChartSem", |
1934 | grupo2 | 70 | new 5+0%2Fdocs%2Fapi+Object">Object[]{reportDocument, semesterCode}, |
71 | new 1.5.0/docs/api/java/lang/String.html">String[]{"reportDocument", "semesterCode"}); |
||
1925 | grupo2 | 72 | return new JSONObject(json); |
73 | } |
||
74 | |||
75 | public JSONObject saveCourseReportDocument(ActionForm form, HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable { |
||
76 | 1.5.0/docs/api/java/lang/String.html">String courseReportDocument = request.getParameter("courseReportDocument"); |
||
1934 | grupo2 | 77 | CourseReportDocument reportDocument = CourseReportDocument.fromJson(courseReportDocument); |
1925 | grupo2 | 78 | |
79 | IServiceManager sm = ServiceManager.getInstance(); |
||
80 | 1.5.0/docs/api/java/lang/String.html">String json = (1.5.0/docs/api/java/lang/String.html">String) sm.execute(RequestUtils.getRequester(request, response), |
||
1914 | grupo2 | 81 | "SaveCourseReportDocument", |
1934 | grupo2 | 82 | new 5+0%2Fdocs%2Fapi+Object">Object[]{reportDocument}, |
83 | new 1.5.0/docs/api/java/lang/String.html">String[]{"reportDocument"}); |
||
1914 | grupo2 | 84 | return new JSONObject(json); |
85 | } |
||
1925 | grupo2 | 86 | |
87 | public ActionForward startEdit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable { |
||
88 | 1.5.0/docs/api/java/lang/String.html">String courseCode = request.getParameter("courseCode"); |
||
89 | 1.5.0/docs/api/java/lang/String.html">String year = request.getParameter("year"); |
||
90 | |||
91 | IServiceManager sm = ServiceManager.getInstance(); |
||
92 | 1.5.0/docs/api/java/lang/String.html">String courseReportJson = (1.5.0/docs/api/java/lang/String.html">String) sm.execute(RequestUtils.getRequester(request, response), |
||
93 | "LoadCourseReportDocument", |
||
94 | new 5+0%2Fdocs%2Fapi+Object">Object[]{courseCode, year}, |
||
95 | new 1.5.0/docs/api/java/lang/String.html">String[]{"courseCode", "year"}); |
||
96 | request.setAttribute("courseReportJson", courseReportJson); |
||
97 | |||
98 | AbstractDao.getCurrentSession().beginTransaction(); |
||
99 | CourseImpl courseImpl = DaoFactory.getCourseDaoImpl().findCourseByCode(courseCode); |
||
100 | request.setAttribute("course", courseImpl); |
||
101 | AbstractDao.getCurrentSession().getTransaction().commit(); |
||
102 | |||
103 | return mapping.findForward("editCourseReport"); |
||
104 | } |
||
1934 | grupo2 | 105 | |
106 | public ActionForward startFormatted(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable { |
||
107 | 1.5.0/docs/api/java/lang/String.html">String courseCode = request.getParameter("courseCode"); |
||
108 | 1.5.0/docs/api/java/lang/String.html">String year = request.getParameter("year"); |
||
109 | |||
110 | IServiceManager sm = ServiceManager.getInstance(); |
||
111 | 1.5.0/docs/api/java/lang/String.html">String courseReportJson = (1.5.0/docs/api/java/lang/String.html">String) sm.execute(RequestUtils.getRequester(request, response), |
||
112 | "LoadCourseReportDocument", |
||
113 | new 5+0%2Fdocs%2Fapi+Object">Object[]{courseCode, year}, |
||
114 | new 1.5.0/docs/api/java/lang/String.html">String[]{"courseCode", "year"}); |
||
115 | request.setAttribute("courseReportJson", courseReportJson); |
||
116 | |||
117 | AbstractDao.getCurrentSession().beginTransaction(); |
||
118 | CourseImpl courseImpl = DaoFactory.getCourseDaoImpl().findCourseByCode(courseCode); |
||
119 | request.setAttribute("course", courseImpl); |
||
120 | AbstractDao.getCurrentSession().getTransaction().commit(); |
||
121 | |||
122 | return mapping.findForward("formatedCourseReport"); |
||
123 | } |
||
1892 | grupo2 | 124 | } |