Rev 1862 | Rev 1905 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1862 | Rev 1873 | ||
---|---|---|---|
Line 5... | Line 5... | ||
5 | import jomm.utils.StreamsUtils; |
5 | import jomm.utils.StreamsUtils; |
6 | import org.apache.log4j.Logger; |
6 | import org.apache.log4j.Logger; |
7 | import org.json.JSONArray; |
7 | import org.json.JSONArray; |
8 | import org.json.JSONException; |
8 | import org.json.JSONException; |
9 | import org.json.JSONObject; |
9 | import org.json.JSONObject; |
10 | import pt.estgp.estgweb.domain.CourseUnit; |
10 | import pt.estgp.estgweb.domain.*; |
11 | import pt.estgp.estgweb.domain.CourseUnitEvaluationImpl; |
- | |
12 | import pt.estgp.estgweb.domain.CourseUnitImpl; |
- | |
13 | import pt.estgp.estgweb.domain.DomainObjectFactory; |
- | |
14 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
11 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
- | 12 | import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum; |
|
15 | import pt.estgp.estgweb.services.courses.coursereport.CourseReportUtils; |
13 | import pt.estgp.estgweb.services.courses.coursereport.CourseReportUtils; |
16 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.*; |
14 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.*; |
17 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.courseunitreport.CourseUnitSection; |
15 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.courseunitreport.CourseUnitSection; |
18 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.components.UnitsLearningResultSemester; |
- | |
19 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.components.UnitsLearningResultUc; |
16 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.LearningGlobalAnalysisSection; |
20 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.components.UnitsLearningResultYear; |
17 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.components.*; |
21 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.components.UnitsLearningResultsTable; |
- | |
22 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.reportucsummary.CourseUnitDtpStat; |
18 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.reportucsummary.CourseUnitDtpStat; |
23 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.reportucsummary.UnitDtpSemester; |
19 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.reportucsummary.UnitDtpSemester; |
24 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.reportucsummary.UnitsDtpTable; |
20 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.reportucsummary.UnitsDtpTable; |
25 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.surveys.SurveysResultsSection; |
21 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.surveys.SurveysResultsSection; |
- | 22 | import pt.estgp.estgweb.services.data.RepositoryFile4JsonView; |
|
- | 23 | import pt.estgp.estgweb.services.data.RepositoryService; |
|
26 | import pt.estgp.estgweb.services.questionarios.QuestionariosReportsService; |
24 | import pt.estgp.estgweb.services.questionarios.QuestionariosReportsService; |
27 | import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.utils.DataTable; |
25 | import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.utils.DataTable; |
28 | import pt.estgp.estgweb.utils.Globals; |
26 | import pt.estgp.estgweb.utils.Globals; |
29 | import pt.estgp.estgweb.utils.documentBuilder.DocumentSection; |
27 | import pt.estgp.estgweb.utils.documentBuilder.DocumentSection; |
30 | import pt.estgp.estgweb.utils.documentBuilder.QuestionariosDataTableComponent; |
28 | import pt.estgp.estgweb.utils.documentBuilder.QuestionariosDataTableComponent; |
- | 29 | import pt.estgp.estgweb.web.controllers.utils.FileUploaded; |
|
31 | import pt.utl.ist.berserk.logic.serviceManager.IService; |
30 | import pt.utl.ist.berserk.logic.serviceManager.IService; |
32 | 31 | ||
33 | import java.io.IOException; |
32 | import java.io.IOException; |
34 | import java.io.InputStream; |
33 | import java.io.InputStream; |
35 | import java.net.URL; |
34 | import java.net.URL; |
Line 64... | Line 63... | ||
64 | * @throws IOException |
63 | * @throws IOException |
65 | * @throws JSONException |
64 | * @throws JSONException |
66 | */ |
65 | */ |
67 | public CourseReportDocument createNewCourseReportDocument(1.5.0/docs/api/java/lang/String.html">String courseCode,1.5.0/docs/api/java/lang/String.html">String year) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException |
66 | public CourseReportDocument createNewCourseReportDocument(1.5.0/docs/api/java/lang/String.html">String courseCode,1.5.0/docs/api/java/lang/String.html">String year) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException |
68 | { |
67 | { |
- | 68 | ||
- | 69 | Course course = DaoFactory.getCourseDaoImpl().findCourseByCode(courseCode); |
|
- | 70 | ||
69 | CourseReportDocument reportCourseDocument = new CourseReportDocument(); |
71 | CourseReportDocument reportCourseDocument = new CourseReportDocument(); |
70 | reportCourseDocument.init(); |
72 | reportCourseDocument.init(course,year); |
- | 73 | ||
71 | 74 | ||
72 | 75 | ||
73 | //FIRST SERVICE TO CALL TO OBTAIN UNITS AND EVALUATIONS |
76 | //FIRST SERVICE TO CALL TO OBTAIN UNITS AND EVALUATIONS |
74 | //THIS IS THE BASE FOR THE REMAIN SERVICE CALLS |
77 | //THIS IS THE BASE FOR THE REMAIN SERVICE CALLS |
75 | List<DocumentSection> courseUnitSections = updateCleanCourseUnitSections(courseCode, year, reportCourseDocument); |
78 | List<DocumentSection> courseUnitSections = updateCleanCourseUnitSections(courseCode, year, reportCourseDocument); |
Line 155... | Line 158... | ||
155 | uc.setAprovados1013(unitSection.getCourseUnitEvaluation().getNumAlunosAprov1013()); |
158 | uc.setAprovados1013(unitSection.getCourseUnitEvaluation().getNumAlunosAprov1013()); |
156 | uc.setAprovados1416(unitSection.getCourseUnitEvaluation().getNumAlunosAprov1416()); |
159 | uc.setAprovados1416(unitSection.getCourseUnitEvaluation().getNumAlunosAprov1416()); |
157 | uc.setAprovados1720(unitSection.getCourseUnitEvaluation().getNumAlunosAprov1720()); |
160 | uc.setAprovados1720(unitSection.getCourseUnitEvaluation().getNumAlunosAprov1720()); |
158 | uc.setSemElementos(unitSection.getCourseUnitEvaluation().getNumAlunosSemElementosAvaliacao()); |
161 | uc.setSemElementos(unitSection.getCourseUnitEvaluation().getNumAlunosSemElementosAvaliacao()); |
159 | uc.setAprovados(unitSection.getCourseUnitEvaluation().getNumAlunosAprovTotal()); |
162 | uc.setAprovados(unitSection.getCourseUnitEvaluation().getNumAlunosAprovTotal()); |
160 | uc.setReprovados(unitSection.getCourseUnitEvaluation().getNumAlunosReprovados()); |
163 | uc.setReprovados(unitSection.getCourseUnitEvaluation().getNumAlunosInscritos() - unitSection.getCourseUnitEvaluation().getNumAlunosAprovTotal() - unitSection.getCourseUnitEvaluation().getNumAlunosSemElementosAvaliacao()); |
161 | 164 | ||
162 | if(uc.getAlunosInscritos() > 0) |
165 | if(uc.getAlunosInscritos() > 0) |
163 | { |
166 | { |
164 | uc.setAprovadosPercent((float) (uc.getAprovados() * 100.0 / uc.getAlunosInscritos())); |
167 | uc.setAprovadosPercent((float) (uc.getAprovados() * 100.0 / uc.getAlunosInscritos())); |
165 | uc.setReprovadosPercent((float) (uc.getReprovados() * 100.0 / uc.getAlunosInscritos())); |
168 | uc.setReprovadosPercent((float) (uc.getReprovados() * 100.0 / uc.getAlunosInscritos())); |
Line 194... | Line 197... | ||
194 | } |
197 | } |
195 | 198 | ||
196 | 199 | ||
197 | //UPDATE TOTAIS DE SEMESTRES E DE ANOS |
200 | //UPDATE TOTAIS DE SEMESTRES E DE ANOS |
198 | float totalCumProgPercentGlobal = 0; |
201 | float totalCumProgPercentGlobal = 0; |
199 | int totalInscritosGlobal = 0; |
202 | float totalInscritosGlobal = 0; |
200 | float totalReprovadosPercentGlobal = 0; |
203 | float totalReprovadosPercentGlobal = 0; |
201 | float totalAprovadosPercentGlobal = 0; |
204 | float totalAprovadosPercentGlobal = 0; |
202 | float totalSemElementosPercentGlobal = 0; |
205 | float totalSemElementosPercentGlobal = 0; |
203 | int totalAprovados1013PercentGlobal = 0; |
206 | float totalAprovados1013PercentGlobal = 0; |
204 | float totalAprovados1416PercentGlobal = 0; |
207 | float totalAprovados1416PercentGlobal = 0; |
205 | float totalAprovados1720PercentGlobal = 0; |
208 | float totalAprovados1720PercentGlobal = 0; |
206 | for(UnitsLearningResultYear learningYearLine: learningResultsTable.getYears()) |
209 | for(UnitsLearningResultYear learningYearLine: learningResultsTable.getYears()) |
207 | { |
210 | { |
208 | float totalCumProgPercentAno = 0; |
211 | float totalCumProgPercentAno = 0; |
209 | int totalInscritosAno = 0; |
212 | float totalInscritosAno = 0; |
210 | float totalReprovadosPercentAno = 0; |
213 | float totalReprovadosPercentAno = 0; |
211 | float totalAprovadosPercentAno = 0; |
214 | float totalAprovadosPercentAno = 0; |
212 | float totalSemElementosPercentAno = 0; |
215 | float totalSemElementosPercentAno = 0; |
213 | int totalAprovados1013PercentAno = 0; |
216 | float totalAprovados1013PercentAno = 0; |
214 | float totalAprovados1416PercentAno = 0; |
217 | float totalAprovados1416PercentAno = 0; |
215 | float totalAprovados1720PercentAno = 0; |
218 | float totalAprovados1720PercentAno = 0; |
216 | 219 | ||
217 | for(UnitsLearningResultSemester semester: learningYearLine.getSemesters()) |
220 | for(UnitsLearningResultSemester semester: learningYearLine.getSemesters()) |
218 | { |
221 | { |
219 | float totalCumProgPercent = 0; |
222 | float totalCumProgPercent = 0; |
220 | int totalInscritos = 0; |
223 | float totalInscritos = 0; |
221 | float totalReprovadosPercent = 0; |
224 | float totalReprovadosPercent = 0; |
222 | float totalAprovadosPercent = 0; |
225 | float totalAprovadosPercent = 0; |
223 | float totalSemElementosPercent = 0; |
226 | float totalSemElementosPercent = 0; |
224 | int totalAprovados1013Percent = 0; |
227 | float totalAprovados1013Percent = 0; |
225 | float totalAprovados1416Percent = 0; |
228 | float totalAprovados1416Percent = 0; |
226 | float totalAprovados1720Percent = 0; |
229 | float totalAprovados1720Percent = 0; |
227 | for(UnitsLearningResultUc uc: semester.getUcs()) |
230 | for(UnitsLearningResultUc uc: semester.getUcs()) |
228 | { |
231 | { |
229 | totalCumProgPercent += uc.getCumprimentoProgramaPercent(); |
232 | totalCumProgPercent += uc.getCumprimentoProgramaPercent(); |
Line 237... | Line 240... | ||
237 | } |
240 | } |
238 | //media de inscritos |
241 | //media de inscritos |
239 | if(semester.getUcs().size() > 0) |
242 | if(semester.getUcs().size() > 0) |
240 | { |
243 | { |
241 | semester.setCumprimentoProgramaPercent( totalCumProgPercent / ((float)semester.getUcs().size())); |
244 | semester.setCumprimentoProgramaPercent( totalCumProgPercent / ((float)semester.getUcs().size())); |
242 | semester.setAlunosInscritos( totalInscritos / (semester.getUcs().size())); |
245 | semester.setAlunosInscritos( totalInscritos / ((float)semester.getUcs().size())); |
243 | semester.setAprovadosPercent( totalAprovadosPercent / ((float)semester.getUcs().size())); |
246 | semester.setAprovadosPercent( totalAprovadosPercent / ((float)semester.getUcs().size())); |
244 | semester.setReprovadosPercent( totalReprovadosPercent / ((float)semester.getUcs().size())); |
247 | semester.setReprovadosPercent( totalReprovadosPercent / ((float)semester.getUcs().size())); |
245 | semester.setSemElementosPercent( totalSemElementosPercent / ((float)semester.getUcs().size())); |
248 | semester.setSemElementosPercent( totalSemElementosPercent / ((float)semester.getUcs().size())); |
246 | semester.setAprovados1013Percent( totalAprovados1013Percent / ((float)semester.getUcs().size())); |
249 | semester.setAprovados1013Percent( totalAprovados1013Percent / ((float)semester.getUcs().size())); |
247 | semester.setAprovados1416Percent( totalAprovados1416Percent / ((float)semester.getUcs().size())); |
250 | semester.setAprovados1416Percent( totalAprovados1416Percent / ((float)semester.getUcs().size())); |
Line 258... | Line 261... | ||
258 | } |
261 | } |
259 | //media de inscritos |
262 | //media de inscritos |
260 | if(learningYearLine.getSemesters().size() > 0) |
263 | if(learningYearLine.getSemesters().size() > 0) |
261 | { |
264 | { |
262 | learningYearLine.setCumprimentoProgramaPercent( totalCumProgPercentAno / ((float)learningYearLine.getSemesters().size())); |
265 | learningYearLine.setCumprimentoProgramaPercent( totalCumProgPercentAno / ((float)learningYearLine.getSemesters().size())); |
263 | learningYearLine.setAlunosInscritos( totalInscritosAno / (learningYearLine.getSemesters().size())); |
266 | learningYearLine.setAlunosInscritos( totalInscritosAno / ((float)learningYearLine.getSemesters().size())); |
264 | learningYearLine.setAprovadosPercent( totalAprovadosPercentAno / ((float)learningYearLine.getSemesters().size())); |
267 | learningYearLine.setAprovadosPercent( totalAprovadosPercentAno / ((float)learningYearLine.getSemesters().size())); |
265 | learningYearLine.setReprovadosPercent( totalReprovadosPercentAno / ((float)learningYearLine.getSemesters().size())); |
268 | learningYearLine.setReprovadosPercent( totalReprovadosPercentAno / ((float)learningYearLine.getSemesters().size())); |
266 | learningYearLine.setSemElementosPercent( totalSemElementosPercentAno / ((float)learningYearLine.getSemesters().size())); |
269 | learningYearLine.setSemElementosPercent( totalSemElementosPercentAno / ((float)learningYearLine.getSemesters().size())); |
267 | learningYearLine.setAprovados1013Percent( totalAprovados1013PercentAno / ((float)learningYearLine.getSemesters().size())); |
270 | learningYearLine.setAprovados1013Percent( totalAprovados1013PercentAno / ((float)learningYearLine.getSemesters().size())); |
268 | learningYearLine.setAprovados1416Percent( totalAprovados1416PercentAno / ((float)learningYearLine.getSemesters().size())); |
271 | learningYearLine.setAprovados1416Percent( totalAprovados1416PercentAno / ((float)learningYearLine.getSemesters().size())); |
Line 287... | Line 290... | ||
287 | learningResultsTable.setSemElementosPercent( totalSemElementosPercentGlobal / ((float)learningResultsTable.getYears().size())); |
290 | learningResultsTable.setSemElementosPercent( totalSemElementosPercentGlobal / ((float)learningResultsTable.getYears().size())); |
288 | learningResultsTable.setAprovados1013Percent( totalAprovados1013PercentGlobal / ((float)learningResultsTable.getYears().size())); |
291 | learningResultsTable.setAprovados1013Percent( totalAprovados1013PercentGlobal / ((float)learningResultsTable.getYears().size())); |
289 | learningResultsTable.setAprovados1416Percent( totalAprovados1416PercentGlobal / ((float)learningResultsTable.getYears().size())); |
292 | learningResultsTable.setAprovados1416Percent( totalAprovados1416PercentGlobal / ((float)learningResultsTable.getYears().size())); |
290 | learningResultsTable.setAprovados1720Percent( totalAprovados1720PercentGlobal / ((float)learningResultsTable.getYears().size())); |
293 | learningResultsTable.setAprovados1720Percent( totalAprovados1720PercentGlobal / ((float)learningResultsTable.getYears().size())); |
291 | } |
294 | } |
292 | - | ||
293 | - | ||
294 | - | ||
295 | - | ||
296 | return learningResultsTable; |
295 | return learningResultsTable; |
297 | //CRIAR A TABELA DE RESUTLADOS GLOBAIS GERAIS COMO UM RESUMO DA ANTERIOR |
- | |
298 | /*for(UnitsLearningResultYear learningYearLine: learningResultsTable.getYears()) |
- | |
299 | { |
- | |
300 | - | ||
301 | }*/ |
- | |
302 | } |
296 | } |
303 | 297 | ||
304 | 298 | ||
305 | /** |
299 | /** |
306 | * Gera uma tabela de estatisticas dos DTP recorrendo ao servico WS de |
300 | * Gera uma tabela de estatisticas dos DTP recorrendo ao servico WS de |
Line 385... | Line 379... | ||
385 | logger.error(e,e); |
379 | logger.error(e,e); |
386 | courseUnitSections = new CourseUnitSection[0]; |
380 | courseUnitSections = new CourseUnitSection[0]; |
387 | } |
381 | } |
388 | 382 | ||
389 | 383 | ||
390 | List<DocumentSection> subSections = new ArrayList<DocumentSection>(); |
384 | ArrayList<DocumentSection> subSections = new ArrayList<DocumentSection>(); |
391 | unitReportsSection.setSections(subSections); |
385 | unitReportsSection.setSections(subSections); |
392 | for(CourseUnit cu :units) |
386 | for(CourseUnit cu :units) |
393 | { |
387 | { |
394 | CourseUnitSection sectionFound = CourseReportUtils.findCourseUnitSection(courseUnitSections, (CourseUnitImpl) cu); |
388 | CourseUnitSection sectionFound = CourseReportUtils.findCourseUnitSection(courseUnitSections, (CourseUnitImpl) cu); |
395 | if(sectionFound == null) |
389 | if(sectionFound == null) |
Line 409... | Line 403... | ||
409 | return subSections; |
403 | return subSections; |
410 | } |
404 | } |
411 | 405 | ||
412 | 406 | ||
413 | 407 | ||
- | 408 | /** |
|
414 | public static void main(1.5.0/docs/api/java/lang/String.html">String[] args) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException { |
409 | * Este servico gera um grafico com a taxa global de aproveitamento e grava-o no repositorio digital |
415 | AbstractDao.getCurrentSession().beginTransaction(); |
410 | * devolvendo o respectivo RepositoryFile4JsonView em json para poder ser anexado ao objecto imagem do |
416 | - | ||
417 | CourseReportDocument reportCourseDocument = new CourseReportServices().createNewCourseReportDocument("44","201617"); |
411 | * widget do grafico |
418 | 1.5.0/docs/api/java/lang/System.html">System.out.println(reportCourseDocument.toJson()); |
412 | * @param reportDocumentJson |
- | 413 | * @param session |
|
- | 414 | * @return |
|
- | 415 | * @throws IOException |
|
- | 416 | */ |
|
419 | AbstractDao.getCurrentSession().getTransaction().commit(); |
417 | public 1.5.0/docs/api/java/lang/String.html">String generateGlobalLearningResultsChartImg(1.5.0/docs/api/java/lang/String.html">String reportDocumentJson,UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
420 | 418 | ||
421 | //System.setProperty("javax.net.ssl.trustStore", "/JORGE/COPIAS/.keystore"); |
419 | CourseReportDocument reportDocument = CourseReportDocument.fromJson(reportDocumentJson); |
422 | //System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); |
420 | LearningResultsSection learningResultsSection = (LearningResultsSection) reportDocument.findDocumentSection(LearningResultsSection.class); |
- | 421 | LearningGlobalAnalysisSection learningGlobalAnalysisSection = (LearningGlobalAnalysisSection) learningResultsSection.findSection(LearningGlobalAnalysisSection.class); |
|
- | 422 | GlobalLearningResultsChartImg chartImg = (GlobalLearningResultsChartImg) learningGlobalAnalysisSection.findDocComponent(GlobalLearningResultsChartImg.class); |
|
423 | 423 | ||
424 | /*URL url = new URL("http://pae.ipportalegre.pt/wsjson/api/app/ws-course-pedagogic-results-list?code=44&year=201617&period=S1"); |
- | |
425 | 424 | ||
- | 425 | UnitsLearningResultsTable table = (UnitsLearningResultsTable) learningResultsSection.findDocComponent(UnitsLearningResultsTable.class); |
|
426 | 426 | ||
427 | 427 | ||
428 | System.out.println(StreamsUtils.readString(url.openStream()));*/ |
428 | FileUploaded fileUploaded = chartImg.generateChart2tmp(table,reportDocument); |
429 | } |
- | |
430 | 429 | ||
431 | /* |
- | |
- | 430 | RepositoryService repositoryService = new RepositoryService(); |
|
432 | 431 | ||
433 | public String loadUnitsAndCreateLearningResultsTables4Course(String courseCode, String year) throws IOException, JSONException |
432 | boolean imageInitialized = chartImg.getImage() != null |
434 | { |
433 | && |
- | 434 | chartImg.getImage().getIdentifier() != null; |
|
435 | 435 | ||
- | 436 | RepositoryFile4JsonView view; |
|
- | 437 | if(imageInitialized) |
|
- | 438 | { |
|
- | 439 | 1.5.0/docs/api/java/lang/String.html">String identifier = chartImg.getImage().getIdentifier(); |
|
- | 440 | view = repositoryService.replaceRepositoryFileFromFileUpload(identifier, fileUploaded, ResourceAccessControlEnum.privateDomain, session); |
|
- | 441 | } |
|
- | 442 | else |
|
- | 443 | { |
|
- | 444 | view = repositoryService.storeRepositoryFileFromFileUpload(fileUploaded,ResourceAccessControlEnum.privateDomain,session); |
|
- | 445 | } |
|
- | 446 | chartImg.setImage(view); |
|
- | 447 | //TODO FALTA GUARDAR O JSON NO CURSO |
|
- | 448 | return view.toJson(); |
|
436 | } |
449 | } |
437 | */ |
- | |
438 | //TODO loadUnitsAndCreateLearningResultsTables4Course |
- | |
439 | //HIPOTESE DEVOLVER DOIS OBJECTOS |
- | |
440 | //SERVICO DE ARRANQUE |
- | |
441 | //DEVOLVE UM REPORT DOCUMENT E O CHAMADOR USA O QUE QUISER |
- | |
442 | //A GERACAO DE GRAFICOS FAZ-SE APENAS A PEDIDO |
- | |
443 | 450 | ||
444 | // SE ELE PEDIR PARA ATUALIZAR TUDO CARREGA-SE UNIDADES E TABELAS NU DOC NOVO |
- | |
445 | // E NO BROWSER SUBSTITUI-SE ESSES ELEMENTOS NOS ANTIGOS a seccao das unidades |
- | |
446 | // e as as tabelas |
- | |
447 | 451 | ||
448 | 452 | ||
449 | 453 | ||
450 | 454 | ||
451 | 455 | ||
- | 456 | /****************************************************************************/ |
|
- | 457 | /* |
|
452 | 458 | ||
453 | 459 | ||
454 | 460 | ||
- | 461 | SERVICOS WS-API |
|
455 | 462 | ||
456 | /****************************************************************************/ |
- | |
- | 463 | ||
- | 464 | ||
457 | /* SERVICOS WS-API |
465 | */ |
458 | /****************************************************************************/ |
466 | /****************************************************************************/ |
459 | 467 | ||
460 | 468 | ||
461 | /** |
469 | /** |
462 | * This service loads a list of course units given course code and year |
470 | * This service loads a list of course units given course code and year |
Line 502... | Line 510... | ||
502 | { |
510 | { |
503 | logger.error("Connecting " + serviceUrl,e); |
511 | logger.error("Connecting " + serviceUrl,e); |
504 | return json; |
512 | return json; |
505 | } |
513 | } |
506 | JSONObject jsonObject = new JSONObject(json); |
514 | JSONObject jsonObject = new JSONObject(json); |
- | 515 | if(jsonObject.get("service").equals("ok")) |
|
507 | return jsonObject.get("response").toString(); |
516 | return jsonObject.get("response").toString(); |
- | 517 | else |
|
- | 518 | return json; |
|
508 | } |
519 | } |
509 | } |
520 | } |
510 | 521 | ||
511 | 522 | ||
512 | 523 | ||
Line 530... | Line 541... | ||
530 | JSONArray array = new JSONArray(); |
541 | JSONArray array = new JSONArray(); |
531 | List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
542 | List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
532 | for(CourseUnit cu: units) |
543 | for(CourseUnit cu: units) |
533 | { |
544 | { |
534 | CourseUnitSection courseUnitSection = CourseReportUtils.createCourseUnitEvaluationSection((CourseUnitImpl) cu); |
545 | CourseUnitSection courseUnitSection = CourseReportUtils.createCourseUnitEvaluationSection((CourseUnitImpl) cu); |
- | 546 | if(courseUnitSection.getAnoPlano() < 0) |
|
- | 547 | { |
|
- | 548 | logger.info("Ano do Plano not available from courseUnitsEvaluation Service, will read from API loadPlanYearForCourseUnitCode"); |
|
- | 549 | try{ |
|
- | 550 | 1.5.0/docs/api/java/lang/String.html">String json = loadPlanYearForCourseUnitCode(courseCode,cu.getCode(),cu.getSemestre()); |
|
- | 551 | int ano = new JSONObject(json).getInt("year"); |
|
- | 552 | courseUnitSection.setAnoPlano(ano); |
|
- | 553 | }catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e ) |
|
- | 554 | { |
|
- | 555 | logger.error("Nao conseguiu obter o ano do plano da API: " + e.toString(),e); |
|
- | 556 | } |
|
- | 557 | } |
|
535 | array.put(courseUnitSection.toJsonObject()); |
558 | array.put(courseUnitSection.toJsonObject()); |
536 | } |
559 | } |
537 | 560 | ||
538 | JSONObject obj = new JSONObject(); |
561 | JSONObject obj = new JSONObject(); |
539 | obj.put("evaluations",array); |
562 | obj.put("evaluations",array); |
Line 557... | Line 580... | ||
557 | logger.error("Connecting " + serviceUrl,e); |
580 | logger.error("Connecting " + serviceUrl,e); |
558 | return json; |
581 | return json; |
559 | } |
582 | } |
560 | 583 | ||
561 | JSONObject jsonObject = new JSONObject(json); |
584 | JSONObject jsonObject = new JSONObject(json); |
- | 585 | if(jsonObject.get("service").equals("ok")) |
|
562 | return jsonObject.get("response").toString(); |
586 | return jsonObject.get("response").toString(); |
- | 587 | else |
|
- | 588 | return json; |
|
563 | } |
589 | } |
564 | } |
590 | } |
565 | 591 | ||
566 | 592 | ||
- | 593 | /** |
|
- | 594 | * |
|
- | 595 | * |
|
- | 596 | * @param courseCode codigo Siges na base de dados |
|
- | 597 | * @param unitCode |
|
- | 598 | * @return Json com o ano do plano exemplo: { year : 1 } |
|
- | 599 | * ou -1 se não for encontrado |
|
- | 600 | */ |
|
- | 601 | public 1.5.0/docs/api/java/lang/String.html">String loadPlanYearForCourseUnitCode(1.5.0/docs/api/java/lang/String.html">String courseCode,1.5.0/docs/api/java/lang/String.html">String unitCode,1.5.0/docs/api/java/lang/String.html">String period) throws JSONException, 1.5.0/docs/api/java/io/IOException.html">IOException { |
|
- | 602 | ||
- | 603 | ||
- | 604 | if(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNIT_PLAN_YEAR.indexOf("localhost")>=0) |
|
- | 605 | { |
|
- | 606 | CourseImpl c = DaoFactory.getCourseDaoImpl().findCourseByCode(courseCode); |
|
- | 607 | int year = c.getUnidadeAnoPlano(period,unitCode); |
|
- | 608 | return "{ year : " + year + " }"; |
|
- | 609 | ||
- | 610 | } |
|
- | 611 | else |
|
- | 612 | { |
|
- | 613 | 1.5.0/docs/api/java/lang/String.html">String json = "{ year : -1 }"; |
|
- | 614 | 1.5.0/docs/api/java/lang/String.html">String serviceUrl = Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNIT_PLAN_YEAR + "?courseCode=" + courseCode + "&unitCode=" + unitCode + "&period=" + period; |
|
- | 615 | try{ |
|
- | 616 | 1.5.0/docs/api/java/net/URL.html">URL url = new 1.5.0/docs/api/java/net/URL.html">URL(serviceUrl); |
|
- | 617 | ||
- | 618 | 1.5.0/docs/api/java/net/URLConnection.html">URLConnection conn = url.openConnection(); |
|
- | 619 | 5+0%2Fdocs%2Fapi+InputStream">InputStream is = conn.getInputStream(); |
|
- | 620 | ||
- | 621 | json = StreamsUtils.readString(is); |
|
- | 622 | is.close(); |
|
- | 623 | }catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
|
- | 624 | { |
|
- | 625 | logger.error("Connecting " + serviceUrl,e); |
|
- | 626 | return json; |
|
- | 627 | } |
|
- | 628 | ||
- | 629 | JSONObject jsonObject = new JSONObject(json); |
|
- | 630 | if(jsonObject.get("service").equals("ok")) |
|
- | 631 | return jsonObject.get("response").toString(); |
|
- | 632 | else |
|
- | 633 | return json; |
|
- | 634 | } |
|
- | 635 | } |
|
- | 636 | ||
- | 637 | ||
- | 638 | ||
- | 639 | ||
- | 640 | ||
- | 641 | ||
- | 642 | ||
- | 643 | ||
- | 644 | ||
- | 645 | ||
- | 646 | ||
- | 647 | ||
- | 648 | ||
- | 649 | public static void main(1.5.0/docs/api/java/lang/String.html">String[] args) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException { |
|
- | 650 | AbstractDao.getCurrentSession().beginTransaction(); |
|
- | 651 | ||
- | 652 | CourseReportDocument reportCourseDocument = new CourseReportServices().createNewCourseReportDocument("44","201617"); |
|
- | 653 | 1.5.0/docs/api/java/lang/System.html">System.out.println(reportCourseDocument.toJson()); |
|
- | 654 | AbstractDao.getCurrentSession().getTransaction().commit(); |
|
- | 655 | ||
- | 656 | //System.setProperty("javax.net.ssl.trustStore", "/JORGE/COPIAS/.keystore"); |
|
- | 657 | //System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); |
|
- | 658 | ||
- | 659 | /*URL url = new URL("http://pae.ipportalegre.pt/wsjson/api/app/ws-course-pedagogic-results-list?code=44&year=201617&period=S1"); |
|
- | 660 | ||
- | 661 | ||
- | 662 | ||
- | 663 | System.out.println(StreamsUtils.readString(url.openStream()));*/ |
|
- | 664 | } |
|
- | 665 | ||
- | 666 | /* |
|
- | 667 | ||
- | 668 | public String loadUnitsAndCreateLearningResultsTables4Course(String courseCode, String year) throws IOException, JSONException |
|
- | 669 | { |
|
- | 670 | ||
- | 671 | } |
|
- | 672 | */ |
|
- | 673 | //TODO loadUnitsAndCreateLearningResultsTables4Course |
|
- | 674 | //HIPOTESE DEVOLVER DOIS OBJECTOS |
|
- | 675 | //SERVICO DE ARRANQUE |
|
- | 676 | //DEVOLVE UM REPORT DOCUMENT E O CHAMADOR USA O QUE QUISER |
|
- | 677 | //A GERACAO DE GRAFICOS FAZ-SE APENAS A PEDIDO |
|
- | 678 | ||
- | 679 | // SE ELE PEDIR PARA ATUALIZAR TUDO CARREGA-SE UNIDADES E TABELAS NU DOC NOVO |
|
- | 680 | // E NO BROWSER SUBSTITUI-SE ESSES ELEMENTOS NOS ANTIGOS a seccao das unidades |
|
- | 681 | // e as as tabelas |
|
- | 682 | ||
- | 683 | ||
- | 684 | ||
567 | } |
685 | } |