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 | |||
| 195 | espaco | 10 | import br.com.ec.core.generic.GenericService; |
| 106 | espaco | 11 | import br.com.ec.domain.model.Loja; |
| 12 | import br.com.ec.domain.model.Produto; |
||
| 13 | import br.com.ec.domain.service.produto.ProdutoService; |
||
| 14 | import br.com.ec.domain.service.seguranca.ContextoSeguranca; |
||
| 195 | espaco | 15 | import br.com.ec.web.exception.VerificadorLancamentoException; |
| 16 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
||
| 17 | import br.com.ec.web.generic.AbstractBean; |
||
| 18 | import br.com.ec.web.message.LancadorMensagem; |
||
| 106 | espaco | 19 | |
| 20 | @Named |
||
| 21 | @Scope("view") |
||
| 22 | public class TransferirEstoqueBean extends AbstractBean<Produto> implements Serializable { |
||
| 23 | |||
| 24 | private static final long serialVersionUID = 1L; |
||
| 25 | |||
| 26 | private Loja lojaEntrada; |
||
| 27 | private Loja lojaSaida; |
||
| 28 | private Produto produto; |
||
| 29 | private Integer quantidadeEstoque; |
||
| 30 | |||
| 31 | private ProdutoService produtoService; |
||
| 32 | |||
| 33 | private ContextoSeguranca contextoSeguranca; |
||
| 34 | |||
| 35 | @Inject |
||
| 36 | public TransferirEstoqueBean(ProdutoService produtoService, ContextoSeguranca contextoSeguranca) { |
||
| 37 | this.produtoService = produtoService; |
||
| 38 | this.contextoSeguranca = contextoSeguranca; |
||
| 39 | } |
||
| 40 | |||
| 41 | @Override |
||
| 42 | public void limparEntidade() { |
||
| 43 | setEntidade(null); |
||
| 44 | setLojaEntrada(null); |
||
| 45 | setLojaSaida(null); |
||
| 46 | setQuantidadeEstoque(0); |
||
| 47 | } |
||
| 48 | |||
| 49 | @Override |
||
| 50 | public GenericService<Produto> getService() { |
||
| 51 | return produtoService; |
||
| 52 | } |
||
| 53 | |||
| 54 | @Override |
||
| 55 | public Produto getEntidade() { |
||
| 56 | return entidade; |
||
| 57 | } |
||
| 58 | |||
| 59 | @Override |
||
| 60 | public Produto getId() { |
||
| 61 | return getEntidade(); |
||
| 62 | } |
||
| 63 | |||
| 64 | public Loja getLojaEntrada() { |
||
| 65 | return lojaEntrada; |
||
| 66 | } |
||
| 67 | public void setLojaEntrada(Loja lojaEntrada) { |
||
| 68 | this.lojaEntrada = lojaEntrada; |
||
| 69 | } |
||
| 70 | |||
| 71 | public Loja getLojaSaida() { |
||
| 72 | return lojaSaida; |
||
| 73 | } |
||
| 74 | public void setLojaSaida(Loja lojaSaida) { |
||
| 75 | this.lojaSaida = lojaSaida; |
||
| 76 | } |
||
| 77 | |||
| 78 | public Produto getProduto() { |
||
| 79 | return produto; |
||
| 80 | } |
||
| 81 | public void setProduto(Produto produto) { |
||
| 82 | this.produto = produto; |
||
| 83 | } |
||
| 84 | |||
| 85 | public Integer getQuantidadeEstoque() { |
||
| 86 | return quantidadeEstoque; |
||
| 87 | } |
||
| 88 | public void setQuantidadeEstoque(Integer quantidadeEstoque) { |
||
| 89 | this.quantidadeEstoque = quantidadeEstoque; |
||
| 90 | } |
||
| 91 | |||
| 92 | public void transferirEstoque() { |
||
| 93 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 94 | public void execute() { |
||
| 95 | produtoService.transferirEstoque(getLojaEntrada(), getLojaSaida(), contextoSeguranca.obterUsuario(), getEntidade(), getQuantidadeEstoque()); |
||
| 96 | limparEntidade(); |
||
| 97 | adicionandoParametroArgsConfirmandoAcao(true); |
||
| 98 | LancadorMensagem.lancarSucesso("TRANSFERÊNCIA REALIZADA COM SUCESSO!"); |
||
| 99 | } |
||
| 100 | }); |
||
| 101 | } |
||
| 102 | |||
| 103 | } |