Rev 106 |
Blame |
Compare with Previous |
Last modification |
View Log
| Download
| RSS feed
package br.com.ec.controller.managedbean;
import java.io.Serializable;
import javax.inject.Inject;
import javax.inject.Named;
import org.springframework.context.annotation.Scope;
import br.com.ec.core.generic.GenericService;
import br.com.ec.domain.model.Loja;
import br.com.ec.domain.model.Produto;
import br.com.ec.domain.service.produto.ProdutoService;
import br.com.ec.domain.service.seguranca.ContextoSeguranca;
import br.com.ec.web.exception.VerificadorLancamentoException;
import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean;
import br.com.ec.web.generic.AbstractBean;
import br.com.ec.web.message.LancadorMensagem;
@Named
@Scope
("view")
public class TransferirEstoqueBean
extends AbstractBean
<Produto
> implements Serializable {
private static final long serialVersionUID = 1L
;
private Loja lojaEntrada
;
private Loja lojaSaida
;
private Produto produto
;
private Integer quantidadeEstoque
;
private ProdutoService produtoService
;
private ContextoSeguranca contextoSeguranca
;
@Inject
public TransferirEstoqueBean
(ProdutoService produtoService, ContextoSeguranca contextoSeguranca
) {
this.
produtoService = produtoService
;
this.
contextoSeguranca = contextoSeguranca
;
}
@
Override
public void limparEntidade
() {
setEntidade
(null);
setLojaEntrada
(null);
setLojaSaida
(null);
setQuantidadeEstoque
(0);
}
@
Override
public GenericService
<Produto
> getService
() {
return produtoService
;
}
@
Override
public Produto getEntidade
() {
return entidade
;
}
@
Override
public Produto getId
() {
return getEntidade
();
}
public Loja getLojaEntrada
() {
return lojaEntrada
;
}
public void setLojaEntrada
(Loja lojaEntrada
) {
this.
lojaEntrada = lojaEntrada
;
}
public Loja getLojaSaida
() {
return lojaSaida
;
}
public void setLojaSaida
(Loja lojaSaida
) {
this.
lojaSaida = lojaSaida
;
}
public Produto getProduto
() {
return produto
;
}
public void setProduto
(Produto produto
) {
this.
produto = produto
;
}
public Integer getQuantidadeEstoque
() {
return quantidadeEstoque
;
}
public void setQuantidadeEstoque
(Integer quantidadeEstoque
) {
this.
quantidadeEstoque = quantidadeEstoque
;
}
public void transferirEstoque
() {
new VerificadorLancamentoException
().
tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean
() {
public void execute
() {
produtoService.
transferirEstoque(getLojaEntrada
(), getLojaSaida
(), contextoSeguranca.
obterUsuario(), getEntidade
(), getQuantidadeEstoque
());
limparEntidade
();
adicionandoParametroArgsConfirmandoAcao
(true);
LancadorMensagem.
lancarSucesso("TRANSFERÊNCIA REALIZADA COM SUCESSO!");
}
});
}
}