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.springframework.context.annotation.Scope; |
||
| 9 | |||
| 10 | import br.com.ec.controller.managedbean.consultademanda.PedidoConsultaPorDemanda; |
||
| 195 | espaco | 11 | import br.com.ec.core.generic.GenericService; |
| 12 | import br.com.ec.core.util.DataUtils; |
||
| 106 | espaco | 13 | import br.com.ec.domain.dto.ParametrosConsultaPedidoDTO; |
| 14 | import br.com.ec.domain.model.Pedido; |
||
| 15 | import br.com.ec.domain.service.pedido.PedidoService; |
||
| 195 | espaco | 16 | import br.com.ec.web.exception.VerificadorLancamentoException; |
| 17 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
||
| 18 | import br.com.ec.web.generic.AbstractBean; |
||
| 19 | import br.com.ec.web.message.LancadorMensagem; |
||
| 106 | espaco | 20 | |
| 21 | @Named |
||
| 22 | @Scope("view") |
||
| 23 | public class FaltaBean extends AbstractBean<Pedido> implements Serializable { |
||
| 24 | |||
| 25 | private static final long serialVersionUID = 1L; |
||
| 26 | |||
| 27 | private PedidoConsultaPorDemanda lazy; |
||
| 28 | private String senhaUsuario; |
||
| 29 | |||
| 30 | private PedidoService pedidoService; |
||
| 31 | |||
| 32 | @Inject |
||
| 33 | public FaltaBean(PedidoConsultaPorDemanda lazy, PedidoService pedidoService) { |
||
| 34 | this.lazy = lazy; |
||
| 35 | this.pedidoService = pedidoService; |
||
| 36 | } |
||
| 37 | |||
| 38 | @Override |
||
| 39 | public void preCarregamento() { |
||
| 40 | limparEntidade(); |
||
| 41 | prepararConsultaDemanda(); |
||
| 42 | } |
||
| 43 | |||
| 44 | @Override |
||
| 45 | public void limparEntidade() { |
||
| 46 | entidade = new Pedido(); |
||
| 47 | // entidade.setEmpresa(new Empresa(ConstantesSEC.Empresa.CODIGO_EMPRESA_FARMACIA_3)); |
||
| 48 | parametrosConsulta = new ParametrosConsultaPedidoDTO(); |
||
| 49 | parametrosConsulta.setEntidade(entidade); |
||
| 50 | ((ParametrosConsultaPedidoDTO)parametrosConsulta).setAtendido(false); |
||
| 51 | setSenhaUsuario(""); |
||
| 52 | } |
||
| 53 | |||
| 54 | @Override |
||
| 55 | public GenericService<Pedido> getService() { |
||
| 56 | return pedidoService; |
||
| 57 | } |
||
| 58 | |||
| 59 | @Override |
||
| 60 | public Pedido getEntidade() { |
||
| 61 | return entidade; |
||
| 62 | } |
||
| 63 | |||
| 64 | @Override |
||
| 65 | public Pedido getId() { |
||
| 66 | return getEntidade(); |
||
| 67 | } |
||
| 68 | |||
| 69 | public PedidoConsultaPorDemanda getLazy() { |
||
| 70 | return lazy; |
||
| 71 | } |
||
| 72 | public void setLazy(PedidoConsultaPorDemanda lazy) { |
||
| 73 | this.lazy = lazy; |
||
| 74 | } |
||
| 75 | public void prepararConsultaDemanda() { |
||
| 76 | lazy.setarParametrosConsulta(getParametrosConsulta()); |
||
| 77 | } |
||
| 78 | |||
| 79 | public String getSenhaUsuario() { |
||
| 80 | return senhaUsuario; |
||
| 81 | } |
||
| 82 | public void setSenhaUsuario(String senhaUsuario) { |
||
| 83 | this.senhaUsuario = senhaUsuario; |
||
| 84 | } |
||
| 85 | |||
| 86 | /***************************************************************/ |
||
| 87 | |||
| 88 | @Override |
||
| 89 | public void cadastrar() { |
||
| 90 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 91 | public void execute() { |
||
| 92 | pedidoService.adicionarPedido(getEntidade(), senhaUsuario); |
||
| 93 | limparEntidade(); |
||
| 94 | LancadorMensagem.lancarSucesso("PEDIDO ADICIONADO COM SUCESSO!"); |
||
| 95 | } |
||
| 96 | }); |
||
| 97 | } |
||
| 98 | |||
| 99 | public void atenderPedido(final Pedido pedido) { |
||
| 100 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 101 | public void execute() { |
||
| 102 | pedido.setDataUltimaAlteracaoSituacao(DataUtils.getDataAtual()); |
||
| 103 | pedidoService.alterar(pedido); |
||
| 104 | LancadorMensagem.lancarSucesso("PEDIDO ATENDIDO COM SUCESSO!"); |
||
| 105 | } |
||
| 106 | }); |
||
| 107 | } |
||
| 108 | |||
| 109 | public void excluirPedido(final Pedido pedido) { |
||
| 110 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 111 | public void execute() { |
||
| 112 | pedidoService.excluir(pedido); |
||
| 113 | LancadorMensagem.lancarSucesso("PEDIDO EXCLUÍDO COM SUCESSO!"); |
||
| 114 | } |
||
| 115 | }); |
||
| 116 | } |
||
| 117 | |||
| 118 | } |