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