Subversion Repositories bacoAlunos

Rev

Rev 1876 | Go to most recent revision | 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");
1876 grupo4 74
        1.5.0/docs/api/java/lang/String.html">String semestre = request.getParameter("semestre");
1704 jmachado 75
 
76
 
77
        IServiceManager sm = ServiceManager.getInstance();
1840 jmachado 78
        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),
79
                "LoadCourseUnitDtpStats",
1876 grupo4 80
                new 5+0%2Fdocs%2Fapi+Object">Object[]{code, year, semestre});
1830 jmachado 81
        return new JSONObject(json);
1704 jmachado 82
    }
83
 
84
 
1876 grupo4 85
    public JSONObject loadPlanYearForCourseUnitCode(ActionForm form,HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable {
1704 jmachado 86
 
1876 grupo4 87
        1.5.0/docs/api/java/lang/String.html">String courseCode = request.getParameter("courseCode");
88
        1.5.0/docs/api/java/lang/String.html">String unitCode = request.getParameter("unitCode");
89
        1.5.0/docs/api/java/lang/String.html">String period = request.getParameter("period");
90
 
91
 
92
        IServiceManager sm = ServiceManager.getInstance();
93
        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),
94
                "LoadPlanYearForCourseUnitCode",
95
                new 5+0%2Fdocs%2Fapi+Object">Object[]{courseCode, unitCode, period});
96
        return new JSONObject(json);
97
    }
98
 
99
 
1704 jmachado 100
    /**
101
     *  * For Json Services
102
     * @param form
103
     * @param request
104
     * @param response
105
     * @return
106
     * @throws Throwable
107
     */
108
    public JSONObject wsListServices(ActionForm form,HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable {
109
 
110
        JSONObject result = new JSONObject();
111
        JSONObject wsServices = new JSONObject();
1830 jmachado 112
        result.put("ws-course-services",wsServices);
1704 jmachado 113
 
114
 
1830 jmachado 115
        JSONObject service1 = new JSONObject();
116
        service1.put("service","/wsjson/api/app/ws-units-report-list");
117
        service1.put("name","getCourseUnitsEvaluations");
118
        service1.put("parameter1","code = siges code");
119
        service1.put("parameter3","year = \"201617,201718,...\"");
120
        service1.put("return","uma tabela em JSON com toda a com um array objetos do tipo CourseUnitSection");
1704 jmachado 121
 
1830 jmachado 122
        JSONObject service2 = new JSONObject();
123
        service2.put("service","/wsjson/api/app/ws-course-pedagogic-results-list");
124
        service2.put("name","getPedagogicReport4Period");
125
        service2.put("parameter1","code = siges code");
126
        service2.put("parameter2","period = \"S1,S2\"");
127
        service2.put("parameter3","year = \"201617,201718,...\"");
1918 grupo4 128
        service2.put("return","uma tabela em JSON com toda a informação de reusltados do pedagogico nesse ano");
1704 jmachado 129
 
1830 jmachado 130
        JSONObject service3 = new JSONObject();
131
        service3.put("service","/wsjson/api/app/ws-units-dtp-stats");
132
        service3.put("name","getCourseUnitDtpStats");
133
        service3.put("parameter1","code = siges code");
134
        service3.put("parameter2","period = \"S1,S2\"");
135
        service3.put("parameter3","year = \"201617,201718,...\"");
1918 grupo4 136
        service3.put("return","uma tabela em JSON com toda a informação de estatistica do preenchimento das pastas DTP");
1704 jmachado 137
 
138
 
139
        JSONArray services = new JSONArray();
1830 jmachado 140
        services.put(service1);
141
        services.put(service2);
142
        services.put(service3);
1704 jmachado 143
        wsServices.put("services",services);
144
 
145
        return result;
146
    }
1830 jmachado 147
 
148
    /*
149
 
150
    public static void main(String[] args) throws Throwable
151
    {
1848 jmachado 152
        URL url = new URL(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_EVALUATION_REPORT + "?code=9119&year=201516&period=S2");
1830 jmachado 153
        InputStream is = url.openStream();
154
 
155
        String json = StreamsUtils.readString(is);
156
        is.close();
157
        JSONObject jsonObject = new JSONObject(json);
158
        System.out.println(jsonObject.toString());
159
 
160
        IServiceManager sm = ServiceManager.getInstance();
161
        json = (String) sm.execute("123", "LoadCourseReportsSections", new Object[]{"9119","201516"});
162
        System.out.println(json);
163
    }
164
    */
1918 grupo4 165
}