Rev 1844 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1844 | Rev 1848 | ||
---|---|---|---|
1 | package pt.estgp.estgweb.services.courses; |
1 | package pt.estgp.estgweb.services.courses; |
2 | 2 | ||
3 | 3 | ||
- | 4 | import jomm.dao.impl.AbstractDao; |
|
4 | import jomm.utils.StreamsUtils; |
5 | import jomm.utils.StreamsUtils; |
5 | import org.apache.log4j.Logger; |
6 | import org.apache.log4j.Logger; |
6 | import org.json.JSONArray; |
7 | import org.json.JSONArray; |
7 | import org.json.JSONException; |
8 | import org.json.JSONException; |
8 | import org.json.JSONObject; |
9 | import org.json.JSONObject; |
9 | import pt.estgp.estgweb.domain.CourseUnit; |
10 | import pt.estgp.estgweb.domain.CourseUnit; |
10 | import pt.estgp.estgweb.domain.CourseUnitEvaluationImpl; |
11 | import pt.estgp.estgweb.domain.CourseUnitEvaluationImpl; |
11 | import pt.estgp.estgweb.domain.CourseUnitImpl; |
12 | import pt.estgp.estgweb.domain.CourseUnitImpl; |
12 | import pt.estgp.estgweb.domain.DomainObjectFactory; |
13 | import pt.estgp.estgweb.domain.DomainObjectFactory; |
13 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
14 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
14 | import pt.estgp.estgweb.services.courses.coursereport.CourseReportUtils; |
15 | import pt.estgp.estgweb.services.courses.coursereport.CourseReportUtils; |
15 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.*; |
16 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.*; |
16 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.courseunitreport.CourseUnitSection; |
17 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.courseunitreport.CourseUnitSection; |
17 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.components.UnitsLearningResultSemester; |
18 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.components.UnitsLearningResultSemester; |
18 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.components.UnitsLearningResultUc; |
19 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.components.UnitsLearningResultUc; |
19 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.components.UnitsLearningResultYear; |
20 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.components.UnitsLearningResultYear; |
20 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.components.UnitsLearningResultsTable; |
21 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.components.UnitsLearningResultsTable; |
21 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.reportucsummary.CourseUnitDtpStat; |
22 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.reportucsummary.CourseUnitDtpStat; |
22 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.reportucsummary.UnitDtpSemester; |
23 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.reportucsummary.UnitDtpSemester; |
23 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.reportucsummary.UnitsDtpTable; |
24 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.reportucsummary.UnitsDtpTable; |
24 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.surveys.SurveysResultsSection; |
25 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.surveys.SurveysResultsSection; |
25 | import pt.estgp.estgweb.services.questionarios.QuestionariosReportsService; |
26 | import pt.estgp.estgweb.services.questionarios.QuestionariosReportsService; |
26 | import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.utils.DataTable; |
27 | import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.utils.DataTable; |
27 | import pt.estgp.estgweb.utils.Globals; |
28 | import pt.estgp.estgweb.utils.Globals; |
28 | import pt.estgp.estgweb.utils.documentBuilder.DocumentSection; |
29 | import pt.estgp.estgweb.utils.documentBuilder.DocumentSection; |
29 | import pt.estgp.estgweb.utils.documentBuilder.QuestionariosDataTableComponent; |
30 | import pt.estgp.estgweb.utils.documentBuilder.QuestionariosDataTableComponent; |
30 | import pt.utl.ist.berserk.logic.serviceManager.IService; |
31 | import pt.utl.ist.berserk.logic.serviceManager.IService; |
31 | 32 | ||
32 | import java.io.IOException; |
33 | import java.io.IOException; |
33 | import java.io.InputStream; |
34 | import java.io.InputStream; |
34 | import java.net.URL; |
35 | import java.net.URL; |
- | 36 | import java.net.URLConnection; |
|
35 | import java.util.*; |
37 | import java.util.*; |
36 | 38 | ||
37 | /** |
39 | /** |
38 | * Created by jorgemachado on 14/10/17. |
40 | * Created by jorgemachado on 14/10/17. |
39 | */ |
41 | */ |
40 | public class CourseReportServices implements IService |
42 | public class CourseReportServices implements IService |
41 | { |
43 | { |
42 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(CourseReportServices.class); |
44 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(CourseReportServices.class); |
43 | 45 | ||
44 | 46 | ||
45 | 47 | ||
46 | 48 | ||
47 | 49 | ||
48 | 50 | ||
49 | 51 | ||
50 | /****************************************************************************/ |
52 | /****************************************************************************/ |
51 | /* SERVICOS CORE DOS REPORTS |
53 | /* SERVICOS CORE DOS REPORTS |
52 | /****************************************************************************/ |
54 | /****************************************************************************/ |
53 | 55 | ||
54 | 56 | ||
55 | /** |
- | |
56 | * Gera uma tabela de estatisticas dos DTP recorrendo ao servico WS de |
- | |
57 | * load de tabelas DTP, caso o serviço nao devolva unidades são criadas novas |
- | |
58 | * com os valores a falso. |
- | |
59 | * |
- | |
60 | * @param courseCode |
- | |
61 | * @param year |
- | |
62 | * @return UnitsDtpTable |
- | |
63 | * @throws IOException |
- | |
64 | * @throws JSONException |
- | |
65 | */ |
- | |
66 | public UnitsDtpTable updateDtpStatsTable4Course(ReportCourseDocument reportCourseDocument, 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 |
- | |
67 | { |
- | |
68 | - | ||
69 | ReportsUcSummarySection reportsUcSummarySection = (ReportsUcSummarySection) reportCourseDocument.findDocumentSection(ReportsUcSummarySection.class); |
- | |
70 | UnitsDtpTable unitsDtpTable = (UnitsDtpTable) reportsUcSummarySection.findDocComponent(UnitsDtpTable.class); |
- | |
71 | UnitDtpSemester semester1 = new UnitDtpSemester(); |
- | |
72 | UnitDtpSemester semester2 = new UnitDtpSemester(); |
- | |
73 | unitsDtpTable.setSemester1(semester1); |
- | |
74 | unitsDtpTable.setSemester2(semester2); |
- | |
75 | - | ||
76 | List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
- | |
77 | - | ||
78 | 1.5.0/docs/api/java/lang/String.html">String json = loadCourseUnitDtpStats(courseCode,year); |
- | |
79 | JSONObject response = new JSONObject(json); |
- | |
80 | JSONArray stats = (JSONArray) response.get("dtpstats"); |
- | |
81 | CourseUnitDtpStat[] statsLoaded = CourseUnitDtpStat.fromJson(stats); |
- | |
82 | - | ||
83 | for(CourseUnit cu :units) |
- | |
84 | { |
- | |
85 | CourseUnitDtpStat statFound = CourseReportUtils.findCourseUnitDtpStat(statsLoaded, (CourseUnitImpl) cu); |
- | |
86 | if(statFound == null) |
- | |
87 | { |
- | |
88 | statFound = CourseReportUtils.createCourseUnitDtpStat(cu); |
- | |
89 | } |
- | |
90 | - | ||
91 | if(((CourseUnitImpl) cu).getSemestreAbsolutoS1S2().equals("S1")) |
- | |
92 | semester1.getCourseUnitDtpStats().add(statFound); |
- | |
93 | else |
- | |
94 | semester2.getCourseUnitDtpStats().add(statFound); |
- | |
95 | } |
- | |
96 | 57 | ||
97 | return unitsDtpTable; |
- | |
98 | - | ||
99 | } |
- | |
100 | 58 | ||
101 | /** |
59 | /** |
102 | * |
60 | * |
103 | * @param courseCode |
61 | * @param courseCode |
104 | * @param year |
62 | * @param year |
105 | * @return |
63 | * @return |
106 | * @throws IOException |
64 | * @throws IOException |
107 | * @throws JSONException |
65 | * @throws JSONException |
108 | */ |
66 | */ |
109 | public ReportCourseDocument 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 |
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 |
110 | { |
68 | { |
111 | ReportCourseDocument reportCourseDocument = new ReportCourseDocument(); |
69 | CourseReportDocument reportCourseDocument = new CourseReportDocument(); |
112 | reportCourseDocument.init(); |
70 | reportCourseDocument.init(); |
113 | 71 | ||
114 | 72 | ||
115 | //FIRST SERVICE TO CALL TO OBTAIN UNITS AND EVALUATIONS |
73 | //FIRST SERVICE TO CALL TO OBTAIN UNITS AND EVALUATIONS |
116 | //THIS IS THE BASE FOR THE REMAIN SERVICE CALLS |
74 | //THIS IS THE BASE FOR THE REMAIN SERVICE CALLS |
117 | List<DocumentSection> courseUnitSections = updateCleanCourseUnitSections(courseCode, year, reportCourseDocument); |
75 | List<DocumentSection> courseUnitSections = updateCleanCourseUnitSections(courseCode, year, reportCourseDocument); |
118 | 76 | ||
119 | //A tabela de resultados globais não vai ser utilizada |
77 | //A tabela de resultados globais não vai ser utilizada |
120 | //PARA CORRER ESTE SERVICO A PARTIR DA INTERFACE É PRECISO |
78 | //PARA CORRER ESTE SERVICO A PARTIR DA INTERFACE É PRECISO |
121 | //PERCEBER QUE DEPENDE DO SERVICO DE UPDATE DAS SECOES DAS COURSEUNITS |
79 | //PERCEBER QUE DEPENDE DO SERVICO DE UPDATE DAS SECOES DAS COURSEUNITS |
122 | UnitsLearningResultsTable unitsLearningResultsTable = updateCleanLearningResultsFromCourseUnitsSections(reportCourseDocument); |
80 | UnitsLearningResultsTable unitsLearningResultsTable = updateCleanLearningResultsFromCourseUnitsSections(reportCourseDocument); |
123 | 81 | ||
124 | 82 | ||
125 | //Atualiza no DOC a tabela de analise DTP |
83 | //Atualiza no DOC a tabela de analise DTP |
126 | UnitsDtpTable unitsDtpTable = updateDtpStatsTable4Course(reportCourseDocument, courseCode, year); |
84 | UnitsDtpTable unitsDtpTable = updateDtpStatsTable4Course(reportCourseDocument, courseCode, year); |
127 | 85 | ||
128 | 86 | ||
129 | //Atualiza as tabelas dos Quesitonários pedagogicos |
87 | //Atualiza as tabelas dos Quesitonários pedagogicos |
130 | SurveysResultsSection surveysResultsSection = updateSurveysDataTables(courseCode, year, reportCourseDocument); |
88 | SurveysResultsSection surveysResultsSection = updateSurveysDataTables(courseCode, year, reportCourseDocument); |
131 | 89 | ||
132 | 90 | ||
133 | return reportCourseDocument; |
91 | return reportCourseDocument; |
134 | } |
92 | } |
135 | 93 | ||
136 | public SurveysResultsSection updateSurveysDataTables(1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String year, ReportCourseDocument reportCourseDocument) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException { |
94 | public SurveysResultsSection updateSurveysDataTables(1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String year, CourseReportDocument reportCourseDocument) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException { |
137 | SurveysSection surveysSection = (SurveysSection) reportCourseDocument.findDocumentSection(SurveysSection.class); |
95 | SurveysSection surveysSection = (SurveysSection) reportCourseDocument.findDocumentSection(SurveysSection.class); |
138 | SurveysResultsSection surveysResultsSection = (SurveysResultsSection) surveysSection.findSubSection(SurveysResultsSection.class); |
96 | SurveysResultsSection surveysResultsSection = (SurveysResultsSection) surveysSection.findSection(SurveysResultsSection.class); |
139 | QuestionariosDataTableComponent dataTableComponentS1 = (QuestionariosDataTableComponent) surveysResultsSection.getComponents().get(0); |
97 | QuestionariosDataTableComponent dataTableComponentS1 = (QuestionariosDataTableComponent) surveysResultsSection.getComponents().get(0); |
140 | QuestionariosDataTableComponent dataTableComponentS2 = (QuestionariosDataTableComponent) surveysResultsSection.getComponents().get(1); |
98 | QuestionariosDataTableComponent dataTableComponentS2 = (QuestionariosDataTableComponent) surveysResultsSection.getComponents().get(1); |
141 | 99 | ||
142 | QuestionariosReportsService questionariosReportsService = new QuestionariosReportsService(); |
100 | QuestionariosReportsService questionariosReportsService = new QuestionariosReportsService(); |
143 | 1.5.0/docs/api/java/lang/String.html">String jsonDataTableS1 = questionariosReportsService.loadReportUnidadesSalasJson(courseCode,year,"S1"); |
101 | 1.5.0/docs/api/java/lang/String.html">String jsonDataTableS1 = questionariosReportsService.loadReportUnidadesSalasJson(courseCode,year,"S1"); |
144 | 1.5.0/docs/api/java/lang/String.html">String jsonDataTableS2 = questionariosReportsService.loadReportUnidadesSalasJson(courseCode,year,"S2"); |
102 | 1.5.0/docs/api/java/lang/String.html">String jsonDataTableS2 = questionariosReportsService.loadReportUnidadesSalasJson(courseCode,year,"S2"); |
145 | DataTable dataTableS1 = DataTable.fromJson(jsonDataTableS1); |
103 | DataTable dataTableS1 = DataTable.fromJson(jsonDataTableS1); |
146 | DataTable dataTableS2 = DataTable.fromJson(jsonDataTableS2); |
104 | DataTable dataTableS2 = DataTable.fromJson(jsonDataTableS2); |
147 | dataTableComponentS1.setDataTable(dataTableS1); |
105 | dataTableComponentS1.setDataTable(dataTableS1); |
148 | dataTableComponentS2.setDataTable(dataTableS2); |
106 | dataTableComponentS2.setDataTable(dataTableS2); |
149 | return surveysResultsSection; |
107 | return surveysResultsSection; |
150 | } |
108 | } |
151 | 109 | ||
152 | /** |
110 | /** |
153 | * Este serviço atualiza a tabela de resultados de aprendizagem com base nas courseunitssections |
111 | * Este serviço atualiza a tabela de resultados de aprendizagem com base nas courseunitssections |
154 | * @param reportCourseDocument |
112 | * @param reportCourseDocument |
155 | * @return UnitsLearningResultsTable |
113 | * @return UnitsLearningResultsTable |
156 | */ |
114 | */ |
157 | public UnitsLearningResultsTable updateCleanLearningResultsFromCourseUnitsSections(ReportCourseDocument reportCourseDocument) |
115 | public UnitsLearningResultsTable updateCleanLearningResultsFromCourseUnitsSections(CourseReportDocument reportCourseDocument) |
158 | { |
116 | { |
159 | CourseUnitsReportsSection unitReportsSection = (CourseUnitsReportsSection) reportCourseDocument.findDocumentSection(CourseUnitsReportsSection.class); |
117 | CourseUnitsReportsSection unitReportsSection = (CourseUnitsReportsSection) reportCourseDocument.findDocumentSection(CourseUnitsReportsSection.class); |
160 | 118 | ||
161 | LearningResultsSection learningResultsSection = (LearningResultsSection) reportCourseDocument.findDocumentSection(LearningResultsSection.class); |
119 | LearningResultsSection learningResultsSection = (LearningResultsSection) reportCourseDocument.findDocumentSection(LearningResultsSection.class); |
162 | UnitsLearningResultsTable learningResultsTable = (UnitsLearningResultsTable) learningResultsSection.findDocComponent(UnitsLearningResultsTable.class); |
120 | UnitsLearningResultsTable learningResultsTable = (UnitsLearningResultsTable) learningResultsSection.findDocComponent(UnitsLearningResultsTable.class); |
163 | 121 | ||
164 | Map<Integer,UnitsLearningResultYear> anosPlano = new HashMap<Integer, UnitsLearningResultYear>(); |
122 | Map<Integer,UnitsLearningResultYear> anosPlano = new HashMap<Integer, UnitsLearningResultYear>(); |
165 | Map<String,UnitsLearningResultSemester> anoSemestre = new HashMap<String, UnitsLearningResultSemester>(); |
123 | Map<String,UnitsLearningResultSemester> anoSemestre = new HashMap<String, UnitsLearningResultSemester>(); |
166 | for(DocumentSection subSection : unitReportsSection.getSubSections()) |
124 | for(DocumentSection subSection : unitReportsSection.getSections()) |
167 | { |
125 | { |
168 | CourseUnitSection unitSection = (CourseUnitSection) subSection; |
126 | CourseUnitSection unitSection = (CourseUnitSection) subSection; |
169 | int anoPlano = unitSection.getAnoPlano(); |
127 | int anoPlano = unitSection.getAnoPlano(); |
170 | UnitsLearningResultYear anoFound = anosPlano.get(anoPlano); |
128 | UnitsLearningResultYear anoFound = anosPlano.get(anoPlano); |
171 | if(anoFound == null) |
129 | if(anoFound == null) |
172 | { |
130 | { |
173 | anoFound = new UnitsLearningResultYear(anoPlano); |
131 | anoFound = new UnitsLearningResultYear(anoPlano); |
174 | anosPlano.put(anoPlano,anoFound); |
132 | anosPlano.put(anoPlano,anoFound); |
175 | learningResultsTable.getYears().add(anoFound); |
133 | learningResultsTable.getYears().add(anoFound); |
176 | } |
134 | } |
177 | 135 | ||
178 | 1.5.0/docs/api/java/lang/String.html">String semestreCode = ((CourseUnitSection) subSection).getPeriod(); |
136 | 1.5.0/docs/api/java/lang/String.html">String semestreCode = ((CourseUnitSection) subSection).getPeriod(); |
179 | UnitsLearningResultSemester semestreFound = anoSemestre.get(anoPlano + "$" + semestreCode); |
137 | UnitsLearningResultSemester semestreFound = anoSemestre.get(anoPlano + "$" + semestreCode); |
180 | if(semestreFound == null) |
138 | if(semestreFound == null) |
181 | { |
139 | { |
182 | semestreFound = new UnitsLearningResultSemester(semestreCode); |
140 | semestreFound = new UnitsLearningResultSemester(semestreCode); |
183 | anoSemestre.put(anoPlano + "$" + semestreCode,semestreFound); |
141 | anoSemestre.put(anoPlano + "$" + semestreCode,semestreFound); |
184 | anoFound.getSemesters().add(semestreFound); |
142 | anoFound.getSemesters().add(semestreFound); |
185 | } |
143 | } |
186 | 144 | ||
187 | UnitsLearningResultUc uc = new UnitsLearningResultUc(); |
145 | UnitsLearningResultUc uc = new UnitsLearningResultUc(); |
188 | uc.setPeriod(semestreCode); |
146 | uc.setPeriod(semestreCode); |
189 | uc.setName(unitSection.getName()); |
147 | uc.setName(unitSection.getName()); |
190 | uc.setSigesCode(unitSection.getSigesCode()); |
148 | uc.setSigesCode(unitSection.getSigesCode()); |
191 | if(unitSection.getCourseUnitEvaluation() != null) |
149 | if(unitSection.getCourseUnitEvaluation() != null) |
192 | { |
150 | { |
193 | 151 | ||
194 | uc.setCumprimentoProgramaPercent(unitSection.getCourseUnitEvaluation().getCumprimentoProgramaPercent()); |
152 | uc.setCumprimentoProgramaPercent(unitSection.getCourseUnitEvaluation().getCumprimentoProgramaPercent()); |
195 | uc.setAlunosInscritos(unitSection.getCourseUnitEvaluation().getNumAlunosInscritos()); |
153 | uc.setAlunosInscritos(unitSection.getCourseUnitEvaluation().getNumAlunosInscritos()); |
196 | 154 | ||
197 | uc.setAprovados1013(unitSection.getCourseUnitEvaluation().getNumAlunosAprov1013()); |
155 | uc.setAprovados1013(unitSection.getCourseUnitEvaluation().getNumAlunosAprov1013()); |
198 | uc.setAprovados1416(unitSection.getCourseUnitEvaluation().getNumAlunosAprov1416()); |
156 | uc.setAprovados1416(unitSection.getCourseUnitEvaluation().getNumAlunosAprov1416()); |
199 | uc.setAprovados1720(unitSection.getCourseUnitEvaluation().getNumAlunosAprov1720()); |
157 | uc.setAprovados1720(unitSection.getCourseUnitEvaluation().getNumAlunosAprov1720()); |
200 | uc.setSemElementos(unitSection.getCourseUnitEvaluation().getNumAlunosSemElementosAvaliacao()); |
158 | uc.setSemElementos(unitSection.getCourseUnitEvaluation().getNumAlunosSemElementosAvaliacao()); |
201 | uc.setAprovados(unitSection.getCourseUnitEvaluation().getNumAlunosAprovTotal()); |
159 | uc.setAprovados(unitSection.getCourseUnitEvaluation().getNumAlunosAprovTotal()); |
202 | uc.setReprovados(unitSection.getCourseUnitEvaluation().getNumAlunosReprovados()); |
160 | uc.setReprovados(unitSection.getCourseUnitEvaluation().getNumAlunosReprovados()); |
203 | 161 | ||
204 | if(uc.getAlunosInscritos() > 0) |
162 | if(uc.getAlunosInscritos() > 0) |
205 | { |
163 | { |
206 | uc.setAprovadosPercent((float) (uc.getAprovados() * 100.0 / uc.getAlunosInscritos())); |
164 | uc.setAprovadosPercent((float) (uc.getAprovados() * 100.0 / uc.getAlunosInscritos())); |
207 | uc.setReprovadosPercent((float) (uc.getReprovados() * 100.0 / uc.getAlunosInscritos())); |
165 | uc.setReprovadosPercent((float) (uc.getReprovados() * 100.0 / uc.getAlunosInscritos())); |
208 | uc.setSemElementosPercent((float) (uc.getSemElementos() * 100.0 / uc.getAlunosInscritos())); |
166 | uc.setSemElementosPercent((float) (uc.getSemElementos() * 100.0 / uc.getAlunosInscritos())); |
209 | } |
167 | } |
210 | 168 | ||
211 | if(uc.getAprovados() > 0) |
169 | if(uc.getAprovados() > 0) |
212 | { |
170 | { |
213 | uc.setAprovados1013Percent((float) (uc.getAprovados1013() * 100.0 / uc.getAprovados())); |
171 | uc.setAprovados1013Percent((float) (uc.getAprovados1013() * 100.0 / uc.getAprovados())); |
214 | uc.setAprovados1416Percent((float) (uc.getAprovados1416() * 100.0 / uc.getAprovados())); |
172 | uc.setAprovados1416Percent((float) (uc.getAprovados1416() * 100.0 / uc.getAprovados())); |
215 | uc.setAprovados1720Percent((float) (uc.getAprovados1720() * 100.0 / uc.getAprovados())); |
173 | uc.setAprovados1720Percent((float) (uc.getAprovados1720() * 100.0 / uc.getAprovados())); |
216 | } |
174 | } |
217 | } |
175 | } |
218 | semestreFound.getUcs().add(uc); |
176 | semestreFound.getUcs().add(uc); |
219 | } |
177 | } |
220 | 178 | ||
221 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(learningResultsTable.getYears(), new Comparator<UnitsLearningResultYear>() { |
179 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(learningResultsTable.getYears(), new Comparator<UnitsLearningResultYear>() { |
222 | @1.5.0/docs/api/java/lang/Override.html">Override |
180 | @1.5.0/docs/api/java/lang/Override.html">Override |
223 | public int compare(UnitsLearningResultYear o1, UnitsLearningResultYear o2) { |
181 | public int compare(UnitsLearningResultYear o1, UnitsLearningResultYear o2) { |
224 | return o1.getAno() - o2.getAno(); |
182 | return o1.getAno() - o2.getAno(); |
225 | } |
183 | } |
226 | }); |
184 | }); |
227 | 185 | ||
228 | for(UnitsLearningResultYear learningYearLine: learningResultsTable.getYears()) |
186 | for(UnitsLearningResultYear learningYearLine: learningResultsTable.getYears()) |
229 | { |
187 | { |
230 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(learningYearLine.getSemesters(),new Comparator<UnitsLearningResultSemester>() { |
188 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(learningYearLine.getSemesters(),new Comparator<UnitsLearningResultSemester>() { |
231 | @1.5.0/docs/api/java/lang/Override.html">Override |
189 | @1.5.0/docs/api/java/lang/Override.html">Override |
232 | public int compare(UnitsLearningResultSemester o1, UnitsLearningResultSemester o2) { |
190 | public int compare(UnitsLearningResultSemester o1, UnitsLearningResultSemester o2) { |
233 | return o1.getSemestre().compareTo(o2.getSemestre()); |
191 | return o1.getSemestre().compareTo(o2.getSemestre()); |
234 | } |
192 | } |
235 | }); |
193 | }); |
236 | } |
194 | } |
237 | 195 | ||
238 | 196 | ||
239 | //UPDATE TOTAIS DE SEMESTRES E DE ANOS |
197 | //UPDATE TOTAIS DE SEMESTRES E DE ANOS |
240 | float totalCumProgPercentGlobal = 0; |
198 | float totalCumProgPercentGlobal = 0; |
241 | int totalInscritosGlobal = 0; |
199 | int totalInscritosGlobal = 0; |
242 | float totalReprovadosPercentGlobal = 0; |
200 | float totalReprovadosPercentGlobal = 0; |
243 | float totalAprovadosPercentGlobal = 0; |
201 | float totalAprovadosPercentGlobal = 0; |
244 | float totalSemElementosPercentGlobal = 0; |
202 | float totalSemElementosPercentGlobal = 0; |
245 | int totalAprovados1013PercentGlobal = 0; |
203 | int totalAprovados1013PercentGlobal = 0; |
246 | float totalAprovados1416PercentGlobal = 0; |
204 | float totalAprovados1416PercentGlobal = 0; |
247 | float totalAprovados1720PercentGlobal = 0; |
205 | float totalAprovados1720PercentGlobal = 0; |
248 | for(UnitsLearningResultYear learningYearLine: learningResultsTable.getYears()) |
206 | for(UnitsLearningResultYear learningYearLine: learningResultsTable.getYears()) |
249 | { |
207 | { |
250 | float totalCumProgPercentAno = 0; |
208 | float totalCumProgPercentAno = 0; |
251 | int totalInscritosAno = 0; |
209 | int totalInscritosAno = 0; |
252 | float totalReprovadosPercentAno = 0; |
210 | float totalReprovadosPercentAno = 0; |
253 | float totalAprovadosPercentAno = 0; |
211 | float totalAprovadosPercentAno = 0; |
254 | float totalSemElementosPercentAno = 0; |
212 | float totalSemElementosPercentAno = 0; |
255 | int totalAprovados1013PercentAno = 0; |
213 | int totalAprovados1013PercentAno = 0; |
256 | float totalAprovados1416PercentAno = 0; |
214 | float totalAprovados1416PercentAno = 0; |
257 | float totalAprovados1720PercentAno = 0; |
215 | float totalAprovados1720PercentAno = 0; |
258 | 216 | ||
259 | for(UnitsLearningResultSemester semester: learningYearLine.getSemesters()) |
217 | for(UnitsLearningResultSemester semester: learningYearLine.getSemesters()) |
260 | { |
218 | { |
261 | float totalCumProgPercent = 0; |
219 | float totalCumProgPercent = 0; |
262 | int totalInscritos = 0; |
220 | int totalInscritos = 0; |
263 | float totalReprovadosPercent = 0; |
221 | float totalReprovadosPercent = 0; |
264 | float totalAprovadosPercent = 0; |
222 | float totalAprovadosPercent = 0; |
265 | float totalSemElementosPercent = 0; |
223 | float totalSemElementosPercent = 0; |
266 | int totalAprovados1013Percent = 0; |
224 | int totalAprovados1013Percent = 0; |
267 | float totalAprovados1416Percent = 0; |
225 | float totalAprovados1416Percent = 0; |
268 | float totalAprovados1720Percent = 0; |
226 | float totalAprovados1720Percent = 0; |
269 | for(UnitsLearningResultUc uc: semester.getUcs()) |
227 | for(UnitsLearningResultUc uc: semester.getUcs()) |
270 | { |
228 | { |
271 | totalCumProgPercent += uc.getCumprimentoProgramaPercent(); |
229 | totalCumProgPercent += uc.getCumprimentoProgramaPercent(); |
272 | totalInscritos += uc.getAlunosInscritos(); |
230 | totalInscritos += uc.getAlunosInscritos(); |
273 | totalAprovadosPercent += uc.getAprovadosPercent(); |
231 | totalAprovadosPercent += uc.getAprovadosPercent(); |
274 | totalReprovadosPercent += uc.getReprovadosPercent(); |
232 | totalReprovadosPercent += uc.getReprovadosPercent(); |
275 | totalSemElementosPercent += uc.getSemElementosPercent(); |
233 | totalSemElementosPercent += uc.getSemElementosPercent(); |
276 | totalAprovados1013Percent += uc.getAprovados1013(); |
234 | totalAprovados1013Percent += uc.getAprovados1013(); |
277 | totalAprovados1416Percent += uc.getAprovados1416(); |
235 | totalAprovados1416Percent += uc.getAprovados1416(); |
278 | totalAprovados1720Percent += uc.getAprovados1720(); |
236 | totalAprovados1720Percent += uc.getAprovados1720(); |
279 | } |
237 | } |
280 | //media de inscritos |
238 | //media de inscritos |
281 | if(semester.getUcs().size() > 0) |
239 | if(semester.getUcs().size() > 0) |
282 | { |
240 | { |
283 | semester.setCumprimentoProgramaPercent( totalCumProgPercent / ((float)semester.getUcs().size())); |
241 | semester.setCumprimentoProgramaPercent( totalCumProgPercent / ((float)semester.getUcs().size())); |
284 | semester.setAlunosInscritos( totalInscritos / (semester.getUcs().size())); |
242 | semester.setAlunosInscritos( totalInscritos / (semester.getUcs().size())); |
285 | semester.setAprovadosPercent( totalAprovadosPercent / ((float)semester.getUcs().size())); |
243 | semester.setAprovadosPercent( totalAprovadosPercent / ((float)semester.getUcs().size())); |
286 | semester.setReprovadosPercent( totalReprovadosPercent / ((float)semester.getUcs().size())); |
244 | semester.setReprovadosPercent( totalReprovadosPercent / ((float)semester.getUcs().size())); |
287 | semester.setSemElementosPercent( totalSemElementosPercent / ((float)semester.getUcs().size())); |
245 | semester.setSemElementosPercent( totalSemElementosPercent / ((float)semester.getUcs().size())); |
288 | semester.setAprovados1013Percent( totalAprovados1013Percent / ((float)semester.getUcs().size())); |
246 | semester.setAprovados1013Percent( totalAprovados1013Percent / ((float)semester.getUcs().size())); |
289 | semester.setAprovados1416Percent( totalAprovados1416Percent / ((float)semester.getUcs().size())); |
247 | semester.setAprovados1416Percent( totalAprovados1416Percent / ((float)semester.getUcs().size())); |
290 | semester.setAprovados1720Percent( totalAprovados1720Percent / ((float)semester.getUcs().size())); |
248 | semester.setAprovados1720Percent( totalAprovados1720Percent / ((float)semester.getUcs().size())); |
291 | } |
249 | } |
292 | totalCumProgPercentAno += semester.getCumprimentoProgramaPercent(); |
250 | totalCumProgPercentAno += semester.getCumprimentoProgramaPercent(); |
293 | totalInscritosAno += semester.getAlunosInscritos(); |
251 | totalInscritosAno += semester.getAlunosInscritos(); |
294 | totalAprovadosPercentAno += semester.getAprovadosPercent(); |
252 | totalAprovadosPercentAno += semester.getAprovadosPercent(); |
295 | totalReprovadosPercentAno += semester.getReprovadosPercent(); |
253 | totalReprovadosPercentAno += semester.getReprovadosPercent(); |
296 | totalSemElementosPercentAno += semester.getSemElementosPercent(); |
254 | totalSemElementosPercentAno += semester.getSemElementosPercent(); |
297 | totalAprovados1013PercentAno += semester.getAprovados1013(); |
255 | totalAprovados1013PercentAno += semester.getAprovados1013(); |
298 | totalAprovados1416PercentAno += semester.getAprovados1416(); |
256 | totalAprovados1416PercentAno += semester.getAprovados1416(); |
299 | totalAprovados1720PercentAno += semester.getAprovados1720(); |
257 | totalAprovados1720PercentAno += semester.getAprovados1720(); |
300 | } |
258 | } |
301 | //media de inscritos |
259 | //media de inscritos |
302 | if(learningYearLine.getSemesters().size() > 0) |
260 | if(learningYearLine.getSemesters().size() > 0) |
303 | { |
261 | { |
304 | learningYearLine.setCumprimentoProgramaPercent( totalCumProgPercentAno / ((float)learningYearLine.getSemesters().size())); |
262 | learningYearLine.setCumprimentoProgramaPercent( totalCumProgPercentAno / ((float)learningYearLine.getSemesters().size())); |
305 | learningYearLine.setAlunosInscritos( totalInscritosAno / (learningYearLine.getSemesters().size())); |
263 | learningYearLine.setAlunosInscritos( totalInscritosAno / (learningYearLine.getSemesters().size())); |
306 | learningYearLine.setAprovadosPercent( totalAprovadosPercentAno / ((float)learningYearLine.getSemesters().size())); |
264 | learningYearLine.setAprovadosPercent( totalAprovadosPercentAno / ((float)learningYearLine.getSemesters().size())); |
307 | learningYearLine.setReprovadosPercent( totalReprovadosPercentAno / ((float)learningYearLine.getSemesters().size())); |
265 | learningYearLine.setReprovadosPercent( totalReprovadosPercentAno / ((float)learningYearLine.getSemesters().size())); |
308 | learningYearLine.setSemElementosPercent( totalSemElementosPercentAno / ((float)learningYearLine.getSemesters().size())); |
266 | learningYearLine.setSemElementosPercent( totalSemElementosPercentAno / ((float)learningYearLine.getSemesters().size())); |
309 | learningYearLine.setAprovados1013Percent( totalAprovados1013PercentAno / ((float)learningYearLine.getSemesters().size())); |
267 | learningYearLine.setAprovados1013Percent( totalAprovados1013PercentAno / ((float)learningYearLine.getSemesters().size())); |
310 | learningYearLine.setAprovados1416Percent( totalAprovados1416PercentAno / ((float)learningYearLine.getSemesters().size())); |
268 | learningYearLine.setAprovados1416Percent( totalAprovados1416PercentAno / ((float)learningYearLine.getSemesters().size())); |
311 | learningYearLine.setAprovados1720Percent( totalAprovados1720PercentAno / ((float)learningYearLine.getSemesters().size())); |
269 | learningYearLine.setAprovados1720Percent( totalAprovados1720PercentAno / ((float)learningYearLine.getSemesters().size())); |
312 | } |
270 | } |
313 | totalCumProgPercentGlobal += learningYearLine.getCumprimentoProgramaPercent(); |
271 | totalCumProgPercentGlobal += learningYearLine.getCumprimentoProgramaPercent(); |
314 | totalInscritosGlobal += learningYearLine.getAlunosInscritos(); |
272 | totalInscritosGlobal += learningYearLine.getAlunosInscritos(); |
315 | totalAprovadosPercentGlobal += learningYearLine.getAprovadosPercent(); |
273 | totalAprovadosPercentGlobal += learningYearLine.getAprovadosPercent(); |
316 | totalReprovadosPercentGlobal += learningYearLine.getReprovadosPercent(); |
274 | totalReprovadosPercentGlobal += learningYearLine.getReprovadosPercent(); |
317 | totalSemElementosPercentGlobal += learningYearLine.getSemElementosPercent(); |
275 | totalSemElementosPercentGlobal += learningYearLine.getSemElementosPercent(); |
318 | totalAprovados1013PercentGlobal += learningYearLine.getAprovados1013(); |
276 | totalAprovados1013PercentGlobal += learningYearLine.getAprovados1013(); |
319 | totalAprovados1416PercentGlobal += learningYearLine.getAprovados1416(); |
277 | totalAprovados1416PercentGlobal += learningYearLine.getAprovados1416(); |
320 | totalAprovados1720PercentGlobal += learningYearLine.getAprovados1720(); |
278 | totalAprovados1720PercentGlobal += learningYearLine.getAprovados1720(); |
321 | } |
279 | } |
322 | 280 | ||
323 | if(learningResultsTable.getYears().size() > 0) |
281 | if(learningResultsTable.getYears().size() > 0) |
324 | { |
282 | { |
325 | learningResultsTable.setCumprimentoProgramaPercent( totalCumProgPercentGlobal / ((float)learningResultsTable.getYears().size())); |
283 | learningResultsTable.setCumprimentoProgramaPercent( totalCumProgPercentGlobal / ((float)learningResultsTable.getYears().size())); |
326 | learningResultsTable.setAlunosInscritos( totalInscritosGlobal / (learningResultsTable.getYears().size())); |
284 | learningResultsTable.setAlunosInscritos( totalInscritosGlobal / (learningResultsTable.getYears().size())); |
327 | learningResultsTable.setAprovadosPercent( totalAprovadosPercentGlobal / ((float)learningResultsTable.getYears().size())); |
285 | learningResultsTable.setAprovadosPercent( totalAprovadosPercentGlobal / ((float)learningResultsTable.getYears().size())); |
328 | learningResultsTable.setReprovadosPercent( totalReprovadosPercentGlobal / ((float)learningResultsTable.getYears().size())); |
286 | learningResultsTable.setReprovadosPercent( totalReprovadosPercentGlobal / ((float)learningResultsTable.getYears().size())); |
329 | learningResultsTable.setSemElementosPercent( totalSemElementosPercentGlobal / ((float)learningResultsTable.getYears().size())); |
287 | learningResultsTable.setSemElementosPercent( totalSemElementosPercentGlobal / ((float)learningResultsTable.getYears().size())); |
330 | learningResultsTable.setAprovados1013Percent( totalAprovados1013PercentGlobal / ((float)learningResultsTable.getYears().size())); |
288 | learningResultsTable.setAprovados1013Percent( totalAprovados1013PercentGlobal / ((float)learningResultsTable.getYears().size())); |
331 | learningResultsTable.setAprovados1416Percent( totalAprovados1416PercentGlobal / ((float)learningResultsTable.getYears().size())); |
289 | learningResultsTable.setAprovados1416Percent( totalAprovados1416PercentGlobal / ((float)learningResultsTable.getYears().size())); |
332 | learningResultsTable.setAprovados1720Percent( totalAprovados1720PercentGlobal / ((float)learningResultsTable.getYears().size())); |
290 | learningResultsTable.setAprovados1720Percent( totalAprovados1720PercentGlobal / ((float)learningResultsTable.getYears().size())); |
333 | } |
291 | } |
334 | 292 | ||
335 | 293 | ||
336 | 294 | ||
337 | 295 | ||
338 | return learningResultsTable; |
296 | return learningResultsTable; |
339 | //CRIAR A TABELA DE RESUTLADOS GLOBAIS GERAIS COMO UM RESUMO DA ANTERIOR |
297 | //CRIAR A TABELA DE RESUTLADOS GLOBAIS GERAIS COMO UM RESUMO DA ANTERIOR |
340 | /*for(UnitsLearningResultYear learningYearLine: learningResultsTable.getYears()) |
298 | /*for(UnitsLearningResultYear learningYearLine: learningResultsTable.getYears()) |
341 | { |
299 | { |
342 | 300 | ||
343 | }*/ |
301 | }*/ |
344 | } |
302 | } |
345 | 303 | ||
346 | 304 | ||
347 | /** |
305 | /** |
- | 306 | * Gera uma tabela de estatisticas dos DTP recorrendo ao servico WS de |
|
- | 307 | * load de tabelas DTP, caso o serviço nao devolva unidades são criadas novas |
|
- | 308 | * com os valores a falso. |
|
- | 309 | * |
|
- | 310 | * @param courseCode |
|
- | 311 | * @param year |
|
- | 312 | * @return UnitsDtpTable |
|
- | 313 | * @throws IOException |
|
- | 314 | * @throws JSONException |
|
- | 315 | */ |
|
- | 316 | public UnitsDtpTable updateDtpStatsTable4Course(CourseReportDocument reportCourseDocument, 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 |
|
- | 317 | { |
|
- | 318 | ||
- | 319 | ReportsUcSummarySection reportsUcSummarySection = (ReportsUcSummarySection) reportCourseDocument.findDocumentSection(ReportsUcSummarySection.class); |
|
- | 320 | UnitsDtpTable unitsDtpTable = (UnitsDtpTable) reportsUcSummarySection.findDocComponent(UnitsDtpTable.class); |
|
- | 321 | UnitDtpSemester semester1 = new UnitDtpSemester(); |
|
- | 322 | UnitDtpSemester semester2 = new UnitDtpSemester(); |
|
- | 323 | unitsDtpTable.setSemester1(semester1); |
|
- | 324 | unitsDtpTable.setSemester2(semester2); |
|
- | 325 | ||
- | 326 | List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
|
- | 327 | ||
- | 328 | CourseUnitDtpStat[] statsLoaded; |
|
- | 329 | try |
|
- | 330 | { |
|
- | 331 | 1.5.0/docs/api/java/lang/String.html">String json = loadCourseUnitDtpStats(courseCode,year); |
|
- | 332 | JSONObject response = new JSONObject(json); |
|
- | 333 | JSONArray stats = (JSONArray) response.get("dtpstats"); |
|
- | 334 | statsLoaded = CourseUnitDtpStat.fromJson(stats); |
|
- | 335 | } |
|
- | 336 | catch(1.5.0/docs/api/java/lang/Exception.html">Exception e) |
|
- | 337 | { |
|
- | 338 | logger.error(e,e); |
|
- | 339 | statsLoaded = new CourseUnitDtpStat[0]; |
|
- | 340 | } |
|
- | 341 | ||
- | 342 | ||
- | 343 | for(CourseUnit cu :units) |
|
- | 344 | { |
|
- | 345 | CourseUnitDtpStat statFound = CourseReportUtils.findCourseUnitDtpStat(statsLoaded, (CourseUnitImpl) cu); |
|
- | 346 | if(statFound == null) |
|
- | 347 | { |
|
- | 348 | statFound = CourseReportUtils.createCourseUnitDtpStat(cu); |
|
- | 349 | } |
|
- | 350 | ||
- | 351 | if(((CourseUnitImpl) cu).getSemestreAbsolutoS1S2().equals("S1")) |
|
- | 352 | semester1.getCourseUnitDtpStats().add(statFound); |
|
- | 353 | else |
|
- | 354 | semester2.getCourseUnitDtpStats().add(statFound); |
|
- | 355 | } |
|
- | 356 | ||
- | 357 | return unitsDtpTable; |
|
- | 358 | ||
- | 359 | } |
|
- | 360 | ||
- | 361 | /** |
|
348 | * Update course unit sections with reports, this method dows not change learning results table |
362 | * Update course unit sections with reports, this method dows not change learning results table |
349 | * values from learning results stays in unit but does not change learning results Table |
363 | * values from learning results stays in unit but does not change learning results Table |
350 | * @param courseCode |
364 | * @param courseCode |
351 | * @param year |
365 | * @param year |
352 | * @param reportCourseDocument |
366 | * @param reportCourseDocument |
353 | * @throws JSONException |
367 | * @throws JSONException |
354 | * @throws IOException |
368 | * @throws IOException |
355 | * @return a list of CourseUnitSection |
369 | * @return a list of CourseUnitSection |
356 | */ |
370 | */ |
357 | public List<DocumentSection> updateCleanCourseUnitSections(1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String year, ReportCourseDocument reportCourseDocument) throws JSONException, 1.5.0/docs/api/java/io/IOException.html">IOException { |
371 | public List<DocumentSection> updateCleanCourseUnitSections(1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String year, CourseReportDocument reportCourseDocument) throws JSONException, 1.5.0/docs/api/java/io/IOException.html">IOException { |
358 | 372 | ||
359 | List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
373 | List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
360 | 374 | ||
361 | 1.5.0/docs/api/java/lang/String.html">String courseUnitSectionsJson = loadCourseEvaluationSections(courseCode,year); |
- | |
362 | JSONObject object = new JSONObject(courseUnitSectionsJson); |
- | |
363 | JSONArray evaluations = object.getJSONArray("evaluations"); |
- | |
364 | CourseUnitSection[] courseUnitSections = CourseUnitSection.fromJsonArray(evaluations.toString()); |
- | |
365 | - | ||
366 | CourseUnitsReportsSection unitReportsSection = (CourseUnitsReportsSection) reportCourseDocument.findDocumentSection(CourseUnitsReportsSection.class); |
375 | CourseUnitsReportsSection unitReportsSection = (CourseUnitsReportsSection) reportCourseDocument.findDocumentSection(CourseUnitsReportsSection.class); |
- | 376 | CourseUnitSection[] courseUnitSections = null; |
|
- | 377 | try{ |
|
- | 378 | 1.5.0/docs/api/java/lang/String.html">String courseUnitSectionsJson = loadCourseEvaluationSections(courseCode,year); |
|
- | 379 | JSONObject object = new JSONObject(courseUnitSectionsJson); |
|
- | 380 | JSONArray evaluations = object.getJSONArray("evaluations"); |
|
- | 381 | courseUnitSections = CourseUnitSection.fromJsonArray(evaluations.toString()); |
|
- | 382 | } |
|
- | 383 | catch(1.5.0/docs/api/java/lang/Exception.html">Exception e) |
|
- | 384 | { |
|
- | 385 | logger.error(e,e); |
|
- | 386 | courseUnitSections = new CourseUnitSection[0]; |
|
- | 387 | } |
|
- | 388 | ||
- | 389 | ||
367 | List<DocumentSection> subSections = new ArrayList<DocumentSection>(); |
390 | List<DocumentSection> subSections = new ArrayList<DocumentSection>(); |
368 | unitReportsSection.setSubSections(subSections); |
391 | unitReportsSection.setSections(subSections); |
369 | for(CourseUnit cu :units) |
392 | for(CourseUnit cu :units) |
370 | { |
393 | { |
371 | CourseUnitSection sectionFound = CourseReportUtils.findCourseUnitSection(courseUnitSections, (CourseUnitImpl) cu); |
394 | CourseUnitSection sectionFound = CourseReportUtils.findCourseUnitSection(courseUnitSections, (CourseUnitImpl) cu); |
372 | if(sectionFound == null) |
395 | if(sectionFound == null) |
373 | { |
396 | { |
374 | sectionFound = CourseReportUtils.createCourseUnitEvaluationSection((CourseUnitImpl) cu); |
397 | sectionFound = CourseReportUtils.createCourseUnitEvaluationSection((CourseUnitImpl) cu); |
375 | } |
398 | } |
376 | if(sectionFound.getCourseUnitEvaluation() == null) |
399 | if(sectionFound.getCourseUnitEvaluation() == null) |
377 | { |
400 | { |
378 | CourseUnitEvaluationImpl courseUnitEvaluation = DomainObjectFactory.createCourseUnitEvaluationImpl(); |
401 | CourseUnitEvaluationImpl courseUnitEvaluation = DomainObjectFactory.createCourseUnitEvaluationImpl(); |
379 | courseUnitEvaluation.setAutoGeneratedCourseReport(true); |
402 | courseUnitEvaluation.setAutoGeneratedCourseReport(true); |
380 | DaoFactory.getCourseUnitEvaluationDaoImpl().save(courseUnitEvaluation); |
403 | DaoFactory.getCourseUnitEvaluationDaoImpl().save(courseUnitEvaluation); |
381 | cu.setCourseUnitEvaluation(courseUnitEvaluation); |
404 | cu.setCourseUnitEvaluation(courseUnitEvaluation); |
382 | sectionFound.setCourseUnitEvaluation(courseUnitEvaluation); |
405 | sectionFound.setCourseUnitEvaluation(courseUnitEvaluation); |
383 | } |
406 | } |
384 | unitReportsSection.getSubSections().add(sectionFound); |
407 | unitReportsSection.getSections().add(sectionFound); |
385 | } |
408 | } |
386 | return subSections; |
409 | return subSections; |
387 | } |
410 | } |
388 | 411 | ||
389 | 412 | ||
390 | 413 | ||
391 | 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 { |
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 { |
392 | /*AbstractDao.getCurrentSession().beginTransaction(); |
415 | AbstractDao.getCurrentSession().beginTransaction(); |
393 | 416 | ||
394 | ReportCourseDocument reportCourseDocument = new CourseReportServices().createNewCourseReportDocument("44","201617"); |
417 | CourseReportDocument reportCourseDocument = new CourseReportServices().createNewCourseReportDocument("44","201617"); |
395 | System.out.println(reportCourseDocument.toJson()); |
418 | 1.5.0/docs/api/java/lang/System.html">System.out.println(reportCourseDocument.toJson()); |
396 | AbstractDao.getCurrentSession().getTransaction().commit();*/ |
419 | AbstractDao.getCurrentSession().getTransaction().commit(); |
397 | 420 | ||
398 | //System.setProperty("javax.net.ssl.trustStore", "/JORGE/COPIAS/.keystore"); |
421 | //System.setProperty("javax.net.ssl.trustStore", "/JORGE/COPIAS/.keystore"); |
399 | //System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); |
422 | //System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); |
400 | 423 | ||
401 | 1.5.0/docs/api/java/net/URL.html">URL url = new 1.5.0/docs/api/java/net/URL.html">URL("http://pae.ipportalegre.pt/wsjson/api/app/ws-course-pedagogic-results-list?code=44&year=201617&period=S1"); |
424 | /*URL url = new URL("http://pae.ipportalegre.pt/wsjson/api/app/ws-course-pedagogic-results-list?code=44&year=201617&period=S1"); |
402 | 425 | ||
403 | 426 | ||
404 | 427 | ||
405 | 1.5.0/docs/api/java/lang/System.html">System.out.println(StreamsUtils.readString(url.openStream())); |
428 | System.out.println(StreamsUtils.readString(url.openStream()));*/ |
406 | } |
429 | } |
407 | 430 | ||
408 | /* |
431 | /* |
409 | 432 | ||
410 | public String loadUnitsAndCreateLearningResultsTables4Course(String courseCode, String year) throws IOException, JSONException |
433 | public String loadUnitsAndCreateLearningResultsTables4Course(String courseCode, String year) throws IOException, JSONException |
411 | { |
434 | { |
412 | 435 | ||
413 | } |
436 | } |
414 | */ |
437 | */ |
415 | //TODO loadUnitsAndCreateLearningResultsTables4Course |
438 | //TODO loadUnitsAndCreateLearningResultsTables4Course |
416 | //HIPOTESE DEVOLVER DOIS OBJECTOS |
439 | //HIPOTESE DEVOLVER DOIS OBJECTOS |
417 | //SERVICO DE ARRANQUE |
440 | //SERVICO DE ARRANQUE |
418 | //DEVOLVE UM REPORT DOCUMENT E O CHAMADOR USA O QUE QUISER |
441 | //DEVOLVE UM REPORT DOCUMENT E O CHAMADOR USA O QUE QUISER |
419 | //A GERACAO DE GRAFICOS FAZ-SE APENAS A PEDIDO |
442 | //A GERACAO DE GRAFICOS FAZ-SE APENAS A PEDIDO |
420 | 443 | ||
421 | // SE ELE PEDIR PARA ATUALIZAR TUDO CARREGA-SE UNIDADES E TABELAS NU DOC NOVO |
444 | // SE ELE PEDIR PARA ATUALIZAR TUDO CARREGA-SE UNIDADES E TABELAS NU DOC NOVO |
422 | // E NO BROWSER SUBSTITUI-SE ESSES ELEMENTOS NOS ANTIGOS a seccao das unidades |
445 | // E NO BROWSER SUBSTITUI-SE ESSES ELEMENTOS NOS ANTIGOS a seccao das unidades |
423 | // e as as tabelas |
446 | // e as as tabelas |
424 | 447 | ||
425 | 448 | ||
426 | 449 | ||
427 | 450 | ||
428 | 451 | ||
429 | 452 | ||
430 | 453 | ||
431 | 454 | ||
432 | 455 | ||
433 | /****************************************************************************/ |
456 | /****************************************************************************/ |
434 | /* SERVICOS WS-API |
457 | /* SERVICOS WS-API |
435 | /****************************************************************************/ |
458 | /****************************************************************************/ |
436 | 459 | ||
437 | 460 | ||
438 | /** |
461 | /** |
439 | * This service loads a list of course units given course code and year |
462 | * This service loads a list of course units given course code and year |
440 | * with dtp stats codes pre-filled |
463 | * with dtp stats codes pre-filled |
441 | * @param courseCode |
464 | * @param courseCode |
442 | * @param year |
465 | * @param year |
443 | * @return |
466 | * @return |
444 | * @throws JSONException |
467 | * @throws JSONException |
445 | * @throws IOException |
468 | * @throws IOException |
446 | */ |
469 | */ |
447 | public 1.5.0/docs/api/java/lang/String.html">String loadCourseUnitDtpStats(1.5.0/docs/api/java/lang/String.html">String courseCode,1.5.0/docs/api/java/lang/String.html">String year) throws JSONException, 1.5.0/docs/api/java/io/IOException.html">IOException { |
470 | public 1.5.0/docs/api/java/lang/String.html">String loadCourseUnitDtpStats(1.5.0/docs/api/java/lang/String.html">String courseCode,1.5.0/docs/api/java/lang/String.html">String year) throws JSONException, 1.5.0/docs/api/java/io/IOException.html">IOException { |
448 | 471 | ||
449 | 472 | ||
450 | if(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_DTP_STATS.indexOf("localhost")>=0) |
473 | if(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_DTP_STATS.indexOf("localhost")>=0) |
451 | { |
474 | { |
452 | JSONArray array = new JSONArray(); |
475 | JSONArray array = new JSONArray(); |
453 | List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
476 | List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
454 | for(CourseUnit cu: units) |
477 | for(CourseUnit cu: units) |
455 | { |
478 | { |
456 | CourseUnitDtpStat stat = CourseReportUtils.createCourseUnitDtpStat(cu); |
479 | CourseUnitDtpStat stat = CourseReportUtils.createCourseUnitDtpStat(cu); |
457 | //sections.add(courseUnitSection); |
480 | //sections.add(courseUnitSection); |
458 | array.put(stat.toJsonObject()); |
481 | array.put(stat.toJsonObject()); |
459 | } |
482 | } |
460 | 483 | ||
461 | JSONObject obj = new JSONObject(); |
484 | JSONObject obj = new JSONObject(); |
462 | obj.put("dtpstats",array); |
485 | obj.put("dtpstats",array); |
463 | 486 | ||
464 | return obj.toString(); |
487 | return obj.toString(); |
465 | } |
488 | } |
466 | else |
489 | else |
467 | { |
490 | { |
468 | 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_UNITS_DTP_STATS + "?code=" + courseCode + "&year=" + year); |
491 | 1.5.0/docs/api/java/lang/String.html">String serviceUrl = Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_DTP_STATS + "?code=" + courseCode + "&year=" + year; |
- | 492 | 1.5.0/docs/api/java/lang/String.html">String json = "{ dtpstats : [] }"; |
|
- | 493 | try{ |
|
- | 494 | 1.5.0/docs/api/java/net/URL.html">URL url = new 1.5.0/docs/api/java/net/URL.html">URL(serviceUrl); |
|
- | 495 | ||
- | 496 | 1.5.0/docs/api/java/net/URLConnection.html">URLConnection conn = url.openConnection(); |
|
469 | 5+0%2Fdocs%2Fapi+InputStream">InputStream is = url.openStream(); |
497 | 5+0%2Fdocs%2Fapi+InputStream">InputStream is = conn.getInputStream(); |
470 | 498 | ||
471 | 1.5.0/docs/api/java/lang/String.html">String json = StreamsUtils.readString(is); |
499 | json = StreamsUtils.readString(is); |
472 | is.close(); |
500 | is.close(); |
- | 501 | }catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
|
- | 502 | { |
|
473 | //TODO temos de extrair o resultado do RESPONSE |
503 | logger.error("Connecting " + serviceUrl,e); |
- | 504 | return json; |
|
- | 505 | } |
|
474 | JSONObject jsonObject = new JSONObject(json); |
506 | JSONObject jsonObject = new JSONObject(json); |
475 | return jsonObject.get("response").toString(); |
507 | return jsonObject.get("response").toString(); |
476 | } |
508 | } |
477 | } |
509 | } |
478 | 510 | ||
479 | 511 | ||
480 | 512 | ||
481 | 513 | ||
482 | /** |
514 | /** |
483 | * |
515 | * |
484 | * Para um determinado curso e ano o serviço faz uma listagem de todas as suas unidades curriculares |
516 | * Para um determinado curso e ano o serviço faz uma listagem de todas as suas unidades curriculares |
485 | * e lista a sua informação básica juntamente com o relatório de avaliação disponivel |
517 | * e lista a sua informação básica juntamente com o relatório de avaliação disponivel |
486 | * O serviço adiciona ainda o Ano de cada unidade por inspeção do Plano de Estudos |
518 | * O serviço adiciona ainda o Ano de cada unidade por inspeção do Plano de Estudos |
487 | * caso a unidade não seja encontrada no Plano de estudos o ano irá ser preenchido com -1 |
519 | * caso a unidade não seja encontrada no Plano de estudos o ano irá ser preenchido com -1 |
488 | * |
520 | * |
489 | * @param courseCode codigo Siges na base de dados |
521 | * @param courseCode codigo Siges na base de dados |
490 | * @param year 201617, 201718 |
522 | * @param year 201617, 201718 |
491 | * @return String JSONObject with a JSON ARRAY of List<CourseUnitSection> |
523 | * @return String JSONObject with a JSON ARRAY of List<CourseUnitSection> |
492 | */ |
524 | */ |
493 | public 1.5.0/docs/api/java/lang/String.html">String loadCourseEvaluationSections(1.5.0/docs/api/java/lang/String.html">String courseCode,1.5.0/docs/api/java/lang/String.html">String year) throws JSONException, 1.5.0/docs/api/java/io/IOException.html">IOException { |
525 | public 1.5.0/docs/api/java/lang/String.html">String loadCourseEvaluationSections(1.5.0/docs/api/java/lang/String.html">String courseCode,1.5.0/docs/api/java/lang/String.html">String year) throws JSONException, 1.5.0/docs/api/java/io/IOException.html">IOException { |
494 | 526 | ||
495 | 527 | ||
496 | if(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_EVALUATION.indexOf("localhost")>=0) |
528 | if(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_EVALUATION_REPORT.indexOf("localhost")>=0) |
497 | { |
529 | { |
498 | JSONArray array = new JSONArray(); |
530 | JSONArray array = new JSONArray(); |
499 | List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
531 | List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
500 | for(CourseUnit cu: units) |
532 | for(CourseUnit cu: units) |
501 | { |
533 | { |
502 | CourseUnitSection courseUnitSection = CourseReportUtils.createCourseUnitEvaluationSection((CourseUnitImpl) cu); |
534 | CourseUnitSection courseUnitSection = CourseReportUtils.createCourseUnitEvaluationSection((CourseUnitImpl) cu); |
503 | array.put(courseUnitSection.toJsonObject()); |
535 | array.put(courseUnitSection.toJsonObject()); |
504 | } |
536 | } |
505 | 537 | ||
506 | JSONObject obj = new JSONObject(); |
538 | JSONObject obj = new JSONObject(); |
507 | obj.put("evaluations",array); |
539 | obj.put("evaluations",array); |
508 | 540 | ||
509 | return obj.toString(); |
541 | return obj.toString(); |
510 | } |
542 | } |
511 | else |
543 | else |
512 | { |
544 | { |
- | 545 | 1.5.0/docs/api/java/lang/String.html">String json = "{ evaluations : [] }"; |
|
513 | 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_UNITS_EVALUATION + "?code=" + courseCode + "&year=" + year); |
546 | 1.5.0/docs/api/java/lang/String.html">String serviceUrl = Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_EVALUATION_REPORT + "?code=" + courseCode + "&year=" + year; |
- | 547 | try{ |
|
- | 548 | 1.5.0/docs/api/java/net/URL.html">URL url = new 1.5.0/docs/api/java/net/URL.html">URL(serviceUrl); |
|
- | 549 | ||
- | 550 | 1.5.0/docs/api/java/net/URLConnection.html">URLConnection conn = url.openConnection(); |
|
514 | 5+0%2Fdocs%2Fapi+InputStream">InputStream is = url.openStream(); |
551 | 5+0%2Fdocs%2Fapi+InputStream">InputStream is = conn.getInputStream(); |
- | 552 | ||
- | 553 | json = StreamsUtils.readString(is); |
|
- | 554 | is.close(); |
|
- | 555 | }catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
|
- | 556 | { |
|
- | 557 | logger.error("Connecting " + serviceUrl,e); |
|
- | 558 | return json; |
|
- | 559 | } |
|
515 | 560 | ||
516 | 1.5.0/docs/api/java/lang/String.html">String json = StreamsUtils.readString(is); |
- | |
517 | is.close(); |
- | |
518 | JSONObject jsonObject = new JSONObject(json); |
561 | JSONObject jsonObject = new JSONObject(json); |
519 | return jsonObject.get("response").toString(); |
562 | return jsonObject.get("response").toString(); |
520 | } |
563 | } |
521 | } |
564 | } |
522 | 565 | ||
523 | 566 | ||
524 | } |
567 | } |
525 | 568 |