Commit 1339b2887a0dc2ae20a176833e533148800ea064
Exists in
master
Merge branch 'tarefa-4451' into cnt-1.0.0-alfa12
Showing
4 changed files
with
33 additions
and
11 deletions
Show diff stats
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,6 +29,7 @@ import br.com.centralit.api.model.TermoReferenciaObservacao; | ||
29 | import br.com.centralit.api.model.TermoReferenciaPenalidade; | 29 | import br.com.centralit.api.model.TermoReferenciaPenalidade; |
30 | import br.com.centralit.api.model.TermoReferenciaSancao; | 30 | import br.com.centralit.api.model.TermoReferenciaSancao; |
31 | import br.com.centralit.api.service.ConfiguracaoParametroSistemaService; | 31 | import br.com.centralit.api.service.ConfiguracaoParametroSistemaService; |
32 | +import br.com.centralit.api.service.ContratoService; | ||
32 | import br.com.centralit.api.service.DominioService; | 33 | import br.com.centralit.api.service.DominioService; |
33 | import br.com.centralit.api.service.InternacionalizacaoService; | 34 | import br.com.centralit.api.service.InternacionalizacaoService; |
34 | import br.com.centralit.api.service.ParceiroService; | 35 | import br.com.centralit.api.service.ParceiroService; |
@@ -39,6 +40,7 @@ import br.com.centralit.api.service.TermoReferenciaService; | @@ -39,6 +40,7 @@ import br.com.centralit.api.service.TermoReferenciaService; | ||
39 | import br.com.centralit.api.service.UsuarioService; | 40 | import br.com.centralit.api.service.UsuarioService; |
40 | import br.com.centralit.framework.controller.ReportController; | 41 | import br.com.centralit.framework.controller.ReportController; |
41 | import br.com.centralit.framework.exception.BusinessException; | 42 | import br.com.centralit.framework.exception.BusinessException; |
43 | +import br.com.centralit.framework.exception.CodigoErro; | ||
42 | import br.com.centralit.framework.model.Dominio; | 44 | import br.com.centralit.framework.model.Dominio; |
43 | import br.com.centralit.framework.model.Usuario; | 45 | import br.com.centralit.framework.model.Usuario; |
44 | import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; | 46 | import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; |
@@ -121,6 +123,9 @@ public class TermoReferenciaServiceImpl extends GenericServiceImpl<TermoReferenc | @@ -121,6 +123,9 @@ public class TermoReferenciaServiceImpl extends GenericServiceImpl<TermoReferenc | ||
121 | //TODO - Ciro 21/01/2016- Substituir esta dependencia por chamada rest | 123 | //TODO - Ciro 21/01/2016- Substituir esta dependencia por chamada rest |
122 | @Autowired | 124 | @Autowired |
123 | private InternacionalizacaoService internacionalizacaoService; | 125 | private InternacionalizacaoService internacionalizacaoService; |
126 | + | ||
127 | + @Autowired | ||
128 | + private ContratoService contratoService; | ||
124 | 129 | ||
125 | private Dominio idioma; | 130 | private Dominio idioma; |
126 | 131 | ||
@@ -157,7 +162,8 @@ public class TermoReferenciaServiceImpl extends GenericServiceImpl<TermoReferenc | @@ -157,7 +162,8 @@ public class TermoReferenciaServiceImpl extends GenericServiceImpl<TermoReferenc | ||
157 | 162 | ||
158 | @Override | 163 | @Override |
159 | public boolean removeById(Long id) { | 164 | public boolean removeById(Long id) { |
160 | - | 165 | + validarExclusao(id); |
166 | + | ||
161 | TermoReferencia termoReferencia = find(id); | 167 | TermoReferencia termoReferencia = find(id); |
162 | if (CollectionUtils.isNotEmpty(termoReferencia.getPenalidades())){ | 168 | if (CollectionUtils.isNotEmpty(termoReferencia.getPenalidades())){ |
163 | penalidadeService.removeList((List<TermoReferenciaPenalidade>) termoReferencia.getPenalidades()); | 169 | penalidadeService.removeList((List<TermoReferenciaPenalidade>) termoReferencia.getPenalidades()); |
@@ -170,6 +176,11 @@ public class TermoReferenciaServiceImpl extends GenericServiceImpl<TermoReferenc | @@ -170,6 +176,11 @@ public class TermoReferenciaServiceImpl extends GenericServiceImpl<TermoReferenc | ||
170 | } | 176 | } |
171 | return termoReferenciaDao.removeById(id); | 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 | private void montarObjetoTermoReferencia(TermoReferencia termoReferencia) { | 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('TermoReferenciaController', ['$scope', | @@ -696,19 +696,20 @@ citApp.controller('TermoReferenciaController', ['$scope', | ||
696 | }; | 696 | }; |
697 | 697 | ||
698 | // MODAL QUE CONFIRMA REMOVER TERMO | 698 | // MODAL QUE CONFIRMA REMOVER TERMO |
699 | - $scope.remove = function(termo){ | 699 | + $scope.remover = function(termo){ |
700 | $scope.$openModalConfirm({ | 700 | $scope.$openModalConfirm({ |
701 | message: $translate.instant('MSG.CONFIRMA_EXCLUIR_TERMO_REFERENCIA'), | 701 | message: $translate.instant('MSG.CONFIRMA_EXCLUIR_TERMO_REFERENCIA'), |
702 | callback: function () { | 702 | callback: function () { |
703 | TermoReferenciaRepository.remove(termo).then(function() { | 703 | TermoReferenciaRepository.remove(termo).then(function() { |
704 | $scope.termoReferencia = {}; | 704 | $scope.termoReferencia = {}; |
705 | 705 | ||
706 | - $scope.$modalConfirmInstance.dismiss('cancel'); | ||
707 | $scope.showAlert("success", $translate.instant('MSG.SUCESSO_EXCLUSAO_TERMO_REFERENCIA')); | 706 | $scope.showAlert("success", $translate.instant('MSG.SUCESSO_EXCLUSAO_TERMO_REFERENCIA')); |
708 | angular.element('#searchTermoReferencia').scope().fetchResult(); | 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('TermoReferenciaListController', ['$scope', 'TermoReferenciaRe | @@ -81,17 +81,13 @@ citApp.controller('TermoReferenciaListController', ['$scope', 'TermoReferenciaRe | ||
81 | $scope.showAlert('warning', $translate.instant('MSG.SELECIONE_UM_ITEM_PARA_VISUALIZACAO')); | 81 | $scope.showAlert('warning', $translate.instant('MSG.SELECIONE_UM_ITEM_PARA_VISUALIZACAO')); |
82 | $scope.setLoadingGet(false); | 82 | $scope.setLoadingGet(false); |
83 | return; | 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 | angular.element('#editTermoReferencia').scope().getTermo(termo.id, edit); | 85 | angular.element('#editTermoReferencia').scope().getTermo(termo.id, edit); |
90 | $scope.$showPageEditWorkspace($scope.workspace); | 86 | $scope.$showPageEditWorkspace($scope.workspace); |
91 | }; | 87 | }; |
92 | 88 | ||
93 | // MODAL QUE CONFIRMA REMOVER Do termo | 89 | // MODAL QUE CONFIRMA REMOVER Do termo |
94 | - $scope.remove = function(){ | 90 | + $scope.remover = function(){ |
95 | var termo = $scope.termoReferenciaChecked; | 91 | var termo = $scope.termoReferenciaChecked; |
96 | 92 | ||
97 | if(termo === null) { | 93 | if(termo === null) { |
@@ -99,7 +95,21 @@ citApp.controller('TermoReferenciaListController', ['$scope', 'TermoReferenciaRe | @@ -99,7 +95,21 @@ citApp.controller('TermoReferenciaListController', ['$scope', 'TermoReferenciaRe | ||
99 | return ; | 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 | $scope.gerarRelatorioTermoReferencia = function (edit) { | 115 | $scope.gerarRelatorioTermoReferencia = function (edit) { |
cit-contratos-web/src/main/webapp/html/termoReferencia/termoReferenciaList.html
@@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
20 | <translate>LABEL.EDITAR</translate> | 20 | <translate>LABEL.EDITAR</translate> |
21 | </button> | 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 | ng-show="true"> | 24 | ng-show="true"> |
25 | <i class="fa fa-times red"></i> | 25 | <i class="fa fa-times red"></i> |
26 | <translate>LABEL.REMOVER</translate> | 26 | <translate>LABEL.REMOVER</translate> |