Commit 419c90f451ae170822bbd2e388eabf4acae9535b
1 parent
9dfba2a7
Exists in
master
redmine #4455 Construção da funcionalidade Rascunho;
Showing
7 changed files
with
79 additions
and
0 deletions
Show diff stats
cit-contratos-api/src/main/java/br/com/centralit/api/dao/ProgramaDao.java
| @@ -31,5 +31,19 @@ public interface ProgramaDao extends CitGenericDAO { | @@ -31,5 +31,19 @@ public interface ProgramaDao extends CitGenericDAO { | ||
| 31 | * @return Collection<Programa> | 31 | * @return Collection<Programa> |
| 32 | */ | 32 | */ |
| 33 | Collection<Programa> findAutoCompleteProgramaByNumeroOrNomeAndOrganizacao(String numeroOrNome, Long idOrganizacao); | 33 | Collection<Programa> findAutoCompleteProgramaByNumeroOrNomeAndOrganizacao(String numeroOrNome, Long idOrganizacao); |
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p> | ||
| 37 | + * | ||
| 38 | + * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | ||
| 39 | + * | ||
| 40 | + * Método responsável por trazer um programa através do id do programa ação. | ||
| 41 | + * | ||
| 42 | + * @author luis.camargo | ||
| 43 | + * | ||
| 44 | + * @param idProgramaAcao | ||
| 45 | + * @return | ||
| 46 | + */ | ||
| 47 | + Programa findByProgramaAcao(Long idProgramaAcao); | ||
| 34 | 48 | ||
| 35 | } | 49 | } |
cit-contratos-api/src/main/java/br/com/centralit/api/dao/impl/ProgramaDaoHibernate.java
| @@ -2,6 +2,8 @@ package br.com.centralit.api.dao.impl; | @@ -2,6 +2,8 @@ package br.com.centralit.api.dao.impl; | ||
| 2 | 2 | ||
| 3 | import java.util.Collection; | 3 | import java.util.Collection; |
| 4 | 4 | ||
| 5 | +import javax.persistence.Query; | ||
| 6 | + | ||
| 5 | import org.apache.commons.lang.StringUtils; | 7 | import org.apache.commons.lang.StringUtils; |
| 6 | import org.springframework.stereotype.Repository; | 8 | import org.springframework.stereotype.Repository; |
| 7 | 9 | ||
| @@ -75,4 +77,19 @@ public class ProgramaDaoHibernate extends CitGenericDAOImpl implements ProgramaD | @@ -75,4 +77,19 @@ public class ProgramaDaoHibernate extends CitGenericDAOImpl implements ProgramaD | ||
| 75 | return this.search(searchSeven, this.persistentClass); | 77 | return this.search(searchSeven, this.persistentClass); |
| 76 | 78 | ||
| 77 | } | 79 | } |
| 80 | + | ||
| 81 | + @Override | ||
| 82 | + public Programa findByProgramaAcao(Long idProgramaAcao) { | ||
| 83 | + | ||
| 84 | + StringBuilder query = new StringBuilder(); | ||
| 85 | + query.append("select p.* ") | ||
| 86 | + .append(" from cnt_programa p ") | ||
| 87 | + .append(" inner join cnt_p_acao pa on pa.programa_id = p.id ") | ||
| 88 | + .append(" where pa.id = :idProgramaAcao "); | ||
| 89 | + | ||
| 90 | + Query resultado = em().createNativeQuery(query.toString(), Programa.class); | ||
| 91 | + resultado.setParameter("idProgramaAcao", idProgramaAcao); | ||
| 92 | + return (Programa) resultado.getSingleResult(); | ||
| 93 | + } | ||
| 94 | + | ||
| 78 | } | 95 | } |
cit-contratos-api/src/main/java/br/com/centralit/api/service/ProgramaService.java
| @@ -32,4 +32,18 @@ public interface ProgramaService extends GenericService<Programa, Long> { | @@ -32,4 +32,18 @@ public interface ProgramaService extends GenericService<Programa, Long> { | ||
| 32 | */ | 32 | */ |
| 33 | Collection <Programa> findAutoCompleteProgramaByNumeroOrNomeAndOrganizacao(String numeroOrNome, Long idOrganizacao); | 33 | Collection <Programa> findAutoCompleteProgramaByNumeroOrNomeAndOrganizacao(String numeroOrNome, Long idOrganizacao); |
| 34 | 34 | ||
| 35 | + /** | ||
| 36 | + * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p> | ||
| 37 | + * | ||
| 38 | + * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | ||
| 39 | + * | ||
| 40 | + * Método responsável por trazer um programa através do id do programa ação. | ||
| 41 | + * | ||
| 42 | + * @author luis.camargo | ||
| 43 | + * | ||
| 44 | + * @param idProgramaAcao | ||
| 45 | + * @return | ||
| 46 | + */ | ||
| 47 | + Programa findByProgramaAcao(Long idProgramaAcao); | ||
| 48 | + | ||
| 35 | } | 49 | } |
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/ProgramaServiceImpl.java
| @@ -49,6 +49,23 @@ public class ProgramaServiceImpl extends GenericServiceImpl<Programa, Long> impl | @@ -49,6 +49,23 @@ public class ProgramaServiceImpl extends GenericServiceImpl<Programa, Long> impl | ||
| 49 | public Collection<Programa> findAllByOrganizacao(Long organizacaoId) { | 49 | public Collection<Programa> findAllByOrganizacao(Long organizacaoId) { |
| 50 | return this.programaDao.findAllByOrganizacao(organizacaoId); | 50 | return this.programaDao.findAllByOrganizacao(organizacaoId); |
| 51 | } | 51 | } |
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p> | ||
| 55 | + * | ||
| 56 | + * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | ||
| 57 | + * | ||
| 58 | + * Método responsável por trazer um programa através do id do programa ação. | ||
| 59 | + * | ||
| 60 | + * @author luis.camargo | ||
| 61 | + * | ||
| 62 | + * @param idProgramaAcao | ||
| 63 | + * @return | ||
| 64 | + */ | ||
| 65 | + @Override | ||
| 66 | + public Programa findByProgramaAcao(Long idProgramaAcao) { | ||
| 67 | + return this.programaDao.findByProgramaAcao(idProgramaAcao); | ||
| 68 | + } | ||
| 52 | 69 | ||
| 53 | /** | 70 | /** |
| 54 | * <p> | 71 | * <p> |
cit-contratos-web/src/main/java/br/com/centralit/controller/ProgramaController.java
| @@ -104,6 +104,13 @@ public class ProgramaController extends GenericController<Programa> { | @@ -104,6 +104,13 @@ public class ProgramaController extends GenericController<Programa> { | ||
| 104 | return responseBody; | 104 | return responseBody; |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | + @RequestMapping(value = "/findByProgramaAcao", method = RequestMethod.GET, produces = "application/json") | ||
| 108 | + @ResponseBody | ||
| 109 | + public ResponseBodyWrapper getValorTotalOS(@RequestParam(value = "idProgramaAcao") Long idProgramaAcao) { | ||
| 110 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(this.programaService.findByProgramaAcao(idProgramaAcao), ViewsContrato.ProgramaAutoCompleteView.class); | ||
| 111 | + return responseBody; | ||
| 112 | + } | ||
| 113 | + | ||
| 107 | /** | 114 | /** |
| 108 | * {@inheritDoc} | 115 | * {@inheritDoc} |
| 109 | */ | 116 | */ |
cit-contratos-web/src/main/webapp/assets/js/angular/custom/controller/ContratoController.js
| @@ -194,6 +194,11 @@ citApp.controller('ContratoController', ['$scope', '$filter', 'FileUploader', 'C | @@ -194,6 +194,11 @@ citApp.controller('ContratoController', ['$scope', '$filter', 'FileUploader', 'C | ||
| 194 | 194 | ||
| 195 | if (rascunho) { | 195 | if (rascunho) { |
| 196 | $scope.contrato = rascunho; | 196 | $scope.contrato = rascunho; |
| 197 | + if ($scope.contrato.programaAcao) { | ||
| 198 | + ProgramaRepository.findByProgramaAcao($scope.contrato.programaAcao.id).then(function(result) { | ||
| 199 | + $scope.programaTemp = result.originalElement; | ||
| 200 | + }); | ||
| 201 | + } | ||
| 197 | } | 202 | } |
| 198 | $scope.workspace.objetoScope = $scope.contrato; | 203 | $scope.workspace.objetoScope = $scope.contrato; |
| 199 | $scope.startTimerIntervalSaveDraft($scope.workspace); | 204 | $scope.startTimerIntervalSaveDraft($scope.workspace); |
cit-contratos-web/src/main/webapp/assets/js/angular/custom/repository/ProgramaRepository.js
| @@ -11,6 +11,11 @@ citApp.factory('ProgramaRepository', ['RestangularContratos', 'AbstractRepositor | @@ -11,6 +11,11 @@ citApp.factory('ProgramaRepository', ['RestangularContratos', 'AbstractRepositor | ||
| 11 | this.findAutoCompleteProgramaByNumeroOrNomeAndOrganizacao = function(value, idOrganizacao) { | 11 | this.findAutoCompleteProgramaByNumeroOrNomeAndOrganizacao = function(value, idOrganizacao) { |
| 12 | return restangularContratos.one('rest/programa').getList("findAutoCompleteProgramaByNumeroOrNomeAndOrganizacao", {"numeroOrNome" : value, "idOrganizacao" : idOrganizacao}).then(); | 12 | return restangularContratos.one('rest/programa').getList("findAutoCompleteProgramaByNumeroOrNomeAndOrganizacao", {"numeroOrNome" : value, "idOrganizacao" : idOrganizacao}).then(); |
| 13 | }; | 13 | }; |
| 14 | + | ||
| 15 | + this.findByProgramaAcao = function(idProgramaAcao) { | ||
| 16 | + return restangularContratos.one(this.route + "/findByProgramaAcao").get({"idProgramaAcao" : idProgramaAcao}).then(); | ||
| 17 | + }; | ||
| 18 | + | ||
| 14 | } | 19 | } |
| 15 | 20 | ||
| 16 | AbstractRepository.extend(ProgramaRepository); | 21 | AbstractRepository.extend(ProgramaRepository); |