Rev 299 | Rev 303 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 299 | Rev 302 | ||
|---|---|---|---|
| Line 9... | Line 9... | ||
| 9 | import org.springframework.context.annotation.Scope; |
9 | import org.springframework.context.annotation.Scope; |
| 10 | 10 | ||
| 11 | import br.com.ec.core.generic.GenericService; |
11 | import br.com.ec.core.generic.GenericService; |
| 12 | import br.com.ec.core.util.VerificadorUtil; |
12 | import br.com.ec.core.util.VerificadorUtil; |
| 13 | import br.com.ec.domain.dto.PessoaDTO; |
13 | import br.com.ec.domain.dto.PessoaDTO; |
| - | 14 | import br.com.ec.domain.model.Endereco; |
|
| 14 | import br.com.ec.domain.model.Pessoa; |
15 | import br.com.ec.domain.model.Pessoa; |
| - | 16 | import br.com.ec.domain.model.tipos.TipoDependentes; |
|
| 15 | import br.com.ec.domain.model.tipos.TipoEscolaridade; |
17 | import br.com.ec.domain.model.tipos.TipoEscolaridade; |
| 16 | import br.com.ec.domain.model.tipos.TipoEstadoCivil; |
18 | import br.com.ec.domain.model.tipos.TipoEstadoCivil; |
| 17 | import br.com.ec.domain.model.tipos.TipoPessoa; |
19 | import br.com.ec.domain.model.tipos.TipoPessoa; |
| 18 | import br.com.ec.domain.model.tipos.TipoRacaCor; |
20 | import br.com.ec.domain.model.tipos.TipoRacaCor; |
| 19 | import br.com.ec.domain.service.PessoaService; |
21 | import br.com.ec.domain.service.PessoaService; |
| Line 28... | Line 30... | ||
| 28 | public class CadastroExternoBean extends AbstractBean<PessoaDTO> implements Serializable { |
30 | public class CadastroExternoBean extends AbstractBean<PessoaDTO> implements Serializable { |
| 29 | 31 | ||
| 30 | private static final long serialVersionUID = 1L; |
32 | private static final long serialVersionUID = 1L; |
| 31 | 33 | ||
| 32 | private Pessoa pessoaSelecionada; |
34 | private Pessoa pessoaSelecionada; |
| - | 35 | private Endereco enderecoSelecionado; |
|
| - | 36 | private String proximoPasso; |
|
| 33 | private PessoaService pessoaService; |
37 | private PessoaService pessoaService; |
| 34 | 38 | ||
| 35 | @Inject |
39 | @Inject |
| 36 | public CadastroExternoBean(PessoaService pessoaService) { |
40 | public CadastroExternoBean(PessoaService pessoaService) { |
| 37 | this.pessoaService = pessoaService; |
41 | this.pessoaService = pessoaService; |
| Line 44... | Line 48... | ||
| 44 | 48 | ||
| 45 | @Override |
49 | @Override |
| 46 | public void limparEntidade() { |
50 | public void limparEntidade() { |
| 47 | PessoaDTO pessoaDTO = new PessoaDTO(); |
51 | PessoaDTO pessoaDTO = new PessoaDTO(); |
| 48 | pessoaDTO.setTipoPessoa(TipoPessoa.FISICA_F.getValor()); |
52 | pessoaDTO.setTipoPessoa(TipoPessoa.FISICA_F.getValor()); |
| - | 53 | pessoaDTO.setNome("NOVATO"); |
|
| 49 | setEntidade(pessoaDTO); |
54 | setEntidade(pessoaDTO); |
| 50 | }
|
55 | }
|
| 51 | 56 | ||
| 52 | @Override |
57 | @Override |
| 53 | public GenericService<PessoaDTO> getService() { |
58 | public GenericService<PessoaDTO> getService() { |
| Line 77... | Line 82... | ||
| 77 | return TipoRacaCor.values(); |
82 | return TipoRacaCor.values(); |
| 78 | }
|
83 | }
|
| 79 | 84 | ||
| 80 | public TipoEscolaridade[] getTiposEscolaridade() { |
85 | public TipoEscolaridade[] getTiposEscolaridade() { |
| 81 | return TipoEscolaridade.values(); |
86 | return TipoEscolaridade.values(); |
| - | 87 | }
|
|
| - | 88 | ||
| - | 89 | public TipoDependentes[] getTiposDependentes() { |
|
| - | 90 | return TipoDependentes.values(); |
|
| 82 | }
|
91 | }
|
| 83 | 92 | ||
| 84 | public Pessoa getPessoaSelecionada() { |
93 | public Pessoa getPessoaSelecionada() { |
| 85 | return pessoaSelecionada; |
94 | return pessoaSelecionada; |
| 86 | }
|
95 | }
|
| 87 | public void setPessoaSelecionada(Pessoa pessoaSelecionada) { |
96 | public void setPessoaSelecionada(Pessoa pessoaSelecionada) { |
| 88 | this.pessoaSelecionada = pessoaSelecionada; |
97 | this.pessoaSelecionada = pessoaSelecionada; |
| - | 98 | }
|
|
| - | 99 | ||
| - | 100 | public Endereco getEnderecoSelecionado() { |
|
| - | 101 | return enderecoSelecionado; |
|
| - | 102 | }
|
|
| - | 103 | public void setEnderecoSelecionado(Endereco enderecoSelecionado) { |
|
| - | 104 | this.enderecoSelecionado = enderecoSelecionado; |
|
| - | 105 | }
|
|
| - | 106 | ||
| - | 107 | public String getProximoPasso() { |
|
| - | 108 | return proximoPasso; |
|
| - | 109 | }
|
|
| - | 110 | public void setProximoPasso(String proximoPasso) { |
|
| - | 111 | this.proximoPasso = proximoPasso; |
|
| 89 | }
|
112 | }
|
| 90 | 113 | ||
| 91 | /*********************************************************/
|
114 | /*********************************************************/
|
| 92 | 115 | ||
| 93 | public void iniciarCadastroExterno() { |
116 | public void iniciarCadastroExterno() { |
| 94 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
117 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
| 95 | public void execute() { |
118 | public void execute() { |
| 96 | setPessoaSelecionada(pessoaService.cadastroExterno(null, new Pessoa(getEntidade()))); |
- | |
| - | 119 | setPessoaSelecionada(pessoaService.cadastroExterno(null, new Pessoa(getEntidade()), null)); |
|
| - | 120 | getPessoaSelecionada().setNome(""); |
|
| - | 121 | setEnderecoSelecionado(getPessoaSelecionada().primeiroEndereco()); |
|
| - | 122 | if (VerificadorUtil.estaNulo(getEnderecoSelecionado())) { |
|
| - | 123 | setEnderecoSelecionado(new Endereco(true)); |
|
| - | 124 | }
|
|
| 97 | }
|
125 | }
|
| 98 | }); |
126 | }); |
| 99 | }
|
127 | }
|
| 100 | 128 | ||
| 101 | public String seguir(FlowEvent evento) { |
129 | public String seguir(FlowEvent evento) { |
| 102 | pessoaService.cadastroExterno(evento, getPessoaSelecionada()); |
- | |
| 103 | return evento.getNewStep(); |
- | |
| - | 130 | setProximoPasso(evento.getOldStep()); |
|
| - | 131 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
|
| - | 132 | public void execute() { |
|
| - | 133 | pessoaService.cadastroExterno(evento, getPessoaSelecionada(), getEnderecoSelecionado()); |
|
| - | 134 | setProximoPasso(evento.getNewStep()); |
|
| - | 135 | }
|
|
| - | 136 | }); |
|
| - | 137 | return getProximoPasso(); |
|
| 104 | }
|
138 | }
|
| 105 | 139 | ||
| 106 | public void confirmarCadastro() { |
- | |
| 107 | // SALVAR
|
- | |
| 108 | // ENVIAR EMAIL DE CONFIRMAÇÃO DE CADASTRO
|
- | |
| - | 140 | public void finalizarCadastro() { |
|
| - | 141 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
|
| - | 142 | public void execute() { |
|
| - | 143 | // SALVAR
|
|
| - | 144 | // ENVIAR EMAIL DE CONFIRMAÇÃO DE CADASTRO
|
|
| - | 145 | setPessoaSelecionada(null); |
|
| - | 146 | setEnderecoSelecionado(null); |
|
| - | 147 | limparEntidade(); |
|
| - | 148 | LancadorMensagem.lancarSucesso("CADASTRO REALIZADO COM SUCESSO"); |
|
| - | 149 | }
|
|
| - | 150 | }); |
|
| 109 | }
|
151 | }
|
| 110 | 152 | ||
| 111 | }
|
153 | }
|