Rev 1840 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1616 | jmachado | 1 | package pt.estgp.estgweb.web.controllers.widgetmodel; |
2 | |||
3 | import org.apache.struts.action.ActionForm; |
||
4 | import org.json.JSONArray; |
||
5 | import org.json.JSONObject; |
||
6 | import pt.estgp.estgweb.web.controllers.utils.AbstractWidgetAjaxController; |
||
1617 | jmachado | 7 | import pt.estgp.estgweb.web.utils.RequestUtils; |
8 | import pt.utl.ist.berserk.logic.serviceManager.IServiceManager; |
||
9 | import pt.utl.ist.berserk.logic.serviceManager.ServiceManager; |
||
1616 | jmachado | 10 | |
11 | import javax.servlet.http.HttpServletRequest; |
||
12 | import javax.servlet.http.HttpServletResponse; |
||
13 | |||
14 | /** |
||
15 | * Created by jorgemachado on 06/01/17. |
||
16 | */ |
||
1830 | jmachado | 17 | public class CoursesServicesWidgetController extends AbstractWidgetAjaxController |
1616 | jmachado | 18 | { |
19 | |||
20 | |||
21 | |||
22 | |||
23 | |||
24 | |||
1617 | jmachado | 25 | |
1704 | jmachado | 26 | |
27 | |||
1830 | jmachado | 28 | /****************************************************************************/ |
29 | /* SERVICOS WS-API |
||
30 | /****************************************************************************/ |
||
1704 | jmachado | 31 | |
1617 | jmachado | 32 | |
33 | /** |
||
34 | * |
||
35 | * @param form |
||
36 | * @param request |
||
37 | * @param response |
||
1830 | jmachado | 38 | * @return |
39 | * @throws Throwable |
||
1617 | jmachado | 40 | */ |
41 | |||
1830 | jmachado | 42 | public JSONObject findPedagogicReport4Period(ActionForm form,HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable { |
1617 | jmachado | 43 | |
1840 | jmachado | 44 | 1.5.0/docs/api/java/lang/String.html">String code = request.getParameter("code"); |
1830 | jmachado | 45 | 1.5.0/docs/api/java/lang/String.html">String year = request.getParameter("year"); |
46 | 1.5.0/docs/api/java/lang/String.html">String period = request.getParameter("period"); |
||
1617 | jmachado | 47 | |
1835 | jmachado | 48 | IServiceManager sm = ServiceManager.getInstance(); |
1840 | jmachado | 49 | 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), |
50 | "QuestionariosReportLoadReportUnidadesSalasJson", |
||
51 | new 5+0%2Fdocs%2Fapi+Object">Object[]{code, year, period}); |
||
1835 | jmachado | 52 | return new JSONObject(json); |
1617 | jmachado | 53 | } |
54 | |||
1830 | jmachado | 55 | public JSONObject getCourseUnitsEvaluations(ActionForm form,HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable { |
1617 | jmachado | 56 | |
1840 | jmachado | 57 | 1.5.0/docs/api/java/lang/String.html">String code = request.getParameter("code"); |
1830 | jmachado | 58 | 1.5.0/docs/api/java/lang/String.html">String year = request.getParameter("year"); |
1617 | jmachado | 59 | |
60 | |||
1830 | jmachado | 61 | IServiceManager sm = ServiceManager.getInstance(); |
1840 | jmachado | 62 | 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), |
63 | "LoadCourseEvaluationSections", |
||
64 | new 5+0%2Fdocs%2Fapi+Object">Object[]{code, year}); |
||
1830 | jmachado | 65 | return new JSONObject(json); |
1617 | jmachado | 66 | } |
1704 | jmachado | 67 | |
68 | |||
69 | |||
1830 | jmachado | 70 | public JSONObject getCourseUnitDtpStats(ActionForm form,HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable { |
1704 | jmachado | 71 | |
1840 | jmachado | 72 | 1.5.0/docs/api/java/lang/String.html">String code = request.getParameter("code"); |
1830 | jmachado | 73 | 1.5.0/docs/api/java/lang/String.html">String year = request.getParameter("year"); |
1704 | jmachado | 74 | |
75 | |||
76 | IServiceManager sm = ServiceManager.getInstance(); |
||
1840 | jmachado | 77 | 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), |
78 | "LoadCourseUnitDtpStats", |
||
79 | new 5+0%2Fdocs%2Fapi+Object">Object[]{code, year}); |
||
1830 | jmachado | 80 | return new JSONObject(json); |
1704 | jmachado | 81 | } |
82 | |||
83 | |||
84 | |||
85 | /** |
||
86 | * * For Json Services |
||
87 | * @param form |
||
88 | * @param request |
||
89 | * @param response |
||
90 | * @return |
||
91 | * @throws Throwable |
||
92 | */ |
||
93 | public JSONObject wsListServices(ActionForm form,HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable { |
||
94 | |||
95 | JSONObject result = new JSONObject(); |
||
96 | JSONObject wsServices = new JSONObject(); |
||
1830 | jmachado | 97 | result.put("ws-course-services",wsServices); |
1704 | jmachado | 98 | |
99 | |||
1830 | jmachado | 100 | JSONObject service1 = new JSONObject(); |
101 | service1.put("service","/wsjson/api/app/ws-units-report-list"); |
||
102 | service1.put("name","getCourseUnitsEvaluations"); |
||
103 | service1.put("parameter1","code = siges code"); |
||
104 | service1.put("parameter3","year = \"201617,201718,...\""); |
||
105 | service1.put("return","uma tabela em JSON com toda a com um array objetos do tipo CourseUnitSection"); |
||
1704 | jmachado | 106 | |
1830 | jmachado | 107 | JSONObject service2 = new JSONObject(); |
108 | service2.put("service","/wsjson/api/app/ws-course-pedagogic-results-list"); |
||
109 | service2.put("name","getPedagogicReport4Period"); |
||
110 | service2.put("parameter1","code = siges code"); |
||
111 | service2.put("parameter2","period = \"S1,S2\""); |
||
112 | service2.put("parameter3","year = \"201617,201718,...\""); |
||
113 | service2.put("return","uma tabela em JSON com toda a informação de reusltados do pedagogico nesse ano"); |
||
1704 | jmachado | 114 | |
1830 | jmachado | 115 | JSONObject service3 = new JSONObject(); |
116 | service3.put("service","/wsjson/api/app/ws-units-dtp-stats"); |
||
117 | service3.put("name","getCourseUnitDtpStats"); |
||
118 | service3.put("parameter1","code = siges code"); |
||
119 | service3.put("parameter2","period = \"S1,S2\""); |
||
120 | service3.put("parameter3","year = \"201617,201718,...\""); |
||
121 | service3.put("return","uma tabela em JSON com toda a informação de estatistica do preenchimento das pastas DTP"); |
||
1704 | jmachado | 122 | |
123 | |||
124 | JSONArray services = new JSONArray(); |
||
1830 | jmachado | 125 | services.put(service1); |
126 | services.put(service2); |
||
127 | services.put(service3); |
||
1704 | jmachado | 128 | wsServices.put("services",services); |
129 | |||
130 | return result; |
||
131 | } |
||
1830 | jmachado | 132 | |
133 | /* |
||
134 | |||
135 | public static void main(String[] args) throws Throwable |
||
136 | { |
||
1848 | jmachado | 137 | URL url = new URL(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_EVALUATION_REPORT + "?code=9119&year=201516&period=S2"); |
1830 | jmachado | 138 | InputStream is = url.openStream(); |
139 | |||
140 | String json = StreamsUtils.readString(is); |
||
141 | is.close(); |
||
142 | JSONObject jsonObject = new JSONObject(json); |
||
143 | System.out.println(jsonObject.toString()); |
||
144 | |||
145 | IServiceManager sm = ServiceManager.getInstance(); |
||
146 | json = (String) sm.execute("123", "LoadCourseReportsSections", new Object[]{"9119","201516"}); |
||
147 | System.out.println(json); |
||
148 | } |
||
149 | */ |
||
1616 | jmachado | 150 | } |