Rev 1928 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1928 | Rev 1934 | ||
---|---|---|---|
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.*; |
10 | import pt.estgp.estgweb.domain.*; |
11 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
11 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
12 | import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum; |
12 | import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum; |
13 | import pt.estgp.estgweb.services.courses.coursereport.CourseReportUtils; |
13 | import pt.estgp.estgweb.services.courses.coursereport.CourseReportUtils; |
14 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.*; |
14 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.*; |
15 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.courseunitreport.CourseUnitSection; |
15 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.courseunitreport.CourseUnitSection; |
16 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.LearningAnalysisSection; |
16 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.LearningAnalysisSection; |
17 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.LearningGlobalAnalysisSection; |
17 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.LearningGlobalAnalysisSection; |
18 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.components.*; |
18 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.components.*; |
19 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.reportucsummary.CourseUnitDtpStat; |
19 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.reportucsummary.CourseUnitDtpStat; |
20 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.reportucsummary.UnitDtpSemester; |
20 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.reportucsummary.UnitDtpSemester; |
21 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.reportucsummary.UnitsDtpTable; |
21 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.reportucsummary.UnitsDtpTable; |
22 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.surveys.SurveysResultsSection; |
22 | import pt.estgp.estgweb.services.courses.coursereport.documentmodel.surveys.SurveysResultsSection; |
23 | import pt.estgp.estgweb.services.data.RepositoryFile4JsonView; |
23 | import pt.estgp.estgweb.services.data.RepositoryFile4JsonView; |
24 | import pt.estgp.estgweb.services.data.RepositoryService; |
24 | import pt.estgp.estgweb.services.data.RepositoryService; |
25 | import pt.estgp.estgweb.services.questionarios.QuestionariosReportsService; |
25 | import pt.estgp.estgweb.services.questionarios.QuestionariosReportsService; |
26 | import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.utils.DataTable; |
26 | import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.utils.DataTable; |
27 | import pt.estgp.estgweb.utils.Globals; |
27 | import pt.estgp.estgweb.utils.Globals; |
28 | import pt.estgp.estgweb.utils.documentBuilder.DocumentSection; |
28 | import pt.estgp.estgweb.utils.documentBuilder.DocumentSection; |
29 | import pt.estgp.estgweb.utils.documentBuilder.QuestionariosDataTableComponent; |
29 | import pt.estgp.estgweb.utils.documentBuilder.QuestionariosDataTableComponent; |
30 | import pt.estgp.estgweb.web.controllers.utils.FileUploaded; |
30 | import pt.estgp.estgweb.web.controllers.utils.FileUploaded; |
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.net.URLConnection; |
36 | import java.net.URLConnection; |
37 | import java.util.*; |
37 | import java.util.*; |
38 | 38 | ||
39 | /** |
39 | /** |
40 | * Created by jorgemachado on 14/10/17. |
40 | * Created by jorgemachado on 14/10/17. |
41 | */ |
41 | */ |
42 | public class CourseReportServices implements IService |
42 | public class CourseReportServices implements IService |
43 | { |
43 | { |
44 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(CourseReportServices.class); |
44 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(CourseReportServices.class); |
45 | 45 | ||
46 | 46 | ||
47 | 47 | ||
48 | 48 | ||
49 | 49 | ||
50 | 50 | ||
51 | 51 | ||
52 | /****************************************************************************/ |
52 | /****************************************************************************/ |
53 | /* SERVICOS CORE DOS REPORTS |
53 | /* SERVICOS CORE DOS REPORTS |
54 | /****************************************************************************/ |
54 | /****************************************************************************/ |
55 | 55 | ||
56 | 56 | ||
57 | 57 | ||
58 | 58 | ||
59 | /** |
59 | /** |
60 | * |
60 | * |
61 | * @param courseCode |
61 | * @param courseCode |
62 | * @param year |
62 | * @param year |
63 | * @return |
63 | * @return |
64 | * @throws IOException |
64 | * @throws IOException |
65 | * @throws JSONException |
65 | * @throws JSONException |
66 | */ |
66 | */ |
67 | public CourseReportDocument createNewCourseReportDocument(1.5.0/docs/api/java/lang/String.html">String courseCode,1.5.0/docs/api/java/lang/String.html">String year) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException |
67 | public CourseReportDocument createNewCourseReportDocument(1.5.0/docs/api/java/lang/String.html">String courseCode,1.5.0/docs/api/java/lang/String.html">String year) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException |
68 | { |
68 | { |
69 | 69 | ||
70 | Course course = DaoFactory.getCourseDaoImpl().findCourseByCode(courseCode); |
70 | Course course = DaoFactory.getCourseDaoImpl().findCourseByCode(courseCode); |
71 | 71 | ||
72 | CourseReportDocument reportCourseDocument = new CourseReportDocument(); |
72 | CourseReportDocument reportCourseDocument = new CourseReportDocument(); |
73 | reportCourseDocument.init(course,year); |
73 | reportCourseDocument.init(course,year); |
74 | 74 | ||
75 | 75 | ||
76 | 76 | ||
77 | //FIRST SERVICE TO CALL TO OBTAIN UNITS AND EVALUATIONS |
77 | //FIRST SERVICE TO CALL TO OBTAIN UNITS AND EVALUATIONS |
78 | //THIS IS THE BASE FOR THE REMAIN SERVICE CALLS |
78 | //THIS IS THE BASE FOR THE REMAIN SERVICE CALLS |
79 | List<DocumentSection> courseUnitSections = updateCleanCourseUnitSections(courseCode, year, reportCourseDocument); |
79 | List<DocumentSection> courseUnitSections = updateCleanCourseUnitSections(courseCode, year, reportCourseDocument); |
80 | 80 | ||
81 | //A tabela de resultados globais não vai ser utilizada |
81 | //A tabela de resultados globais não vai ser utilizada |
82 | //PARA CORRER ESTE SERVICO A PARTIR DA INTERFACE É PRECISO |
82 | //PARA CORRER ESTE SERVICO A PARTIR DA INTERFACE É PRECISO |
83 | //PERCEBER QUE DEPENDE DO SERVICO DE UPDATE DAS SECOES DAS COURSEUNITS |
83 | //PERCEBER QUE DEPENDE DO SERVICO DE UPDATE DAS SECOES DAS COURSEUNITS |
84 | UnitsLearningResultsTable unitsLearningResultsTable = updateCleanLearningResultsFromCourseUnitsSections(reportCourseDocument); |
84 | UnitsLearningResultsTable unitsLearningResultsTable = updateCleanLearningResultsFromCourseUnitsSections(reportCourseDocument); |
85 | 85 | ||
86 | 86 | ||
87 | //Atualiza no DOC a tabela de analise DTP |
87 | //Atualiza no DOC a tabela de analise DTP |
88 | UnitsDtpTable unitsDtpTable = updateDtpStatsTable4Course(reportCourseDocument, courseCode, year); |
88 | UnitsDtpTable unitsDtpTable = updateDtpStatsTable4Course(reportCourseDocument, courseCode, year); |
89 | 89 | ||
90 | 90 | ||
91 | //Atualiza as tabelas dos Quesitonários pedagogicos |
91 | //Atualiza as tabelas dos Quesitonários pedagogicos |
92 | SurveysResultsSection surveysResultsSection = updateSurveysDataTables(courseCode, year, reportCourseDocument); |
92 | SurveysResultsSection surveysResultsSection = updateSurveysDataTables(courseCode, year, reportCourseDocument); |
93 | 93 | ||
94 | 94 | ||
95 | return reportCourseDocument; |
95 | return reportCourseDocument; |
96 | } |
96 | } |
97 | 97 | ||
98 | public SurveysResultsSection updateSurveysDataTables(1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String year, CourseReportDocument reportCourseDocument) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException { |
98 | public SurveysResultsSection updateSurveysDataTables(1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String year, CourseReportDocument reportCourseDocument) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException { |
99 | SurveysSection surveysSection = (SurveysSection) reportCourseDocument.findDocumentSection(SurveysSection.class); |
99 | SurveysSection surveysSection = (SurveysSection) reportCourseDocument.findDocumentSection(SurveysSection.class); |
100 | SurveysResultsSection surveysResultsSection = (SurveysResultsSection) surveysSection.findSection(SurveysResultsSection.class); |
100 | SurveysResultsSection surveysResultsSection = (SurveysResultsSection) surveysSection.findSection(SurveysResultsSection.class); |
101 | QuestionariosDataTableComponent dataTableComponentS1 = (QuestionariosDataTableComponent) surveysResultsSection.getComponents().get(0); |
101 | QuestionariosDataTableComponent dataTableComponentS1 = (QuestionariosDataTableComponent) surveysResultsSection.getComponents().get(0); |
102 | QuestionariosDataTableComponent dataTableComponentS2 = (QuestionariosDataTableComponent) surveysResultsSection.getComponents().get(1); |
102 | QuestionariosDataTableComponent dataTableComponentS2 = (QuestionariosDataTableComponent) surveysResultsSection.getComponents().get(1); |
103 | 103 | ||
104 | QuestionariosReportsService questionariosReportsService = new QuestionariosReportsService(); |
104 | QuestionariosReportsService questionariosReportsService = new QuestionariosReportsService(); |
105 | 1.5.0/docs/api/java/lang/String.html">String jsonDataTableS1 = questionariosReportsService.loadReportUnidadesSalasJson(courseCode,year,"S1"); |
105 | 1.5.0/docs/api/java/lang/String.html">String jsonDataTableS1 = questionariosReportsService.loadReportUnidadesSalasJson(courseCode,year,"S1"); |
106 | 1.5.0/docs/api/java/lang/String.html">String jsonDataTableS2 = questionariosReportsService.loadReportUnidadesSalasJson(courseCode,year,"S2"); |
106 | 1.5.0/docs/api/java/lang/String.html">String jsonDataTableS2 = questionariosReportsService.loadReportUnidadesSalasJson(courseCode,year,"S2"); |
107 | DataTable dataTableS1 = DataTable.fromJson(jsonDataTableS1); |
107 | DataTable dataTableS1 = DataTable.fromJson(jsonDataTableS1); |
108 | DataTable dataTableS2 = DataTable.fromJson(jsonDataTableS2); |
108 | DataTable dataTableS2 = DataTable.fromJson(jsonDataTableS2); |
109 | dataTableComponentS1.setDataTable(dataTableS1); |
109 | dataTableComponentS1.setDataTable(dataTableS1); |
110 | dataTableComponentS2.setDataTable(dataTableS2); |
110 | dataTableComponentS2.setDataTable(dataTableS2); |
111 | return surveysResultsSection; |
111 | return surveysResultsSection; |
112 | } |
112 | } |
113 | 113 | ||
114 | /** |
114 | /** |
115 | * Este serviço atualiza a tabela de resultados de aprendizagem com base nas courseunitssections |
115 | * Este serviço atualiza a tabela de resultados de aprendizagem com base nas courseunitssections |
116 | * @param reportCourseDocument |
116 | * @param reportCourseDocument |
117 | * @return UnitsLearningResultsTable |
117 | * @return UnitsLearningResultsTable |
118 | */ |
118 | */ |
119 | public UnitsLearningResultsTable updateCleanLearningResultsFromCourseUnitsSections(CourseReportDocument reportCourseDocument) |
119 | public UnitsLearningResultsTable updateCleanLearningResultsFromCourseUnitsSections(CourseReportDocument reportCourseDocument) |
120 | { |
120 | { |
121 | CourseUnitsReportsSection unitReportsSection = (CourseUnitsReportsSection) reportCourseDocument.findDocumentSection(CourseUnitsReportsSection.class); |
121 | CourseUnitsReportsSection unitReportsSection = (CourseUnitsReportsSection) reportCourseDocument.findDocumentSection(CourseUnitsReportsSection.class); |
122 | 122 | ||
123 | LearningResultsSection learningResultsSection = (LearningResultsSection) reportCourseDocument.findDocumentSection(LearningResultsSection.class); |
123 | LearningResultsSection learningResultsSection = (LearningResultsSection) reportCourseDocument.findDocumentSection(LearningResultsSection.class); |
124 | UnitsLearningResultsTable learningResultsTable = (UnitsLearningResultsTable) learningResultsSection.findDocComponent(UnitsLearningResultsTable.class); |
124 | UnitsLearningResultsTable learningResultsTable = (UnitsLearningResultsTable) learningResultsSection.findDocComponent(UnitsLearningResultsTable.class); |
125 | 125 | ||
126 | Map<Integer,UnitsLearningResultYear> anosPlano = new HashMap<Integer, UnitsLearningResultYear>(); |
126 | Map<Integer,UnitsLearningResultYear> anosPlano = new HashMap<Integer, UnitsLearningResultYear>(); |
127 | Map<String,UnitsLearningResultSemester> anoSemestre = new HashMap<String, UnitsLearningResultSemester>(); |
127 | Map<String,UnitsLearningResultSemester> anoSemestre = new HashMap<String, UnitsLearningResultSemester>(); |
128 | for(DocumentSection subSection : unitReportsSection.getSections()) |
128 | for(DocumentSection subSection : unitReportsSection.getSections()) |
129 | { |
129 | { |
130 | CourseUnitSection unitSection = (CourseUnitSection) subSection; |
130 | CourseUnitSection unitSection = (CourseUnitSection) subSection; |
131 | int anoPlano = unitSection.getAnoPlano(); |
131 | int anoPlano = unitSection.getAnoPlano(); |
132 | UnitsLearningResultYear anoFound = anosPlano.get(anoPlano); |
132 | UnitsLearningResultYear anoFound = anosPlano.get(anoPlano); |
133 | if(anoFound == null) |
133 | if(anoFound == null) |
134 | { |
134 | { |
135 | anoFound = new UnitsLearningResultYear(anoPlano); |
135 | anoFound = new UnitsLearningResultYear(anoPlano); |
136 | anosPlano.put(anoPlano,anoFound); |
136 | anosPlano.put(anoPlano,anoFound); |
137 | learningResultsTable.getYears().add(anoFound); |
137 | learningResultsTable.getYears().add(anoFound); |
138 | } |
138 | } |
139 | 139 | ||
140 | 1.5.0/docs/api/java/lang/String.html">String semestreCode = ((CourseUnitSection) subSection).getPeriod(); |
140 | 1.5.0/docs/api/java/lang/String.html">String semestreCode = ((CourseUnitSection) subSection).getPeriod(); |
141 | UnitsLearningResultSemester semestreFound = anoSemestre.get(anoPlano + "$" + semestreCode); |
141 | UnitsLearningResultSemester semestreFound = anoSemestre.get(anoPlano + "$" + semestreCode); |
142 | if(semestreFound == null) |
142 | if(semestreFound == null) |
143 | { |
143 | { |
144 | semestreFound = new UnitsLearningResultSemester(semestreCode); |
144 | semestreFound = new UnitsLearningResultSemester(semestreCode); |
145 | anoSemestre.put(anoPlano + "$" + semestreCode,semestreFound); |
145 | anoSemestre.put(anoPlano + "$" + semestreCode,semestreFound); |
146 | anoFound.getSemesters().add(semestreFound); |
146 | anoFound.getSemesters().add(semestreFound); |
147 | } |
147 | } |
148 | 148 | ||
149 | UnitsLearningResultUc uc = new UnitsLearningResultUc(); |
149 | UnitsLearningResultUc uc = new UnitsLearningResultUc(); |
150 | uc.setPeriod(semestreCode); |
150 | uc.setPeriod(semestreCode); |
151 | uc.setName(unitSection.getName()); |
151 | uc.setName(unitSection.getName()); |
152 | uc.setSigesCode(unitSection.getSigesCode()); |
152 | uc.setSigesCode(unitSection.getSigesCode()); |
153 | if(unitSection.getCourseUnitEvaluation() != null) |
153 | if(unitSection.getCourseUnitEvaluation() != null) |
154 | { |
154 | { |
155 | 155 | ||
156 | uc.setCumprimentoProgramaPercent(unitSection.getCourseUnitEvaluation().getCumprimentoProgramaPercent()); |
156 | uc.setCumprimentoProgramaPercent(unitSection.getCourseUnitEvaluation().getCumprimentoProgramaPercent()); |
157 | uc.setAlunosInscritos(unitSection.getCourseUnitEvaluation().getNumAlunosInscritos()); |
157 | uc.setAlunosInscritos(unitSection.getCourseUnitEvaluation().getNumAlunosInscritos()); |
158 | 158 | ||
159 | uc.setAprovados1013(unitSection.getCourseUnitEvaluation().getNumAlunosAprov1013()); |
159 | uc.setAprovados1013(unitSection.getCourseUnitEvaluation().getNumAlunosAprov1013()); |
160 | uc.setAprovados1416(unitSection.getCourseUnitEvaluation().getNumAlunosAprov1416()); |
160 | uc.setAprovados1416(unitSection.getCourseUnitEvaluation().getNumAlunosAprov1416()); |
161 | uc.setAprovados1720(unitSection.getCourseUnitEvaluation().getNumAlunosAprov1720()); |
161 | uc.setAprovados1720(unitSection.getCourseUnitEvaluation().getNumAlunosAprov1720()); |
162 | uc.setSemElementos(unitSection.getCourseUnitEvaluation().getNumAlunosSemElementosAvaliacao()); |
162 | uc.setSemElementos(unitSection.getCourseUnitEvaluation().getNumAlunosSemElementosAvaliacao()); |
163 | uc.setAprovados(unitSection.getCourseUnitEvaluation().getNumAlunosAprovTotal()); |
163 | uc.setAprovados(unitSection.getCourseUnitEvaluation().getNumAlunosAprovTotal()); |
164 | uc.setReprovados(unitSection.getCourseUnitEvaluation().getNumAlunosInscritos() - unitSection.getCourseUnitEvaluation().getNumAlunosAprovTotal() - unitSection.getCourseUnitEvaluation().getNumAlunosSemElementosAvaliacao()); |
164 | uc.setReprovados(unitSection.getCourseUnitEvaluation().getNumAlunosInscritos() - unitSection.getCourseUnitEvaluation().getNumAlunosAprovTotal() - unitSection.getCourseUnitEvaluation().getNumAlunosSemElementosAvaliacao()); |
165 | 165 | ||
166 | if(uc.getAlunosInscritos() > 0) |
166 | if(uc.getAlunosInscritos() > 0) |
167 | { |
167 | { |
168 | uc.setAprovadosPercent((float) (uc.getAprovados() * 100.0 / uc.getAlunosInscritos())); |
168 | uc.setAprovadosPercent((float) (uc.getAprovados() * 100.0 / uc.getAlunosInscritos())); |
169 | uc.setReprovadosPercent((float) (uc.getReprovados() * 100.0 / uc.getAlunosInscritos())); |
169 | uc.setReprovadosPercent((float) (uc.getReprovados() * 100.0 / uc.getAlunosInscritos())); |
170 | uc.setSemElementosPercent((float) (uc.getSemElementos() * 100.0 / uc.getAlunosInscritos())); |
170 | uc.setSemElementosPercent((float) (uc.getSemElementos() * 100.0 / uc.getAlunosInscritos())); |
171 | } |
171 | } |
172 | 172 | ||
173 | if(uc.getAprovados() > 0) |
173 | if(uc.getAprovados() > 0) |
174 | { |
174 | { |
175 | uc.setAprovados1013Percent((float) (uc.getAprovados1013() * 100.0 / uc.getAprovados())); |
175 | uc.setAprovados1013Percent((float) (uc.getAprovados1013() * 100.0 / uc.getAprovados())); |
176 | uc.setAprovados1416Percent((float) (uc.getAprovados1416() * 100.0 / uc.getAprovados())); |
176 | uc.setAprovados1416Percent((float) (uc.getAprovados1416() * 100.0 / uc.getAprovados())); |
177 | uc.setAprovados1720Percent((float) (uc.getAprovados1720() * 100.0 / uc.getAprovados())); |
177 | uc.setAprovados1720Percent((float) (uc.getAprovados1720() * 100.0 / uc.getAprovados())); |
178 | } |
178 | } |
179 | } |
179 | } |
180 | semestreFound.getUcs().add(uc); |
180 | semestreFound.getUcs().add(uc); |
181 | } |
181 | } |
182 | 182 | ||
183 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(learningResultsTable.getYears(), new Comparator<UnitsLearningResultYear>() { |
183 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(learningResultsTable.getYears(), new Comparator<UnitsLearningResultYear>() { |
184 | @1.5.0/docs/api/java/lang/Override.html">Override |
184 | @1.5.0/docs/api/java/lang/Override.html">Override |
185 | public int compare(UnitsLearningResultYear o1, UnitsLearningResultYear o2) { |
185 | public int compare(UnitsLearningResultYear o1, UnitsLearningResultYear o2) { |
186 | return o1.getAno() - o2.getAno(); |
186 | return o1.getAno() - o2.getAno(); |
187 | } |
187 | } |
188 | }); |
188 | }); |
189 | 189 | ||
190 | for(UnitsLearningResultYear learningYearLine: learningResultsTable.getYears()) |
190 | for(UnitsLearningResultYear learningYearLine: learningResultsTable.getYears()) |
191 | { |
191 | { |
192 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(learningYearLine.getSemesters(),new Comparator<UnitsLearningResultSemester>() { |
192 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(learningYearLine.getSemesters(),new Comparator<UnitsLearningResultSemester>() { |
193 | @1.5.0/docs/api/java/lang/Override.html">Override |
193 | @1.5.0/docs/api/java/lang/Override.html">Override |
194 | public int compare(UnitsLearningResultSemester o1, UnitsLearningResultSemester o2) { |
194 | public int compare(UnitsLearningResultSemester o1, UnitsLearningResultSemester o2) { |
195 | return o1.getSemestre().compareTo(o2.getSemestre()); |
195 | return o1.getSemestre().compareTo(o2.getSemestre()); |
196 | } |
196 | } |
197 | }); |
197 | }); |
198 | } |
198 | } |
199 | 199 | ||
200 | 200 | ||
201 | //UPDATE TOTAIS DE SEMESTRES E DE ANOS |
201 | //UPDATE TOTAIS DE SEMESTRES E DE ANOS |
202 | float totalCumProgPercentGlobal = 0; |
202 | float totalCumProgPercentGlobal = 0; |
203 | float totalInscritosGlobal = 0; |
203 | float totalInscritosGlobal = 0; |
204 | float totalReprovadosPercentGlobal = 0; |
204 | float totalReprovadosPercentGlobal = 0; |
205 | float totalAprovadosPercentGlobal = 0; |
205 | float totalAprovadosPercentGlobal = 0; |
206 | float totalSemElementosPercentGlobal = 0; |
206 | float totalSemElementosPercentGlobal = 0; |
207 | float totalAprovados1013PercentGlobal = 0; |
207 | float totalAprovados1013PercentGlobal = 0; |
208 | float totalAprovados1416PercentGlobal = 0; |
208 | float totalAprovados1416PercentGlobal = 0; |
209 | float totalAprovados1720PercentGlobal = 0; |
209 | float totalAprovados1720PercentGlobal = 0; |
210 | for(UnitsLearningResultYear learningYearLine: learningResultsTable.getYears()) |
210 | for(UnitsLearningResultYear learningYearLine: learningResultsTable.getYears()) |
211 | { |
211 | { |
212 | float totalCumProgPercentAno = 0; |
212 | float totalCumProgPercentAno = 0; |
213 | float totalInscritosAno = 0; |
213 | float totalInscritosAno = 0; |
214 | float totalReprovadosPercentAno = 0; |
214 | float totalReprovadosPercentAno = 0; |
215 | float totalAprovadosPercentAno = 0; |
215 | float totalAprovadosPercentAno = 0; |
216 | float totalSemElementosPercentAno = 0; |
216 | float totalSemElementosPercentAno = 0; |
217 | float totalAprovados1013PercentAno = 0; |
217 | float totalAprovados1013PercentAno = 0; |
218 | float totalAprovados1416PercentAno = 0; |
218 | float totalAprovados1416PercentAno = 0; |
219 | float totalAprovados1720PercentAno = 0; |
219 | float totalAprovados1720PercentAno = 0; |
220 | 220 | ||
221 | for(UnitsLearningResultSemester semester: learningYearLine.getSemesters()) |
221 | for(UnitsLearningResultSemester semester: learningYearLine.getSemesters()) |
222 | { |
222 | { |
223 | float totalCumProgPercent = 0; |
223 | float totalCumProgPercent = 0; |
224 | float totalInscritos = 0; |
224 | float totalInscritos = 0; |
225 | float totalReprovadosPercent = 0; |
225 | float totalReprovadosPercent = 0; |
226 | float totalAprovadosPercent = 0; |
226 | float totalAprovadosPercent = 0; |
227 | float totalSemElementosPercent = 0; |
227 | float totalSemElementosPercent = 0; |
228 | float totalAprovados1013Percent = 0; |
228 | float totalAprovados1013Percent = 0; |
229 | float totalAprovados1416Percent = 0; |
229 | float totalAprovados1416Percent = 0; |
230 | float totalAprovados1720Percent = 0; |
230 | float totalAprovados1720Percent = 0; |
231 | for(UnitsLearningResultUc uc: semester.getUcs()) |
231 | for(UnitsLearningResultUc uc: semester.getUcs()) |
232 | { |
232 | { |
233 | totalCumProgPercent += uc.getCumprimentoProgramaPercent(); |
233 | totalCumProgPercent += uc.getCumprimentoProgramaPercent(); |
234 | totalInscritos += uc.getAlunosInscritos(); |
234 | totalInscritos += uc.getAlunosInscritos(); |
235 | totalAprovadosPercent += uc.getAprovadosPercent(); |
235 | totalAprovadosPercent += uc.getAprovadosPercent(); |
236 | totalReprovadosPercent += uc.getReprovadosPercent(); |
236 | totalReprovadosPercent += uc.getReprovadosPercent(); |
237 | totalSemElementosPercent += uc.getSemElementosPercent(); |
237 | totalSemElementosPercent += uc.getSemElementosPercent(); |
238 | totalAprovados1013Percent += uc.getAprovados1013(); |
238 | totalAprovados1013Percent += uc.getAprovados1013(); |
239 | totalAprovados1416Percent += uc.getAprovados1416(); |
239 | totalAprovados1416Percent += uc.getAprovados1416(); |
240 | totalAprovados1720Percent += uc.getAprovados1720(); |
240 | totalAprovados1720Percent += uc.getAprovados1720(); |
241 | } |
241 | } |
242 | //media de inscritos |
242 | //media de inscritos |
243 | if(semester.getUcs().size() > 0) |
243 | if(semester.getUcs().size() > 0) |
244 | { |
244 | { |
245 | semester.setCumprimentoProgramaPercent( totalCumProgPercent / ((float)semester.getUcs().size())); |
245 | semester.setCumprimentoProgramaPercent( totalCumProgPercent / ((float)semester.getUcs().size())); |
246 | semester.setAlunosInscritos( totalInscritos / ((float)semester.getUcs().size())); |
246 | semester.setAlunosInscritos( totalInscritos / ((float)semester.getUcs().size())); |
247 | semester.setAprovadosPercent( totalAprovadosPercent / ((float)semester.getUcs().size())); |
247 | semester.setAprovadosPercent( totalAprovadosPercent / ((float)semester.getUcs().size())); |
248 | semester.setReprovadosPercent( totalReprovadosPercent / ((float)semester.getUcs().size())); |
248 | semester.setReprovadosPercent( totalReprovadosPercent / ((float)semester.getUcs().size())); |
249 | semester.setSemElementosPercent( totalSemElementosPercent / ((float)semester.getUcs().size())); |
249 | semester.setSemElementosPercent( totalSemElementosPercent / ((float)semester.getUcs().size())); |
250 | semester.setAprovados1013Percent( totalAprovados1013Percent / ((float)semester.getUcs().size())); |
250 | semester.setAprovados1013Percent( totalAprovados1013Percent / ((float)semester.getUcs().size())); |
251 | semester.setAprovados1416Percent( totalAprovados1416Percent / ((float)semester.getUcs().size())); |
251 | semester.setAprovados1416Percent( totalAprovados1416Percent / ((float)semester.getUcs().size())); |
252 | semester.setAprovados1720Percent( totalAprovados1720Percent / ((float)semester.getUcs().size())); |
252 | semester.setAprovados1720Percent( totalAprovados1720Percent / ((float)semester.getUcs().size())); |
253 | } |
253 | } |
254 | totalCumProgPercentAno += semester.getCumprimentoProgramaPercent(); |
254 | totalCumProgPercentAno += semester.getCumprimentoProgramaPercent(); |
255 | totalInscritosAno += semester.getAlunosInscritos(); |
255 | totalInscritosAno += semester.getAlunosInscritos(); |
256 | totalAprovadosPercentAno += semester.getAprovadosPercent(); |
256 | totalAprovadosPercentAno += semester.getAprovadosPercent(); |
257 | totalReprovadosPercentAno += semester.getReprovadosPercent(); |
257 | totalReprovadosPercentAno += semester.getReprovadosPercent(); |
258 | totalSemElementosPercentAno += semester.getSemElementosPercent(); |
258 | totalSemElementosPercentAno += semester.getSemElementosPercent(); |
259 | totalAprovados1013PercentAno += semester.getAprovados1013(); |
259 | totalAprovados1013PercentAno += semester.getAprovados1013(); |
260 | totalAprovados1416PercentAno += semester.getAprovados1416(); |
260 | totalAprovados1416PercentAno += semester.getAprovados1416(); |
261 | totalAprovados1720PercentAno += semester.getAprovados1720(); |
261 | totalAprovados1720PercentAno += semester.getAprovados1720(); |
262 | } |
262 | } |
263 | //media de inscritos |
263 | //media de inscritos |
264 | if(learningYearLine.getSemesters().size() > 0) |
264 | if(learningYearLine.getSemesters().size() > 0) |
265 | { |
265 | { |
266 | learningYearLine.setCumprimentoProgramaPercent( totalCumProgPercentAno / ((float)learningYearLine.getSemesters().size())); |
266 | learningYearLine.setCumprimentoProgramaPercent( totalCumProgPercentAno / ((float)learningYearLine.getSemesters().size())); |
267 | learningYearLine.setAlunosInscritos( totalInscritosAno / ((float)learningYearLine.getSemesters().size())); |
267 | learningYearLine.setAlunosInscritos( totalInscritosAno / ((float)learningYearLine.getSemesters().size())); |
268 | learningYearLine.setAprovadosPercent( totalAprovadosPercentAno / ((float)learningYearLine.getSemesters().size())); |
268 | learningYearLine.setAprovadosPercent( totalAprovadosPercentAno / ((float)learningYearLine.getSemesters().size())); |
269 | learningYearLine.setReprovadosPercent( totalReprovadosPercentAno / ((float)learningYearLine.getSemesters().size())); |
269 | learningYearLine.setReprovadosPercent( totalReprovadosPercentAno / ((float)learningYearLine.getSemesters().size())); |
270 | learningYearLine.setSemElementosPercent( totalSemElementosPercentAno / ((float)learningYearLine.getSemesters().size())); |
270 | learningYearLine.setSemElementosPercent( totalSemElementosPercentAno / ((float)learningYearLine.getSemesters().size())); |
271 | learningYearLine.setAprovados1013Percent( totalAprovados1013PercentAno / ((float)learningYearLine.getSemesters().size())); |
271 | learningYearLine.setAprovados1013Percent( totalAprovados1013PercentAno / ((float)learningYearLine.getSemesters().size())); |
272 | learningYearLine.setAprovados1416Percent( totalAprovados1416PercentAno / ((float)learningYearLine.getSemesters().size())); |
272 | learningYearLine.setAprovados1416Percent( totalAprovados1416PercentAno / ((float)learningYearLine.getSemesters().size())); |
273 | learningYearLine.setAprovados1720Percent( totalAprovados1720PercentAno / ((float)learningYearLine.getSemesters().size())); |
273 | learningYearLine.setAprovados1720Percent( totalAprovados1720PercentAno / ((float)learningYearLine.getSemesters().size())); |
274 | } |
274 | } |
275 | totalCumProgPercentGlobal += learningYearLine.getCumprimentoProgramaPercent(); |
275 | totalCumProgPercentGlobal += learningYearLine.getCumprimentoProgramaPercent(); |
276 | totalInscritosGlobal += learningYearLine.getAlunosInscritos(); |
276 | totalInscritosGlobal += learningYearLine.getAlunosInscritos(); |
277 | totalAprovadosPercentGlobal += learningYearLine.getAprovadosPercent(); |
277 | totalAprovadosPercentGlobal += learningYearLine.getAprovadosPercent(); |
278 | totalReprovadosPercentGlobal += learningYearLine.getReprovadosPercent(); |
278 | totalReprovadosPercentGlobal += learningYearLine.getReprovadosPercent(); |
279 | totalSemElementosPercentGlobal += learningYearLine.getSemElementosPercent(); |
279 | totalSemElementosPercentGlobal += learningYearLine.getSemElementosPercent(); |
280 | totalAprovados1013PercentGlobal += learningYearLine.getAprovados1013(); |
280 | totalAprovados1013PercentGlobal += learningYearLine.getAprovados1013(); |
281 | totalAprovados1416PercentGlobal += learningYearLine.getAprovados1416(); |
281 | totalAprovados1416PercentGlobal += learningYearLine.getAprovados1416(); |
282 | totalAprovados1720PercentGlobal += learningYearLine.getAprovados1720(); |
282 | totalAprovados1720PercentGlobal += learningYearLine.getAprovados1720(); |
283 | } |
283 | } |
284 | 284 | ||
285 | if(learningResultsTable.getYears().size() > 0) |
285 | if(learningResultsTable.getYears().size() > 0) |
286 | { |
286 | { |
287 | learningResultsTable.setCumprimentoProgramaPercent( totalCumProgPercentGlobal / ((float)learningResultsTable.getYears().size())); |
287 | learningResultsTable.setCumprimentoProgramaPercent( totalCumProgPercentGlobal / ((float)learningResultsTable.getYears().size())); |
288 | learningResultsTable.setAlunosInscritos( totalInscritosGlobal / (learningResultsTable.getYears().size())); |
288 | learningResultsTable.setAlunosInscritos( totalInscritosGlobal / (learningResultsTable.getYears().size())); |
289 | learningResultsTable.setAprovadosPercent( totalAprovadosPercentGlobal / ((float)learningResultsTable.getYears().size())); |
289 | learningResultsTable.setAprovadosPercent( totalAprovadosPercentGlobal / ((float)learningResultsTable.getYears().size())); |
290 | learningResultsTable.setReprovadosPercent( totalReprovadosPercentGlobal / ((float)learningResultsTable.getYears().size())); |
290 | learningResultsTable.setReprovadosPercent( totalReprovadosPercentGlobal / ((float)learningResultsTable.getYears().size())); |
291 | learningResultsTable.setSemElementosPercent( totalSemElementosPercentGlobal / ((float)learningResultsTable.getYears().size())); |
291 | learningResultsTable.setSemElementosPercent( totalSemElementosPercentGlobal / ((float)learningResultsTable.getYears().size())); |
292 | learningResultsTable.setAprovados1013Percent( totalAprovados1013PercentGlobal / ((float)learningResultsTable.getYears().size())); |
292 | learningResultsTable.setAprovados1013Percent( totalAprovados1013PercentGlobal / ((float)learningResultsTable.getYears().size())); |
293 | learningResultsTable.setAprovados1416Percent( totalAprovados1416PercentGlobal / ((float)learningResultsTable.getYears().size())); |
293 | learningResultsTable.setAprovados1416Percent( totalAprovados1416PercentGlobal / ((float)learningResultsTable.getYears().size())); |
294 | learningResultsTable.setAprovados1720Percent( totalAprovados1720PercentGlobal / ((float)learningResultsTable.getYears().size())); |
294 | learningResultsTable.setAprovados1720Percent( totalAprovados1720PercentGlobal / ((float)learningResultsTable.getYears().size())); |
295 | } |
295 | } |
296 | return learningResultsTable; |
296 | return learningResultsTable; |
297 | } |
297 | } |
298 | 298 | ||
299 | 299 | ||
300 | /** |
300 | /** |
301 | * Gera uma tabela de estatisticas dos DTP recorrendo ao servico WS de |
301 | * Gera uma tabela de estatisticas dos DTP recorrendo ao servico WS de |
302 | * load de tabelas DTP, caso o serviço nao devolva unidades são criadas novas |
302 | * load de tabelas DTP, caso o serviço nao devolva unidades são criadas novas |
303 | * com os valores a falso. |
303 | * com os valores a falso. |
304 | * |
304 | * |
305 | * @param courseCode |
305 | * @param courseCode |
306 | * @param year |
306 | * @param year |
307 | * @return UnitsDtpTable |
307 | * @return UnitsDtpTable |
308 | * @throws IOException |
308 | * @throws IOException |
309 | * @throws JSONException |
309 | * @throws JSONException |
310 | */ |
310 | */ |
311 | public UnitsDtpTable updateDtpStatsTable4Course(CourseReportDocument reportCourseDocument, 1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String year) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException |
311 | public UnitsDtpTable updateDtpStatsTable4Course(CourseReportDocument reportCourseDocument, 1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String year) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException |
312 | { |
312 | { |
313 | 313 | ||
314 | ReportsUcSummarySection reportsUcSummarySection = (ReportsUcSummarySection) reportCourseDocument.findDocumentSection(ReportsUcSummarySection.class); |
314 | ReportsUcSummarySection reportsUcSummarySection = (ReportsUcSummarySection) reportCourseDocument.findDocumentSection(ReportsUcSummarySection.class); |
315 | UnitsDtpTable unitsDtpTable = (UnitsDtpTable) reportsUcSummarySection.findDocComponent(UnitsDtpTable.class); |
315 | UnitsDtpTable unitsDtpTable = (UnitsDtpTable) reportsUcSummarySection.findDocComponent(UnitsDtpTable.class); |
316 | UnitDtpSemester semester1 = new UnitDtpSemester(); |
316 | UnitDtpSemester semester1 = new UnitDtpSemester(); |
317 | UnitDtpSemester semester2 = new UnitDtpSemester(); |
317 | UnitDtpSemester semester2 = new UnitDtpSemester(); |
318 | unitsDtpTable.setSemester1(semester1); |
318 | unitsDtpTable.setSemester1(semester1); |
319 | unitsDtpTable.setSemester2(semester2); |
319 | unitsDtpTable.setSemester2(semester2); |
320 | 320 | ||
321 | List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
321 | List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
322 | 322 | ||
323 | CourseUnitDtpStat[] statsLoaded; |
323 | CourseUnitDtpStat[] statsLoaded; |
324 | try |
324 | try |
325 | { |
325 | { |
326 | 1.5.0/docs/api/java/lang/String.html">String json = loadCourseUnitDtpStats(courseCode,year); |
326 | 1.5.0/docs/api/java/lang/String.html">String json = loadCourseUnitDtpStats(courseCode,year); |
327 | JSONObject response = new JSONObject(json); |
327 | JSONObject response = new JSONObject(json); |
328 | JSONArray stats = (JSONArray) response.get("dtpstats"); |
328 | JSONArray stats = (JSONArray) response.get("dtpstats"); |
329 | statsLoaded = CourseUnitDtpStat.fromJson(stats); |
329 | statsLoaded = CourseUnitDtpStat.fromJson(stats); |
330 | } |
330 | } |
331 | catch(1.5.0/docs/api/java/lang/Exception.html">Exception e) |
331 | catch(1.5.0/docs/api/java/lang/Exception.html">Exception e) |
332 | { |
332 | { |
333 | logger.error(e,e); |
333 | logger.error(e,e); |
334 | statsLoaded = new CourseUnitDtpStat[0]; |
334 | statsLoaded = new CourseUnitDtpStat[0]; |
335 | } |
335 | } |
336 | 336 | ||
337 | 337 | ||
338 | for(CourseUnit cu :units) |
338 | for(CourseUnit cu :units) |
339 | { |
339 | { |
340 | CourseUnitDtpStat statFound = CourseReportUtils.findCourseUnitDtpStat(statsLoaded, (CourseUnitImpl) cu); |
340 | CourseUnitDtpStat statFound = CourseReportUtils.findCourseUnitDtpStat(statsLoaded, (CourseUnitImpl) cu); |
341 | if(statFound == null) |
341 | if(statFound == null) |
342 | { |
342 | { |
343 | statFound = CourseReportUtils.createCourseUnitDtpStat(cu); |
343 | statFound = CourseReportUtils.createCourseUnitDtpStat(cu); |
344 | } |
344 | } |
345 | 345 | ||
346 | if(((CourseUnitImpl) cu).getSemestreAbsolutoS1S2().equals("S1")) |
346 | if(((CourseUnitImpl) cu).getSemestreAbsolutoS1S2().equals("S1")) |
347 | semester1.getCourseUnitDtpStats().add(statFound); |
347 | semester1.getCourseUnitDtpStats().add(statFound); |
348 | else |
348 | else |
349 | semester2.getCourseUnitDtpStats().add(statFound); |
349 | semester2.getCourseUnitDtpStats().add(statFound); |
350 | } |
350 | } |
351 | 351 | ||
352 | return unitsDtpTable; |
352 | return unitsDtpTable; |
353 | 353 | ||
354 | } |
354 | } |
355 | 355 | ||
356 | /** |
356 | /** |
357 | * Update course unit sections with reports, this method dows not change learning results table |
357 | * Update course unit sections with reports, this method dows not change learning results table |
358 | * values from learning results stays in unit but does not change learning results Table |
358 | * values from learning results stays in unit but does not change learning results Table |
359 | * @param courseCode |
359 | * @param courseCode |
360 | * @param year |
360 | * @param year |
361 | * @param reportCourseDocument |
361 | * @param reportCourseDocument |
362 | * @throws JSONException |
362 | * @throws JSONException |
363 | * @throws IOException |
363 | * @throws IOException |
364 | * @return a list of CourseUnitSection |
364 | * @return a list of CourseUnitSection |
365 | */ |
365 | */ |
366 | public List<DocumentSection> updateCleanCourseUnitSections(1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String year, CourseReportDocument reportCourseDocument) throws JSONException, 1.5.0/docs/api/java/io/IOException.html">IOException { |
366 | public List<DocumentSection> updateCleanCourseUnitSections(1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String year, CourseReportDocument reportCourseDocument) throws JSONException, 1.5.0/docs/api/java/io/IOException.html">IOException { |
367 | 367 | ||
368 | List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
368 | List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
369 | 369 | ||
370 | CourseUnitsReportsSection unitReportsSection = (CourseUnitsReportsSection) reportCourseDocument.findDocumentSection(CourseUnitsReportsSection.class); |
370 | CourseUnitsReportsSection unitReportsSection = (CourseUnitsReportsSection) reportCourseDocument.findDocumentSection(CourseUnitsReportsSection.class); |
371 | CourseUnitSection[] courseUnitSections = null; |
371 | CourseUnitSection[] courseUnitSections = null; |
372 | try{ |
372 | try{ |
373 | 1.5.0/docs/api/java/lang/String.html">String courseUnitSectionsJson = loadCourseEvaluationSections(courseCode,year); |
373 | 1.5.0/docs/api/java/lang/String.html">String courseUnitSectionsJson = loadCourseEvaluationSections(courseCode,year); |
374 | JSONObject object = new JSONObject(courseUnitSectionsJson); |
374 | JSONObject object = new JSONObject(courseUnitSectionsJson); |
375 | JSONArray evaluations = object.getJSONArray("evaluations"); |
375 | JSONArray evaluations = object.getJSONArray("evaluations"); |
376 | courseUnitSections = CourseUnitSection.fromJsonArray(evaluations.toString()); |
376 | courseUnitSections = CourseUnitSection.fromJsonArray(evaluations.toString()); |
377 | } |
377 | } |
378 | catch(1.5.0/docs/api/java/lang/Exception.html">Exception e) |
378 | catch(1.5.0/docs/api/java/lang/Exception.html">Exception e) |
379 | { |
379 | { |
380 | logger.error(e,e); |
380 | logger.error(e,e); |
381 | courseUnitSections = new CourseUnitSection[0]; |
381 | courseUnitSections = new CourseUnitSection[0]; |
382 | } |
382 | } |
383 | 383 | ||
384 | 384 | ||
385 | ArrayList<DocumentSection> subSections = new ArrayList<DocumentSection>(); |
385 | ArrayList<DocumentSection> subSections = new ArrayList<DocumentSection>(); |
386 | unitReportsSection.setSections(subSections); |
386 | unitReportsSection.setSections(subSections); |
387 | for(CourseUnit cu :units) |
387 | for(CourseUnit cu :units) |
388 | { |
388 | { |
389 | CourseUnitSection sectionFound = CourseReportUtils.findCourseUnitSection(courseUnitSections, (CourseUnitImpl) cu); |
389 | CourseUnitSection sectionFound = CourseReportUtils.findCourseUnitSection(courseUnitSections, (CourseUnitImpl) cu); |
390 | if(sectionFound == null) |
390 | if(sectionFound == null) |
391 | { |
391 | { |
392 | sectionFound = CourseReportUtils.createCourseUnitEvaluationSection((CourseUnitImpl) cu); |
392 | sectionFound = CourseReportUtils.createCourseUnitEvaluationSection((CourseUnitImpl) cu); |
393 | } |
393 | } |
394 | if(sectionFound.getCourseUnitEvaluation() == null) |
394 | if(sectionFound.getCourseUnitEvaluation() == null) |
395 | { |
395 | { |
396 | CourseUnitEvaluationImpl courseUnitEvaluation = DomainObjectFactory.createCourseUnitEvaluationImpl(); |
396 | CourseUnitEvaluationImpl courseUnitEvaluation = DomainObjectFactory.createCourseUnitEvaluationImpl(); |
397 | courseUnitEvaluation.setAutoGeneratedCourseReport(true); |
397 | courseUnitEvaluation.setAutoGeneratedCourseReport(true); |
398 | DaoFactory.getCourseUnitEvaluationDaoImpl().save(courseUnitEvaluation); |
398 | DaoFactory.getCourseUnitEvaluationDaoImpl().save(courseUnitEvaluation); |
399 | cu.setCourseUnitEvaluation(courseUnitEvaluation); |
399 | cu.setCourseUnitEvaluation(courseUnitEvaluation); |
400 | sectionFound.setCourseUnitEvaluation(courseUnitEvaluation); |
400 | sectionFound.setCourseUnitEvaluation(courseUnitEvaluation); |
401 | } |
401 | } |
402 | unitReportsSection.getSections().add(sectionFound); |
402 | unitReportsSection.getSections().add(sectionFound); |
403 | } |
403 | } |
404 | return subSections; |
404 | return subSections; |
405 | } |
405 | } |
406 | 406 | ||
407 | 407 | ||
408 | 408 | ||
409 | /** |
409 | /** |
410 | * Este servico gera um grafico com a taxa global de aproveitamento e grava-o no repositorio digital |
410 | * Este servico gera um grafico com a taxa global de aproveitamento e grava-o no repositorio digital |
411 | * devolvendo o respectivo RepositoryFile4JsonView em json para poder ser anexado ao objecto imagem do |
411 | * devolvendo o respectivo RepositoryFile4JsonView em json para poder ser anexado ao objecto imagem do |
412 | * widget do grafico |
412 | * widget do grafico |
413 | * @param reportDocumentJson |
413 | * @param reportDocument |
414 | * @param session |
414 | * @param session |
415 | * @return |
415 | * @return |
416 | * @throws IOException |
416 | * @throws IOException |
417 | */ |
417 | */ |
418 | public 1.5.0/docs/api/java/lang/String.html">String generateGlobalLearningResultsChartImg(1.5.0/docs/api/java/lang/String.html">String reportDocumentJson,UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
418 | public 1.5.0/docs/api/java/lang/String.html">String generateGlobalLearningResultsChartImg(CourseReportDocument reportDocument,UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
419 | 419 | ||
420 | CourseReportDocument reportDocument = CourseReportDocument.fromJson(reportDocumentJson); |
- | |
421 | LearningResultsSection learningResultsSection = (LearningResultsSection) reportDocument.findDocumentSection(LearningResultsSection.class); |
420 | LearningResultsSection learningResultsSection = (LearningResultsSection) reportDocument.findDocumentSection(LearningResultsSection.class); |
422 | LearningGlobalAnalysisSection learningGlobalAnalysisSection = (LearningGlobalAnalysisSection) learningResultsSection.findSection(LearningGlobalAnalysisSection.class); |
421 | LearningGlobalAnalysisSection learningGlobalAnalysisSection = (LearningGlobalAnalysisSection) learningResultsSection.findSection(LearningGlobalAnalysisSection.class); |
423 | GlobalLearningResultsChartImg chartImg = (GlobalLearningResultsChartImg) learningGlobalAnalysisSection.findDocComponent(GlobalLearningResultsChartImg.class); |
422 | GlobalLearningResultsChartImg chartImg = (GlobalLearningResultsChartImg) learningGlobalAnalysisSection.findDocComponent(GlobalLearningResultsChartImg.class); |
424 | 423 | ||
425 | 424 | ||
426 | UnitsLearningResultsTable table = (UnitsLearningResultsTable) learningResultsSection.findDocComponent(UnitsLearningResultsTable.class); |
425 | UnitsLearningResultsTable table = (UnitsLearningResultsTable) learningResultsSection.findDocComponent(UnitsLearningResultsTable.class); |
427 | 426 | ||
428 | 427 | ||
429 | FileUploaded fileUploaded = chartImg.generateChart2tmp(table,reportDocument); |
428 | FileUploaded fileUploaded = chartImg.generateChart2tmp(table,reportDocument); |
430 | 429 | ||
431 | RepositoryService repositoryService = new RepositoryService(); |
430 | RepositoryService repositoryService = new RepositoryService(); |
432 | 431 | ||
433 | boolean imageInitialized = chartImg.getImage() != null |
432 | boolean imageInitialized = chartImg.getImage() != null |
434 | && |
433 | && |
435 | chartImg.getImage().getIdentifier() != null; |
434 | chartImg.getImage().getIdentifier() != null; |
436 | 435 | ||
437 | RepositoryFile4JsonView view; |
436 | RepositoryFile4JsonView view; |
438 | if(imageInitialized) |
437 | if(imageInitialized) |
439 | { |
438 | { |
440 | 1.5.0/docs/api/java/lang/String.html">String identifier = chartImg.getImage().getIdentifier(); |
439 | 1.5.0/docs/api/java/lang/String.html">String identifier = chartImg.getImage().getIdentifier(); |
441 | view = repositoryService.replaceRepositoryFileFromFileUpload(identifier, fileUploaded, ResourceAccessControlEnum.publicDomain, session); |
440 | view = repositoryService.replaceRepositoryFileFromFileUpload(identifier, fileUploaded, ResourceAccessControlEnum.publicDomain, session); |
442 | } |
441 | } |
443 | else |
442 | else |
444 | { |
443 | { |
445 | view = repositoryService.storeRepositoryFileFromFileUpload(fileUploaded,ResourceAccessControlEnum.publicDomain,session); |
444 | view = repositoryService.storeRepositoryFileFromFileUpload(fileUploaded,ResourceAccessControlEnum.publicDomain,session); |
446 | } |
445 | } |
447 | chartImg.setImage(view); |
446 | chartImg.setImage(view); |
448 | //TODO FALTA GUARDAR O JSON NO CURSO |
447 | saveCourseReportDocument(reportDocument, session); |
449 | return view.toJson(); |
448 | return view.toJson(); |
450 | } |
449 | } |
451 | 450 | ||
452 | public 1.5.0/docs/api/java/lang/String.html">String generateGenerateGlobalLearningResultsChartYearImg(1.5.0/docs/api/java/lang/String.html">String reportDocumentJson,UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
451 | public 1.5.0/docs/api/java/lang/String.html">String generateGenerateGlobalLearningResultsChartYearImg(CourseReportDocument reportDocument,UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
453 | 452 | ||
454 | CourseReportDocument reportDocument = CourseReportDocument.fromJson(reportDocumentJson); |
- | |
455 | LearningResultsSection learningResultsSection = (LearningResultsSection) reportDocument.findDocumentSection(LearningResultsSection.class); |
453 | LearningResultsSection learningResultsSection = (LearningResultsSection) reportDocument.findDocumentSection(LearningResultsSection.class); |
456 | LearningGlobalAnalysisSection learningGlobalAnalysisSection = (LearningGlobalAnalysisSection) learningResultsSection.findSection(LearningGlobalAnalysisSection.class); |
454 | LearningGlobalAnalysisSection learningGlobalAnalysisSection = (LearningGlobalAnalysisSection) learningResultsSection.findSection(LearningGlobalAnalysisSection.class); |
457 | GlobalLearningResultsChartYearImg chartImg = (GlobalLearningResultsChartYearImg) learningGlobalAnalysisSection.findDocComponent(GlobalLearningResultsChartYearImg.class); |
455 | GlobalLearningResultsChartYearImg chartImg = (GlobalLearningResultsChartYearImg) learningGlobalAnalysisSection.findDocComponent(GlobalLearningResultsChartYearImg.class); |
458 | 456 | ||
459 | UnitsLearningResultsTable table = (UnitsLearningResultsTable) learningResultsSection.findDocComponent(UnitsLearningResultsTable.class); |
457 | UnitsLearningResultsTable table = (UnitsLearningResultsTable) learningResultsSection.findDocComponent(UnitsLearningResultsTable.class); |
460 | 458 | ||
461 | 459 | ||
462 | FileUploaded fileUploaded = chartImg.generateChart2tmp(table,reportDocument); |
460 | FileUploaded fileUploaded = chartImg.generateChart2tmp(table,reportDocument); |
463 | 461 | ||
464 | RepositoryService repositoryService = new RepositoryService(); |
462 | RepositoryService repositoryService = new RepositoryService(); |
465 | 463 | ||
466 | boolean imageInitialized = chartImg.getImage() != null |
464 | boolean imageInitialized = chartImg.getImage() != null |
467 | && |
465 | && |
468 | chartImg.getImage().getIdentifier() != null; |
466 | chartImg.getImage().getIdentifier() != null; |
469 | 467 | ||
470 | RepositoryFile4JsonView view; |
468 | RepositoryFile4JsonView view; |
471 | if(imageInitialized) |
469 | if(imageInitialized) |
472 | { |
470 | { |
473 | 1.5.0/docs/api/java/lang/String.html">String identifier = chartImg.getImage().getIdentifier(); |
471 | 1.5.0/docs/api/java/lang/String.html">String identifier = chartImg.getImage().getIdentifier(); |
474 | view = repositoryService.replaceRepositoryFileFromFileUpload(identifier, fileUploaded, ResourceAccessControlEnum.publicDomain, session); |
472 | view = repositoryService.replaceRepositoryFileFromFileUpload(identifier, fileUploaded, ResourceAccessControlEnum.publicDomain, session); |
475 | } |
473 | } |
476 | else |
474 | else |
477 | { |
475 | { |
478 | view = repositoryService.storeRepositoryFileFromFileUpload(fileUploaded,ResourceAccessControlEnum.publicDomain,session); |
476 | view = repositoryService.storeRepositoryFileFromFileUpload(fileUploaded,ResourceAccessControlEnum.publicDomain,session); |
479 | } |
477 | } |
480 | chartImg.setImage(view); |
478 | chartImg.setImage(view); |
481 | //TODO FALTA GUARDAR O JSON NO CURSO |
479 | saveCourseReportDocument(reportDocument, session); |
482 | return view.toJson(); |
480 | return view.toJson(); |
483 | } |
481 | } |
484 | 482 | ||
485 | public 1.5.0/docs/api/java/lang/String.html">String generateGenerateGlobalLearningResultsChartSem(1.5.0/docs/api/java/lang/String.html">String reportDocumentJson, 1.5.0/docs/api/java/lang/String.html">String semesterCode, UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
483 | public 1.5.0/docs/api/java/lang/String.html">String generateGenerateGlobalLearningResultsChartSem(CourseReportDocument reportDocument, 1.5.0/docs/api/java/lang/String.html">String semesterCode, UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
486 | 484 | ||
487 | CourseReportDocument reportDocument = CourseReportDocument.fromJson(reportDocumentJson); |
- | |
488 | LearningResultsSection learningResultsSection = (LearningResultsSection) reportDocument.findDocumentSection(LearningResultsSection.class); |
485 | LearningResultsSection learningResultsSection = (LearningResultsSection) reportDocument.findDocumentSection(LearningResultsSection.class); |
489 | LearningAnalysisSection learningAnalysisSection = (LearningAnalysisSection) learningResultsSection.findSection(LearningAnalysisSection.class); |
486 | LearningAnalysisSection learningAnalysisSection = (LearningAnalysisSection) learningResultsSection.findSection(LearningAnalysisSection.class); |
490 | LearningResultsChartSem chartImg = (LearningResultsChartSem) learningAnalysisSection.findDocComponent(LearningResultsChartSem.class, semesterCode); |
487 | LearningResultsChartSem chartImg = (LearningResultsChartSem) learningAnalysisSection.findDocComponent(LearningResultsChartSem.class, semesterCode); |
491 | 488 | ||
492 | UnitsLearningResultsTable table = (UnitsLearningResultsTable) learningResultsSection.findDocComponent(UnitsLearningResultsTable.class); |
489 | UnitsLearningResultsTable table = (UnitsLearningResultsTable) learningResultsSection.findDocComponent(UnitsLearningResultsTable.class); |
493 | 490 | ||
494 | 491 | ||
495 | FileUploaded fileUploaded = chartImg.generateChart2tmp(table,reportDocument); |
492 | FileUploaded fileUploaded = chartImg.generateChart2tmp(table,reportDocument); |
496 | 493 | ||
497 | RepositoryService repositoryService = new RepositoryService(); |
494 | RepositoryService repositoryService = new RepositoryService(); |
498 | 495 | ||
499 | boolean imageInitialized = chartImg.getImage() != null |
496 | boolean imageInitialized = chartImg.getImage() != null |
500 | && |
497 | && |
501 | chartImg.getImage().getIdentifier() != null; |
498 | chartImg.getImage().getIdentifier() != null; |
502 | 499 | ||
503 | RepositoryFile4JsonView view; |
500 | RepositoryFile4JsonView view; |
504 | if(imageInitialized) |
501 | if(imageInitialized) |
505 | { |
502 | { |
506 | 1.5.0/docs/api/java/lang/String.html">String identifier = chartImg.getImage().getIdentifier(); |
503 | 1.5.0/docs/api/java/lang/String.html">String identifier = chartImg.getImage().getIdentifier(); |
507 | view = repositoryService.replaceRepositoryFileFromFileUpload(identifier, fileUploaded, ResourceAccessControlEnum.publicDomain, session); |
504 | view = repositoryService.replaceRepositoryFileFromFileUpload(identifier, fileUploaded, ResourceAccessControlEnum.publicDomain, session); |
508 | } |
505 | } |
509 | else |
506 | else |
510 | { |
507 | { |
511 | view = repositoryService.storeRepositoryFileFromFileUpload(fileUploaded,ResourceAccessControlEnum.publicDomain,session); |
508 | view = repositoryService.storeRepositoryFileFromFileUpload(fileUploaded,ResourceAccessControlEnum.publicDomain,session); |
512 | } |
509 | } |
513 | chartImg.setImage(view); |
510 | chartImg.setImage(view); |
514 | //TODO FALTA GUARDAR O JSON NO CURSO |
511 | saveCourseReportDocument(reportDocument, session); |
515 | return view.toJson(); |
512 | return view.toJson(); |
516 | } |
513 | } |
517 | 514 | ||
518 | public 1.5.0/docs/api/java/lang/String.html">String saveCourseReportDocument(1.5.0/docs/api/java/lang/String.html">String reportDocumentJson,UserSession session) { |
515 | public 1.5.0/docs/api/java/lang/String.html">String saveCourseReportDocument(CourseReportDocument reportDocument, UserSession session) { |
519 | CourseReportDocument reportDocument = CourseReportDocument.fromJson(reportDocumentJson); |
- | |
520 | - | ||
521 | Course c = DaoFactory.getCourseDaoImpl().findCourseByCode(reportDocument.getCourseCode()); |
- | |
522 | CourseYear cy = DaoFactory.getCourseYearDaoImpl().findCourseYearU(reportDocument.getCourseCode(), reportDocument.getYear()); |
516 | CourseYear cy = DaoFactory.getCourseYearDaoImpl().findCourseYearU(reportDocument.getCourseCode(), reportDocument.getYear()); |
523 | 517 | ||
524 | if (cy == null) { |
518 | if (cy == null) { |
- | 519 | Course c = DaoFactory.getCourseDaoImpl().findCourseByCode(reportDocument.getCourseCode()); |
|
525 | cy = DomainObjectFactory.createCourseYearImpl(); |
520 | cy = DomainObjectFactory.createCourseYearImpl(); |
526 | cy.setCourse(c); |
521 | cy.setCourse(c); |
527 | c.getCourseYears().add(cy); |
522 | c.getCourseYears().add(cy); |
528 | cy.setImportYear(reportDocument.getYear()); |
523 | cy.setImportYear(reportDocument.getYear()); |
529 | DaoFactory.getCourseYearDaoImpl().save(cy); |
524 | DaoFactory.getCourseYearDaoImpl().save(cy); |
530 | } |
525 | } |
531 | cy.setCourseReportDocument(reportDocumentJson); |
526 | cy.setCourseReportDocument(reportDocument.toJson()); |
532 | 527 | ||
533 | return reportDocument.toJson(); |
528 | return reportDocument.toJson(); |
534 | } |
529 | } |
535 | 530 | ||
536 | public 1.5.0/docs/api/java/lang/String.html">String loadCourseReportDocument(1.5.0/docs/api/java/lang/String.html">String courseCode,1.5.0/docs/api/java/lang/String.html">String year,UserSession session) { |
531 | public 1.5.0/docs/api/java/lang/String.html">String loadCourseReportDocument(1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String year, UserSession session) { |
537 | CourseYear cy = DaoFactory.getCourseYearDaoImpl().findCourseYearU(courseCode, year); |
532 | CourseYear cy = DaoFactory.getCourseYearDaoImpl().findCourseYearU(courseCode, year); |
538 | 533 | ||
539 | 1.5.0/docs/api/java/lang/String.html">String courseReportJson = null; |
534 | 1.5.0/docs/api/java/lang/String.html">String courseReportJson = null; |
540 | if (cy != null) { |
535 | if (cy != null) { |
541 | courseReportJson = cy.getCourseReportDocument(); |
536 | courseReportJson = cy.getCourseReportDocument(); |
542 | } |
537 | } |
543 | 538 | ||
544 | if (courseReportJson == null) { |
539 | if (courseReportJson == null) { |
545 | try { |
540 | try { |
546 | CourseReportDocument courseReport = createNewCourseReportDocument(courseCode, year); |
541 | CourseReportDocument courseReport = createNewCourseReportDocument(courseCode, year); |
547 | courseReportJson = courseReport.toJson(); |
542 | courseReportJson = courseReport.toJson(); |
548 | saveCourseReportDocument(courseReportJson, session); |
543 | saveCourseReportDocument(courseReport, session); |
549 | } catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) { |
544 | } catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) { |
550 | 1.5.0/docs/api/java/lang/System.html">System.out.println(e); |
545 | 1.5.0/docs/api/java/lang/System.html">System.out.println(e); |
551 | e.printStackTrace(); |
546 | e.printStackTrace(); |
552 | } |
547 | } |
553 | } |
548 | } |
554 | 549 | ||
555 | return courseReportJson; |
550 | return courseReportJson; |
556 | } |
551 | } |
557 | 552 | ||
558 | 553 | ||
559 | /****************************************************************************/ |
554 | /****************************************************************************/ |
560 | /* |
555 | /* |
561 | 556 | ||
562 | 557 | ||
563 | 558 | ||
564 | SERVICOS WS-API |
559 | SERVICOS WS-API |
565 | 560 | ||
566 | 561 | ||
567 | 562 | ||
568 | */ |
563 | */ |
569 | /****************************************************************************/ |
564 | /****************************************************************************/ |
570 | 565 | ||
571 | 566 | ||
572 | /** |
567 | /** |
573 | * This service loads a list of course units given course code and year |
568 | * This service loads a list of course units given course code and year |
574 | * with dtp stats codes pre-filled |
569 | * with dtp stats codes pre-filled |
575 | * @param courseCode |
570 | * @param courseCode |
576 | * @param year |
571 | * @param year |
577 | * @return |
572 | * @return |
578 | * @throws JSONException |
573 | * @throws JSONException |
579 | * @throws IOException |
574 | * @throws IOException |
580 | */ |
575 | */ |
581 | 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 { |
576 | 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 { |
582 | 577 | ||
583 | 578 | ||
584 | if(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_DTP_STATS.indexOf("localhost")>=0) |
579 | if(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_DTP_STATS.indexOf("localhost")>=0) |
585 | { |
580 | { |
586 | JSONArray array = new JSONArray(); |
581 | JSONArray array = new JSONArray(); |
587 | List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
582 | List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
588 | for(CourseUnit cu: units) |
583 | for(CourseUnit cu: units) |
589 | { |
584 | { |
590 | CourseUnitDtpStat stat = CourseReportUtils.createCourseUnitDtpStat(cu); |
585 | CourseUnitDtpStat stat = CourseReportUtils.createCourseUnitDtpStat(cu); |
591 | //sections.add(courseUnitSection); |
586 | //sections.add(courseUnitSection); |
592 | array.put(stat.toJsonObject()); |
587 | array.put(stat.toJsonObject()); |
593 | } |
588 | } |
594 | 589 | ||
595 | JSONObject obj = new JSONObject(); |
590 | JSONObject obj = new JSONObject(); |
596 | obj.put("dtpstats",array); |
591 | obj.put("dtpstats",array); |
597 | 592 | ||
598 | return obj.toString(); |
593 | return obj.toString(); |
599 | } |
594 | } |
600 | else |
595 | else |
601 | { |
596 | { |
602 | 1.5.0/docs/api/java/lang/String.html">String serviceUrl = Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_DTP_STATS + "?code=" + courseCode + "&year=" + year; |
597 | 1.5.0/docs/api/java/lang/String.html">String serviceUrl = Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_DTP_STATS + "?code=" + courseCode + "&year=" + year; |
603 | 1.5.0/docs/api/java/lang/String.html">String json = "{ dtpstats : [] }"; |
598 | 1.5.0/docs/api/java/lang/String.html">String json = "{ dtpstats : [] }"; |
604 | try{ |
599 | try{ |
605 | 1.5.0/docs/api/java/net/URL.html">URL url = new 1.5.0/docs/api/java/net/URL.html">URL(serviceUrl); |
600 | 1.5.0/docs/api/java/net/URL.html">URL url = new 1.5.0/docs/api/java/net/URL.html">URL(serviceUrl); |
606 | 601 | ||
607 | 1.5.0/docs/api/java/net/URLConnection.html">URLConnection conn = url.openConnection(); |
602 | 1.5.0/docs/api/java/net/URLConnection.html">URLConnection conn = url.openConnection(); |
608 | 5+0%2Fdocs%2Fapi+InputStream">InputStream is = conn.getInputStream(); |
603 | 5+0%2Fdocs%2Fapi+InputStream">InputStream is = conn.getInputStream(); |
609 | 604 | ||
610 | json = StreamsUtils.readString(is); |
605 | json = StreamsUtils.readString(is); |
611 | is.close(); |
606 | is.close(); |
612 | }catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
607 | }catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
613 | { |
608 | { |
614 | logger.error("Connecting " + serviceUrl,e); |
609 | logger.error("Connecting " + serviceUrl,e); |
615 | return json; |
610 | return json; |
616 | } |
611 | } |
617 | JSONObject jsonObject = new JSONObject(json); |
612 | JSONObject jsonObject = new JSONObject(json); |
618 | if(jsonObject.get("service").equals("ok")) |
613 | if(jsonObject.get("service").equals("ok")) |
619 | return jsonObject.get("response").toString(); |
614 | return jsonObject.get("response").toString(); |
620 | else |
615 | else |
621 | return json; |
616 | return json; |
622 | } |
617 | } |
623 | } |
618 | } |
624 | 619 | ||
625 | 620 | ||
626 | 621 | ||
627 | 622 | ||
628 | /** |
623 | /** |
629 | * |
624 | * |
630 | * Para um determinado curso e ano o serviço faz uma listagem de todas as suas unidades curriculares |
625 | * Para um determinado curso e ano o serviço faz uma listagem de todas as suas unidades curriculares |
631 | * e lista a sua informação básica juntamente com o relatório de avaliação disponivel |
626 | * e lista a sua informação básica juntamente com o relatório de avaliação disponivel |
632 | * O serviço adiciona ainda o Ano de cada unidade por inspeção do Plano de Estudos |
627 | * O serviço adiciona ainda o Ano de cada unidade por inspeção do Plano de Estudos |
633 | * caso a unidade não seja encontrada no Plano de estudos o ano irá ser preenchido com -1 |
628 | * caso a unidade não seja encontrada no Plano de estudos o ano irá ser preenchido com -1 |
634 | * |
629 | * |
635 | * @param courseCode codigo Siges na base de dados |
630 | * @param courseCode codigo Siges na base de dados |
636 | * @param year 201617, 201718 |
631 | * @param year 201617, 201718 |
637 | * @return String JSONObject with a JSON ARRAY of List<CourseUnitSection> |
632 | * @return String JSONObject with a JSON ARRAY of List<CourseUnitSection> |
638 | */ |
633 | */ |
639 | 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 { |
634 | 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 { |
640 | 635 | ||
641 | 636 | ||
642 | if(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_EVALUATION_REPORT.indexOf("localhost")>=0) |
637 | if(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_EVALUATION_REPORT.indexOf("localhost")>=0) |
643 | { |
638 | { |
644 | JSONArray array = new JSONArray(); |
639 | JSONArray array = new JSONArray(); |
645 | List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
640 | List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
646 | for(CourseUnit cu: units) |
641 | for(CourseUnit cu: units) |
647 | { |
642 | { |
648 | CourseUnitSection courseUnitSection = CourseReportUtils.createCourseUnitEvaluationSection((CourseUnitImpl) cu); |
643 | CourseUnitSection courseUnitSection = CourseReportUtils.createCourseUnitEvaluationSection((CourseUnitImpl) cu); |
649 | if(courseUnitSection.getAnoPlano() < 0) |
644 | if(courseUnitSection.getAnoPlano() < 0) |
650 | { |
645 | { |
651 | logger.info("Ano do Plano not available from courseUnitsEvaluation Service, will read from API loadPlanYearForCourseUnitCode"); |
646 | logger.info("Ano do Plano not available from courseUnitsEvaluation Service, will read from API loadPlanYearForCourseUnitCode"); |
652 | try{ |
647 | try{ |
653 | 1.5.0/docs/api/java/lang/String.html">String json = loadPlanYearForCourseUnitCode(courseCode,cu.getCode(),cu.getSemestre()); |
648 | 1.5.0/docs/api/java/lang/String.html">String json = loadPlanYearForCourseUnitCode(courseCode,cu.getCode(),cu.getSemestre()); |
654 | int ano = new JSONObject(json).getInt("year"); |
649 | int ano = new JSONObject(json).getInt("year"); |
655 | courseUnitSection.setAnoPlano(ano); |
650 | courseUnitSection.setAnoPlano(ano); |
656 | }catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e ) |
651 | }catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e ) |
657 | { |
652 | { |
658 | logger.error("Nao conseguiu obter o ano do plano da API: " + e.toString(),e); |
653 | logger.error("Nao conseguiu obter o ano do plano da API: " + e.toString(),e); |
659 | } |
654 | } |
660 | } |
655 | } |
661 | array.put(courseUnitSection.toJsonObject()); |
656 | array.put(courseUnitSection.toJsonObject()); |
662 | } |
657 | } |
663 | 658 | ||
664 | JSONObject obj = new JSONObject(); |
659 | JSONObject obj = new JSONObject(); |
665 | obj.put("evaluations",array); |
660 | obj.put("evaluations",array); |
666 | 661 | ||
667 | return obj.toString(); |
662 | return obj.toString(); |
668 | } |
663 | } |
669 | else |
664 | else |
670 | { |
665 | { |
671 | 1.5.0/docs/api/java/lang/String.html">String json = "{ evaluations : [] }"; |
666 | 1.5.0/docs/api/java/lang/String.html">String json = "{ evaluations : [] }"; |
672 | 1.5.0/docs/api/java/lang/String.html">String serviceUrl = Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_EVALUATION_REPORT + "?code=" + courseCode + "&year=" + year; |
667 | 1.5.0/docs/api/java/lang/String.html">String serviceUrl = Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_EVALUATION_REPORT + "?code=" + courseCode + "&year=" + year; |
673 | try{ |
668 | try{ |
674 | 1.5.0/docs/api/java/net/URL.html">URL url = new 1.5.0/docs/api/java/net/URL.html">URL(serviceUrl); |
669 | 1.5.0/docs/api/java/net/URL.html">URL url = new 1.5.0/docs/api/java/net/URL.html">URL(serviceUrl); |
675 | 670 | ||
676 | 1.5.0/docs/api/java/net/URLConnection.html">URLConnection conn = url.openConnection(); |
671 | 1.5.0/docs/api/java/net/URLConnection.html">URLConnection conn = url.openConnection(); |
677 | 5+0%2Fdocs%2Fapi+InputStream">InputStream is = conn.getInputStream(); |
672 | 5+0%2Fdocs%2Fapi+InputStream">InputStream is = conn.getInputStream(); |
678 | 673 | ||
679 | json = StreamsUtils.readString(is); |
674 | json = StreamsUtils.readString(is); |
680 | is.close(); |
675 | is.close(); |
681 | }catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
676 | }catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
682 | { |
677 | { |
683 | logger.error("Connecting " + serviceUrl,e); |
678 | logger.error("Connecting " + serviceUrl,e); |
684 | return json; |
679 | return json; |
685 | } |
680 | } |
686 | 681 | ||
687 | JSONObject jsonObject = new JSONObject(json); |
682 | JSONObject jsonObject = new JSONObject(json); |
688 | if(jsonObject.get("service").equals("ok")) |
683 | if(jsonObject.get("service").equals("ok")) |
689 | return jsonObject.get("response").toString(); |
684 | return jsonObject.get("response").toString(); |
690 | else |
685 | else |
691 | return json; |
686 | return json; |
692 | } |
687 | } |
693 | } |
688 | } |
694 | 689 | ||
695 | 690 | ||
696 | /** |
691 | /** |
697 | * |
692 | * |
698 | * |
693 | * |
699 | * @param courseCode codigo Siges na base de dados |
694 | * @param courseCode codigo Siges na base de dados |
700 | * @param unitCode |
695 | * @param unitCode |
701 | * @return Json com o ano do plano exemplo: { year : 1 } |
696 | * @return Json com o ano do plano exemplo: { year : 1 } |
702 | * ou -1 se não for encontrado |
697 | * ou -1 se não for encontrado |
703 | */ |
698 | */ |
704 | public 1.5.0/docs/api/java/lang/String.html">String loadPlanYearForCourseUnitCode(1.5.0/docs/api/java/lang/String.html">String courseCode,1.5.0/docs/api/java/lang/String.html">String unitCode,1.5.0/docs/api/java/lang/String.html">String period) throws JSONException, 1.5.0/docs/api/java/io/IOException.html">IOException { |
699 | public 1.5.0/docs/api/java/lang/String.html">String loadPlanYearForCourseUnitCode(1.5.0/docs/api/java/lang/String.html">String courseCode,1.5.0/docs/api/java/lang/String.html">String unitCode,1.5.0/docs/api/java/lang/String.html">String period) throws JSONException, 1.5.0/docs/api/java/io/IOException.html">IOException { |
705 | 700 | ||
706 | 701 | ||
707 | if(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNIT_PLAN_YEAR.indexOf("localhost")>=0) |
702 | if(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNIT_PLAN_YEAR.indexOf("localhost")>=0) |
708 | { |
703 | { |
709 | CourseImpl c = DaoFactory.getCourseDaoImpl().findCourseByCode(courseCode); |
704 | CourseImpl c = DaoFactory.getCourseDaoImpl().findCourseByCode(courseCode); |
710 | int year = c.getUnidadeAnoPlano(period,unitCode); |
705 | int year = c.getUnidadeAnoPlano(period,unitCode); |
711 | return "{ year : " + year + " }"; |
706 | return "{ year : " + year + " }"; |
712 | 707 | ||
713 | } |
708 | } |
714 | else |
709 | else |
715 | { |
710 | { |
716 | 1.5.0/docs/api/java/lang/String.html">String json = "{ year : -1 }"; |
711 | 1.5.0/docs/api/java/lang/String.html">String json = "{ year : -1 }"; |
717 | 1.5.0/docs/api/java/lang/String.html">String serviceUrl = Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNIT_PLAN_YEAR + "?courseCode=" + courseCode + "&unitCode=" + unitCode + "&period=" + period; |
712 | 1.5.0/docs/api/java/lang/String.html">String serviceUrl = Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNIT_PLAN_YEAR + "?courseCode=" + courseCode + "&unitCode=" + unitCode + "&period=" + period; |
718 | try{ |
713 | try{ |
719 | 1.5.0/docs/api/java/net/URL.html">URL url = new 1.5.0/docs/api/java/net/URL.html">URL(serviceUrl); |
714 | 1.5.0/docs/api/java/net/URL.html">URL url = new 1.5.0/docs/api/java/net/URL.html">URL(serviceUrl); |
720 | 715 | ||
721 | 1.5.0/docs/api/java/net/URLConnection.html">URLConnection conn = url.openConnection(); |
716 | 1.5.0/docs/api/java/net/URLConnection.html">URLConnection conn = url.openConnection(); |
722 | 5+0%2Fdocs%2Fapi+InputStream">InputStream is = conn.getInputStream(); |
717 | 5+0%2Fdocs%2Fapi+InputStream">InputStream is = conn.getInputStream(); |
723 | 718 | ||
724 | json = StreamsUtils.readString(is); |
719 | json = StreamsUtils.readString(is); |
725 | is.close(); |
720 | is.close(); |
726 | }catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
721 | }catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
727 | { |
722 | { |
728 | logger.error("Connecting " + serviceUrl,e); |
723 | logger.error("Connecting " + serviceUrl,e); |
729 | return json; |
724 | return json; |
730 | } |
725 | } |
731 | 726 | ||
732 | JSONObject jsonObject = new JSONObject(json); |
727 | JSONObject jsonObject = new JSONObject(json); |
733 | if(jsonObject.get("service").equals("ok")) |
728 | if(jsonObject.get("service").equals("ok")) |
734 | return jsonObject.get("response").toString(); |
729 | return jsonObject.get("response").toString(); |
735 | else |
730 | else |
736 | return json; |
731 | return json; |
737 | } |
732 | } |
738 | } |
733 | } |
739 | 734 | ||
740 | 735 | ||
741 | 736 | ||
742 | 737 | ||
743 | 738 | ||
744 | 739 | ||
745 | 740 | ||
746 | 741 | ||
747 | 742 | ||
748 | 743 | ||
749 | 744 | ||
750 | 745 | ||
751 | 746 | ||
752 | 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 { |
747 | 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 { |
753 | AbstractDao.getCurrentSession().beginTransaction(); |
748 | AbstractDao.getCurrentSession().beginTransaction(); |
754 | 749 | ||
755 | CourseReportDocument reportCourseDocument = new CourseReportServices().createNewCourseReportDocument("44","201617"); |
750 | CourseReportDocument reportCourseDocument = new CourseReportServices().createNewCourseReportDocument("44","201617"); |
756 | 1.5.0/docs/api/java/lang/System.html">System.out.println(reportCourseDocument.toJson()); |
751 | 1.5.0/docs/api/java/lang/System.html">System.out.println(reportCourseDocument.toJson()); |
757 | AbstractDao.getCurrentSession().getTransaction().commit(); |
752 | AbstractDao.getCurrentSession().getTransaction().commit(); |
758 | 753 | ||
759 | //System.setProperty("javax.net.ssl.trustStore", "/JORGE/COPIAS/.keystore"); |
754 | //System.setProperty("javax.net.ssl.trustStore", "/JORGE/COPIAS/.keystore"); |
760 | //System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); |
755 | //System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); |
761 | 756 | ||
762 | /*URL url = new URL("http://pae.ipportalegre.pt/wsjson/api/app/ws-course-pedagogic-results-list?code=44&year=201617&period=S1"); |
757 | /*URL url = new URL("http://pae.ipportalegre.pt/wsjson/api/app/ws-course-pedagogic-results-list?code=44&year=201617&period=S1"); |
763 | 758 | ||
764 | 759 | ||
765 | 760 | ||
766 | System.out.println(StreamsUtils.readString(url.openStream()));*/ |
761 | System.out.println(StreamsUtils.readString(url.openStream()));*/ |
767 | } |
762 | } |
768 | 763 | ||
769 | /* |
764 | /* |
770 | 765 | ||
771 | public String loadUnitsAndCreateLearningResultsTables4Course(String courseCode, String year) throws IOException, JSONException |
766 | public String loadUnitsAndCreateLearningResultsTables4Course(String courseCode, String year) throws IOException, JSONException |
772 | { |
767 | { |
773 | 768 | ||
774 | } |
769 | } |
775 | */ |
770 | */ |
776 | //TODO loadUnitsAndCreateLearningResultsTables4Course |
771 | //TODO loadUnitsAndCreateLearningResultsTables4Course |
777 | //HIPOTESE DEVOLVER DOIS OBJECTOS |
772 | //HIPOTESE DEVOLVER DOIS OBJECTOS |
778 | //SERVICO DE ARRANQUE |
773 | //SERVICO DE ARRANQUE |
779 | //DEVOLVE UM REPORT DOCUMENT E O CHAMADOR USA O QUE QUISER |
774 | //DEVOLVE UM REPORT DOCUMENT E O CHAMADOR USA O QUE QUISER |
780 | //A GERACAO DE GRAFICOS FAZ-SE APENAS A PEDIDO |
775 | //A GERACAO DE GRAFICOS FAZ-SE APENAS A PEDIDO |
781 | 776 | ||
782 | // SE ELE PEDIR PARA ATUALIZAR TUDO CARREGA-SE UNIDADES E TABELAS NU DOC NOVO |
777 | // SE ELE PEDIR PARA ATUALIZAR TUDO CARREGA-SE UNIDADES E TABELAS NU DOC NOVO |
783 | // E NO BROWSER SUBSTITUI-SE ESSES ELEMENTOS NOS ANTIGOS a seccao das unidades |
778 | // E NO BROWSER SUBSTITUI-SE ESSES ELEMENTOS NOS ANTIGOS a seccao das unidades |
784 | // e as as tabelas |
779 | // e as as tabelas |
785 | 780 | ||
786 | 781 | ||
787 | 782 | ||
788 | } |
783 | } |
789 | 784 |