Rev 106 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 106 | espaco | 1 | package br.com.ec.controller.managedbean; |
| 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.com.ec.controller.managedbean.consultademanda.ClienteConsultaPorDemanda; |
||
| 195 | espaco | 12 | import br.com.ec.core.generic.GenericService; |
| 106 | espaco | 13 | import br.com.ec.domain.dto.ParametrosConsultaClienteDTO; |
| 14 | import br.com.ec.domain.model.Cliente; |
||
| 15 | import br.com.ec.domain.model.tipos.TipoRelatorioCliente; |
||
| 16 | import br.com.ec.domain.service.cliente.ClienteService; |
||
| 195 | espaco | 17 | import br.com.ec.web.exception.VerificadorLancamentoException; |
| 18 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandRelatorioStreamedContent; |
||
| 19 | import br.com.ec.web.generic.AbstractBean; |
||
| 106 | espaco | 20 | |
| 21 | @Named |
||
| 22 | @Scope("view") |
||
| 23 | public class ClienteConsultaBean extends AbstractBean<Cliente> implements Serializable { |
||
| 24 | |||
| 25 | private static final long serialVersionUID = 1L; |
||
| 26 | |||
| 27 | private ClienteConsultaPorDemanda lazy; |
||
| 28 | private ClienteService clienteService; |
||
| 29 | |||
| 30 | @Inject |
||
| 31 | public ClienteConsultaBean(ClienteConsultaPorDemanda lazy, ClienteService clienteService) { |
||
| 32 | this.lazy = lazy; |
||
| 33 | this.clienteService = clienteService; |
||
| 34 | } |
||
| 35 | |||
| 36 | @Override |
||
| 37 | public void preCarregamento() { |
||
| 38 | entidade = new Cliente(); |
||
| 39 | entidade.setAtivo(true); |
||
| 40 | parametrosConsulta = new ParametrosConsultaClienteDTO(); |
||
| 41 | parametrosConsulta.setEntidade(entidade); |
||
| 42 | prepararConsultaDemanda(); |
||
| 43 | } |
||
| 44 | |||
| 45 | @Override |
||
| 46 | public void limparEntidade() { |
||
| 47 | setEntidade(new Cliente()); |
||
| 48 | } |
||
| 49 | |||
| 50 | @Override |
||
| 51 | public GenericService<Cliente> getService() { |
||
| 52 | return null; |
||
| 53 | } |
||
| 54 | |||
| 55 | @Override |
||
| 56 | public Cliente getEntidade() { |
||
| 57 | return entidade; |
||
| 58 | } |
||
| 59 | |||
| 60 | @Override |
||
| 61 | public Cliente getId() { |
||
| 62 | return getEntidade(); |
||
| 63 | } |
||
| 64 | |||
| 65 | public ClienteConsultaPorDemanda getLazy() { |
||
| 66 | return lazy; |
||
| 67 | } |
||
| 68 | public void setLazy(ClienteConsultaPorDemanda lazy) { |
||
| 69 | this.lazy = lazy; |
||
| 70 | } |
||
| 71 | public void prepararConsultaDemanda() { |
||
| 72 | lazy.setarParametrosConsulta(getParametrosConsulta()); |
||
| 73 | } |
||
| 74 | |||
| 75 | public TipoRelatorioCliente[] getTiposRelatorio() { |
||
| 76 | return TipoRelatorioCliente.values(); |
||
| 77 | } |
||
| 78 | |||
| 79 | public StreamedContent downloadPlanilha() { |
||
| 80 | return new VerificadorLancamentoException().verificarLancamentoException(new CommandRelatorioStreamedContent() { |
||
| 81 | @Override |
||
| 82 | public StreamedContent execute() { |
||
| 83 | return clienteService.gerarArquivoExcel(getParametrosConsulta()); |
||
| 84 | } |
||
| 85 | }); |
||
| 86 | } |
||
| 87 | |||
| 88 | } |