Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | package br.edu.cesmac.sic.controller.beans; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | |||
| 5 | import javax.inject.Inject; |
||
| 6 | import javax.inject.Named; |
||
| 7 | |||
| 8 | import org.primefaces.model.StreamedContent; |
||
| 9 | import org.springframework.context.annotation.Scope; |
||
| 10 | |||
| 11 | import br.edu.cesmac.relatorio.util.RelatorioUtils; |
||
| 12 | import br.edu.cesmac.sic.core.domain.model.ProjetoPesquisa; |
||
| 13 | import br.edu.cesmac.sic.core.domain.model.dto.FiltroRelatorioProcessoSeletivo; |
||
| 14 | import br.edu.cesmac.sic.core.domain.model.dto.FiltroRelatorioProjetoPesquisa; |
||
| 15 | import br.edu.cesmac.sic.core.domain.model.dto.RelatorioAvaliacaoDTO; |
||
| 16 | import br.edu.cesmac.sic.core.domain.model.tipo.TipoRelatorioSistema; |
||
| 17 | import br.edu.cesmac.sic.core.domain.service.EmissorRelatorioService; |
||
| 18 | import br.edu.cesmac.web.exception.VerificadorLancamentoException; |
||
| 19 | import br.edu.cesmac.web.exception.VerificadorLancamentoException.CommandRelatorioStreamedContent; |
||
| 20 | import net.sf.jasperreports.engine.JasperPrint; |
||
| 21 | |||
| 22 | @Named |
||
| 23 | @Scope("view") |
||
| 24 | public class RelatorioBean implements Serializable { |
||
| 25 | |||
| 26 | private static final long serialVersionUID = 1L; |
||
| 27 | |||
| 28 | private EmissorRelatorioService emissorRelatorioService; |
||
| 29 | |||
| 30 | private FiltroRelatorioProcessoSeletivo filtroRelatorioProcessoSeletivo = new FiltroRelatorioProcessoSeletivo(); |
||
| 31 | |||
| 32 | private FiltroRelatorioProjetoPesquisa filtroRelatorioProjetoPesquisa = new FiltroRelatorioProjetoPesquisa(); |
||
| 33 | |||
| 34 | private RelatorioAvaliacaoDTO relatorioAvaliacaoDTO; |
||
| 35 | |||
| 36 | @Inject |
||
| 37 | public RelatorioBean(EmissorRelatorioService emissorRelatorioService) { |
||
| 38 | this.emissorRelatorioService = emissorRelatorioService; |
||
| 39 | } |
||
| 40 | |||
| 41 | public FiltroRelatorioProcessoSeletivo getFiltroRelatorioProcessoSeletivo() { |
||
| 42 | return filtroRelatorioProcessoSeletivo; |
||
| 43 | } |
||
| 44 | public void setFiltroRelatorioProcessoSeletivo(FiltroRelatorioProcessoSeletivo filtroRelatorioProcessoSeletivo) { |
||
| 45 | this.filtroRelatorioProcessoSeletivo = filtroRelatorioProcessoSeletivo; |
||
| 46 | } |
||
| 47 | |||
| 48 | public TipoRelatorioSistema[] getTiposRelatorioSistema() { |
||
| 49 | return TipoRelatorioSistema.values(); |
||
| 50 | } |
||
| 51 | |||
| 52 | public FiltroRelatorioProjetoPesquisa getFiltroRelatorioProjetoPesquisa() { |
||
| 53 | return filtroRelatorioProjetoPesquisa; |
||
| 54 | } |
||
| 55 | |||
| 56 | public void setFiltroRelatorioProjetoPesquisa(FiltroRelatorioProjetoPesquisa filtroRelatorioProjetoPesquisa) { |
||
| 57 | this.filtroRelatorioProjetoPesquisa = filtroRelatorioProjetoPesquisa; |
||
| 58 | } |
||
| 59 | |||
| 60 | public RelatorioAvaliacaoDTO getRelatorioAvaliacaoDTO() { |
||
| 61 | return relatorioAvaliacaoDTO; |
||
| 62 | } |
||
| 63 | public void setRelatorioAvaliacaoDTO(RelatorioAvaliacaoDTO relatorioAvaliacaoDTO) { |
||
| 64 | this.relatorioAvaliacaoDTO = relatorioAvaliacaoDTO; |
||
| 65 | } |
||
| 66 | |||
| 67 | public StreamedContent emitirRelatorioProcessoSeletivo() { |
||
| 68 | return new VerificadorLancamentoException().verificarLancamentoException(new CommandRelatorioStreamedContent() { |
||
| 69 | @Override |
||
| 70 | public StreamedContent execute() { |
||
| 71 | JasperPrint relatorio = emissorRelatorioService.emitirRelatorioProcessoSeletivo(filtroRelatorioProcessoSeletivo); |
||
| 72 | return RelatorioUtils.gerarPdf(relatorio, relatorio.getName()); |
||
| 73 | } |
||
| 74 | }); |
||
| 75 | } |
||
| 76 | |||
| 77 | public StreamedContent emitirAvaliacoesDoProjetoPesquisa(final ProjetoPesquisa projetoPesquisa) { |
||
| 78 | return new VerificadorLancamentoException().verificarLancamentoException(new CommandRelatorioStreamedContent() { |
||
| 79 | @Override |
||
| 80 | public StreamedContent execute() { |
||
| 81 | getFiltroRelatorioProjetoPesquisa().setProjetoPesquisa(projetoPesquisa); |
||
| 82 | getFiltroRelatorioProjetoPesquisa().setTipoRelatorio(TipoRelatorioSistema.AVALIACAO); |
||
| 83 | |||
| 84 | // Avaliacao avaliacao = new Avaliacao(); |
||
| 85 | // AvaliacaoId avaliacaoId = new AvaliacaoId(); |
||
| 86 | // avaliacaoId.setSequencialAvaliador(new Long(1)); |
||
| 87 | // avaliacao.setAvaliacaoId(avaliacaoId); |
||
| 88 | // avaliacao.setIndicadorTecnicoCientificoRelevante(false); |
||
| 89 | // getFiltroRelatorioProjetoPesquisa().getAvaliacoes().add(avaliacao); |
||
| 90 | JasperPrint relatorio = emissorRelatorioService.emitirAvaliacoesDoProjetoPesquisa(getFiltroRelatorioProjetoPesquisa()); |
||
| 91 | return RelatorioUtils.gerarPdf(relatorio, relatorio.getName()); |
||
| 92 | } |
||
| 93 | }); |
||
| 94 | } |
||
| 95 | |||
| 96 | } |