Commit 415e2fb914a9622861f17d75c71333836763f171
Exists in
master
Merge remote-tracking branch 'remotes/origin/tarefa-4545' into cnt-1.0.0-alfa13
Showing
5 changed files
with
48 additions
and
7 deletions
Show diff stats
cit-tabelas-corp-api/src/main/java/br/com/centralit/api/model/Documento.java
@@ -104,9 +104,13 @@ public class Documento extends PersistentObjectAuditOrganizacao { | @@ -104,9 +104,13 @@ public class Documento extends PersistentObjectAuditOrganizacao { | ||
104 | 104 | ||
105 | /** Atributo anexos. */ | 105 | /** Atributo anexos. */ |
106 | @NotAudited | 106 | @NotAudited |
107 | - @OneToMany(fetch = FetchType.LAZY, mappedBy = "documento", cascade = CascadeType.ALL) | 107 | + @OneToMany(fetch = FetchType.LAZY, mappedBy = "documento", cascade = CascadeType.ALL, orphanRemoval = true) |
108 | @JsonView({ Views.GenericView.class }) | 108 | @JsonView({ Views.GenericView.class }) |
109 | private Collection<Anexo> anexos; | 109 | private Collection<Anexo> anexos; |
110 | + | ||
111 | + @NotAudited | ||
112 | + @JsonView({ Views.GenericView.class }) | ||
113 | + private String uuid; | ||
110 | 114 | ||
111 | /** | 115 | /** |
112 | * Retorna o valor do atributo <code>id</code> | 116 | * Retorna o valor do atributo <code>id</code> |
@@ -248,4 +252,12 @@ public class Documento extends PersistentObjectAuditOrganizacao { | @@ -248,4 +252,12 @@ public class Documento extends PersistentObjectAuditOrganizacao { | ||
248 | this.emitenteEstrutura = emitenteEstrutura; | 252 | this.emitenteEstrutura = emitenteEstrutura; |
249 | } | 253 | } |
250 | 254 | ||
255 | + public String getUuid() { | ||
256 | + return uuid; | ||
257 | + } | ||
258 | + | ||
259 | + public void setUuid(String uuid) { | ||
260 | + this.uuid = uuid; | ||
261 | + } | ||
262 | + | ||
251 | } | 263 | } |
cit-tabelas-corp-api/src/main/java/br/com/centralit/api/service/EnderecoService.java
@@ -96,5 +96,7 @@ public interface EnderecoService extends GenericService<Endereco, Long> { | @@ -96,5 +96,7 @@ public interface EnderecoService extends GenericService<Endereco, Long> { | ||
96 | * @return | 96 | * @return |
97 | */ | 97 | */ |
98 | Endereco buscarEnderecoWSCorreio(String cep); | 98 | Endereco buscarEnderecoWSCorreio(String cep); |
99 | + | ||
100 | + String buscaUltimoCodigoEndereco(); | ||
99 | 101 | ||
100 | } | 102 | } |
cit-tabelas-corp-api/src/main/java/br/com/centralit/api/service/impl/EnderecoServiceImpl.java
@@ -284,6 +284,18 @@ public class EnderecoServiceImpl extends GenericServiceImpl<Endereco, Long> impl | @@ -284,6 +284,18 @@ public class EnderecoServiceImpl extends GenericServiceImpl<Endereco, Long> impl | ||
284 | 284 | ||
285 | entity.setCodigo(codigo); | 285 | entity.setCodigo(codigo); |
286 | } | 286 | } |
287 | + | ||
288 | + @Override | ||
289 | + public String buscaUltimoCodigoEndereco(){ | ||
290 | + Endereco ultimoRegistro = (Endereco) this.enderecoDao.buscarUltimoRegistroComOrdenadoParametrizada("codigo"); | ||
291 | + | ||
292 | + Long sequencial = null; | ||
293 | + if (UtilObjeto.isReferencia(ultimoRegistro)) { | ||
294 | + sequencial = ultimoRegistro.getCodigo() == null ? null : Long.parseLong(ultimoRegistro.getCodigo()); | ||
295 | + } | ||
296 | + | ||
297 | + return sequencial.toString(); | ||
298 | + } | ||
287 | 299 | ||
288 | /** | 300 | /** |
289 | * <p> | 301 | * <p> |
cit-tabelas-corp-api/src/main/java/br/com/centralit/api/service/impl/PessoaServiceImpl.java
@@ -23,6 +23,7 @@ import br.com.centralit.api.model.PessoaJuridica; | @@ -23,6 +23,7 @@ import br.com.centralit.api.model.PessoaJuridica; | ||
23 | import br.com.centralit.api.model.Portador; | 23 | import br.com.centralit.api.model.Portador; |
24 | import br.com.centralit.api.model.Telefone; | 24 | import br.com.centralit.api.model.Telefone; |
25 | import br.com.centralit.api.service.ColaboradorService; | 25 | import br.com.centralit.api.service.ColaboradorService; |
26 | +import br.com.centralit.api.service.ConfiguracaoParametroSistemaService; | ||
26 | import br.com.centralit.api.service.ContatoService; | 27 | import br.com.centralit.api.service.ContatoService; |
27 | import br.com.centralit.api.service.DominioService; | 28 | import br.com.centralit.api.service.DominioService; |
28 | import br.com.centralit.api.service.EnderecoService; | 29 | import br.com.centralit.api.service.EnderecoService; |
@@ -133,6 +134,10 @@ public class PessoaServiceImpl extends GenericServiceImpl<Pessoa, Long> implemen | @@ -133,6 +134,10 @@ public class PessoaServiceImpl extends GenericServiceImpl<Pessoa, Long> implemen | ||
133 | /** Atributo seguradoraService. */ | 134 | /** Atributo seguradoraService. */ |
134 | @Autowired | 135 | @Autowired |
135 | private SeguradoraService seguradoraService; | 136 | private SeguradoraService seguradoraService; |
137 | + | ||
138 | + /** Atributo configuracaoParametroSistemaService. */ | ||
139 | + @Autowired | ||
140 | + private ConfiguracaoParametroSistemaService configuracaoParametroSistemaService; | ||
136 | 141 | ||
137 | /** Atributo moduloService. */ | 142 | /** Atributo moduloService. */ |
138 | @Autowired | 143 | @Autowired |
@@ -399,12 +404,20 @@ public class PessoaServiceImpl extends GenericServiceImpl<Pessoa, Long> implemen | @@ -399,12 +404,20 @@ public class PessoaServiceImpl extends GenericServiceImpl<Pessoa, Long> implemen | ||
399 | telefone.setPessoa(pessoaVH.getPessoa()); | 404 | telefone.setPessoa(pessoaVH.getPessoa()); |
400 | 405 | ||
401 | } | 406 | } |
407 | + | ||
402 | // Percorre a lista de endereco para setar a referencia da pessoa | 408 | // Percorre a lista de endereco para setar a referencia da pessoa |
409 | + String ultimoCodigoEndereco = enderecoService.buscaUltimoCodigoEndereco(); | ||
403 | for (Endereco endereco : pessoaVH.getPessoa().getEnderecos()) { | 410 | for (Endereco endereco : pessoaVH.getPessoa().getEnderecos()) { |
404 | 411 | ||
405 | endereco.setPessoa(pessoaVH.getPessoa()); | 412 | endereco.setPessoa(pessoaVH.getPessoa()); |
413 | + | ||
414 | + if(endereco.getCodigo() == null || endereco.getCodigo().equals("")){ | ||
415 | + ultimoCodigoEndereco = configuracaoParametroSistemaService.gerarNumeroIdentificacaoSeguencial(Long.valueOf(ultimoCodigoEndereco)); | ||
416 | + endereco.setCodigo(ultimoCodigoEndereco); | ||
417 | + } | ||
406 | 418 | ||
407 | } | 419 | } |
420 | + | ||
408 | // Percorre a lista de contatos para setar a referencia de pessoa | 421 | // Percorre a lista de contatos para setar a referencia de pessoa |
409 | for (Contato contato : pessoaVH.getPessoa().getContatos()) { | 422 | for (Contato contato : pessoaVH.getPessoa().getContatos()) { |
410 | 423 |
cit-tabelas-corp-web/src/main/webapp/assets/js/angular/custom/directive/AssociarDocumentoDirective.js
@@ -147,10 +147,11 @@ citApp.directive("componenteAssociarDocumentos", ["$translate", | @@ -147,10 +147,11 @@ citApp.directive("componenteAssociarDocumentos", ["$translate", | ||
147 | 147 | ||
148 | $scope.excluir = function(){ | 148 | $scope.excluir = function(){ |
149 | var documento = this.item; | 149 | var documento = this.item; |
150 | - if(documento.id !== undefined) { | ||
151 | - DocumentoRepository.remove(documento); | ||
152 | - $scope.appController.showAlertSucesso("success", $translate.instant('MSG.REGISTRO_EXCLUIDO')); | ||
153 | - } | 150 | +// [luis.camargo - 19/04/2016] O orphanRemoval do hibernate cuida da exclusão do documento ao gravar a alteração do cadastro. |
151 | +// if(documento.id !== undefined) { | ||
152 | +// DocumentoRepository.remove(documento); | ||
153 | +// $scope.appController.showAlertSucesso("success", $translate.instant('MSG.REGISTRO_EXCLUIDO')); | ||
154 | +// } | ||
154 | $scope.documentos.splice(documento.$index, 1); | 155 | $scope.documentos.splice(documento.$index, 1); |
155 | $scope.appController.$modalConfirmInstance.dismiss('cancel'); | 156 | $scope.appController.$modalConfirmInstance.dismiss('cancel'); |
156 | }; | 157 | }; |
@@ -245,13 +246,14 @@ citApp.directive("componenteAssociarDocumentos", ["$translate", | @@ -245,13 +246,14 @@ citApp.directive("componenteAssociarDocumentos", ["$translate", | ||
245 | $scope.excluirAnexo = function(){ | 246 | $scope.excluirAnexo = function(){ |
246 | var anexo = this.item; | 247 | var anexo = this.item; |
247 | if(anexo.id) { | 248 | if(anexo.id) { |
248 | - AnexoRepository.remove(anexo); | 249 | +// [luis.camargo - 19/04/2016] O orphanRemoval do hibernate cuida da exclusão do anexo ao gravar a alteração do cadastro. |
250 | +// AnexoRepository.remove(anexo); | ||
249 | $scope.documento.anexos.forEach(function (entity, key) { | 251 | $scope.documento.anexos.forEach(function (entity, key) { |
250 | if(entity.id === anexo.id){ | 252 | if(entity.id === anexo.id){ |
251 | $scope.documento.anexos.splice(key, 1); | 253 | $scope.documento.anexos.splice(key, 1); |
252 | } | 254 | } |
253 | }); | 255 | }); |
254 | - $scope.appController.showAlertSucesso("success", $translate.instant('MSG.REGISTRO_EXCLUIDO')); | 256 | +// $scope.appController.showAlertSucesso("success", $translate.instant('MSG.REGISTRO_EXCLUIDO')); |
255 | $scope.appController.$modalConfirmInstance.dismiss('cancel'); | 257 | $scope.appController.$modalConfirmInstance.dismiss('cancel'); |
256 | } | 258 | } |
257 | }; | 259 | }; |