Rev 195 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 195 | Rev 339 | ||
|---|---|---|---|
| Line 10... | Line 10... | ||
| 10 | import br.com.ec.controller.managedbean.consultademanda.PontoConsultaPorDemanda; |
10 | import br.com.ec.controller.managedbean.consultademanda.PontoConsultaPorDemanda; |
| 11 | import br.com.ec.core.consulta.ParametrosConsulta; |
11 | import br.com.ec.core.consulta.ParametrosConsulta; |
| 12 | import br.com.ec.core.generic.GenericService; |
12 | import br.com.ec.core.generic.GenericService; |
| 13 | import br.com.ec.domain.model.Pessoa; |
13 | import br.com.ec.domain.model.Pessoa; |
| 14 | import br.com.ec.domain.model.Ponto; |
14 | import br.com.ec.domain.model.Ponto; |
| 15 | import br.com.ec.domain.service.loja.LojaService; |
- | |
| - | 15 | import br.com.ec.domain.service.ponto.PontoService; |
|
| - | 16 | import br.com.ec.web.exception.VerificadorLancamentoException; |
|
| - | 17 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
|
| 16 | import br.com.ec.web.generic.AbstractBean; |
18 | import br.com.ec.web.generic.AbstractBean; |
| - | 19 | import br.com.ec.web.message.LancadorMensagem; |
|
| 17 | 20 | ||
| 18 | @Named |
21 | @Named |
| 19 | @Scope("view") |
22 | @Scope("view") |
| 20 | public class PontoConsultaBean extends AbstractBean<Ponto> implements Serializable { |
23 | public class PontoConsultaBean extends AbstractBean<Ponto> implements Serializable { |
| 21 | 24 | ||
| 22 | private static final long serialVersionUID = 1L; |
25 | private static final long serialVersionUID = 1L; |
| 23 | 26 | ||
| 24 | private PontoConsultaPorDemanda lazy; |
27 | private PontoConsultaPorDemanda lazy; |
| 25 | 28 | ||
| 26 | private LojaService lojaService; |
- | |
| - | 29 | private PontoService pontoService; |
|
| - | 30 | ||
| - | 31 | private Ponto pontoSelecionado; |
|
| 27 | 32 | ||
| 28 | @Inject |
33 | @Inject |
| 29 | public PontoConsultaBean(PontoConsultaPorDemanda lazy, LojaService lojaService) { |
- | |
| - | 34 | public PontoConsultaBean(PontoConsultaPorDemanda lazy, PontoService pontoService) { |
|
| 30 | this.lazy = lazy; |
35 | this.lazy = lazy; |
| 31 | this.lojaService = lojaService; |
- | |
| - | 36 | this.pontoService = pontoService; |
|
| 32 | }
|
37 | }
|
| 33 | 38 | ||
| 34 | @Override |
39 | @Override |
| 35 | public void preCarregamento() { |
40 | public void preCarregamento() { |
| 36 | entidade = new Ponto(); |
41 | entidade = new Ponto(); |
| 37 | parametrosConsulta = new ParametrosConsulta<Ponto>(); |
42 | parametrosConsulta = new ParametrosConsulta<Ponto>(); |
| 38 | parametrosConsulta.setEntidade(entidade); |
43 | parametrosConsulta.setEntidade(entidade); |
| - | 44 | pontoSelecionado = null; |
|
| 39 | prepararConsultaDemanda(); |
45 | prepararConsultaDemanda(); |
| 40 | }
|
46 | }
|
| 41 | 47 | ||
| 42 | @Override |
48 | @Override |
| 43 | public void limparEntidade() { |
49 | public void limparEntidade() { |
| 44 | setEntidade(new Ponto()); |
50 | setEntidade(new Ponto()); |
| - | 51 | setPontoSelecionado(null); |
|
| 45 | }
|
52 | }
|
| 46 | 53 | ||
| 47 | @Override |
54 | @Override |
| 48 | public GenericService<Ponto> getService() { |
55 | public GenericService<Ponto> getService() { |
| 49 | return null; |
- | |
| - | 56 | return pontoService; |
|
| 50 | }
|
57 | }
|
| 51 | 58 | ||
| 52 | @Override |
59 | @Override |
| 53 | public Ponto getEntidade() { |
60 | public Ponto getEntidade() { |
| 54 | return entidade; |
61 | return entidade; |
| Line 65... | Line 72... | ||
| 65 | public void setLazy(PontoConsultaPorDemanda lazy) { |
72 | public void setLazy(PontoConsultaPorDemanda lazy) { |
| 66 | this.lazy = lazy; |
73 | this.lazy = lazy; |
| 67 | }
|
74 | }
|
| 68 | public void prepararConsultaDemanda() { |
75 | public void prepararConsultaDemanda() { |
| 69 | lazy.setarParametrosConsulta(getParametrosConsulta()); |
76 | lazy.setarParametrosConsulta(getParametrosConsulta()); |
| - | 77 | }
|
|
| - | 78 | ||
| - | 79 | public Ponto getPontoSelecionado() { |
|
| - | 80 | return pontoSelecionado; |
|
| - | 81 | }
|
|
| - | 82 | public void setPontoSelecionado(Ponto pontoSelecionado) { |
|
| - | 83 | this.pontoSelecionado = pontoSelecionado; |
|
| 70 | }
|
84 | }
|
| 71 | 85 | ||
| 72 | public void selecionarPessoaParaConsulta(Pessoa pessoa) { |
86 | public void selecionarPessoaParaConsulta(Pessoa pessoa) { |
| 73 | getParametrosConsulta().getEntidade().setPessoa(pessoa); |
87 | getParametrosConsulta().getEntidade().setPessoa(pessoa); |
| 74 | }
|
88 | }
|
| 75 | 89 | ||
| 76 | public void retirarPessoaParaConsulta() { |
90 | public void retirarPessoaParaConsulta() { |
| 77 | getParametrosConsulta().getEntidade().setPessoa(null); |
91 | getParametrosConsulta().getEntidade().setPessoa(null); |
| - | 92 | }
|
|
| - | 93 | ||
| - | 94 | /*****************************************************/
|
|
| - | 95 | ||
| - | 96 | public void consultarPonto(Ponto ponto) { |
|
| - | 97 | setPontoSelecionado(getService().consultarPorId(ponto)); |
|
| - | 98 | }
|
|
| - | 99 | ||
| - | 100 | public void validarPonto() { |
|
| - | 101 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
|
| - | 102 | public void execute() { |
|
| - | 103 | getService().alterar(getPontoSelecionado()); |
|
| - | 104 | prepararConsultaDemanda(); |
|
| - | 105 | LancadorMensagem.lancarSucesso("PONTO VALIDADO COM SUCESSO"); |
|
| - | 106 | }
|
|
| - | 107 | }); |
|
| 78 | }
|
108 | }
|
| 79 | 109 | ||
| 80 | }
|
110 | }
|