Subversion Repositories bacoAlunos

Rev

Rev 1830 | Rev 1840 | 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
 
1830 jmachado 44
        1.5.0/docs/api/java/lang/String.html">String year = request.getParameter("year");
45
        1.5.0/docs/api/java/lang/String.html">String code = request.getParameter("code");
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();
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), "QuestionariosReportLoadReportUnidadesSalasJson", new 5+0%2Fdocs%2Fapi+Object">Object[]{code, year, period});
50
        return new JSONObject(json);
1617 jmachado 51
    }
52
 
1830 jmachado 53
    public JSONObject getCourseUnitsEvaluations(ActionForm form,HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable {
1617 jmachado 54
 
1830 jmachado 55
        1.5.0/docs/api/java/lang/String.html">String year = request.getParameter("year");
56
        1.5.0/docs/api/java/lang/String.html">String code = request.getParameter("code");
1617 jmachado 57
 
58
 
1830 jmachado 59
        IServiceManager sm = ServiceManager.getInstance();
60
        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), "LoadCourseEvaluationSections", new 5+0%2Fdocs%2Fapi+Object">Object[]{code, year});
61
        return new JSONObject(json);
1617 jmachado 62
    }
1704 jmachado 63
 
64
 
65
 
1830 jmachado 66
    public JSONObject getCourseUnitDtpStats(ActionForm form,HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable {
1704 jmachado 67
 
1830 jmachado 68
        1.5.0/docs/api/java/lang/String.html">String year = request.getParameter("year");
69
        1.5.0/docs/api/java/lang/String.html">String code = request.getParameter("code");
1704 jmachado 70
 
71
 
72
        IServiceManager sm = ServiceManager.getInstance();
1830 jmachado 73
        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), "LoadCourseUnitDtpStats", new 5+0%2Fdocs%2Fapi+Object">Object[]{code, year});
74
        return new JSONObject(json);
1704 jmachado 75
    }
76
 
77
 
78
 
79
    /**
80
     *  * For Json Services
81
     * @param form
82
     * @param request
83
     * @param response
84
     * @return
85
     * @throws Throwable
86
     */
87
    public JSONObject wsListServices(ActionForm form,HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable {
88
 
89
        JSONObject result = new JSONObject();
90
        JSONObject wsServices = new JSONObject();
1830 jmachado 91
        result.put("ws-course-services",wsServices);
1704 jmachado 92
 
93
 
1830 jmachado 94
        JSONObject service1 = new JSONObject();
95
        service1.put("service","/wsjson/api/app/ws-units-report-list");
96
        service1.put("name","getCourseUnitsEvaluations");
97
        service1.put("parameter1","code = siges code");
98
        service1.put("parameter3","year = \"201617,201718,...\"");
99
        service1.put("return","uma tabela em JSON com toda a com um array objetos do tipo CourseUnitSection");
1704 jmachado 100
 
1830 jmachado 101
        JSONObject service2 = new JSONObject();
102
        service2.put("service","/wsjson/api/app/ws-course-pedagogic-results-list");
103
        service2.put("name","getPedagogicReport4Period");
104
        service2.put("parameter1","code = siges code");
105
        service2.put("parameter2","period = \"S1,S2\"");
106
        service2.put("parameter3","year = \"201617,201718,...\"");
107
        service2.put("return","uma tabela em JSON com toda a informação de reusltados do pedagogico nesse ano");
1704 jmachado 108
 
1830 jmachado 109
        JSONObject service3 = new JSONObject();
110
        service3.put("service","/wsjson/api/app/ws-units-dtp-stats");
111
        service3.put("name","getCourseUnitDtpStats");
112
        service3.put("parameter1","code = siges code");
113
        service3.put("parameter2","period = \"S1,S2\"");
114
        service3.put("parameter3","year = \"201617,201718,...\"");
115
        service3.put("return","uma tabela em JSON com toda a informação de estatistica do preenchimento das pastas DTP");
1704 jmachado 116
 
117
 
118
        JSONArray services = new JSONArray();
1830 jmachado 119
        services.put(service1);
120
        services.put(service2);
121
        services.put(service3);
1704 jmachado 122
        wsServices.put("services",services);
123
 
124
        return result;
125
    }
1830 jmachado 126
 
127
    /*
128
 
129
    public static void main(String[] args) throws Throwable
130
    {
131
        URL url = new URL(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_EVALUATION + "?code=9119&year=201516&period=S2");
132
        InputStream is = url.openStream();
133
 
134
        String json = StreamsUtils.readString(is);
135
        is.close();
136
        JSONObject jsonObject = new JSONObject(json);
137
        System.out.println(jsonObject.toString());
138
 
139
        IServiceManager sm = ServiceManager.getInstance();
140
        json = (String) sm.execute("123", "LoadCourseReportsSections", new Object[]{"9119","201516"});
141
        System.out.println(json);
142
    }
143
    */
1616 jmachado 144
}