Rev 1579 | Rev 1586 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1574 | jmachado | 1 | package pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors; |
1569 | jmachado | 2 | |
3 | import jomm.utils.PdfUtils; |
||
4 | import org.apache.fop.apps.FOPException; |
||
5 | import org.apache.log4j.Logger; |
||
6 | import org.dom4j.DocumentException; |
||
7 | import pt.estgp.estgweb.Globals; |
||
8 | import pt.estgp.estgweb.domain.Course; |
||
1585 | jmachado | 9 | import pt.estgp.estgweb.domain.QuestionarioReportCursoFile; |
10 | import pt.estgp.estgweb.domain.QuestionarioReportCursoFileImpl; |
||
11 | import pt.estgp.estgweb.domain.QuestionarioReportFileGroupCursosAnoImpl; |
||
1569 | jmachado | 12 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
1585 | jmachado | 13 | import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum; |
14 | import pt.estgp.estgweb.services.data.RepositoryService; |
||
1574 | jmachado | 15 | import pt.estgp.estgweb.services.jobs.ServiceJob; |
16 | import pt.estgp.estgweb.services.logresults.ILogMessages; |
||
1585 | jmachado | 17 | import pt.estgp.estgweb.services.logresults.LogMessageTypeEnum; |
18 | import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessage; |
||
1574 | jmachado | 19 | import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessages; |
1585 | jmachado | 20 | import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.queries.*; |
1576 | jmachado | 21 | import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.reportdomains.CursoPublicReport; |
22 | import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.reportdomains.EntityEvaluated; |
||
1574 | jmachado | 23 | import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.utils.*; |
1569 | jmachado | 24 | import pt.estgp.estgweb.utils.ConfigProperties; |
25 | import pt.estgp.estgweb.utils.DatesUtils; |
||
26 | import pt.estgp.estgweb.utils.Dom4jUtil; |
||
27 | |||
28 | import javax.xml.transform.TransformerException; |
||
29 | import javax.xml.transform.dom.DOMSource; |
||
1571 | jmachado | 30 | import java.awt.*; |
1574 | jmachado | 31 | import java.io.File; |
1585 | jmachado | 32 | import java.io.FileInputStream; |
1569 | jmachado | 33 | import java.io.FileOutputStream; |
34 | import java.io.IOException; |
||
1570 | jmachado | 35 | import java.text.SimpleDateFormat; |
36 | import java.util.*; |
||
1571 | jmachado | 37 | import java.util.List; |
1569 | jmachado | 38 | |
39 | /** |
||
40 | * Created by jorgemachado on 16/12/16. |
||
41 | */ |
||
1574 | jmachado | 42 | public class CursoPublicReportGenerator extends ReportAlunosGenerator |
1569 | jmachado | 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(DocenteReportGenerator.class); |
||
45 | |||
46 | |||
1574 | jmachado | 47 | |
1569 | jmachado | 48 | 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, DocumentException, 1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException, FOPException |
49 | { |
||
50 | |||
51 | //String teacherCode = "44451"; |
||
52 | //String teacherCode = "20122"; |
||
1570 | jmachado | 53 | 1.5.0/docs/api/java/lang/String.html">String courseCode = "9119"; |
1573 | jmachado | 54 | //String courseCode = "9104"; |
1569 | jmachado | 55 | 1.5.0/docs/api/java/lang/String.html">String anoLectivo = "201516"; |
1573 | jmachado | 56 | //String[] periodos = new String[]{"S2","T3","T4","A"}; |
57 | 1.5.0/docs/api/java/lang/String.html">String[] periodos = new 1.5.0/docs/api/java/lang/String.html">String[]{"S1"}; |
||
1571 | jmachado | 58 | 1.5.0/docs/api/java/lang/String.html">String[] degrees = new 1.5.0/docs/api/java/lang/String.html">String[]{"L","M","T","E"}; |
1574 | jmachado | 59 | new CursoPublicReportGenerator(anoLectivo,periodos,degrees,courseCode).processCourse(courseCode); |
1569 | jmachado | 60 | |
61 | } |
||
62 | |||
1579 | jmachado | 63 | public CursoPublicReportGenerator() { |
64 | super(null, null, null); |
||
65 | } |
||
66 | |||
1569 | jmachado | 67 | public CursoPublicReportGenerator(1.5.0/docs/api/java/lang/String.html">String anoLectivo, 1.5.0/docs/api/java/lang/String.html">String[] periodos, 1.5.0/docs/api/java/lang/String.html">String[] degrees, 1.5.0/docs/api/java/lang/String.html">String courseCode) { |
68 | super(anoLectivo, periodos, degrees); |
||
69 | } |
||
70 | |||
1585 | jmachado | 71 | public CursoPublicReport processCourse(1.5.0/docs/api/java/lang/String.html">String courseCode) throws 1.5.0/docs/api/java/io/IOException.html">IOException, DocumentException, 1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException, FOPException |
1569 | jmachado | 72 | { |
1574 | jmachado | 73 | CursoPublicReport cursoReport = getCoursePublicReport(courseCode); |
1569 | jmachado | 74 | if(cursoReport == null) |
75 | { |
||
1585 | jmachado | 76 | 1.5.0/docs/api/java/lang/String.html">String msg = " Curso " + courseCode + " nao tem respostas nestas condições "; |
77 | logger.warn(msg); |
||
78 | serviceLogWarn(msg); |
||
79 | 1.5.0/docs/api/java/lang/System.html">System.out.println(); |
||
80 | return cursoReport; |
||
1569 | jmachado | 81 | } |
82 | |||
83 | ChartBuilderUtil.createChartTiposAlunos(cursoReport, "tiposAlunosTmp"); |
||
84 | ChartBuilderUtil.createChartTaxaRespostas(cursoReport, "taxaRespostasTmp"); |
||
85 | ChartBuilderUtil.createChartTaxaParticipacao(cursoReport, "taxaParticipacaoTmp"); |
||
86 | ChartBuilderUtil.createChartUnidadesContribuicao(cursoReport,"unidadesContribuicao"); |
||
87 | |||
88 | |||
1574 | jmachado | 89 | 1.5.0/docs/api/java/lang/String.html">String path = generatePdfReport(cursoReport); |
1585 | jmachado | 90 | cursoReport.setPathGeneratedPdfTemp(path); |
91 | return cursoReport; |
||
1569 | jmachado | 92 | |
93 | } |
||
94 | |||
1574 | jmachado | 95 | private 1.5.0/docs/api/java/lang/String.html">String generatePdfReport(CursoPublicReport cursoReport) throws DocumentException, 1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException, 1.5.0/docs/api/java/io/IOException.html">IOException, FOPException { |
96 | 1.5.0/docs/api/java/lang/String.html">String startPath = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + "reportCurso" + cursoReport.getCursoStats().getCodigoCurso(); |
||
1571 | jmachado | 97 | 1.5.0/docs/api/java/lang/String.html">String path = startPath + ".pdf"; |
1569 | jmachado | 98 | |
99 | 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream out = new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(path); |
||
100 | Map<String,Object> params = new HashMap<String,Object>(); |
||
101 | params.put("site", Globals.SITE_URL); |
||
102 | params.put("updateDate", pt.estgp.estgweb.web.utils.DatesUtils.getStringFromDate(new 5+0%2Fdocs%2Fapi+Date">Date() )); |
||
103 | |||
104 | |||
105 | org.w3c.dom.5+0%2Fdocs%2Fapi+Document">Document dom2 = cursoReport.serialize(); |
||
106 | Dom4jUtil.writeSout(dom2); |
||
1571 | jmachado | 107 | Dom4jUtil.write(dom2,new java.io.1.5.0/docs/api/java/io/File.html">File(startPath + ".xml")); |
1569 | jmachado | 108 | |
109 | PdfUtils.setAuthority("Relatório de Avaliação Pedagógica - Relatório Público de Curso - " + |
||
110 | cursoReport.getCursoStats().getNomeCurso() + " (" + cursoReport.getCursoStats().getCodigoCurso() + " ) " + |
||
111 | "- Ano letivo " + cursoReport.getAnoLectivo() + " - Periodos " + cursoReport.getSemestres().toString() + "" + |
||
112 | " Tipos de Curso - " + cursoReport.getDegrees().toString(), |
||
113 | cursoReport.getCursoStats().getNomeCurso(), "Avaliação Pedagógica Docentes, Inqueritos aos Alunos"); |
||
1574 | jmachado | 114 | PdfUtils.createPdfFromXml(new 1.5.0/docs/api/javax/xml/transform/dom/DOMSource.html">DOMSource(dom2), "pt/estgp/estgweb/services/questionarios/pedagogico/reportprocessors/xsl/cursoPublicReport.fo.xsl", out, params); |
1569 | jmachado | 115 | out.flush(); |
116 | out.close(); |
||
1574 | jmachado | 117 | return path; |
1569 | jmachado | 118 | } |
119 | |||
1574 | jmachado | 120 | private CursoPublicReport getCoursePublicReport(1.5.0/docs/api/java/lang/String.html">String courseCode) throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
1569 | jmachado | 121 | |
1585 | jmachado | 122 | //AbstractDao.getCurrentSession().beginTransaction(); |
1569 | jmachado | 123 | |
124 | Course c = DaoFactory.getCourseDaoImpl().findCourseByCode(courseCode); |
||
125 | |||
126 | CursoPublicReport cursoReport = new CursoPublicReport(); |
||
127 | |||
128 | //dados relativos ao questionario |
||
129 | cursoReport.setAnoLectivo(DatesUtils.getImportYearFormatted(anoLectivo)); |
||
130 | cursoReport.setSemestres(ReportUtils.getFormatedSemestres(periodos)); |
||
131 | cursoReport.setDegrees(ReportUtils.getFormatedDegrees(degrees)); |
||
132 | |||
133 | |||
134 | //dados relativos ao curso |
||
135 | cursoReport.getCursoStats().setCodigoCurso(courseCode); |
||
136 | cursoReport.getCursoStats().setNomeCurso(c.getName()); |
||
137 | cursoReport.getCursoStats().setCodigoCurso(c.getCode()); |
||
138 | cursoReport.getCursoStats().setNomeInstituicao(ConfigProperties.getProperty("institution.code." + c.getInstitutionalCode())); |
||
139 | cursoReport.getCursoStats().setCodigoInstituicao(c.getInstitutionalCode()); |
||
140 | cursoReport.getCursoStats().setCodigoNacionalInstituicao(ConfigProperties.getProperty("institution.national.code." + c.getInstitutionalCode())); |
||
141 | cursoReport.getCursoStats().setAbreviaturaInstituicao(ConfigProperties.getProperty("institution.code.prefix." + c.getInstitutionalCode())); |
||
142 | cursoReport.setAnoLectivo(anoLectivo); |
||
143 | |||
144 | |||
145 | |||
146 | |||
147 | |||
1585 | jmachado | 148 | //Caso nao haja respostas |
149 | //este metodo preenche todas as questões relativas a respostas e generos m/f e idades, mas |
||
150 | // devolve total de respostas para ser usada aqui como verificacao |
||
151 | int respostas = AlunosQueryDao.countAlunosQueResponderamAoCurso(courseCode, anoLectivo, cursoReport, periodos, degrees); |
||
152 | QuestionariosQueryDao.countQuestionariosRespostasAoCurso(courseCode, anoLectivo, cursoReport, periodos, degrees); |
||
153 | //todo testar curso sem respostas |
||
154 | if(respostas > 0) |
||
1569 | jmachado | 155 | { |
1585 | jmachado | 156 | AlunosQueryDao.countTiposAlunosComRespostasAoCurso(courseCode, anoLectivo, cursoReport, periodos, degrees); |
157 | AlunosQueryDao.countIdadesAlunosComRespostasAoCurso(courseCode, anoLectivo, cursoReport, periodos, degrees); |
||
158 | |||
159 | //TABELAS |
||
160 | QuestionariosQueryDao.createDataTableIdades(cursoReport, "Alunos"); |
||
161 | QuestionariosQueryDao.createDataTableLocalidadesAoCurso(cursoReport, courseCode, anoLectivo, periodos, degrees, "Alunos"); |
||
1569 | jmachado | 162 | } |
163 | |||
1570 | jmachado | 164 | UnidadesQueryDao.createTableTaxaRespostaUnidadeAoCurso(cursoReport, courseCode, anoLectivo, periodos, degrees); |
1569 | jmachado | 165 | |
1585 | jmachado | 166 | if(respostas > 0) |
167 | { |
||
1570 | jmachado | 168 | //EVOLUCAO DAS RESPOSTAS |
1574 | jmachado | 169 | List<Object[]> semanaContagemCurso = QuestionariosQueryDao.obtainEvolucaoRespostas(new 1.5.0/docs/api/java/lang/String.html">String[]{courseCode}, EntityEvaluated.CURSO,anoLectivo,periodos,degrees); |
1570 | jmachado | 170 | List<Object[]> semanaContagemEscola = QuestionariosQueryDao.obtainEvolucaoRespostas(new 1.5.0/docs/api/java/lang/String.html">String[]{cursoReport.getCursoStats().getCodigoInstituicao()},EntityEvaluated.ESCOLA,anoLectivo,periodos,degrees); |
171 | 1.5.0/docs/api/java/lang/String.html">String distRespostas = ChartBuilderUtil.createTimeSeriesCursoRepostas("distribuicaoRespostasSemanal",cursoReport.getCursoStats().getNomeCurso(),cursoReport.getCursoStats().getAbreviaturaInstituicao(),semanaContagemCurso,semanaContagemEscola); |
||
172 | cursoReport.setPathDistribuicaoRespostasSemanalChart(distRespostas); |
||
1569 | jmachado | 173 | |
1570 | jmachado | 174 | DataTable tableEvolucaoRespostas = criarEvolucaoTaxasRespostas(semanaContagemCurso,cursoReport.getQuestionariosReqTotal()); |
175 | cursoReport.setTabelaEvolucaoRespostas(tableEvolucaoRespostas); |
||
176 | |||
177 | |||
1571 | jmachado | 178 | //Os cursos na Escola são todos os cursos, na pratica nao serve para nada porque |
179 | //A media de todos os cursos na escola é a media da escola considerando a restricao de graus e periodos |
||
180 | //media nas Escolas por pergunta e media nos Cursos por pergunta é igual |
||
181 | //A media da entidade neste caso é a do curso |
||
1569 | jmachado | 182 | List<String> codigosTodosCursosDaEscola = QueryDaoUtils.getCodigosCursosEscola(cursoReport.getCursoStats().getCodigoInstituicao(),anoLectivo, periodos, degrees); |
1571 | jmachado | 183 | |
1569 | jmachado | 184 | //List<String> codigosEscola = QueryDaoUtils.getCodigosEscolaDocente(teacherCode, anoLectivo, periodos, degrees); |
1571 | jmachado | 185 | List<String> codigosEscola = new ArrayList<String>(); |
186 | codigosEscola.add(cursoReport.getCursoStats().getCodigoInstituicao()); |
||
1569 | jmachado | 187 | |
188 | |||
1571 | jmachado | 189 | cursoReport.getCursoStats().setDocentesDoCurso((int) QueryDaoUtils.countDocentesNosCursos(courseCode, anoLectivo, periodos, degrees)); |
190 | cursoReport.getCursoStats().setDocentesDaEscola((int) QueryDaoUtils.countDocentesNasEscolas(cursoReport.getCursoStats().getCodigoInstituicao(), anoLectivo, periodos, degrees)); |
||
1569 | jmachado | 191 | |
1585 | jmachado | 192 | // @todoRefactor |
193 | // O DocenteReport tem as unidades na escola e as unidades no curso |
||
194 | // O CursoReport nao tem, estao antes no CursoStats |
||
195 | // Uma vez que sao usados em todos os reports de Alunos poderiam ser colocados no QuestionarioAlunos não é problematico |
||
196 | // vai buscar às cadeiras temos de fazer override do metodo e puxa-lo para o QuestionarioAlunos |
||
197 | //ou nao porque o UnidadesDaEscola foi introduzido dentro do Curso não se puxou para o QuestionarioAlunos |
||
1571 | jmachado | 198 | //o xsl vai ter de usar este caso o use |
199 | cursoReport.getCursoStats().setUnidadesDoCurso((int) QueryDaoUtils.countUnidadesNosCursos(courseCode, anoLectivo, periodos, degrees)); |
||
200 | cursoReport.getCursoStats().setUnidadesDaEscola((int) QueryDaoUtils.countUnidadesNasEscolas(cursoReport.getCursoStats().getCodigoInstituicao(), anoLectivo, periodos, degrees)); |
||
1569 | jmachado | 201 | |
1571 | jmachado | 202 | |
1574 | jmachado | 203 | ReportAlunosGenerator.criarGraficosRespostasAgregadas(new 1.5.0/docs/api/java/lang/String.html">String[]{courseCode}, |
1571 | jmachado | 204 | EntityEvaluated.CURSO, |
1569 | jmachado | 205 | anoLectivo, |
1571 | jmachado | 206 | cursoReport, |
207 | codigosTodosCursosDaEscola, |
||
1569 | jmachado | 208 | codigosEscola, |
209 | 0, |
||
1571 | jmachado | 210 | cursoReport.getCursoStats().getRespostasAgregadasGrupoUnidade().getRespostasAgregadasChartTable(), |
211 | cursoReport.getCursoStats().getRespostasAgregadasGrupoUnidade(), |
||
212 | PerguntasGrupoQueryDao.GRUPO_UNIDADE_CODE_PERGUNTAS, null, |
||
213 | periodos, degrees, true); |
||
1569 | jmachado | 214 | |
1574 | jmachado | 215 | ReportAlunosGenerator.criarGraficosRespostasAgregadas(new 1.5.0/docs/api/java/lang/String.html">String[]{courseCode}, |
1571 | jmachado | 216 | EntityEvaluated.CURSO, |
1569 | jmachado | 217 | anoLectivo, |
1571 | jmachado | 218 | cursoReport, |
219 | codigosTodosCursosDaEscola, |
||
1569 | jmachado | 220 | codigosEscola, |
1573 | jmachado | 221 | 4000, |
1571 | jmachado | 222 | cursoReport.getCursoStats().getRespostasAgregadasGrupoUnidade().getRespostasAgregadasChartTable2Secs(), |
223 | cursoReport.getCursoStats().getRespostasAgregadasGrupoUnidade(), |
||
224 | PerguntasGrupoQueryDao.GRUPO_UNIDADE_CODE_PERGUNTAS, null, |
||
225 | periodos, degrees, false); |
||
1569 | jmachado | 226 | |
1571 | jmachado | 227 | |
1574 | jmachado | 228 | ReportAlunosGenerator.criarGraficosRespostasAgregadas(new 1.5.0/docs/api/java/lang/String.html">String[]{courseCode}, |
1571 | jmachado | 229 | EntityEvaluated.CURSO, |
1569 | jmachado | 230 | anoLectivo, |
1571 | jmachado | 231 | cursoReport, |
232 | codigosTodosCursosDaEscola, |
||
1569 | jmachado | 233 | codigosEscola, |
234 | 0, |
||
1571 | jmachado | 235 | cursoReport.getCursoStats().getRespostasAgregadasGrupoSalas().getRespostasAgregadasChartTable(), |
236 | cursoReport.getCursoStats().getRespostasAgregadasGrupoSalas(), |
||
237 | PerguntasGrupoQueryDao.GRUPO_SALAS_CODE_PERGUNTAS, null, |
||
238 | periodos, degrees, true); |
||
1569 | jmachado | 239 | |
1574 | jmachado | 240 | ReportAlunosGenerator.criarGraficosRespostasAgregadas(new 1.5.0/docs/api/java/lang/String.html">String[]{courseCode}, |
1571 | jmachado | 241 | EntityEvaluated.CURSO, |
1569 | jmachado | 242 | anoLectivo, |
1571 | jmachado | 243 | cursoReport, |
244 | codigosTodosCursosDaEscola, |
||
1569 | jmachado | 245 | codigosEscola, |
1573 | jmachado | 246 | 9000, |
1571 | jmachado | 247 | cursoReport.getCursoStats().getRespostasAgregadasGrupoSalas().getRespostasAgregadasChartTable2Secs(), |
248 | cursoReport.getCursoStats().getRespostasAgregadasGrupoSalas(), |
||
249 | PerguntasGrupoQueryDao.GRUPO_SALAS_CODE_PERGUNTAS, null, |
||
250 | periodos, degrees, false); |
||
1569 | jmachado | 251 | |
252 | |||
1585 | jmachado | 253 | UnidadesQueryDao.criarTabelasCadeirasCurso(courseCode, |
254 | anoLectivo, |
||
255 | cursoReport, |
||
256 | 0, periodos, degrees,cursoReport.getCursoStats().getUnidadesStats()); |
||
1571 | jmachado | 257 | |
1569 | jmachado | 258 | |
1585 | jmachado | 259 | ChartWithDataTable analiseConjuntaChartWithTable = criarAnaliseConjuntaDeUnidades(cursoReport.getCursoStats().getUnidadesStats()); |
260 | cursoReport.setAnaliseConjuntaChartWithTable(analiseConjuntaChartWithTable); |
||
1569 | jmachado | 261 | |
1585 | jmachado | 262 | 1.5.0/docs/api/java/lang/String.html">String pathOrdenadaMediaUnidades = criarAnaliseConjuntaDeUnidadesOrdenadaMediaUnidades(cursoReport.getCursoStats().getUnidadesStats()); |
263 | cursoReport.setAnaliseConjuntaChartOrderMediaUnidades(pathOrdenadaMediaUnidades); |
||
1569 | jmachado | 264 | |
1585 | jmachado | 265 | 1.5.0/docs/api/java/lang/String.html">String pathOrdenadaMediaSalas = criarAnaliseConjuntaDeUnidadesOrdenadaMediaSalas(cursoReport.getCursoStats().getUnidadesStats()); |
266 | cursoReport.setAnaliseConjuntaChartOrderMediaSalas(pathOrdenadaMediaSalas); |
||
1569 | jmachado | 267 | |
1585 | jmachado | 268 | ArrayList<TabelaPerguntaComparativosUnidades> listaTabelasComparativasUnidadesPergunta = criarAnaliseConjuntaDeUnidadesAPergunta(cursoReport.getCursoStats().getRespostasAgregadasGrupoUnidade().getPerguntasStats(), cursoReport.getCursoStats().getUnidadesStats(),PerguntasGrupoQueryDao.GRUPO_UNIDADE_CODE_PERGUNTAS,null); |
269 | cursoReport.setListaUnidadesComprativasPergunta(listaTabelasComparativasUnidadesPergunta); |
||
1569 | jmachado | 270 | |
1585 | jmachado | 271 | ArrayList<TabelaPerguntaComparativosUnidades> listaTabelasComparativasUnidadesPerguntaSalas = criarAnaliseConjuntaDeUnidadesAPergunta(cursoReport.getCursoStats().getRespostasAgregadasGrupoUnidade().getPerguntasStats(), cursoReport.getCursoStats().getUnidadesStats(),PerguntasGrupoQueryDao.GRUPO_SALAS_CODE_PERGUNTAS,null); |
272 | cursoReport.setListaUnidadesComprativasPerguntaSalas(listaTabelasComparativasUnidadesPerguntaSalas); |
||
1569 | jmachado | 273 | |
1585 | jmachado | 274 | DataTable dataTableTodasAsUndiadesTodasPerguntas = criarTabelaComRespostasATodasAsPerguntas(cursoReport); |
275 | cursoReport.setTodasAsRespostasMediasGruposUnidadesESalas(dataTableTodasAsUndiadesTodasPerguntas); |
||
1569 | jmachado | 276 | |
1585 | jmachado | 277 | } |
278 | //AbstractDao.getCurrentSession().getTransaction().commit(); |
||
1572 | jmachado | 279 | return cursoReport; |
280 | } |
||
1569 | jmachado | 281 | |
1572 | jmachado | 282 | private DataTable criarTabelaComRespostasATodasAsPerguntas(CursoPublicReport cursoReport) { |
283 | DataTable tabelaComRespostasATodasAsPerguntasUnidadesSalas = new DataTable(); |
||
1569 | jmachado | 284 | |
1572 | jmachado | 285 | DataTable.Row headerHidden = tabelaComRespostasATodasAsPerguntasUnidadesSalas.addRowHeader(); |
286 | headerHidden.setInvisible(true); |
||
287 | DataTable.Row headerGroups = tabelaComRespostasATodasAsPerguntasUnidadesSalas.addRowHeader(); |
||
288 | DataTable.Row header = tabelaComRespostasATodasAsPerguntasUnidadesSalas.addRowHeader(); |
||
1569 | jmachado | 289 | |
1572 | jmachado | 290 | |
291 | headerHidden.addColTextCenter("Inv " + "Unidade Curricular"); |
||
292 | headerGroups.addColInvisible(); |
||
1573 | jmachado | 293 | header.addColTextCenter("Unidade Curricular"); |
1572 | jmachado | 294 | |
1573 | jmachado | 295 | |
296 | |||
297 | |||
1572 | jmachado | 298 | headerHidden.addColTextCenter("Inv " + "Curso"); |
299 | headerGroups.addColInvisible(); |
||
1573 | jmachado | 300 | header.addColTextCenter("Curso"); |
1572 | jmachado | 301 | |
1573 | jmachado | 302 | //CABECALHOS UNIDADES |
303 | List<PerguntaStats> perguntaStatsesUnidadeHeader = cursoReport.getCursoStats().getRespostasAgregadasGrupoUnidade().getPerguntasStats(); |
||
304 | if(perguntaStatsesUnidadeHeader.size() > 0) |
||
305 | { |
||
306 | DataTable.Row.Col c = headerGroups.addColTextCenter("Unidade Curricular"); |
||
307 | c.setColspan(perguntaStatsesUnidadeHeader.size()); |
||
308 | c.setBackgroundColor(ChartBuilderUtil.getRgbXslColor(ChartBuilderUtil.COLOR_SECTION_GREEN)); |
||
309 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(perguntaStatsesUnidadeHeader,new Comparator<PerguntaStats>() { |
||
310 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
311 | public int compare(PerguntaStats o1, PerguntaStats o2) { |
||
312 | return 1.5.0/docs/api/java/lang/Integer.html">Integer.parseInt(o1.getNumero()) - 1.5.0/docs/api/java/lang/Integer.html">Integer.parseInt(o2.getNumero()); |
||
313 | } |
||
314 | }); |
||
315 | for(PerguntaStats perguntaStats : perguntaStatsesUnidadeHeader) |
||
316 | { |
||
317 | headerHidden.addColTextCenter("Inv " + perguntaStats.getNumero()); |
||
318 | header.addColTextCenter(perguntaStats.getNumero()).setBackgroundColor(ChartBuilderUtil.getRgbXslColor(ChartBuilderUtil.COLOR_SECTION_GREEN)); |
||
1572 | jmachado | 319 | } |
320 | } |
||
321 | |||
1573 | jmachado | 322 | //CABECALHOS SALAS |
323 | List<PerguntaStats> perguntaStatsesSalasHeader = cursoReport.getCursoStats().getRespostasAgregadasGrupoSalas().getPerguntasStats(); |
||
324 | if(perguntaStatsesSalasHeader.size() > 0) |
||
325 | { |
||
326 | DataTable.Row.Col c = headerGroups.addColTextCenter("Instalações"); |
||
327 | c.setColspan(perguntaStatsesSalasHeader.size()); |
||
328 | c.setBackgroundColor(ChartBuilderUtil.getRgbXslColor(ChartBuilderUtil.COLOR_SECTION_ROSE)); |
||
329 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(perguntaStatsesSalasHeader,new Comparator<PerguntaStats>() { |
||
330 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
331 | public int compare(PerguntaStats o1, PerguntaStats o2) { |
||
332 | return 1.5.0/docs/api/java/lang/Integer.html">Integer.parseInt(o1.getNumero()) - 1.5.0/docs/api/java/lang/Integer.html">Integer.parseInt(o2.getNumero()); |
||
333 | } |
||
334 | }); |
||
335 | for(PerguntaStats perguntaStats : perguntaStatsesSalasHeader) |
||
336 | { |
||
337 | header.addColTextCenter(perguntaStats.getNumero()); |
||
338 | headerHidden.addColTextCenter("Inv " + perguntaStats.getNumero()).setBackgroundColor(ChartBuilderUtil.getRgbXslColor(ChartBuilderUtil.COLOR_SECTION_ROSE)); |
||
1572 | jmachado | 339 | } |
340 | } |
||
341 | |||
1573 | jmachado | 342 | |
343 | |||
344 | |||
1572 | jmachado | 345 | header.addColTextCenter("Insc."); |
346 | headerHidden.addColTextCenter("Inv Insc."); |
||
347 | headerGroups.addColInvisible(); |
||
348 | |||
349 | headerHidden.addColTextCenter("Inv Resps."); |
||
350 | header.addColTextCenter("Resps."); |
||
351 | headerGroups.addColInvisible(); |
||
352 | |||
353 | for(UnidadeStats unidadeStats: cursoReport.getCursoStats().getUnidadesStats()) |
||
354 | { |
||
355 | DataTable.Row unidadeRow = tabelaComRespostasATodasAsPerguntasUnidadesSalas.addRowNormal(); |
||
356 | unidadeRow.addColTextCenter(unidadeStats.getNomeUnidade()); |
||
357 | unidadeRow.addColTextCenter(unidadeStats.getNomeCurso()); |
||
358 | |||
359 | |||
360 | //COLUNA POR CADA MEDIA DE CADA PERGUNTA NAS UNIDADES |
||
361 | List<PerguntaStats> perguntaStatsesUnidades = unidadeStats.getUnidadeStatsGrupoUnidade().getPerguntasStats(); |
||
362 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(perguntaStatsesUnidades,new Comparator<PerguntaStats>() { |
||
363 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
364 | public int compare(PerguntaStats o1, PerguntaStats o2) { |
||
365 | return 1.5.0/docs/api/java/lang/Integer.html">Integer.parseInt(o1.getNumero()) - 1.5.0/docs/api/java/lang/Integer.html">Integer.parseInt(o2.getNumero()); |
||
366 | } |
||
367 | }); |
||
1573 | jmachado | 368 | |
369 | for(PerguntaStats guiaHeader: perguntaStatsesUnidadeHeader) |
||
1572 | jmachado | 370 | { |
1573 | jmachado | 371 | boolean found = false; |
372 | for(PerguntaStats perguntaStats : perguntaStatsesUnidades) |
||
373 | { |
||
374 | if(perguntaStats.getNumero().equals(guiaHeader.getNumero())) |
||
375 | { |
||
376 | unidadeRow.addColPercentageDefinedCenter(perguntaStats.getMediaEntidadeEmAvaliacaoPrint(), perguntaStats.getPercentMediaEntidadeEmAvaliacao(), true); |
||
377 | found = true; |
||
378 | break; |
||
379 | } |
||
380 | } |
||
381 | if(!found) |
||
382 | unidadeRow.addColTextCenter("--"); |
||
1572 | jmachado | 383 | } |
384 | |||
1573 | jmachado | 385 | |
1572 | jmachado | 386 | //COLUNA POR CADA MEDIA DE CADA PERGUNTA NAS SALAS |
387 | List<PerguntaStats> perguntaStatsSalas = unidadeStats.getUnidadeStatsGrupoSalas().getPerguntasStats(); |
||
388 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(perguntaStatsSalas,new Comparator<PerguntaStats>() { |
||
389 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
390 | public int compare(PerguntaStats o1, PerguntaStats o2) { |
||
391 | return 1.5.0/docs/api/java/lang/Integer.html">Integer.parseInt(o1.getNumero()) - 1.5.0/docs/api/java/lang/Integer.html">Integer.parseInt(o2.getNumero()); |
||
392 | } |
||
393 | }); |
||
1573 | jmachado | 394 | for(PerguntaStats guiaHeader: perguntaStatsesSalasHeader) |
1572 | jmachado | 395 | { |
1573 | jmachado | 396 | boolean found = false; |
397 | for(PerguntaStats perguntaStats : perguntaStatsSalas) |
||
398 | { |
||
399 | if(perguntaStats.getNumero().equals(guiaHeader.getNumero())) |
||
400 | { |
||
401 | unidadeRow.addColPercentageDefinedCenter(perguntaStats.getMediaEntidadeEmAvaliacaoPrint(), perguntaStats.getPercentMediaEntidadeEmAvaliacao(), true); |
||
402 | found = true; |
||
403 | break; |
||
404 | } |
||
405 | } |
||
406 | if(!found) |
||
407 | unidadeRow.addColTextCenter("--"); |
||
1572 | jmachado | 408 | } |
409 | |||
1573 | jmachado | 410 | |
1572 | jmachado | 411 | unidadeRow.addColTextCenter("" + unidadeStats.getInscritos()); |
412 | unidadeRow.addColTextCenter("" + unidadeStats.getRespostas()); |
||
413 | } |
||
414 | return tabelaComRespostasATodasAsPerguntasUnidadesSalas; |
||
1569 | jmachado | 415 | } |
1570 | jmachado | 416 | |
1572 | jmachado | 417 | private ArrayList<TabelaPerguntaComparativosUnidades> criarAnaliseConjuntaDeUnidadesAPergunta(List<PerguntaStats> perguntasAgregadasGrupo, ArrayList<UnidadeStats> unidadesStats, 1.5.0/docs/api/java/lang/String.html">String grupo, 1.5.0/docs/api/java/lang/String.html">String subgrupo) |
418 | { |
||
419 | Map<String, List<UnidadePergunta>> unidadesPerguntas = new HashMap<String, List<UnidadePergunta>>(); |
||
420 | for(UnidadeStats unidadeStats: unidadesStats) |
||
421 | { |
||
422 | for(PerguntaStats prgStatUnidade :unidadeStats.findUnidadeStatsGrupo(grupo,subgrupo).getPerguntasStats()) |
||
423 | { |
||
424 | List<UnidadePergunta> unidadesPerguntasList = unidadesPerguntas.get(prgStatUnidade.getPergunta()); |
||
425 | if(unidadesPerguntasList == null) |
||
426 | { |
||
427 | unidadesPerguntasList = new ArrayList<UnidadePergunta>(); |
||
428 | unidadesPerguntas.put(prgStatUnidade.getPergunta(),unidadesPerguntasList); |
||
429 | } |
||
430 | unidadesPerguntasList.add(new UnidadePergunta(unidadeStats,prgStatUnidade)); |
||
431 | } |
||
432 | } |
||
433 | ArrayList<TabelaPerguntaComparativosUnidades> tabelas = new ArrayList<TabelaPerguntaComparativosUnidades>(); |
||
434 | |||
435 | |||
436 | for(1.5.0/docs/api/java/lang/String.html">String pergunta: unidadesPerguntas.keySet()) |
||
437 | { |
||
438 | TabelaPerguntaComparativosUnidades tabelaPerguntaComparativosUnidades = new TabelaPerguntaComparativosUnidades(); |
||
439 | tabelas.add(tabelaPerguntaComparativosUnidades); |
||
440 | tabelaPerguntaComparativosUnidades.setPergunta(pergunta); |
||
441 | |||
442 | DataTable perguntaUnidadesTable = new DataTable(); |
||
443 | tabelaPerguntaComparativosUnidades.setTabelaComparativaUnidades(perguntaUnidadesTable); |
||
444 | DataTable.Row header = perguntaUnidadesTable.addRowHeader(); |
||
445 | header.addColTextCenter("Unidade Curricular"); |
||
446 | header.addColTextCenter("Curso"); |
||
447 | header.addColTextCenter("Insc."); |
||
448 | header.addColTextCenter("Resp."); |
||
449 | header.addColTextCenter("% Resposta"); |
||
450 | header.addColTextCenter("Média"); |
||
451 | header.addColTextCenter("Desvio"); |
||
452 | |||
453 | List<UnidadePergunta> unidadesPergunta = unidadesPerguntas.get(pergunta); |
||
454 | |||
455 | //SUPOSTAMENTE VEM SEMPRE PREENCHIDO |
||
456 | if(unidadesPergunta != null && unidadesPergunta.size() > 0) |
||
457 | tabelaPerguntaComparativosUnidades.setPerguntaNumero(unidadesPergunta.get(0).getPerguntaStats().getNumero()); |
||
458 | |||
459 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(unidadesPergunta,new Comparator<UnidadePergunta>() { |
||
460 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
461 | public int compare(UnidadePergunta o1, UnidadePergunta o2) { |
||
462 | double sub = o2.getPerguntaStats().getMediaEntidadeEmAvaliacao() - o1.getPerguntaStats().getMediaEntidadeEmAvaliacao(); |
||
463 | if(sub < 0.0) |
||
464 | return -1; |
||
465 | else if (sub > 0.0) |
||
466 | return 1; |
||
467 | else return 0; |
||
468 | } |
||
469 | }); |
||
470 | for(UnidadePergunta unidadePergunta: unidadesPergunta) |
||
471 | { |
||
472 | DataTable.Row rowUnidade = perguntaUnidadesTable.addRowNormal(); |
||
473 | |||
474 | rowUnidade.addColLabelCenter(unidadePergunta.getUnidadeStats().getNomeUnidade()); |
||
475 | rowUnidade.addColLabelCenter(unidadePergunta.getUnidadeStats().getNomeCurso()); |
||
476 | rowUnidade.addColTextRight("" + unidadePergunta.getUnidadeStats().getInscritos()); |
||
477 | rowUnidade.addColTextRight("" + unidadePergunta.getUnidadeStats().getRespostas()); |
||
478 | rowUnidade.addColTextRight("" + unidadePergunta.getUnidadeStats().getTaxaRespostaPrint0Slots()); |
||
479 | rowUnidade.addColPercentageDefinedCenter("" + unidadePergunta.getPerguntaStats().getMediaEntidadeEmAvaliacaoPrint(), unidadePergunta.getPerguntaStats().getPercentMediaEntidadeEmAvaliacao(), true); |
||
480 | rowUnidade.addColTextRight(unidadePergunta.getPerguntaStats().getDesvio()); |
||
481 | } |
||
482 | |||
483 | } |
||
484 | |||
485 | return tabelas; |
||
486 | } |
||
487 | |||
1571 | jmachado | 488 | private ChartWithDataTable criarAnaliseConjuntaDeUnidades(List<UnidadeStats> unidadesStats) |
489 | { |
||
490 | DataTable tabelaDocenteUnidade = new DataTable(); |
||
491 | try { |
||
1570 | jmachado | 492 | |
1571 | jmachado | 493 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(unidadesStats, new Comparator<UnidadeStats>() { |
494 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
495 | public int compare(UnidadeStats o1, UnidadeStats o2) { |
||
496 | return o1.getNomeUnidade().compareTo(o2.getNomeUnidade()); |
||
497 | } |
||
498 | }); |
||
499 | 1.5.0/docs/api/java/lang/String.html">String unidadeSalasPath = criarChartETabelaMediaGruposPorUnidade(500,30, unidadesStats, |
||
500 | PerguntasGrupoQueryDao.GRUPO_UNIDADE_CODE_PERGUNTAS, |
||
501 | null, |
||
502 | PerguntasGrupoQueryDao.GRUPO_SALAS_CODE_PERGUNTAS, |
||
503 | null, |
||
504 | tabelaDocenteUnidade, |
||
505 | "unidadeSalas", |
||
506 | new 1.5.0/docs/api/java/awt/Color.html">Color[]{ChartBuilderUtil.COLOR_SECTION_GREEN_DARK,ChartBuilderUtil.COLOR_SECTION_ROSE_DARK}, |
||
507 | new 1.5.0/docs/api/java/awt/Color.html">Color[]{1.5.0/docs/api/java/awt/Color.html">Color.black,1.5.0/docs/api/java/awt/Color.html">Color.black} |
||
508 | ); |
||
1570 | jmachado | 509 | |
1571 | jmachado | 510 | return |
511 | new ChartWithDataTable( |
||
512 | "Analise Conjunta de Unidades", |
||
513 | "Unidade VS Instalações/Equipamentos/Outros Recursos", |
||
514 | unidadeSalasPath, |
||
515 | tabelaDocenteUnidade); |
||
516 | |||
517 | } catch (1.5.0/docs/api/java/io/IOException.html">IOException e) { |
||
518 | logger.error(e,e); |
||
519 | } |
||
520 | return null; |
||
521 | |||
522 | } |
||
523 | |||
524 | private 1.5.0/docs/api/java/lang/String.html">String criarAnaliseConjuntaDeUnidadesOrdenadaMediaUnidades(List<UnidadeStats> unidadesStats) |
||
525 | { |
||
526 | try { |
||
527 | |||
528 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(unidadesStats,new Comparator<UnidadeStats>() { |
||
529 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
530 | public int compare(UnidadeStats o1, UnidadeStats o2) { |
||
531 | |||
532 | double sub = (o2.getUnidadeStatsGrupoUnidade().getMediasGrupo().getAvaliacaoMedia() |
||
533 | - |
||
534 | o1.getUnidadeStatsGrupoUnidade().getMediasGrupo().getAvaliacaoMedia()); |
||
535 | if(sub > 0.0) |
||
536 | return 1; |
||
537 | else if (sub < 0.0) |
||
538 | return -1; |
||
539 | return 0; |
||
540 | } |
||
541 | }); |
||
542 | 1.5.0/docs/api/java/lang/String.html">String unidadeSalasPath = criarChartETabelaMediaGruposPorUnidade(500,30, unidadesStats, |
||
543 | PerguntasGrupoQueryDao.GRUPO_UNIDADE_CODE_PERGUNTAS, |
||
544 | null, |
||
545 | PerguntasGrupoQueryDao.GRUPO_SALAS_CODE_PERGUNTAS, |
||
546 | null, |
||
547 | null, |
||
548 | "unidadeSalasOrderMediaUnidades", |
||
549 | new 1.5.0/docs/api/java/awt/Color.html">Color[]{ChartBuilderUtil.COLOR_SECTION_GREEN_DARK,ChartBuilderUtil.COLOR_SECTION_ROSE_DARK}, |
||
550 | new 1.5.0/docs/api/java/awt/Color.html">Color[]{1.5.0/docs/api/java/awt/Color.html">Color.black,1.5.0/docs/api/java/awt/Color.html">Color.black} |
||
551 | ); |
||
552 | |||
553 | return unidadeSalasPath; |
||
554 | |||
555 | } catch (1.5.0/docs/api/java/io/IOException.html">IOException e) { |
||
556 | logger.error(e,e); |
||
557 | } |
||
558 | return null; |
||
559 | |||
560 | } |
||
561 | |||
562 | private 1.5.0/docs/api/java/lang/String.html">String criarAnaliseConjuntaDeUnidadesOrdenadaMediaSalas(List<UnidadeStats> unidadesStats) |
||
563 | { |
||
564 | try { |
||
565 | |||
566 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(unidadesStats,new Comparator<UnidadeStats>() { |
||
567 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
568 | public int compare(UnidadeStats o1, UnidadeStats o2) { |
||
569 | |||
570 | double sub = (o2.getUnidadeStatsGrupoSalas().getMediasGrupo().getAvaliacaoMedia() |
||
571 | - |
||
572 | o1.getUnidadeStatsGrupoSalas().getMediasGrupo().getAvaliacaoMedia()); |
||
573 | if(sub > 0.0) |
||
574 | return 1; |
||
575 | else if (sub < 0.0) |
||
576 | return -1; |
||
577 | return 0; |
||
578 | } |
||
579 | }); |
||
580 | 1.5.0/docs/api/java/lang/String.html">String unidadeSalasPath = criarChartETabelaMediaGruposPorUnidade(500,30, unidadesStats, |
||
581 | PerguntasGrupoQueryDao.GRUPO_UNIDADE_CODE_PERGUNTAS, |
||
582 | null, |
||
583 | PerguntasGrupoQueryDao.GRUPO_SALAS_CODE_PERGUNTAS, |
||
584 | null, |
||
585 | null, |
||
586 | "unidadeSalasOrderMediaSalas", |
||
587 | new 1.5.0/docs/api/java/awt/Color.html">Color[]{ChartBuilderUtil.COLOR_SECTION_GREEN_DARK,ChartBuilderUtil.COLOR_SECTION_ROSE_DARK}, |
||
588 | new 1.5.0/docs/api/java/awt/Color.html">Color[]{1.5.0/docs/api/java/awt/Color.html">Color.black,1.5.0/docs/api/java/awt/Color.html">Color.black} |
||
589 | ); |
||
590 | |||
591 | return unidadeSalasPath; |
||
592 | |||
593 | } catch (1.5.0/docs/api/java/io/IOException.html">IOException e) { |
||
594 | logger.error(e,e); |
||
595 | } |
||
596 | return null; |
||
597 | |||
598 | } |
||
599 | |||
600 | |||
1570 | jmachado | 601 | /** |
602 | * |
||
603 | * @param semanaContagemCurso List<[count,Week,Year]> |
||
604 | */ |
||
605 | private DataTable criarEvolucaoTaxasRespostas(List<Object[]> semanaContagemCurso, int respostasRequisitadas) |
||
606 | { |
||
607 | DataTable tableEvolucaoRespostas = new DataTable(); |
||
608 | |||
609 | DataTable.Row header = tableEvolucaoRespostas.addRowHeader(); |
||
610 | |||
611 | header.addColTextCenter("Semana"); |
||
612 | header.addColTextCenter("Respostas obtidas na semana"); |
||
613 | header.addColTextCenter("Respostas Acumuladas"); |
||
614 | header.addColTextCenter("Por Responder"); |
||
615 | header.addColTextCenter("Esperadas"); |
||
616 | header.addColTextCenter("%"); |
||
617 | |||
618 | int acumuladas = 0; |
||
619 | |||
620 | 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat dateFormat = new 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat( "dd-MMM-yyyy" ); |
||
621 | |||
622 | if(semanaContagemCurso.size() > 0) |
||
623 | { |
||
624 | for(5+0%2Fdocs%2Fapi+Object">Object[] semanaObj : semanaContagemCurso) |
||
625 | { |
||
626 | 1.5.0/docs/api/java/lang/Long.html">Long count = (1.5.0/docs/api/java/lang/Long.html">Long) semanaObj[0]; |
||
627 | acumuladas += count; |
||
628 | int faltam = respostasRequisitadas - acumuladas; |
||
629 | 1.5.0/docs/api/java/lang/Integer.html">Integer semana = (1.5.0/docs/api/java/lang/Integer.html">Integer) semanaObj[1]; |
||
630 | 1.5.0/docs/api/java/lang/Integer.html">Integer ano = (1.5.0/docs/api/java/lang/Integer.html">Integer) semanaObj[2]; |
||
631 | 1.5.0/docs/api/java/lang/String.html">String percentagemPrt = ChartBuilderUtil.getPercentagemPrint0Slots(acumuladas,respostasRequisitadas); |
||
632 | double percentagem = ChartBuilderUtil.getPercentagem(acumuladas,respostasRequisitadas); |
||
633 | |||
634 | 1.5.0/docs/api/java/util/Calendar.html">Calendar calendar = 1.5.0/docs/api/java/util/Calendar.html">Calendar.getInstance(); |
||
635 | calendar.clear(); |
||
636 | |||
1571 | jmachado | 637 | calendar.set(1.5.0/docs/api/java/util/Calendar.html">Calendar.YEAR, ano); |
638 | calendar.set(1.5.0/docs/api/java/util/Calendar.html">Calendar.WEEK_OF_YEAR, semana); |
||
639 | calendar.set(1.5.0/docs/api/java/util/Calendar.html">Calendar.DAY_OF_WEEK, 7); |
||
1570 | jmachado | 640 | 1.5.0/docs/api/java/lang/String.html">String dataFinalDaSemana = dateFormat.format(calendar.getTime()); |
641 | |||
642 | DataTable.Row rowSemana = tableEvolucaoRespostas.addRowNormal(); |
||
643 | rowSemana.addColTextCenter(dataFinalDaSemana); |
||
644 | rowSemana.addColNumberRight(count + ""); |
||
645 | rowSemana.addColNumberRight(acumuladas + "").setBackgroundColor(DataTable.getColorGradientForPercentage(percentagem/100.0)); |
||
646 | rowSemana.addColNumberRight(faltam + ""); |
||
647 | rowSemana.addColNumberRight(""+ respostasRequisitadas); |
||
648 | rowSemana.addColPercentageProgressCenter(percentagemPrt); |
||
649 | } |
||
650 | } |
||
651 | return tableEvolucaoRespostas; |
||
652 | } |
||
1574 | jmachado | 653 | |
1585 | jmachado | 654 | |
1574 | jmachado | 655 | protected ILogMessages runJobServiceTask() throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
656 | { |
||
657 | long questionarioReportId = 1.5.0/docs/api/java/lang/Long.html">Long.parseLong(getParametersMap().get(ServiceJob.JOB_questionario_report_id_KEY).getObject()); |
||
658 | DefaultLogMessages logMessages = new DefaultLogMessages(); |
||
1585 | jmachado | 659 | |
660 | int cursosEncontrados = 0; |
||
661 | int cursosProcessados = 0; |
||
662 | int cursosFalhados = 0; |
||
663 | int cursosSemRespostas = 0; |
||
664 | int cursosSemUnidadesAfetas = 0; |
||
665 | int cursosComRespostas = 0; |
||
666 | |||
667 | QuestionarioReportFileGroupCursosAnoImpl reportGroup = (QuestionarioReportFileGroupCursosAnoImpl) DaoFactory.getQuestionarioReportFileGroupCursosAnoDaoImpl().load(questionarioReportId); |
||
668 | |||
669 | anoLectivo = reportGroup.getImportYear(); |
||
670 | periodos = reportGroup.getPeriodosArray(); |
||
671 | degrees = reportGroup.getDegreesArray(); |
||
672 | |||
673 | 1.5.0/docs/api/java/lang/String.html">String msg = "Starting process for Report Cursos (" + questionarioReportId + "): " + reportGroup.getTitle(); |
||
674 | serviceLogInfo(msg); |
||
675 | logger.info(msg); |
||
676 | |||
677 | |||
678 | List<String> courseCodes = QuestionariosQueryDao.findCoursesSigesCodes(reportGroup.getImportYear(), periodos, degrees); |
||
679 | |||
680 | msg = "Vai processar " + courseCodes.size() + " Cursos "; |
||
681 | serviceLogInfo(msg); |
||
682 | logger.info(msg); |
||
683 | for(1.5.0/docs/api/java/lang/String.html">String sigesCode: courseCodes) |
||
684 | { |
||
685 | if(sigesCode == null) |
||
686 | { |
||
687 | msg = "Found Course with siges code null, not known but has units in " + reportGroup.getImportYear(); |
||
688 | serviceLogInfo(msg); |
||
689 | logger.info(msg); |
||
690 | continue; |
||
691 | } |
||
692 | cursosEncontrados++; |
||
693 | |||
694 | /** COMMIT OPERATION **/ |
||
695 | setProgress((int)((((float)cursosEncontrados)/((float)courseCodes.size()))*100.0f)); |
||
696 | commitPartially(); |
||
697 | /** COMMIT OPERATION **/ |
||
698 | |||
699 | try{ |
||
700 | Course c = DaoFactory.getCourseDaoImpl().findCourseByCode(""+sigesCode); |
||
701 | msg = "(" + cursosEncontrados + "/" + courseCodes.size() + ") Found Course sigesCode: " + sigesCode + " " + c.getName() + " will start process"; |
||
702 | serviceLogInfo(msg); |
||
703 | logger.info(msg); |
||
704 | CursoPublicReport cursoReport = processCourse("" + sigesCode); |
||
705 | |||
706 | |||
707 | if(cursoReport == null) |
||
708 | cursosSemRespostas++; |
||
709 | else{ |
||
710 | 1.5.0/docs/api/java/lang/String.html">String tmpPath = cursoReport.getPathGeneratedPdfTemp(); |
||
711 | |||
712 | QuestionarioReportCursoFile q = DaoFactory.getQuestionarioReportCursoFileDaoImpl().findBySigesCode(1.5.0/docs/api/java/lang/Integer.html">Integer.parseInt(sigesCode),reportGroup.getId()); |
||
713 | if(q == null) |
||
714 | { |
||
715 | q = new QuestionarioReportCursoFileImpl(); |
||
716 | q.setReportGroup(reportGroup); |
||
717 | q.setEntityCode("" + sigesCode); |
||
718 | q.setEntityName(c.getName()); |
||
719 | //q.setCourse(c); |
||
720 | DaoFactory.getQuestionarioReportCursoFileDaoImpl().save(q); |
||
721 | } |
||
722 | |||
723 | q.setInquiridos(cursoReport.getInquiridosTotal()); |
||
724 | q.setInquiridosComResposta(cursoReport.getInquiridosComResposta()); |
||
725 | q.setRespostasRequisitadas(cursoReport.getQuestionariosReqTotal()); |
||
726 | q.setRespostas(cursoReport.getQuestionariosReqRespondidos()); |
||
727 | q.setUnidades(cursoReport.getUnidadesRequisitadas()); |
||
728 | |||
729 | |||
730 | //STATS |
||
731 | if(q.getInquiridos() == 0) |
||
732 | cursosSemUnidadesAfetas++; |
||
733 | else if(q.getRespostas() == 0) |
||
734 | cursosSemRespostas++; |
||
735 | else |
||
736 | cursosComRespostas++; |
||
737 | |||
738 | |||
739 | 1.5.0/docs/api/java/io/File.html">File tmpFile = new 1.5.0/docs/api/java/io/File.html">File(tmpPath); |
||
740 | if(q.getRepositoryStream() == null || q.getRepositoryStream().trim().length() == 0) |
||
741 | { |
||
742 | 1.5.0/docs/api/java/lang/String.html">String repositoryStreamCode = new RepositoryService().storeRepositoryFile( |
||
743 | new 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream(tmpPath), |
||
744 | "application/pdf", |
||
745 | "pdf", |
||
746 | (int)tmpFile.length(), |
||
747 | tmpFile.getName(), |
||
748 | "reports.QuestionarioReportCursoFile course: " + c.getName() + " (" + sigesCode + ") " + " ano:" + anoLectivo + " periodos:" + periodos.toString() + " degrees:" + degrees.toString(), |
||
749 | ResourceAccessControlEnum.authenticatedDomain,//Este relatório de curso é publico |
||
750 | DaoFactory.getUserDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(1))); |
||
751 | q.setRepositoryStream(repositoryStreamCode); |
||
752 | } |
||
753 | else |
||
754 | { |
||
755 | new RepositoryService().updateRepositoryFile( |
||
756 | q.getRepositoryStream(), |
||
757 | new 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream(tmpPath), |
||
758 | "application/pdf", |
||
759 | "pdf", |
||
760 | (int)tmpFile.length(), |
||
761 | tmpFile.getName(), |
||
762 | "reports.QuestionarioReportCursoFile curso: " + c.getName() + " (" + sigesCode + ") " + " ano:" + anoLectivo + " periodos:" + periodos.toString() + " degrees:" + degrees.toString(), |
||
763 | ResourceAccessControlEnum.authenticatedDomain); |
||
764 | } |
||
765 | } |
||
766 | //Final |
||
767 | cursosProcessados++; |
||
768 | }catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
769 | { |
||
770 | msg = "FAIL - Teacher with siges: " + sigesCode; |
||
771 | serviceLogError(msg,e); |
||
772 | logger.error(msg,e); |
||
773 | cursosFalhados++; |
||
774 | } |
||
775 | } |
||
776 | |||
777 | serviceLogInfo("######################################"); |
||
778 | serviceLogInfo("######################################"); |
||
779 | serviceLogInfo("#Cursos Encontrados:" + cursosEncontrados); |
||
780 | serviceLogInfo("#Cursos Processados:" + cursosProcessados); |
||
781 | serviceLogInfo("#Cursos Com Resposta:" + cursosComRespostas); |
||
782 | serviceLogInfo("#Cursos Sem Respostas:" + cursosSemRespostas); |
||
783 | serviceLogInfo("#Cursos Sem Unidades Afetas:" + cursosSemUnidadesAfetas); |
||
784 | serviceLogInfo("#Cursos Falhados:" + cursosFalhados); |
||
785 | |||
786 | logger.info("######################################"); |
||
787 | logger.info("######################################"); |
||
788 | logger.info("#Cursos Encontrados:" + cursosEncontrados); |
||
789 | logger.info("#Cursos Processados:" + cursosProcessados); |
||
790 | logger.info("#Cursos Falhados:" + cursosFalhados); |
||
791 | logger.info("#Cursos Com Resposta:" + cursosComRespostas); |
||
792 | logger.info("#Cursos Sem Respostas:" + cursosSemRespostas); |
||
793 | logger.info("#Cursos Sem Unidades Afetas:" + cursosSemUnidadesAfetas); |
||
794 | |||
795 | reportGroup = (QuestionarioReportFileGroupCursosAnoImpl) DaoFactory.getQuestionarioReportFileGroupCursosAnoDaoImpl().load(questionarioReportId); |
||
796 | reportGroup.setEntidadesEncontradas(cursosEncontrados); |
||
797 | reportGroup.setEntidadesProcessadas(cursosProcessados); |
||
798 | reportGroup.setEntidadesFalhadas(cursosFalhados); |
||
799 | reportGroup.setEntidadesComRespostas(cursosComRespostas); |
||
800 | reportGroup.setEntidadesSemRespostas(cursosSemRespostas); |
||
801 | reportGroup.setEntidadesSemUnidadesAfetas(cursosSemUnidadesAfetas); |
||
802 | |||
803 | logger.info("terminating docente reports generation"); |
||
804 | serviceLogInfo("terminating docente reports generation"); |
||
805 | logMessages.addMessage(new DefaultLogMessage("report.docente.gen.terminating", LogMessageTypeEnum.INFO)); |
||
806 | setProgress(100); |
||
807 | commitPartially(); |
||
1579 | jmachado | 808 | return logMessages; |
1574 | jmachado | 809 | } |
1569 | jmachado | 810 | } |