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 1... | Line 1... | ||
| 1 | package br.com.ec.domain.service.impl; |
1 | package br.com.ec.domain.service.impl; |
| 2 | 2 | ||
| - | 3 | import java.util.ArrayList; |
|
| 3 | import java.util.List; |
4 | import java.util.List; |
| 4 | 5 | ||
| 5 | import org.primefaces.event.FlowEvent; |
6 | import org.primefaces.event.FlowEvent; |
| 6 | import org.springframework.beans.factory.annotation.Autowired; |
7 | import org.springframework.beans.factory.annotation.Autowired; |
| 7 | import org.springframework.stereotype.Service; |
8 | import org.springframework.stereotype.Service; |
| Line 10... | Line 11... | ||
| 10 | import br.com.ec.core.generic.AbstractService; |
11 | import br.com.ec.core.generic.AbstractService; |
| 11 | import br.com.ec.core.generic.GenericRepository; |
12 | import br.com.ec.core.generic.GenericRepository; |
| 12 | import br.com.ec.core.util.VerificadorUtil; |
13 | import br.com.ec.core.util.VerificadorUtil; |
| 13 | import br.com.ec.core.validador.Validador; |
14 | import br.com.ec.core.validador.Validador; |
| 14 | import br.com.ec.domain.dto.PessoaDTO; |
15 | import br.com.ec.domain.dto.PessoaDTO; |
| - | 16 | import br.com.ec.domain.model.Endereco; |
|
| 15 | import br.com.ec.domain.model.Pessoa; |
17 | import br.com.ec.domain.model.Pessoa; |
| 16 | import br.com.ec.domain.service.FuncionarioService; |
18 | import br.com.ec.domain.service.FuncionarioService; |
| 17 | import br.com.ec.domain.service.PessoaService; |
19 | import br.com.ec.domain.service.PessoaService; |
| 18 | import br.com.ec.repository.PessoaRepository; |
20 | import br.com.ec.repository.PessoaRepository; |
| 19 | 21 | ||
| Line 52... | Line 54... | ||
| 52 | public Pessoa consultarPessoaPorCpfOuCpnj(String cpfCnpj) { |
54 | public Pessoa consultarPessoaPorCpfOuCpnj(String cpfCnpj) { |
| 53 | return pessoaRepository.consultarPessoaPorCpfOuCpnj(cpfCnpj); |
55 | return pessoaRepository.consultarPessoaPorCpfOuCpnj(cpfCnpj); |
| 54 | }
|
56 | }
|
| 55 | 57 | ||
| 56 | @Override |
58 | @Override |
| 57 | public Pessoa cadastroExterno(FlowEvent evento, Pessoa pessoa) { |
- | |
| - | 59 | public Pessoa cadastroExterno(FlowEvent evento, Pessoa pessoa, Endereco endereco) { |
|
| 58 | if (VerificadorUtil.estaNulo(evento)) { |
60 | if (VerificadorUtil.estaNulo(evento)) { |
| 59 | Pessoa pessoaConsultada = consultarPessoaPorCpfOuCpnj(pessoa.getCpfCnpj()); |
61 | Pessoa pessoaConsultada = consultarPessoaPorCpfOuCpnj(pessoa.getCpfCnpj()); |
| 60 | if (VerificadorUtil.estaNulo(pessoaConsultada)) { |
62 | if (VerificadorUtil.estaNulo(pessoaConsultada)) { |
| 61 | pessoa.setCadastroFinalizado(false); |
63 | pessoa.setCadastroFinalizado(false); |
| 62 | pessoa.setOptantePeloFGTS(true); |
64 | pessoa.setOptantePeloFGTS(true); |
| Line 65... | Line 67... | ||
| 65 | }
|
67 | }
|
| 66 | if (pessoaConsultada.getCadastroFinalizado()) { |
68 | if (pessoaConsultada.getCadastroFinalizado()) { |
| 67 | throw new NegocioException("CADASTRO INDISPONÍVEL"); |
69 | throw new NegocioException("CADASTRO INDISPONÍVEL"); |
| 68 | }
|
70 | }
|
| 69 | return pessoaConsultada; |
71 | return pessoaConsultada; |
| - | 72 | }
|
|
| - | 73 | if (VerificadorUtil.naoEstaNulo(endereco)) { |
|
| - | 74 | if (VerificadorUtil.naoEstaNuloOuVazio(endereco.getCep())) { |
|
| - | 75 | pessoa.atualizarEndereco(endereco); |
|
| - | 76 | }
|
|
| 70 | }
|
77 | }
|
| 71 | this.alterar(pessoa); |
78 | this.alterar(pessoa); |
| 72 | return pessoa; |
- | |
| - | 79 | return detalharPessoa(pessoa.getSequencial()); |
|
| 73 | }
|
80 | }
|
| 74 | 81 | ||
| 75 | @Override |
82 | @Override |
| 76 | public Pessoa detalharPessoa(Long sequencialPessoa) { |
83 | public Pessoa detalharPessoa(Long sequencialPessoa) { |
| 77 | return pessoaRepository.detalharPessoa(sequencialPessoa); |
84 | return pessoaRepository.detalharPessoa(sequencialPessoa); |