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