Commit 3bf5cba412cd1b974d1e4306ca504b2cb1b6e5e5
1 parent
051e769b
Exists in
master
and in
1 other branch
Adiciona queryParam nome no listarSeries
Adicionado queryParam nome que permitirá encontrar séries que sejam iguais ao nome informado.
Showing
2 changed files
with
13 additions
and
5 deletions
Show diff stats
src/main/java/br/gov/ans/integracao/sei/rest/SeriesResource.java
| ... | ... | @@ -40,13 +40,18 @@ public class SeriesResource { |
| 40 | 40 | @GET |
| 41 | 41 | @Path("{unidade}/series") |
| 42 | 42 | @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
| 43 | - public Serie[] listarSeries(@PathParam("unidade") String unidade, @QueryParam("tipo-processo") String tipoProcesso, @QueryParam("filtro") String filtro) throws Exception{ | |
| 43 | + public Serie[] listarSeries(@PathParam("unidade") String unidade, @QueryParam("tipo-processo") String tipoProcesso, @QueryParam("filtro") String filtro, | |
| 44 | + @QueryParam("nome") String nome) throws Exception{ | |
| 44 | 45 | Serie[] series = seiNativeService.listarSeries(Constantes.SIGLA_SEI_BROKER, Constantes.CHAVE_IDENTIFICACAO, isBlank(unidade)? null : unidadeResource.consultarCodigo(unidade), tipoProcesso); |
| 45 | 46 | |
| 46 | - if(StringUtils.isNotBlank(filtro)){ | |
| 47 | + if(StringUtils.isNotBlank(filtro) || StringUtils.isNotBlank(nome)){ | |
| 47 | 48 | List<Serie> list = new ArrayList<Serie>(Arrays.asList(series)); |
| 48 | 49 | |
| 49 | - list.removeIf(serie -> !serie.getNome().toLowerCase().contains(filtro.toLowerCase())); | |
| 50 | + if(StringUtils.isNotBlank(nome)){ | |
| 51 | + list.removeIf(serie -> !serie.getNome().toLowerCase().equals(nome.toLowerCase())); | |
| 52 | + }else{ | |
| 53 | + list.removeIf(serie -> !serie.getNome().toLowerCase().contains(filtro.toLowerCase())); | |
| 54 | + } | |
| 50 | 55 | |
| 51 | 56 | if(list.isEmpty()){ |
| 52 | 57 | throw new NotFoundException(messages.getMessage("erro.series.nao.encontradas")); |
| ... | ... | @@ -61,8 +66,9 @@ public class SeriesResource { |
| 61 | 66 | @GET |
| 62 | 67 | @Path("{unidade}/tipos-documentos") |
| 63 | 68 | @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
| 64 | - public Response listarTiposDocumentos(@PathParam("unidade") String unidade, @QueryParam("filtro") String filtro) throws Exception{ | |
| 65 | - Serie[] series = listarSeries(unidade, null, filtro); | |
| 69 | + public Response listarTiposDocumentos(@PathParam("unidade") String unidade, @QueryParam("filtro") String filtro, | |
| 70 | + @QueryParam("nome") String nome) throws Exception{ | |
| 71 | + Serie[] series = listarSeries(unidade, null, filtro, nome); | |
| 66 | 72 | |
| 67 | 73 | if(series == null || series.length < 1){ |
| 68 | 74 | throw new NotFoundException(messages.getMessage("erro.tipo.documento.nao.encontrado")); | ... | ... |
src/main/resources/apidoc/serie.apidoc
| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | * @apiParam (Path Parameters) {String} unidade Sigla da Unidade cadastrada no SEI. |
| 12 | 12 | * |
| 13 | 13 | * @apiParam (Query Parameters) {String} [filtro] Para filtrar por series que contenham o trecho no nome. |
| 14 | + * @apiParam (Query Parameters) {String} [nome] Para selecionar a série que possua nome igual. | |
| 14 | 15 | * @apiParam (Query Parameters) {String} [tipo-processo=null] Para filtrar por determinado tipo de processo. |
| 15 | 16 | * |
| 16 | 17 | * @apiExample {curl} Exemplo de requisição: |
| ... | ... | @@ -42,6 +43,7 @@ |
| 42 | 43 | * @apiParam (Path Parameters) {String} unidade Sigla da Unidade cadastrada no SEI. |
| 43 | 44 | * |
| 44 | 45 | * @apiParam (Query Parameters) {String} [filtro] Para filtrar por documentos que contenham o trecho no nome. |
| 46 | + * @apiParam (Query Parameters) {String} [nome] Para selecionar a série que possua nome igual. | |
| 45 | 47 | * |
| 46 | 48 | * @apiExample {curl} Exemplo de requisição: |
| 47 | 49 | * curl -i https://<host>/sei-broker/service/COSAP/tipos-documentos | ... | ... |