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