Rev 302 | Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 299 | espaco | 1 | package br.com.ec.controller; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | |||
| 5 | import javax.inject.Inject; |
||
| 6 | import javax.inject.Named; |
||
| 7 | |||
| 8 | import org.primefaces.event.FlowEvent; |
||
| 9 | import org.springframework.context.annotation.Scope; |
||
| 10 | |||
| 11 | import br.com.ec.core.generic.GenericService; |
||
| 12 | import br.com.ec.core.util.VerificadorUtil; |
||
| 13 | import br.com.ec.domain.dto.PessoaDTO; |
||
| 14 | import br.com.ec.domain.model.Pessoa; |
||
| 15 | import br.com.ec.domain.model.tipos.TipoEscolaridade; |
||
| 16 | import br.com.ec.domain.model.tipos.TipoEstadoCivil; |
||
| 17 | import br.com.ec.domain.model.tipos.TipoPessoa; |
||
| 18 | import br.com.ec.domain.model.tipos.TipoRacaCor; |
||
| 19 | import br.com.ec.domain.service.PessoaService; |
||
| 20 | import br.com.ec.web.exception.VerificadorLancamentoException; |
||
| 21 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
||
| 22 | import br.com.ec.web.generic.AbstractBean; |
||
| 23 | import br.com.ec.web.message.LancadorMensagem; |
||
| 24 | import br.com.ec.web.util.TipoOperacao; |
||
| 25 | |||
| 26 | @Named |
||
| 27 | @Scope("view") |
||
| 28 | public class CadastroExternoBean extends AbstractBean<PessoaDTO> implements Serializable { |
||
| 29 | |||
| 30 | private static final long serialVersionUID = 1L; |
||
| 31 | |||
| 32 | private Pessoa pessoaSelecionada; |
||
| 33 | private PessoaService pessoaService; |
||
| 34 | |||
| 35 | @Inject |
||
| 36 | public CadastroExternoBean(PessoaService pessoaService) { |
||
| 37 | this.pessoaService = pessoaService; |
||
| 38 | } |
||
| 39 | |||
| 40 | @Override |
||
| 41 | public void preCarregamento() { |
||
| 42 | limparEntidade(); |
||
| 43 | } |
||
| 44 | |||
| 45 | @Override |
||
| 46 | public void limparEntidade() { |
||
| 47 | PessoaDTO pessoaDTO = new PessoaDTO(); |
||
| 48 | pessoaDTO.setTipoPessoa(TipoPessoa.FISICA_F.getValor()); |
||
| 49 | setEntidade(pessoaDTO); |
||
| 50 | } |
||
| 51 | |||
| 52 | @Override |
||
| 53 | public GenericService<PessoaDTO> getService() { |
||
| 54 | return null; |
||
| 55 | } |
||
| 56 | |||
| 57 | @Override |
||
| 58 | public PessoaDTO getEntidade() { |
||
| 59 | return entidade; |
||
| 60 | } |
||
| 61 | |||
| 62 | @Override |
||
| 63 | public void preConsultar() { |
||
| 64 | setTipoOperacao(TipoOperacao.CONSULTAR); |
||
| 65 | } |
||
| 66 | |||
| 67 | @Override |
||
| 68 | public PessoaDTO getId() { |
||
| 69 | return getEntidade(); |
||
| 70 | } |
||
| 71 | |||
| 72 | public TipoEstadoCivil[] getTiposEstadoCivil() { |
||
| 73 | return TipoEstadoCivil.values(); |
||
| 74 | } |
||
| 75 | |||
| 76 | public TipoRacaCor[] getTiposRacaCor() { |
||
| 77 | return TipoRacaCor.values(); |
||
| 78 | } |
||
| 79 | |||
| 80 | public TipoEscolaridade[] getTiposEscolaridade() { |
||
| 81 | return TipoEscolaridade.values(); |
||
| 82 | } |
||
| 83 | |||
| 84 | public Pessoa getPessoaSelecionada() { |
||
| 85 | return pessoaSelecionada; |
||
| 86 | } |
||
| 87 | public void setPessoaSelecionada(Pessoa pessoaSelecionada) { |
||
| 88 | this.pessoaSelecionada = pessoaSelecionada; |
||
| 89 | } |
||
| 90 | |||
| 91 | /*********************************************************/ |
||
| 92 | |||
| 93 | public void iniciarCadastroExterno() { |
||
| 94 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 95 | public void execute() { |
||
| 96 | setPessoaSelecionada(pessoaService.cadastroExterno(null, new Pessoa(getEntidade()))); |
||
| 97 | } |
||
| 98 | }); |
||
| 99 | } |
||
| 100 | |||
| 101 | public String seguir(FlowEvent evento) { |
||
| 102 | pessoaService.cadastroExterno(evento, getPessoaSelecionada()); |
||
| 103 | return evento.getNewStep(); |
||
| 104 | } |
||
| 105 | |||
| 106 | public void confirmarCadastro() { |
||
| 107 | // SALVAR |
||
| 108 | // ENVIAR EMAIL DE CONFIRMAÇÃO DE CADASTRO |
||
| 109 | } |
||
| 110 | |||
| 111 | } |