Commit 1339b2887a0dc2ae20a176833e533148800ea064

Authored by Ronan Tavares Camargo
2 parents 1b8c2c4e 48700476
Exists in master

Merge branch 'tarefa-4451' into cnt-1.0.0-alfa12

cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/TermoReferenciaServiceImpl.java
... ... @@ -29,6 +29,7 @@ import br.com.centralit.api.model.TermoReferenciaObservacao;
29 29 import br.com.centralit.api.model.TermoReferenciaPenalidade;
30 30 import br.com.centralit.api.model.TermoReferenciaSancao;
31 31 import br.com.centralit.api.service.ConfiguracaoParametroSistemaService;
  32 +import br.com.centralit.api.service.ContratoService;
32 33 import br.com.centralit.api.service.DominioService;
33 34 import br.com.centralit.api.service.InternacionalizacaoService;
34 35 import br.com.centralit.api.service.ParceiroService;
... ... @@ -39,6 +40,7 @@ import br.com.centralit.api.service.TermoReferenciaService;
39 40 import br.com.centralit.api.service.UsuarioService;
40 41 import br.com.centralit.framework.controller.ReportController;
41 42 import br.com.centralit.framework.exception.BusinessException;
  43 +import br.com.centralit.framework.exception.CodigoErro;
42 44 import br.com.centralit.framework.model.Dominio;
43 45 import br.com.centralit.framework.model.Usuario;
44 46 import br.com.centralit.framework.service.arquitetura.GenericServiceImpl;
... ... @@ -121,6 +123,9 @@ public class TermoReferenciaServiceImpl extends GenericServiceImpl<TermoReferenc
121 123 //TODO - Ciro 21/01/2016- Substituir esta dependencia por chamada rest
122 124 @Autowired
123 125 private InternacionalizacaoService internacionalizacaoService;
  126 +
  127 + @Autowired
  128 + private ContratoService contratoService;
124 129  
125 130 private Dominio idioma;
126 131  
... ... @@ -157,7 +162,8 @@ public class TermoReferenciaServiceImpl extends GenericServiceImpl<TermoReferenc
157 162  
158 163 @Override
159 164 public boolean removeById(Long id) {
160   -
  165 + validarExclusao(id);
  166 +
161 167 TermoReferencia termoReferencia = find(id);
162 168 if (CollectionUtils.isNotEmpty(termoReferencia.getPenalidades())){
163 169 penalidadeService.removeList((List<TermoReferenciaPenalidade>) termoReferencia.getPenalidades());
... ... @@ -170,6 +176,11 @@ public class TermoReferenciaServiceImpl extends GenericServiceImpl&lt;TermoReferenc
170 176 }
171 177 return termoReferenciaDao.removeById(id);
172 178 }
  179 +
  180 + private void validarExclusao(Long id) {
  181 + Boolean isVinculado = contratoService.existeVinculo("termoReferencia.id", id);
  182 + lancarBusinessException("VALIDACAO.REMOCAO_COM_VINCULO", CodigoErro.REGRA_NEGOCIO.getValue(), isVinculado);
  183 + }
173 184  
174 185 private void montarObjetoTermoReferencia(TermoReferencia termoReferencia) {
175 186  
... ...
cit-contratos-web/src/main/webapp/assets/js/angular/custom/controller/TermoReferenciaController.js
... ... @@ -696,19 +696,20 @@ citApp.controller(&#39;TermoReferenciaController&#39;, [&#39;$scope&#39;,
696 696 };
697 697  
698 698 // MODAL QUE CONFIRMA REMOVER TERMO
699   - $scope.remove = function(termo){
  699 + $scope.remover = function(termo){
700 700 $scope.$openModalConfirm({
701 701 message: $translate.instant('MSG.CONFIRMA_EXCLUIR_TERMO_REFERENCIA'),
702 702 callback: function () {
703 703 TermoReferenciaRepository.remove(termo).then(function() {
704 704 $scope.termoReferencia = {};
705 705  
706   - $scope.$modalConfirmInstance.dismiss('cancel');
707 706 $scope.showAlert("success", $translate.instant('MSG.SUCESSO_EXCLUSAO_TERMO_REFERENCIA'));
708 707 angular.element('#searchTermoReferencia').scope().fetchResult();
709 708  
710   - $scope.resetForm();
711 709 });
  710 +
  711 + $scope.$modalConfirmInstance.dismiss('cancel');
  712 + $scope.resetForm();
712 713 }
713 714 });
714 715 };
... ...
cit-contratos-web/src/main/webapp/assets/js/angular/custom/controller/TermoReferenciaListController.js
... ... @@ -81,17 +81,13 @@ citApp.controller(&#39;TermoReferenciaListController&#39;, [&#39;$scope&#39;, &#39;TermoReferenciaRe
81 81 $scope.showAlert('warning', $translate.instant('MSG.SELECIONE_UM_ITEM_PARA_VISUALIZACAO'));
82 82 $scope.setLoadingGet(false);
83 83 return;
84   - } else if (edit && $scope.termoReferenciaChecked.dataTermoGerado){
85   - $scope.showAlert('warning', $translate.instant('MSG.TERMO_REFERENCIA_JA_GERADO'));
86   - $scope.setLoadingGet(false);
87   - return;
88 84 }
89 85 angular.element('#editTermoReferencia').scope().getTermo(termo.id, edit);
90 86 $scope.$showPageEditWorkspace($scope.workspace);
91 87 };
92 88  
93 89 // MODAL QUE CONFIRMA REMOVER Do termo
94   - $scope.remove = function(){
  90 + $scope.remover = function(){
95 91 var termo = $scope.termoReferenciaChecked;
96 92  
97 93 if(termo === null) {
... ... @@ -99,7 +95,21 @@ citApp.controller(&#39;TermoReferenciaListController&#39;, [&#39;$scope&#39;, &#39;TermoReferenciaRe
99 95 return ;
100 96 }
101 97  
102   - angular.element('#editTermoReferencia').scope().remove(termo);
  98 + $scope.$openModalConfirm({
  99 + message: $translate.instant('MSG.CONFIRMA_EXCLUIR_TERMO_REFERENCIA'),
  100 + callback: function () {
  101 + TermoReferenciaRepository.remove(termo).then(function() {
  102 + $scope.termoReferencia = {};
  103 +
  104 + $scope.showAlert("success", $translate.instant('MSG.SUCESSO_EXCLUSAO_TERMO_REFERENCIA'));
  105 + angular.element('#searchTermoReferencia').scope().fetchResult();
  106 +
  107 + });
  108 +
  109 + $scope.$modalConfirmInstance.dismiss('cancel');
  110 + $scope.resetForm();
  111 + }
  112 + });
103 113 };
104 114  
105 115 $scope.gerarRelatorioTermoReferencia = function (edit) {
... ...
cit-contratos-web/src/main/webapp/html/termoReferencia/termoReferenciaList.html
... ... @@ -20,7 +20,7 @@
20 20 <translate>LABEL.EDITAR</translate>
21 21 </button>
22 22  
23   - <button title="{{$translate.instant('LABEL.REMOVER')}}" alt="{{$translate.instant('LABEL.REMOVER')}}" class="btn btn-clear" ng-click="remove();" type="button"
  23 + <button title="{{$translate.instant('LABEL.REMOVER')}}" alt="{{$translate.instant('LABEL.REMOVER')}}" class="btn btn-clear" ng-click="remover();" type="button"
24 24 ng-show="true">
25 25 <i class="fa fa-times red"></i>
26 26 <translate>LABEL.REMOVER</translate>
... ...