Commit 415e2fb914a9622861f17d75c71333836763f171

Authored by luis.camargo
2 parents bce10ddd c140b099
Exists in master

Merge remote-tracking branch 'remotes/origin/tarefa-4545' into cnt-1.0.0-alfa13

cit-tabelas-corp-api/src/main/java/br/com/centralit/api/model/Documento.java
... ... @@ -104,9 +104,13 @@ public class Documento extends PersistentObjectAuditOrganizacao {
104 104  
105 105 /** Atributo anexos. */
106 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 108 @JsonView({ Views.GenericView.class })
109 109 private Collection<Anexo> anexos;
  110 +
  111 + @NotAudited
  112 + @JsonView({ Views.GenericView.class })
  113 + private String uuid;
110 114  
111 115 /**
112 116 * Retorna o valor do atributo <code>id</code>
... ... @@ -248,4 +252,12 @@ public class Documento extends PersistentObjectAuditOrganizacao {
248 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&lt;Endereco, Long&gt; {
96 96 * @return
97 97 */
98 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&lt;Endereco, Long&gt; impl
284 284  
285 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 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 23 import br.com.centralit.api.model.Portador;
24 24 import br.com.centralit.api.model.Telefone;
25 25 import br.com.centralit.api.service.ColaboradorService;
  26 +import br.com.centralit.api.service.ConfiguracaoParametroSistemaService;
26 27 import br.com.centralit.api.service.ContatoService;
27 28 import br.com.centralit.api.service.DominioService;
28 29 import br.com.centralit.api.service.EnderecoService;
... ... @@ -133,6 +134,10 @@ public class PessoaServiceImpl extends GenericServiceImpl&lt;Pessoa, Long&gt; implemen
133 134 /** Atributo seguradoraService. */
134 135 @Autowired
135 136 private SeguradoraService seguradoraService;
  137 +
  138 + /** Atributo configuracaoParametroSistemaService. */
  139 + @Autowired
  140 + private ConfiguracaoParametroSistemaService configuracaoParametroSistemaService;
136 141  
137 142 /** Atributo moduloService. */
138 143 @Autowired
... ... @@ -399,12 +404,20 @@ public class PessoaServiceImpl extends GenericServiceImpl&lt;Pessoa, Long&gt; implemen
399 404 telefone.setPessoa(pessoaVH.getPessoa());
400 405  
401 406 }
  407 +
402 408 // Percorre a lista de endereco para setar a referencia da pessoa
  409 + String ultimoCodigoEndereco = enderecoService.buscaUltimoCodigoEndereco();
403 410 for (Endereco endereco : pessoaVH.getPessoa().getEnderecos()) {
404 411  
405 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 421 // Percorre a lista de contatos para setar a referencia de pessoa
409 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(&quot;componenteAssociarDocumentos&quot;, [&quot;$translate&quot;,
147 147  
148 148 $scope.excluir = function(){
149 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 155 $scope.documentos.splice(documento.$index, 1);
155 156 $scope.appController.$modalConfirmInstance.dismiss('cancel');
156 157 };
... ... @@ -245,13 +246,14 @@ citApp.directive(&quot;componenteAssociarDocumentos&quot;, [&quot;$translate&quot;,
245 246 $scope.excluirAnexo = function(){
246 247 var anexo = this.item;
247 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 251 $scope.documento.anexos.forEach(function (entity, key) {
250 252 if(entity.id === anexo.id){
251 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 257 $scope.appController.$modalConfirmInstance.dismiss('cancel');
256 258 }
257 259 };
... ...