Subversion Repositories bacoAlunos

Rev

Rev 1627 | Rev 1705 | 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
 
1571 jmachado 3
import jomm.dao.impl.AbstractDao;
1586 jmachado 4
import jomm.utils.FilesUtils;
1571 jmachado 5
import org.apache.log4j.Logger;
6
import org.hibernate.Query;
7
import pt.estgp.estgweb.domain.OlapStarFactQuestionarioAnswer;
1586 jmachado 8
import pt.estgp.estgweb.domain.QuestionarioReportFileAno;
9
import pt.estgp.estgweb.domain.QuestionarioReportFileGroupAno;
10
import pt.estgp.estgweb.domain.dao.DaoFactory;
11
import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum;
12
import pt.estgp.estgweb.services.data.RepositoryService;
1571 jmachado 13
import pt.estgp.estgweb.services.questionarios.PedagogicoAlunosProcessor;
1574 jmachado 14
import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.queries.PerguntasGrupoQueryDao;
15
import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.queries.QueryDaoUtils;
16
import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.queries.QuestionariosQueryDao;
1576 jmachado 17
import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.reportdomains.EntityEvaluated;
18
import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.reportdomains.QuestionariosAlunosReport;
1574 jmachado 19
import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.utils.*;
1571 jmachado 20
import pt.estgp.estgweb.utils.ConfigProperties;
21
 
22
import java.awt.*;
1586 jmachado 23
import java.io.File;
24
import java.io.FileInputStream;
25
import java.io.FileNotFoundException;
1571 jmachado 26
import java.io.IOException;
27
import java.text.DecimalFormat;
28
import java.util.ArrayList;
29
import java.util.List;
30
 
1569 jmachado 31
/**
32
 * Created by jorgemachado on 16/12/16.
33
 */
1579 jmachado 34
public abstract class ReportAlunosGenerator extends ReportGenerator
1569 jmachado 35
{
36
 
1574 jmachado 37
    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(ReportAlunosGenerator.class);
1571 jmachado 38
 
1569 jmachado 39
    protected 1.5.0/docs/api/java/lang/String.html">String anoLectivo;
40
    protected 1.5.0/docs/api/java/lang/String.html">String[] periodos;
41
    protected 1.5.0/docs/api/java/lang/String.html">String[] degrees;
42
 
1574 jmachado 43
    public ReportAlunosGenerator(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) {
1569 jmachado 44
        this.anoLectivo = anoLectivo;
45
        this.periodos = periodos;
46
        this.degrees = degrees;
47
    }
1570 jmachado 48
 
49
 
1571 jmachado 50
    /**
51
     * Gera um gráfico com todas as respostas agregadas por questao para um professor
52
     * @param codes
53
     * @param anoLectivo
54
     * @param report
55
     */
1626 jmachado 56
    public static boolean criarGraficosRespostasAgregadas(1.5.0/docs/api/java/lang/String.html">String[] codes,
1571 jmachado 57
                                                        EntityEvaluated entityEvaluated,
58
                                                        1.5.0/docs/api/java/lang/String.html">String anoLectivo,
59
                                                        QuestionariosAlunosReport report,
60
                                                        List<String> codigosCurso,
61
                                                        List<String> codigosEscola,
62
                                                        double tempoMinimo,
63
                                                        RespostasAgregadasGrupoStats.RespostasAgregadasChartTable respostasAgregadasChartTable,
64
                                                        RespostasAgregadasGrupoStats respostasAgregadasGrupo,
65
                                                        1.5.0/docs/api/java/lang/String.html">String grupo,
66
                                                        1.5.0/docs/api/java/lang/String.html">String subGrupo,
67
                                                        1.5.0/docs/api/java/lang/String.html">String[] periodos,
68
                                                        1.5.0/docs/api/java/lang/String.html">String[] degrees,
69
                                                        boolean generateChart)
70
    {
71
        1.5.0/docs/api/java/lang/String.html">String periodosQuery = QueryDaoUtils.createPeriodosQuery(periodos, "quest", true);
72
        1.5.0/docs/api/java/lang/String.html">String degreesQuery = QueryDaoUtils.createDegreesQuery(degrees, "curso", true);
73
 
74
        1.5.0/docs/api/java/lang/String.html">String whereFragmentEntity = QuestionariosQueryDao.getWhereEntityCodesFragment(codes,entityEvaluated);
75
 
76
        1.5.0/docs/api/javax/management/Query.html">Query query;//*****CRIAR REPOSTAS DO GRUPO DOCENTE*****///
77
 
78
 
79
        query = AbstractDao.getCurrentSession().createQuery("" +
80
                "SELECT " +
81
                "avg(fc.intResposta) as media," +
82
                "sum(case when fc.intResposta = 1 then 1 else 0 end) as r1," +
83
                "sum(case when fc.intResposta = 2 then 1 else 0 end) as r2," +
84
                "sum(case when fc.intResposta = 3 then 1 else 0 end) as r3," +
85
                "sum(case when fc.intResposta = 4 then 1 else 0 end) as r4," +
86
                "sum(case when fc.intResposta = 5 then 1 else 0 end) as r5," +
87
                "std(fc.intResposta) as desvio," +
88
                "count(fc.id) as total, " +
89
                "prgp.pergunta as pergunta, " +
90
                "prgp.numero as numero, " +
91
                "avg(fc.tempoLevado) as tempoMedioLevado " +
92
 
93
                "FROM  " + OlapStarFactQuestionarioAnswer.class.getName() + " fc " +
94
                "JOIN fc.olapPergunta prgp " +
95
                "JOIN fc.olapTipologia tipo " +
96
                "JOIN fc.olapQuestionario quest " +
97
                "JOIN fc.olapCurso curso " +
98
                "JOIN fc.olapTimeLine timeLine " +
99
 
100
                "where " +
101
 
102
                " quest.ano = :ano " +
103
                whereFragmentEntity +
104
                "and timeLine.nome = '" + PedagogicoAlunosProcessor.getHistoryDriveConstraintStatic() + "' " +
105
                (tempoMinimo > 0 ?  " and fc.tempoLevado > :tempoLevado " : "" ) +
106
                periodosQuery +
107
                degreesQuery +
108
                (grupo == null ? "" : " and prgp.grupoCode = :grupoCode ") +
109
                (subGrupo == null ? "" : " and prgp.subGrupoCode = :subGrupoCode ") +
110
                "group by prgp.numero " +
111
                "order by prgp.numero ");
112
        if(grupo != null)
113
            query.setString("grupoCode",grupo);
114
        if(subGrupo != null)
115
            query.setString("subGrupoCode",subGrupo);
116
//        query.setString("codigoSiges",teacherCode);
117
        query.setString("ano",anoLectivo);
118
        if(tempoMinimo > 0)
119
        {
120
            query.setDouble("tempoLevado",tempoMinimo);
121
        }
122
 
1626 jmachado 123
        List<Object[]> resultsTest = query.list();
124
        if(resultsTest == null || resultsTest.size() == 0)
125
        {
126
            return false;
127
        }
1571 jmachado 128
 
1626 jmachado 129
 
1571 jmachado 130
        DataTable tableRespostasAgregadas = new DataTable();
131
 
132
 
133
 
134
        DataTable.Row header = tableRespostasAgregadas.addRowHeader();
135
        header.addColTextCenter("Questão");
136
        header.addColTextCenter("Resps.");
1627 jmachado 137
        header.addColTextCenter("Resps. Esper.");
1626 jmachado 138
        //header.addColTextCenter("Tempo Médio de Resposta (seg.)");
139
        header.addColTextCenter("% Resp.");
1571 jmachado 140
        header.addColTextCenter("Nada Satisf. %");
141
        header.addColTextCenter("Pouco Satisf. %");
142
        header.addColTextCenter("Satisf. %");
143
        header.addColTextCenter("Bastante Satisf. %");
144
        header.addColTextCenter("Muito Satisf. %");
145
        header.addColTextCenter("Média");
146
        header.addColTextCenter("Desvio Padrão");
147
 
148
        if(entityEvaluated == EntityEvaluated.DOCENTE)
149
        {
150
            header.addColTextCenter("Média dos Cursos em que Lecciona");
151
            header.addColTextCenter("Diff Cursos");
152
            header.addColTextCenter("Média das Escolas em que Lecciona");
153
            header.addColTextCenter("Diff Escolas");
154
        }
155
        else if(entityEvaluated == EntityEvaluated.CURSO)
156
        {
157
            header.addColTextCenter("Média da Escola");
158
            header.addColTextCenter("Diff Escola");
159
        }
160
        else
161
        {
162
            throw new 1.5.0/docs/api/java/lang/RuntimeException.html">RuntimeException("Não implementado");
163
        }
164
 
165
 
166
 
1626 jmachado 167
        PerguntasGrupoQueryDao.getMediasGrupo(codes, entityEvaluated, anoLectivo, report, codigosCurso, codigosEscola, grupo, subGrupo, respostasAgregadasGrupo.getMediasGrupo(), periodos, degrees);
168
 
169
 
170
        //Um ciclo por pergunta numero
1571 jmachado 171
        for(5+0%2Fdocs%2Fapi+Object">Object[] resultTest : resultsTest)
172
        {
173
            1.5.0/docs/api/java/lang/Double.html">Double tempoMedioLevado = (1.5.0/docs/api/java/lang/Double.html">Double) resultTest[10];
174
            1.5.0/docs/api/java/lang/Double.html">Double mediaDocente = (1.5.0/docs/api/java/lang/Double.html">Double) resultTest[0];
175
            1.5.0/docs/api/java/lang/Double.html">Double desvio = (1.5.0/docs/api/java/lang/Double.html">Double) resultTest[6];
176
            1.5.0/docs/api/java/lang/Long.html">Long total = (1.5.0/docs/api/java/lang/Long.html">Long) resultTest[7];
177
            double min = mediaDocente - (desvio*2);
178
            double max = mediaDocente + (desvio*2);
179
            if(max > 5) max = 5;
1626 jmachado 180
            1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat df = new 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat("#,##0.00");
1571 jmachado 181
 
182
            1.5.0/docs/api/java/lang/String.html">String questao = resultTest[8].toString();
183
            1.5.0/docs/api/java/lang/String.html">String numero = resultTest[9].toString();
184
 
185
 
186
            DataTable.Row rowUnidade = tableRespostasAgregadas.addRowNormal();
187
            rowUnidade.addColLabelCenter(questao);
188
            rowUnidade.addColTextCenter(""+total);
1626 jmachado 189
            rowUnidade.addColTextCenter("" + report.getQuestionariosReqTotal());
190
            //rowUnidade.addColTextCenter(df.format(tempoMedioLevado/1000.0));
191
            rowUnidade.addColPercentageCenter(ChartBuilderUtil.getPercentagemPrint0Slots(total, report.getQuestionariosReqTotal()), true);
1571 jmachado 192
            DataTable.Row.Col colResposta1 = rowUnidade.addColTextCenter(resultTest[1].toString());
193
            DataTable.Row.Col colResposta2 = rowUnidade.addColTextCenter(resultTest[2].toString());
194
            DataTable.Row.Col colResposta3 = rowUnidade.addColTextCenter(resultTest[3].toString());
195
            DataTable.Row.Col colResposta4 = rowUnidade.addColTextCenter(resultTest[4].toString());
196
            DataTable.Row.Col colResposta5 = rowUnidade.addColTextCenter(resultTest[5].toString());
197
 
198
            1.5.0/docs/api/java/lang/Long.html">Long respostas1 = (1.5.0/docs/api/java/lang/Long.html">Long) resultTest[1];
199
            1.5.0/docs/api/java/lang/Long.html">Long respostas2 = (1.5.0/docs/api/java/lang/Long.html">Long) resultTest[2];
200
            1.5.0/docs/api/java/lang/Long.html">Long respostas3 = (1.5.0/docs/api/java/lang/Long.html">Long) resultTest[3];
201
            1.5.0/docs/api/java/lang/Long.html">Long respostas4 = (1.5.0/docs/api/java/lang/Long.html">Long) resultTest[4];
202
            1.5.0/docs/api/java/lang/Long.html">Long respostas5 = (1.5.0/docs/api/java/lang/Long.html">Long) resultTest[5];
203
 
204
            if(respostas1 >= respostas2 && respostas1 >= respostas3 && respostas1 >= respostas4 && respostas1 >= respostas5)
205
            {
206
                colResposta1.setBackgroundColor(ChartBuilderUtil.COLOR_1_HEX);
207
            }else if(respostas2 >= respostas1  && respostas2 >= respostas3 && respostas2 >= respostas4 && respostas2 >= respostas5)
208
            {
209
                colResposta2.setBackgroundColor(ChartBuilderUtil.COLOR_2_HEX);
210
            }else if(respostas3 >= respostas1  && respostas3 >= respostas2 && respostas3 >= respostas4 && respostas3 >= respostas5)
211
            {
212
                colResposta3.setBackgroundColor(ChartBuilderUtil.COLOR_3_HEX);
213
            }else if(respostas4 >= respostas1  && respostas4 >= respostas2 && respostas4 >= respostas3 && respostas4 >= respostas5)
214
            {
215
                colResposta4.setBackgroundColor(ChartBuilderUtil.COLOR_4_HEX);
216
            }else if(respostas5 >= respostas1  && respostas5 >= respostas2 && respostas5 >= respostas3 && respostas5 >= respostas4)
217
            {
218
                colResposta5.setBackgroundColor(ChartBuilderUtil.COLOR_5_HEX);
219
            }
220
 
221
 
222
 
223
 
224
 
225
            double mediaCursos = QueryDaoUtils.getMediaCursos(codigosCurso, anoLectivo, numero, tempoMinimo, grupo,subGrupo, periodos, degrees);
226
            double mediaEscolas = QueryDaoUtils.getMediaEscolas(codigosEscola, anoLectivo, numero, tempoMinimo, grupo,subGrupo, periodos, degrees);
227
 
228
 
229
 
230
            try {
231
                PerguntaStats perguntaStatsAndChart;
232
 
233
                if(tempoMinimo <= 0 && generateChart)
234
                {
235
                    List<String> info = new ArrayList<String>();
236
                    info.add("Desvio Padrão: " + df.format(desvio));
237
                    info.add("Média: " + df.format(mediaDocente));
238
                    info.add("Respostas: " + total);
239
                    info.add("95% respostas entre: " + df.format(min) + " e " + df.format(max));
240
                    perguntaStatsAndChart = ChartBuilderUtil.createChartRespostasPergunta(questao, info,
241
                            new int[]{
242
                                    ((1.5.0/docs/api/java/lang/Long.html">Long) resultTest[1]).intValue(),
243
                                    ((1.5.0/docs/api/java/lang/Long.html">Long) resultTest[2]).intValue(),
244
                                    ((1.5.0/docs/api/java/lang/Long.html">Long) resultTest[3]).intValue(),
245
                                    ((1.5.0/docs/api/java/lang/Long.html">Long) resultTest[4]).intValue(),
246
                                    ((1.5.0/docs/api/java/lang/Long.html">Long) resultTest[5]).intValue(),
247
                            }, "resposta" + tempoMinimo + numero, report.getQuestionariosReqRespondidos());
248
 
249
                }
250
                else
251
                    perguntaStatsAndChart = new PerguntaStats();
252
 
253
                perguntaStatsAndChart.setPergunta(questao);
254
                perguntaStatsAndChart.setNumero(numero);
255
                perguntaStatsAndChart.setGrupo(grupo);
256
                perguntaStatsAndChart.setSubGrupo(subGrupo);
1572 jmachado 257
                perguntaStatsAndChart.setDesvio(df.format(desvio));
1571 jmachado 258
                perguntaStatsAndChart.setMediaCursosPrint(df.format(mediaCursos));
259
                perguntaStatsAndChart.setMediaEscolasPrint(df.format(mediaEscolas));
260
                perguntaStatsAndChart.setMediaCursos(mediaCursos);
261
                perguntaStatsAndChart.setMediaEscolas(mediaEscolas);
262
                perguntaStatsAndChart.setMediaEntidadeEmAvaliacao(mediaDocente);
263
                perguntaStatsAndChart.setMediaEntidadeEmAvaliacaoPrint(df.format(mediaDocente));
264
                perguntaStatsAndChart.setPercentMediaCursos("" + ((int) ((mediaCursos / 5.0) * 100.0)));
265
                perguntaStatsAndChart.setPercentMediaEscolas("" + ((int) ((mediaEscolas / 5.0) * 100.0)));
266
                perguntaStatsAndChart.setPercentMediaEntidadeEmAvaliacao("" + ((int)((mediaDocente/5.0)*100.0)));
267
 
268
                perguntaStatsAndChart.setDiffMediaCurso(mediaDocente - mediaCursos);
269
                perguntaStatsAndChart.setDiffMediaEscola(mediaDocente - mediaEscolas);
270
                perguntaStatsAndChart.setDiffMediaCursoPrint(df.format(mediaDocente - mediaCursos));
271
                perguntaStatsAndChart.setDiffMediaEscolaPrint(df.format(mediaDocente - mediaEscolas));
272
 
273
                rowUnidade.addColPercentageDefinedCenter(perguntaStatsAndChart.getMediaEntidadeEmAvaliacaoPrint(), perguntaStatsAndChart.getPercentMediaEntidadeEmAvaliacao(), true);
274
                rowUnidade.addColTextCenter(df.format(desvio));
275
                if(entityEvaluated == EntityEvaluated.DOCENTE)
276
                {
277
                    rowUnidade.addColPercentageDefinedCenter(perguntaStatsAndChart.getMediaCursosPrint(),perguntaStatsAndChart.getPercentMediaCursos(),true);
278
                    rowUnidade.addColNumberRight(perguntaStatsAndChart.getDiffMediaCursoPrint()).setBackgroundColor(ChartBuilderUtil.getBackgroundColorDiff(perguntaStatsAndChart.getDiffMediaCurso()));
279
                }
280
                else if(entityEvaluated == EntityEvaluated.CURSO)
281
                {
1579 jmachado 282
                    //do nothing
1571 jmachado 283
                }
284
                else
285
                {
286
                    throw new 1.5.0/docs/api/java/lang/RuntimeException.html">RuntimeException("Não implementado"); //para lembrar se implementar o de cima e esquecer este
287
                }
288
                rowUnidade.addColPercentageDefinedCenter(perguntaStatsAndChart.getMediaEscolasPrint(),perguntaStatsAndChart.getPercentMediaEscolas(),true);
289
                rowUnidade.addColNumberRight(perguntaStatsAndChart.getDiffMediaEscolaPrint()).setBackgroundColor(ChartBuilderUtil.getBackgroundColorDiff(perguntaStatsAndChart.getDiffMediaEscola()));
290
 
291
                respostasAgregadasChartTable.getRespostasAgregadasCharts().addChart(perguntaStatsAndChart);
292
                respostasAgregadasChartTable.setRespostasTable(tableRespostasAgregadas);
1626 jmachado 293
                //Adicionar o Grafico ao perguntaStats deste grupo
1571 jmachado 294
                if(tempoMinimo <= 0)
295
                {
296
                    //adicionada segunda vez para ficar na classe de agregação de respostas e medias
297
                    //legadamente ja estavam no chart mas metem-se aqui tambem pois estavam em rows e afins
298
                    respostasAgregadasGrupo.getPerguntasStats().add(perguntaStatsAndChart);
299
                }
300
 
301
            } catch (1.5.0/docs/api/java/io/IOException.html">IOException e) {
302
                logger.error(e,e);
303
            }
304
        }
1626 jmachado 305
        respostasAgregadasGrupo.setValid(true);
306
        return true;
1571 jmachado 307
 
308
    }
309
 
310
 
311
    protected 1.5.0/docs/api/java/lang/String.html">String criarChartETabelaMediaGruposPorUnidade(int width,int heightCategory,List<UnidadeStats> unidadesStats,1.5.0/docs/api/java/lang/String.html">String grupo1,1.5.0/docs/api/java/lang/String.html">String subgrupo1, 1.5.0/docs/api/java/lang/String.html">String grupo2,1.5.0/docs/api/java/lang/String.html">String subgrupo2,DataTable table,1.5.0/docs/api/java/lang/String.html">String tmpPathPrefix,1.5.0/docs/api/java/awt/Color.html">Color[] barColors,1.5.0/docs/api/java/awt/Color.html">Color[] labelsColors) throws 1.5.0/docs/api/java/io/IOException.html">IOException
312
    {
313
        //Se houver subgrupo usa-se a label do subgrupo
314
        1.5.0/docs/api/java/lang/String.html">String grupo1propertyIndex = subgrupo1 != null ?  ConfigProperties.getProperty("questionario.group.inverse." + subgrupo1) : ConfigProperties.getProperty("questionario.group.inverse." + grupo1);
315
        1.5.0/docs/api/java/lang/String.html">String grupo1Label = ConfigProperties.getProperty("questionario.group" + grupo1propertyIndex + ".title");
316
        1.5.0/docs/api/java/lang/String.html">String grupo2propertyIndex = subgrupo2 != null ? grupo2propertyIndex = ConfigProperties.getProperty("questionario.group.inverse." + subgrupo2) : ConfigProperties.getProperty("questionario.group.inverse." + grupo2);
317
        1.5.0/docs/api/java/lang/String.html">String grupo2Label = ConfigProperties.getProperty("questionario.group" + grupo2propertyIndex + ".title");
318
 
319
        if(table != null)
320
        {
321
            DataTable.Row headerDefinition = table.addRowHeader();
322
            headerDefinition.setInvisible(true);
323
            headerDefinition.addColTextCenter("Unidade Inv").setWidth("20%");
324
            headerDefinition.addColTextCenter("Código Inv");
325
            headerDefinition.addColTextCenter("Curso Inv").setWidth("20%");
326
            headerDefinition.addColTextCenter("Código Curso Inv");
327
            headerDefinition.addColTextCenter("Respostas Inv");
328
            headerDefinition.addColTextCenter("Média Inv");
329
            headerDefinition.addColTextCenter("Desvio Inv");
330
            headerDefinition.addColTextCenter("Média Curso Inv");
331
            headerDefinition.addColTextCenter("Média Escola Inv");
332
            headerDefinition.addColTextCenter("Média Inv");
333
            headerDefinition.addColTextCenter("Desvio Inv");
334
            headerDefinition.addColTextCenter("Média Curso Inv");
335
            headerDefinition.addColTextCenter("Média Escola Inv");
336
 
337
            DataTable.Row header = table.addRowHeader();
338
 
339
 
340
            header.addColInvisible().setColspan(5);
341
            DataTable.Row.Col colgrupo1 = header.addColTextCenter(grupo1Label);
342
            DataTable.Row.Col colgrupo2 =  header.addColTextCenter(grupo2Label);
343
            colgrupo1.setColspan(4);
344
            colgrupo2.setColspan(4);
345
 
346
            colgrupo1.setBackgroundColor(ChartBuilderUtil.getRgbXslColor(barColors[0]));
347
            colgrupo2.setBackgroundColor(ChartBuilderUtil.getRgbXslColor(barColors[1]));
348
 
349
            DataTable.Row header2 = table.addRowHeader();
350
            header2.addColTextCenter("Unidade");
351
            header2.addColTextCenter("Código");
352
            header2.addColTextCenter("Curso");
353
            header2.addColTextCenter("Código Curso");
354
            header2.addColTextCenter("Resps");
355
            header2.addColTextCenter("Média").setBackgroundColor(colgrupo1.getBackgroundColor());
356
            header2.addColTextCenter("Desvio").setBackgroundColor(colgrupo1.getBackgroundColor());
357
            header2.addColTextCenter("Média Curso").setBackgroundColor(colgrupo1.getBackgroundColor());
358
            header2.addColTextCenter("Média Escola").setBackgroundColor(colgrupo1.getBackgroundColor());
359
            header2.addColTextCenter("Média").setBackgroundColor(colgrupo2.getBackgroundColor());
360
            header2.addColTextCenter("Desvio").setBackgroundColor(colgrupo2.getBackgroundColor());
361
            header2.addColTextCenter("Média Curso").setBackgroundColor(colgrupo2.getBackgroundColor());
362
            header2.addColTextCenter("Média Escola").setBackgroundColor(colgrupo2.getBackgroundColor());
363
        }
364
 
365
        double valores[][] = new double[unidadesStats.size()][2];
366
        1.5.0/docs/api/java/lang/String.html">String [] categories = new 1.5.0/docs/api/java/lang/String.html">String[unidadesStats.size()];
367
        int i = 0;
368
 
1626 jmachado 369
        1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat df =new 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat("#,##0.00");
1571 jmachado 370
        for(UnidadeStats unidadeStats : unidadesStats)
371
        {
372
            UnidadeStats.UnidadeStatsGrupo unidadeStatsGrupo1 = unidadeStats.findUnidadeStatsGrupo(grupo1,subgrupo1);
373
            UnidadeStats.UnidadeStatsGrupo unidadeStatsGrupo2 = unidadeStats.findUnidadeStatsGrupo(grupo2,subgrupo2);
374
            valores[i][0] = unidadeStatsGrupo1.getMediasGrupo().getAvaliacaoMedia();
375
            valores[i][1] = unidadeStatsGrupo2.getMediasGrupo().getAvaliacaoMedia();
376
            categories[i] = unidadeStats.getNomeUnidadeComCursoAbreviado();
377
            i++;
378
 
379
            if(table != null)
380
            {
381
                DataTable.Row rowUnit = table.addRowNormal();
382
                rowUnit.addColTextCenter(unidadeStats.getNomeUnidade());
383
                rowUnit.addColTextCenter(unidadeStats.getCodigoUnidade());
384
                rowUnit.addColTextCenter(unidadeStats.getNomeCurso());
385
                rowUnit.addColTextCenter(unidadeStats.getCodigoCurso());
386
                rowUnit.addColNumberRight("" + unidadeStats.getRespostas());
387
 
388
                rowUnit.addColPercentageDefinedCenter(df.format(unidadeStatsGrupo1.getMediasGrupo().getAvaliacaoMedia()), unidadeStatsGrupo1.getMediasGrupo().getPercentAvaliacaoMediaForTables(), true);
389
                rowUnit.addColNumberRight(df.format(unidadeStatsGrupo1.getMediasGrupo().getDesvioPadrao()));
390
                rowUnit.addColPercentageDefinedCenter(df.format(unidadeStatsGrupo1.getMediasGrupo().getMediaGlobalNosCursos()), unidadeStatsGrupo1.getMediasGrupo().getPercentMediaGlobalNosCursosForTables(), true);
391
                rowUnit.addColPercentageDefinedCenter(df.format(unidadeStatsGrupo1.getMediasGrupo().getMediaGlobalNasEscolas()), unidadeStatsGrupo1.getMediasGrupo().getPercentMediaGlobalNasEscolasForTables(), true);
392
 
393
                rowUnit.addColPercentageDefinedCenter(df.format(unidadeStatsGrupo2.getMediasGrupo().getAvaliacaoMedia()), unidadeStatsGrupo2.getMediasGrupo().getPercentAvaliacaoMediaForTables(), true);
394
                rowUnit.addColNumberRight(df.format(unidadeStatsGrupo2.getMediasGrupo().getDesvioPadrao()));
395
                rowUnit.addColPercentageDefinedCenter(df.format(unidadeStatsGrupo2.getMediasGrupo().getMediaGlobalNosCursos()), unidadeStatsGrupo2.getMediasGrupo().getPercentMediaGlobalNosCursosForTables(), true);
396
                rowUnit.addColPercentageDefinedCenter(df.format(unidadeStatsGrupo2.getMediasGrupo().getMediaGlobalNasEscolas()), unidadeStatsGrupo2.getMediasGrupo().getPercentMediaGlobalNasEscolasForTables(), true);
397
            }
398
 
399
        }
400
 
401
        1.5.0/docs/api/java/lang/String.html">String path = ChartBuilderUtil.createBarChartBarsCategories(
402
                new 1.5.0/docs/api/java/lang/String.html">String[]{grupo1Label,grupo2Label},
403
                categories,
404
                barColors,
405
                labelsColors,
406
                valores,
407
                0,5, tmpPathPrefix + "unidadesConjuntas",width,heightCategory);
408
        return path;
409
    }
1586 jmachado 410
 
411
    public 1.5.0/docs/api/java/lang/String.html">String generateBigDataCSV(1.5.0/docs/api/java/lang/String.html">String[] periodos,1.5.0/docs/api/java/lang/String.html">String[] degrees)
412
    {
413
        //ZipOutputStream()
414
        //AbstractDao.getCurrentSession().
415
        return null;
416
    }
417
 
418
    public void zipFolder(QuestionarioReportFileGroupAno q, 1.5.0/docs/api/java/io/File.html">File reportGroupFolder,1.5.0/docs/api/java/lang/String.html">String desc,ResourceAccessControlEnum access) throws 1.5.0/docs/api/java/io/IOException.html">IOException
419
    {
420
        1.5.0/docs/api/java/lang/String.html">String zipFilePath =  reportGroupFolder.getAbsolutePath() + ".zip";
421
        FilesUtils.zipFolder(reportGroupFolder.getAbsolutePath(), zipFilePath);
422
        FilesUtils.delete(reportGroupFolder.getAbsolutePath());
423
        1.5.0/docs/api/java/io/File.html">File zipFile = new 1.5.0/docs/api/java/io/File.html">File(zipFilePath);
424
 
425
        if(q.getRepositoryStreamZipFile() == null || q.getRepositoryStreamZipFile().trim().length() == 0)
426
        {
427
            1.5.0/docs/api/java/lang/String.html">String repositoryStreamCode = new RepositoryService().storeRepositoryFile(
428
                    new 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream(zipFile),
429
                    "application/zip",
430
                    "zip",
431
                    (int)zipFile.length(),
432
                    zipFile.getName(),
433
                    desc,
434
                    access,
1703 jmachado 435
                    null, DaoFactory.getUserDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(1)));
1586 jmachado 436
            q.setRepositoryStreamZipFile(repositoryStreamCode);
437
        }
438
        else
439
        {
440
            new RepositoryService().updateRepositoryFile(
441
                    q.getRepositoryStreamZipFile(),
442
                    new 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream(zipFile),
443
                    "application/zip",
444
                    "zip",
445
                    (int)zipFile.length(),
446
                    zipFile.getName(),
447
                    desc,
448
                    access);
449
        }
450
        zipFile.delete();
451
    }
452
 
453
    protected void sendPdfToRepository(QuestionarioReportFileAno reportFile, 1.5.0/docs/api/java/io/File.html">File tmpFile, 1.5.0/docs/api/java/lang/String.html">String descricao,ResourceAccessControlEnum access) throws 1.5.0/docs/api/java/io/FileNotFoundException.html">FileNotFoundException {
454
        if(reportFile.getRepositoryStream() == null || reportFile.getRepositoryStream().trim().length() == 0)
455
        {
456
            1.5.0/docs/api/java/lang/String.html">String repositoryStreamCode = new RepositoryService().storeRepositoryFile(
457
                    new 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream(tmpFile),
458
                    "application/pdf",
459
                    "pdf",
460
                    (int)tmpFile.length(),
461
                    tmpFile.getName(),
462
                    descricao,
463
                    access,//Este relatório de curso é publico
1703 jmachado 464
                    null,
1586 jmachado 465
                    DaoFactory.getUserDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(1)));
466
            reportFile.setRepositoryStream(repositoryStreamCode);
467
        }
468
        else
469
        {
470
            new RepositoryService().updateRepositoryFile(
471
                    reportFile.getRepositoryStream(),
472
                    new 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream(tmpFile),
473
                    "application/pdf",
474
                    "pdf",
475
                    (int)tmpFile.length(),
476
                    tmpFile.getName(),
477
                    descricao,
478
                    access);
479
        }
480
    }
1569 jmachado 481
}