Search in sources :

Example 36 with IndicacaoAlunoDTO

use of com.tomasio.projects.trainning.dto.IndicacaoAlunoDTO in project trainning by fernandotomasio.

the class EXC002CSV method makeReport.

@Override
public void makeReport() {
    AtividadesEnsinoService service = (AtividadesEnsinoService) services.get("atividadesEnsinoService");
    OrganizationalService organizationalService = (OrganizationalService) services.get("organizationalService");
    Writer writter = null;
    try {
        writter = new OutputStreamWriter(os, "UTF-8");
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(EXC002CSV.class.getName()).log(Level.SEVERE, null, ex);
    }
    BufferedWriter bufferedWriter = new BufferedWriter(writter);
    // recuperar paramentro turmaId
    Long turmaId = (Long) params.get("turmaId");
    TurmaDTO turma = service.findTurmaEfetiva(turmaId);
    // Recuperar parametro sobre filtro por status da indicação
    String statusIndicacao = "";
    statusIndicacao += (String) params.get("status");
    if ("CONC".equals(statusIndicacao)) {
        // mostrar conclusoes
        List<ConclusaoDTO> conclusoes = new ArrayList<ConclusaoDTO>();
        ConclusaoDTO[] concluidosComComparecimento = service.findAllConcluidosByTurma(turmaId, true);
        conclusoes.addAll(Arrays.asList(concluidosComComparecimento));
        ConclusaoDTO[] concluidosSemComparecimento = service.findAllConcluidosByTurma(turmaId, false);
        conclusoes.addAll(Arrays.asList(concluidosSemComparecimento));
        for (ConclusaoDTO conclusao : conclusoes) {
            try {
                MatriculaDTO matricula = service.findMatricula(conclusao.getMatricula().getId());
                PessoaDTO pessoa = organizationalService.findPessoa(matricula.getPessoa().getId());
                /*
                     if (apresentacao instanceof ApresentacaoDTO) {
                     bufferedWriter.write("ALUNO");
                     } else {
                     bufferedWriter.write("INSTRUTOR");
                     }
                     */
                bufferedWriter.write("ALUNO");
                bufferedWriter.write(",");
                if (turma != null) {
                    bufferedWriter.write(turma.getCurso().getCodigo() + "-" + turma.getNumeroTurma());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getPessoa().getPosto() != null) {
                    bufferedWriter.write(matricula.getPessoa().getPosto());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getPessoa().getQuadro() != null) {
                    bufferedWriter.write(matricula.getPessoa().getQuadro());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getPessoa().getEspecialidade() != null) {
                    bufferedWriter.write(matricula.getPessoa().getEspecialidade());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getPessoa().getNome() != null) {
                    bufferedWriter.write(matricula.getPessoa().getNome());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getPessoa().getNomeGuerra() != null) {
                    bufferedWriter.write(matricula.getPessoa().getNomeGuerra());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getOrganizacao() != null && pessoa.getOrganizacao().getSigla() != null) {
                    bufferedWriter.write(pessoa.getOrganizacao().getSigla());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getIndicacao().getEmail() != null) {
                    bufferedWriter.write(matricula.getIndicacao().getEmail());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getIndicacao().getTelefone() != null) {
                    bufferedWriter.write(matricula.getIndicacao().getTelefone());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getIndicacao().getTelefoneCelular() != null) {
                    bufferedWriter.write(matricula.getIndicacao().getTelefoneCelular());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getPessoa().getSaram() != null) {
                    bufferedWriter.write(matricula.getPessoa().getSaram());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getPessoa().getCpf() != null) {
                    bufferedWriter.write(matricula.getPessoa().getCpf());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (conclusao.isComAproveitamento()) {
                    bufferedWriter.write("CONCLUIU COM APROVEITAMENTO");
                } else {
                    bufferedWriter.write("NÃO CONCLUIU");
                }
                bufferedWriter.write(",");
                // obs
                if (conclusao.getObservacao() != null) {
                    bufferedWriter.write(conclusao.getObservacao());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                // parecer
                if (conclusao.getParecer() != null) {
                    bufferedWriter.write(conclusao.getParecer());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                bufferedWriter.write(",");
                // solicitação da Seção de Avaliação do ILA
                if (matricula.getIndicacao().getChefia() != null) {
                    bufferedWriter.write(matricula.getIndicacao().getChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getIndicacao().getEmailChefia() != null) {
                    bufferedWriter.write(matricula.getIndicacao().getEmailChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getIndicacao().getTelefoneChefia() != null) {
                    bufferedWriter.write(matricula.getIndicacao().getTelefoneChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                // não está retornando
                if (matricula.getIndicacao().getTelefoneOM() != null) {
                    bufferedWriter.write(matricula.getIndicacao().getTelefoneOM());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.newLine();
            } catch (IOException ex) {
                Logger.getLogger(EXC002CSV.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        try {
            bufferedWriter.flush();
            bufferedWriter.close();
        } catch (IOException ex) {
            Logger.getLogger(EXC002CSV.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else if ("APRE".equals(statusIndicacao)) {
        // mostrar apenas os apresentados
        List<ApresentacaoDTO> apresentacoes = new ArrayList<ApresentacaoDTO>();
        // IndicacaoDTO[] indicacoesInstrutores = service.findAllIndicacoesInstrutoresSelecionados(turmaId);
        // indicacoes.addAll(Arrays.asList(indicacoesInstrutores));
        ApresentacaoDTO[] indicacoesAlunosApresentados = service.findAllApresentadosByTurmaId(turmaId);
        apresentacoes.addAll(Arrays.asList(indicacoesAlunosApresentados));
        ApresentacaoDTO[] indicacoesAlunosNaoApresentados = service.findAllNaoApresentadosByTurma(turmaId);
        apresentacoes.addAll(Arrays.asList(indicacoesAlunosNaoApresentados));
        for (ApresentacaoDTO apresentacao : apresentacoes) {
            try {
                PessoaDTO pessoa = organizationalService.findPessoa(apresentacao.getMatricula().getPessoa().getId());
                /*
                     if (apresentacao instanceof ApresentacaoDTO) {
                     bufferedWriter.write("ALUNO");
                     } else {
                     bufferedWriter.write("INSTRUTOR");
                     }
                     */
                bufferedWriter.write("ALUNO");
                bufferedWriter.write(",");
                if (turma != null) {
                    bufferedWriter.write(turma.getCurso().getCodigo() + "-" + turma.getNumeroTurma());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (apresentacao.getMatricula().getPessoa().getPosto() != null) {
                    bufferedWriter.write(apresentacao.getMatricula().getPessoa().getPosto());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (apresentacao.getMatricula().getPessoa().getQuadro() != null) {
                    bufferedWriter.write(apresentacao.getMatricula().getPessoa().getQuadro());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (apresentacao.getMatricula().getPessoa().getEspecialidade() != null) {
                    bufferedWriter.write(apresentacao.getMatricula().getPessoa().getEspecialidade());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (apresentacao.getMatricula().getPessoa().getNome() != null) {
                    bufferedWriter.write(apresentacao.getMatricula().getPessoa().getNome());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (apresentacao.getMatricula().getPessoa().getNomeGuerra() != null) {
                    bufferedWriter.write(apresentacao.getMatricula().getPessoa().getNomeGuerra());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getOrganizacao() != null && pessoa.getOrganizacao().getSigla() != null) {
                    bufferedWriter.write(pessoa.getOrganizacao().getSigla());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (apresentacao.getMatricula().getIndicacao().getEmail() != null) {
                    bufferedWriter.write(apresentacao.getMatricula().getIndicacao().getEmail());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (apresentacao.getMatricula().getIndicacao().getTelefone() != null) {
                    bufferedWriter.write(apresentacao.getMatricula().getIndicacao().getTelefone());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (apresentacao.getMatricula().getIndicacao().getTelefoneCelular() != null) {
                    bufferedWriter.write(apresentacao.getMatricula().getIndicacao().getTelefoneCelular());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (apresentacao.getMatricula().getPessoa().getSaram() != null) {
                    bufferedWriter.write(apresentacao.getMatricula().getPessoa().getSaram());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (apresentacao.getMatricula().getPessoa().getCpf() != null) {
                    bufferedWriter.write(apresentacao.getMatricula().getPessoa().getCpf());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (apresentacao.isComparecimento()) {
                    bufferedWriter.write("COMPARECEU");
                } else {
                    bufferedWriter.write("NÃO COMPARECEU");
                }
                bufferedWriter.write(",");
                // obs
                if (apresentacao.getObservacao() != null) {
                    bufferedWriter.write(apresentacao.getObservacao());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                bufferedWriter.write(",");
                // solicitação da Seção de Avaliação do ILA
                if (apresentacao.getMatricula().getIndicacao().getChefia() != null) {
                    bufferedWriter.write(apresentacao.getMatricula().getIndicacao().getChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (apresentacao.getMatricula().getIndicacao().getEmailChefia() != null) {
                    bufferedWriter.write(apresentacao.getMatricula().getIndicacao().getEmailChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (apresentacao.getMatricula().getIndicacao().getTelefoneChefia() != null) {
                    bufferedWriter.write(apresentacao.getMatricula().getIndicacao().getTelefoneChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                // não está retornando
                if (apresentacao.getMatricula().getIndicacao().getTelefoneOM() != null) {
                    bufferedWriter.write(apresentacao.getMatricula().getIndicacao().getTelefoneOM());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.newLine();
            } catch (IOException ex) {
                Logger.getLogger(EXC002CSV.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        try {
            bufferedWriter.flush();
            bufferedWriter.close();
        } catch (IOException ex) {
            Logger.getLogger(EXC002CSV.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else if ("MTCL".equals(statusIndicacao)) {
        // mostrar apenas os matriculados
        List<MatriculaDTO> matriculas = new ArrayList<MatriculaDTO>();
        MatriculaDTO[] matriculasInstrutores = service.findAllMatriculasInstrutores(turmaId);
        matriculas.addAll(Arrays.asList(matriculasInstrutores));
        MatriculaDTO[] matriculasAlunos = service.findAllMatriculasAlunos(turmaId);
        matriculas.addAll(Arrays.asList(matriculasAlunos));
        for (MatriculaDTO matricula : matriculas) {
            try {
                PessoaDTO pessoa = organizationalService.findPessoa(matricula.getPessoa().getId());
                if (matricula instanceof MatriculaAlunoDTO) {
                    bufferedWriter.write("ALUNO");
                } else {
                    bufferedWriter.write("INSTRUTOR");
                }
                bufferedWriter.write(",");
                if (turma != null) {
                    bufferedWriter.write(turma.getCurso().getCodigo() + "-" + turma.getNumeroTurma());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getPessoa().getPosto() != null) {
                    bufferedWriter.write(matricula.getPessoa().getPosto());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getPessoa().getQuadro() != null) {
                    bufferedWriter.write(matricula.getPessoa().getQuadro());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getPessoa().getEspecialidade() != null) {
                    bufferedWriter.write(matricula.getPessoa().getEspecialidade());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getPessoa().getNome() != null) {
                    bufferedWriter.write(matricula.getPessoa().getNome());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getPessoa().getNomeGuerra() != null) {
                    bufferedWriter.write(matricula.getPessoa().getNomeGuerra());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getOrganizacao() != null && pessoa.getOrganizacao().getSigla() != null) {
                    bufferedWriter.write(pessoa.getOrganizacao().getSigla());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getIndicacao().getEmail() != null) {
                    bufferedWriter.write(matricula.getIndicacao().getEmail());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getIndicacao().getTelefone() != null) {
                    bufferedWriter.write(matricula.getIndicacao().getTelefone());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getIndicacao().getTelefoneCelular() != null) {
                    bufferedWriter.write(matricula.getIndicacao().getTelefoneCelular());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getPessoa().getSaram() != null) {
                    bufferedWriter.write(matricula.getPessoa().getSaram());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getPessoa().getCpf() != null) {
                    bufferedWriter.write(matricula.getPessoa().getCpf());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                // não está retornando
                if (matricula.getIndicacao().getStatus() != null) {
                    bufferedWriter.write(matricula.getIndicacao().getStatus());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                CancelamentoMatriculaDTO cancelamento = new CancelamentoMatriculaDTO();
                if (matricula.isCancelada()) {
                    bufferedWriter.write("MATRICULA CANCELADA");
                    // buscar cancelamento
                    cancelamento = service.findCancelamentoMatriculaByMatricula(matricula.getId());
                } else {
                    bufferedWriter.write("MATRICULADO NO CURSO ");
                }
                bufferedWriter.write(",");
                // data cancelameno
                if (matricula.isCancelada()) {
                    SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
                    bufferedWriter.write(df.format(cancelamento.getDataCancelamento()));
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                // obs cancelamento
                if (matricula.isCancelada()) {
                    bufferedWriter.write(cancelamento.getObservacao());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                bufferedWriter.write(",");
                // solicitação da Seção de Avaliação do ILA
                if (matricula.getIndicacao().getChefia() != null) {
                    bufferedWriter.write(matricula.getIndicacao().getChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getIndicacao().getEmailChefia() != null) {
                    bufferedWriter.write(matricula.getIndicacao().getEmailChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (matricula.getIndicacao().getTelefoneChefia() != null) {
                    bufferedWriter.write(matricula.getIndicacao().getTelefoneChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                // não está retornando
                if (matricula.getIndicacao().getTelefoneOM() != null) {
                    bufferedWriter.write(matricula.getIndicacao().getTelefoneOM());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.newLine();
            } catch (IOException ex) {
                Logger.getLogger(EXC002CSV.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        try {
            bufferedWriter.flush();
            bufferedWriter.close();
        } catch (IOException ex) {
            Logger.getLogger(EXC002CSV.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else if ("PRE MTCL".equals(statusIndicacao)) {
        // mostrar apenas os PRE matriculados
        // listar instrutores
        PreMatriculaDTO[] preMatriculasInstrutores = service.findAllPreMatriculasInstrutores(turmaId);
        for (PreMatriculaDTO preMatricula : preMatriculasInstrutores) {
            try {
                PessoaDTO pessoa = organizationalService.findPessoa(preMatricula.getPessoa().getId());
                bufferedWriter.write("INSTRUTOR");
                bufferedWriter.write(",");
                if (turma != null) {
                    bufferedWriter.write(turma.getCurso().getCodigo() + "-" + turma.getNumeroTurma());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getPessoa().getPosto() != null) {
                    bufferedWriter.write(preMatricula.getPessoa().getPosto());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getPessoa().getQuadro() != null) {
                    bufferedWriter.write(preMatricula.getPessoa().getQuadro());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getPessoa().getEspecialidade() != null) {
                    bufferedWriter.write(preMatricula.getPessoa().getEspecialidade());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getPessoa().getNome() != null) {
                    bufferedWriter.write(preMatricula.getPessoa().getNome());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getPessoa().getNomeGuerra() != null) {
                    bufferedWriter.write(preMatricula.getPessoa().getNomeGuerra());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getOrganizacao() != null && pessoa.getOrganizacao().getSigla() != null) {
                    bufferedWriter.write(pessoa.getOrganizacao().getSigla());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getIndicacao().getEmail() != null) {
                    bufferedWriter.write(preMatricula.getIndicacao().getEmail());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getIndicacao().getTelefone() != null) {
                    bufferedWriter.write(preMatricula.getIndicacao().getTelefone());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getIndicacao().getTelefoneCelular() != null) {
                    bufferedWriter.write(preMatricula.getIndicacao().getTelefoneCelular());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getPessoa().getSaram() != null) {
                    bufferedWriter.write(preMatricula.getPessoa().getSaram());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getPessoa().getCpf() != null) {
                    bufferedWriter.write(preMatricula.getPessoa().getCpf());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getIndicacao().getStatus() != null) {
                    bufferedWriter.write(preMatricula.getIndicacao().getStatus());
                } else {
                    bufferedWriter.write("PRE MTCL");
                }
                bufferedWriter.write(",");
                // solicitação da Seção de Avaliação do ILA
                if (preMatricula.getIndicacao().getChefia() != null) {
                    bufferedWriter.write(preMatricula.getIndicacao().getChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getIndicacao().getEmailChefia() != null) {
                    bufferedWriter.write(preMatricula.getIndicacao().getEmailChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getIndicacao().getTelefoneChefia() != null) {
                    bufferedWriter.write(preMatricula.getIndicacao().getTelefoneChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getIndicacao().getTelefoneOM() != null) {
                    bufferedWriter.write(preMatricula.getIndicacao().getTelefoneOM());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.newLine();
            } catch (IOException ex) {
                Logger.getLogger(EXC002CSV.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        // listar alunos
        PreMatriculaDTO[] preMatriculasAlunos = service.findAllPreMatriculasAlunos(turmaId);
        for (PreMatriculaDTO preMatricula : preMatriculasAlunos) {
            try {
                PessoaDTO pessoa = organizationalService.findPessoa(preMatricula.getPessoa().getId());
                bufferedWriter.write("ALUNO");
                bufferedWriter.write(",");
                if (turma != null) {
                    bufferedWriter.write(turma.getCurso().getCodigo() + "-" + turma.getNumeroTurma());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getPessoa().getPosto() != null) {
                    bufferedWriter.write(preMatricula.getPessoa().getPosto());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getPessoa().getQuadro() != null) {
                    bufferedWriter.write(preMatricula.getPessoa().getQuadro());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getPessoa().getEspecialidade() != null) {
                    bufferedWriter.write(preMatricula.getPessoa().getEspecialidade());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getPessoa().getNome() != null) {
                    bufferedWriter.write(preMatricula.getPessoa().getNome());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getPessoa().getNomeGuerra() != null) {
                    bufferedWriter.write(preMatricula.getPessoa().getNomeGuerra());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getOrganizacao() != null && pessoa.getOrganizacao().getSigla() != null) {
                    bufferedWriter.write(pessoa.getOrganizacao().getSigla());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getIndicacao().getEmail() != null) {
                    bufferedWriter.write(preMatricula.getIndicacao().getEmail());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getIndicacao().getTelefone() != null) {
                    bufferedWriter.write(preMatricula.getIndicacao().getTelefone());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getIndicacao().getTelefoneCelular() != null) {
                    bufferedWriter.write(preMatricula.getIndicacao().getTelefoneCelular());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getPessoa().getSaram() != null) {
                    bufferedWriter.write(preMatricula.getPessoa().getSaram());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getPessoa().getCpf() != null) {
                    bufferedWriter.write(preMatricula.getPessoa().getCpf());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                // não está retornando
                if (preMatricula.getIndicacao().getStatus() != null) {
                    bufferedWriter.write(preMatricula.getIndicacao().getStatus());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                // solicitação da Seção de Avaliação do ILA
                if (preMatricula.getIndicacao().getChefia() != null) {
                    bufferedWriter.write(preMatricula.getIndicacao().getChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getIndicacao().getEmailChefia() != null) {
                    bufferedWriter.write(preMatricula.getIndicacao().getEmailChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (preMatricula.getIndicacao().getTelefoneChefia() != null) {
                    bufferedWriter.write(preMatricula.getIndicacao().getTelefoneChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                // não está retornando
                if (preMatricula.getIndicacao().getTelefoneOM() != null) {
                    bufferedWriter.write(preMatricula.getIndicacao().getTelefoneOM());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.newLine();
            } catch (IOException ex) {
                Logger.getLogger(EXC002CSV.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        try {
            bufferedWriter.flush();
            bufferedWriter.close();
        } catch (IOException ex) {
            Logger.getLogger(EXC002CSV.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else if ("SLC".equals(statusIndicacao)) {
        // mostrar apenas os selecionados
        List<IndicacaoDTO> indicacoes = new ArrayList<IndicacaoDTO>();
        IndicacaoDTO[] indicacoesInstrutores = service.findAllIndicacoesInstrutoresSelecionados(turmaId);
        indicacoes.addAll(Arrays.asList(indicacoesInstrutores));
        IndicacaoDTO[] indicacoesAlunos = service.findAllIndicacoesAlunosSelecionadosForOrdemMatricula(turmaId);
        indicacoes.addAll(Arrays.asList(indicacoesAlunos));
        for (IndicacaoDTO indicacao : indicacoes) {
            try {
                PessoaDTO pessoa = organizationalService.findPessoa(indicacao.getPessoa().getId());
                if (indicacao instanceof IndicacaoAlunoDTO) {
                    bufferedWriter.write("ALUNO");
                } else {
                    bufferedWriter.write("INSTRUTOR");
                }
                bufferedWriter.write(",");
                if (turma != null) {
                    bufferedWriter.write(turma.getCurso().getCodigo() + "-" + turma.getNumeroTurma());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getPosto() != null) {
                    bufferedWriter.write(pessoa.getPosto());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getQuadro() != null) {
                    bufferedWriter.write(pessoa.getQuadro());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getEspecialidade() != null) {
                    bufferedWriter.write(pessoa.getEspecialidade());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getNome() != null) {
                    bufferedWriter.write(pessoa.getNome());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getNomeGuerra() != null) {
                    bufferedWriter.write(pessoa.getNomeGuerra());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getOrganizacao() != null && pessoa.getOrganizacao().getSigla() != null) {
                    bufferedWriter.write(pessoa.getOrganizacao().getSigla());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (indicacao.getEmail() != null) {
                    bufferedWriter.write(indicacao.getEmail());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (indicacao.getTelefone() != null) {
                    bufferedWriter.write(indicacao.getTelefone());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (indicacao.getTelefoneCelular() != null) {
                    bufferedWriter.write(indicacao.getTelefoneCelular());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getSaram() != null) {
                    bufferedWriter.write(pessoa.getSaram());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getCpf() != null) {
                    bufferedWriter.write(pessoa.getCpf());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (indicacao.getStatus() != null) {
                    bufferedWriter.write(indicacao.getStatus());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                // solicitação da Seção de Avaliação do ILA
                if (indicacao.getChefia() != null) {
                    bufferedWriter.write(indicacao.getChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (indicacao.getEmailChefia() != null) {
                    bufferedWriter.write(indicacao.getEmailChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (indicacao.getTelefoneChefia() != null) {
                    bufferedWriter.write(indicacao.getTelefoneChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                // não está retornando
                if (indicacao.getTelefoneOM() != null) {
                    bufferedWriter.write(indicacao.getTelefoneOM());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.newLine();
            } catch (IOException ex) {
                Logger.getLogger(EXC002CSV.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        try {
            bufferedWriter.flush();
            bufferedWriter.close();
        } catch (IOException ex) {
            Logger.getLogger(EXC002CSV.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        // mostrar indicados em geral
        List<IndicacaoDTO> indicacoes = new ArrayList<IndicacaoDTO>();
        IndicacaoDTO[] indicacoesInstrutores = service.findAllIndicacoesInstrutores(turmaId);
        indicacoes.addAll(Arrays.asList(indicacoesInstrutores));
        IndicacaoDTO[] indicacoesAlunos = service.findAllIndicacoesAlunos(turmaId);
        indicacoes.addAll(Arrays.asList(indicacoesAlunos));
        for (IndicacaoDTO indicacao : indicacoes) {
            try {
                PessoaDTO pessoa = organizationalService.findPessoa(indicacao.getPessoa().getId());
                if (indicacao instanceof IndicacaoAlunoDTO) {
                    bufferedWriter.write("ALUNO");
                } else {
                    bufferedWriter.write("INSTRUTOR");
                }
                bufferedWriter.write(",");
                if (turma != null) {
                    bufferedWriter.write(turma.getCurso().getCodigo() + "-" + turma.getNumeroTurma());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getPosto() != null) {
                    bufferedWriter.write(pessoa.getPosto());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getQuadro() != null) {
                    bufferedWriter.write(pessoa.getQuadro());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getEspecialidade() != null) {
                    bufferedWriter.write(pessoa.getEspecialidade());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getNome() != null) {
                    bufferedWriter.write(pessoa.getNome());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getNomeGuerra() != null) {
                    bufferedWriter.write(pessoa.getNomeGuerra());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getOrganizacao() != null && pessoa.getOrganizacao().getSigla() != null) {
                    bufferedWriter.write(pessoa.getOrganizacao().getSigla());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (indicacao.getEmail() != null) {
                    bufferedWriter.write(indicacao.getEmail());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (indicacao.getTelefone() != null) {
                    bufferedWriter.write(indicacao.getTelefone());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (indicacao.getTelefoneCelular() != null) {
                    bufferedWriter.write(indicacao.getTelefoneCelular());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getSaram() != null) {
                    bufferedWriter.write(pessoa.getSaram());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (pessoa.getCpf() != null) {
                    bufferedWriter.write(pessoa.getCpf());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (indicacao.getStatus() != null) {
                    bufferedWriter.write(indicacao.getStatus());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                // solicitação da Seção de Avaliação do ILA
                if (indicacao.getChefia() != null) {
                    bufferedWriter.write(indicacao.getChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (indicacao.getEmailChefia() != null) {
                    bufferedWriter.write(indicacao.getEmailChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                if (indicacao.getTelefoneChefia() != null) {
                    bufferedWriter.write(indicacao.getTelefoneChefia());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.write(",");
                // não está retornando
                if (indicacao.getTelefoneOM() != null) {
                    bufferedWriter.write(indicacao.getTelefoneOM());
                } else {
                    bufferedWriter.write("");
                }
                bufferedWriter.newLine();
            } catch (IOException ex) {
                Logger.getLogger(EXC002CSV.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        try {
            bufferedWriter.flush();
            bufferedWriter.close();
        } catch (IOException ex) {
            Logger.getLogger(EXC002CSV.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
// fim do if de filtro dos indicados pelo STATUS
}
Also used : CancelamentoMatriculaDTO(com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO) ArrayList(java.util.ArrayList) TurmaDTO(com.tomasio.projects.trainning.dto.TurmaDTO) BufferedWriter(java.io.BufferedWriter) IndicacaoDTO(com.tomasio.projects.trainning.dto.IndicacaoDTO) MatriculaAlunoDTO(com.tomasio.projects.trainning.dto.MatriculaAlunoDTO) IndicacaoAlunoDTO(com.tomasio.projects.trainning.dto.IndicacaoAlunoDTO) ArrayList(java.util.ArrayList) List(java.util.List) ApresentacaoDTO(com.tomasio.projects.trainning.dto.ApresentacaoDTO) PreMatriculaDTO(com.tomasio.projects.trainning.dto.PreMatriculaDTO) CancelamentoMatriculaDTO(com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO) MatriculaDTO(com.tomasio.projects.trainning.dto.MatriculaDTO) ConclusaoDTO(com.tomasio.projects.trainning.dto.ConclusaoDTO) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) PreMatriculaDTO(com.tomasio.projects.trainning.dto.PreMatriculaDTO) PessoaDTO(com.tomasio.projects.trainning.dto.PessoaDTO) OrganizationalService(com.tomasio.projects.trainning.interfaces.OrganizationalService) OutputStreamWriter(java.io.OutputStreamWriter) SimpleDateFormat(java.text.SimpleDateFormat) BufferedWriter(java.io.BufferedWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) AtividadesEnsinoService(com.tomasio.projects.trainning.interfaces.AtividadesEnsinoService)

Aggregations

IndicacaoAlunoDTO (com.tomasio.projects.trainning.dto.IndicacaoAlunoDTO)36 CoreException (com.tomasio.projects.trainning.exeption.CoreException)25 PessoaDTO (com.tomasio.projects.trainning.dto.PessoaDTO)19 TurmaEfetivaDTO (com.tomasio.projects.trainning.dto.TurmaEfetivaDTO)18 OrganizacaoDTO (com.tomasio.projects.trainning.dto.OrganizacaoDTO)17 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)17 Date (java.util.Date)13 IndicacaoDAO (com.tomasio.projects.trainning.dao.IndicacaoDAO)12 DAOException (com.tomasio.projects.trainning.exception.DAOException)12 IndicacaoAluno (com.tomasio.projects.trainning.model.IndicacaoAluno)12 Transactional (org.springframework.transaction.annotation.Transactional)12 CustoDTO (com.tomasio.projects.trainning.dto.CustoDTO)11 ParseException (java.text.ParseException)11 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)8 IndicacaoDTO (com.tomasio.projects.trainning.dto.IndicacaoDTO)6 Map (java.util.Map)6 Indicacao (com.tomasio.projects.trainning.model.Indicacao)4 SimpleDateFormat (java.text.SimpleDateFormat)4 MatriculaDTO (com.tomasio.projects.trainning.dto.MatriculaDTO)3