Subversion Repositories bacoAlunos

Rev

Rev 1840 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1840 Rev 1848
Line 18... Line 18...
18
import pt.utl.ist.berserk.logic.serviceManager.IService;
18
import pt.utl.ist.berserk.logic.serviceManager.IService;
19
 
19
 
20
import java.io.IOException;
20
import java.io.IOException;
21
import java.io.InputStream;
21
import java.io.InputStream;
22
import java.net.URL;
22
import java.net.URL;
-
 
23
import java.net.URLConnection;
23
import java.util.ArrayList;
24
import java.util.ArrayList;
24
import java.util.HashSet;
25
import java.util.HashSet;
25
import java.util.List;
26
import java.util.List;
26
import java.util.Set;
27
import java.util.Set;
27
 
28
 
Line 163... Line 164...
163
     * @throws IOException
164
     * @throws IOException
164
     */
165
     */
165
    public 1.5.0/docs/api/java/lang/String.html">String loadReportUnidadesSalasJson(1.5.0/docs/api/java/lang/String.html">String sigesCode, 1.5.0/docs/api/java/lang/String.html">String year, 1.5.0/docs/api/java/lang/String.html">String periodIncluded) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException {
166
    public 1.5.0/docs/api/java/lang/String.html">String loadReportUnidadesSalasJson(1.5.0/docs/api/java/lang/String.html">String sigesCode, 1.5.0/docs/api/java/lang/String.html">String year, 1.5.0/docs/api/java/lang/String.html">String periodIncluded) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException {
166
 
167
 
167
 
168
 
168
        if(Globals.SYSTEM_WSJSON_SERVICE_COURSE_REPORT_RESULTS.indexOf("localhost")>=0)
169
        if(Globals.SYSTEM_WSJSON_SERVICE_COURSE_QUESTIONARIOS_REPORT_RESULTS.indexOf("localhost")>=0)
169
        {
170
        {
170
            Criteria c = DaoFactory.getQuestionarioReportCursoFileDaoImpl().createCriteria();
171
            Criteria c = DaoFactory.getQuestionarioReportCursoFileDaoImpl().createCriteria();
171
            c.createAlias("reportGroup","rg");
172
            c.createAlias("reportGroup","rg");
172
            c.add(like("rg.periodos","%" + periodIncluded + "%"));
173
            c.add(like("rg.periodos","%" + periodIncluded + "%"));
173
            c.add(eq("rg.importYear",year));
174
            c.add(eq("rg.importYear",year));
Line 181... Line 182...
181
                return "{}";
182
                return "{}";
182
            return files.get(0).getCourseReportQuestionsJson();
183
            return files.get(0).getCourseReportQuestionsJson();
183
        }
184
        }
184
        else
185
        else
185
        {
186
        {
-
 
187
            1.5.0/docs/api/java/lang/String.html">String json = "{ }";
186
            1.5.0/docs/api/java/net/URL.html">URL url = new 1.5.0/docs/api/java/net/URL.html">URL(Globals.SYSTEM_WSJSON_SERVICE_COURSE_REPORT_RESULTS + "?code=" + sigesCode + "&year=" + year + "&period="+periodIncluded);
188
            1.5.0/docs/api/java/lang/String.html">String serviceUrl = Globals.SYSTEM_WSJSON_SERVICE_COURSE_QUESTIONARIOS_REPORT_RESULTS + "?code=" + sigesCode + "&year=" + year + "&period="+periodIncluded;
-
 
189
            try{
-
 
190
                1.5.0/docs/api/java/net/URL.html">URL url = new 1.5.0/docs/api/java/net/URL.html">URL(serviceUrl);
-
 
191
 
-
 
192
                1.5.0/docs/api/java/net/URLConnection.html">URLConnection conn = url.openConnection();
187
            5+0%2Fdocs%2Fapi+InputStream">InputStream is = url.openStream();
193
                5+0%2Fdocs%2Fapi+InputStream">InputStream is = conn.getInputStream();
-
 
194
 
-
 
195
                json = StreamsUtils.readString(is);
-
 
196
                is.close();
-
 
197
            }catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e)
-
 
198
            {
-
 
199
                logger.error("Connecting " + serviceUrl,e);
-
 
200
                return json;
-
 
201
            }
188
 
202
 
189
            1.5.0/docs/api/java/lang/String.html">String json = StreamsUtils.readString(is);
-
 
190
            is.close();
-
 
191
            JSONObject jsonObject = new JSONObject(json);
203
            JSONObject jsonObject = new JSONObject(json);
192
            return jsonObject.get("response").toString();
204
            return jsonObject.get("response").toString();
193
 
205
 
194
        }
206
        }
195
 
207