Commit 59b5055e27eab9ff1faaf01ecb6a27b104de36d8
1 parent
ac6b87a1
Exists in
master
#19 - Exibicao de validacoes em tela
Showing
12 changed files
with
168 additions
and
20 deletions
Show diff stats
documents/layouts_recadastramento/Layout_Retorno_Cadastro.xlsx
No preview for this file type
gcom/WEB-INF/cadastro/struts-config-CarregarDadosAtualizacaoCadastral.xml
... | ... | @@ -18,7 +18,11 @@ |
18 | 18 | <action |
19 | 19 | type="gcom.gui.cadastro.CarregarDadosAtualizacaoCadastralAction" |
20 | 20 | validate="true" |
21 | - path="/carregarDadosAtualizacaoCadastralAction" /> | |
21 | + path="/carregarDadosAtualizacaoCadastralAction"> | |
22 | + | |
23 | + <forward name="CarregarDadosAtualizacaoCadastralAction" | |
24 | + path="/jsp/cadastro/carregar_dados_atualizacao_cadastral.jsp" /> | |
25 | + </action> | |
22 | 26 | |
23 | 27 | </action-mappings> |
24 | 28 | ... | ... |
gcom/jsp/cadastro/carregar_dados_atualizacao_cadastral.jsp
... | ... | @@ -148,6 +148,53 @@ |
148 | 148 | </table> |
149 | 149 | </td> |
150 | 150 | </tr> |
151 | + | |
152 | + | |
153 | + <logic:present name="colecaoErrosCadastro"> | |
154 | + <tr> | |
155 | + <td colspan="2"> | |
156 | + <strong> | |
157 | + <font color="#FF0000">Arquivo de atualização cadastral possui erros</font> | |
158 | + </strong> | |
159 | + </td> | |
160 | + </tr> | |
161 | + <tr> | |
162 | + <td colspan="2"> | |
163 | + <div style="width: 100%; height: 100%; overflow: auto;"> | |
164 | + <table width="100%" bgcolor="#99CCFF"> | |
165 | + <tr bordercolor="#FFFFFF" bgcolor="#90c7fc"> | |
166 | + <td width="140"> Matrícula do imóvel</td> | |
167 | + <td> Descrição do erro </td> | |
168 | + </tr> | |
169 | + <% String cor = "#cbe5fe";%> | |
170 | + <logic:iterate name="colecaoErrosCadastro" id="element"> | |
171 | + <% if (cor.equalsIgnoreCase("#cbe5fe")){ | |
172 | + cor = "#FFFFFF";%> | |
173 | + <tr bgcolor="#FFFFFF" height="18"> | |
174 | + <%} else{ | |
175 | + cor = "#cbe5fe";%> | |
176 | + <tr bgcolor="#cbe5fe" height="18"> | |
177 | + <%}%> | |
178 | + | |
179 | + <td><bean:write name="element" property="key"/></td> | |
180 | + <td> | |
181 | + <table> | |
182 | + <logic:iterate name="element" property="value" id="erro"> | |
183 | + <tr> | |
184 | + <td><bean:write name="erro"/></td> | |
185 | + </tr> | |
186 | + </logic:iterate> | |
187 | + | |
188 | + </table> | |
189 | + </td> | |
190 | + </tr> | |
191 | + </logic:iterate> | |
192 | + </table> | |
193 | + </div> | |
194 | + </td> | |
195 | + </tr> | |
196 | + </logic:present> | |
197 | + | |
151 | 198 | </table> |
152 | 199 | <p class="style1"> </p> |
153 | 200 | </td> | ... | ... |
gcom/jsp/util/rodape.jsp
src/gcom/cadastro/ControladorCadastro.java
... | ... | @@ -7751,7 +7751,7 @@ public class ControladorCadastro implements SessionBean { |
7751 | 7751 | ParserUtil parserTipo = new ParserUtil(line); |
7752 | 7752 | String registroTipo = parserTipo.obterDadoParserTrim(2); |
7753 | 7753 | |
7754 | - String conteudo = line.substring(2); | |
7754 | + String conteudo = new String(line.substring(2).getBytes(), "UTF-8"); | |
7755 | 7755 | ParserUtil parserConteudo = new ParserUtil(conteudo); |
7756 | 7756 | |
7757 | 7757 | if ("00".equals(registroTipo)) { | ... | ... |
src/gcom/cadastro/atualizacaocadastral/command/AtualizacaoCadastral.java
... | ... | @@ -15,6 +15,8 @@ public class AtualizacaoCadastral { |
15 | 15 | |
16 | 16 | private AtualizacaoCadastralImovel imovelAtual = new AtualizacaoCadastralImovel(); |
17 | 17 | |
18 | + private boolean erroCadastro = false; | |
19 | + | |
18 | 20 | public ArquivoTextoAtualizacaoCadastral getArquivoTexto() { |
19 | 21 | return arquivoTexto; |
20 | 22 | } |
... | ... | @@ -32,7 +34,7 @@ public class AtualizacaoCadastral { |
32 | 34 | } |
33 | 35 | |
34 | 36 | public AtualizacaoCadastralImovel novaAtualizacaoImovel(){ |
35 | - AtualizacaoCadastralImovel imovel = new AtualizacaoCadastralImovel(); | |
37 | + AtualizacaoCadastralImovel imovel = new AtualizacaoCadastralImovel(this); | |
36 | 38 | imovelAtual = imovel; |
37 | 39 | imoveis.add(imovel); |
38 | 40 | return imovel; |
... | ... | @@ -41,4 +43,16 @@ public class AtualizacaoCadastral { |
41 | 43 | public AtualizacaoCadastralImovel getImovelAtual(){ |
42 | 44 | return imovelAtual; |
43 | 45 | } |
44 | -} | |
46 | + | |
47 | + public List<AtualizacaoCadastralImovel> getAtualizacoesImovel(){ | |
48 | + return imoveis; | |
49 | + } | |
50 | + | |
51 | + public boolean existeErroNoCadastro() { | |
52 | + return erroCadastro; | |
53 | + } | |
54 | + | |
55 | + public void cadastroComErro() { | |
56 | + this.erroCadastro = true; | |
57 | + } | |
58 | +} | |
45 | 59 | \ No newline at end of file | ... | ... |
src/gcom/cadastro/atualizacaocadastral/command/AtualizacaoCadastralImovel.java
... | ... | @@ -22,11 +22,19 @@ public class AtualizacaoCadastralImovel { |
22 | 22 | |
23 | 23 | private List<String> mensagensErro = new ArrayList<String>(); |
24 | 24 | |
25 | - private boolean erroCadastro = false; | |
26 | - | |
27 | 25 | private DadoAtualizacaoImovel dadosImovel = new DadoAtualizacaoImovel(); |
28 | 26 | |
29 | 27 | private List<DadoAtualizacaoRamoAtividade> dadosRamoAtividade = new ArrayList<DadoAtualizacaoRamoAtividade>(); |
28 | + | |
29 | + private AtualizacaoCadastral atualizacaoArquivo; | |
30 | + | |
31 | + public AtualizacaoCadastralImovel(){ | |
32 | + | |
33 | + } | |
34 | + | |
35 | + public AtualizacaoCadastralImovel(AtualizacaoCadastral atualizacaoArquivo) { | |
36 | + this.atualizacaoArquivo = atualizacaoArquivo; | |
37 | + } | |
30 | 38 | |
31 | 39 | public List<String> getNomesImagens() { |
32 | 40 | return nomesImagens; |
... | ... | @@ -105,7 +113,7 @@ public class AtualizacaoCadastralImovel { |
105 | 113 | } |
106 | 114 | |
107 | 115 | public boolean cadastroInvalido() { |
108 | - return erroCadastro; | |
116 | + return mensagensErro.size() > 0; | |
109 | 117 | } |
110 | 118 | |
111 | 119 | public List<String> getMensagensErro() { |
... | ... | @@ -113,7 +121,7 @@ public class AtualizacaoCadastralImovel { |
113 | 121 | } |
114 | 122 | |
115 | 123 | public void addMensagemErro(String erro) { |
116 | - erroCadastro = true; | |
124 | + atualizacaoArquivo.cadastroComErro(); | |
117 | 125 | mensagensErro.add(erro); |
118 | 126 | } |
119 | 127 | ... | ... |
src/gcom/cadastro/atualizacaocadastral/command/ParseClienteCommand.java
... | ... | @@ -240,16 +240,16 @@ public class ParseClienteCommand extends AbstractAtualizacaoCadastralCommand { |
240 | 240 | atualizacao.getImovelAtual().addMensagemErro("Nome de proprietário inválido."); |
241 | 241 | } |
242 | 242 | |
243 | - if (Util.cpfCnpjInvalido(linha.get("cnpjCpfUsuario"))){ | |
243 | + if (StringUtils.isNotEmpty(linha.get("cnpjCpfUsuario")) && Util.cpfCnpjInvalido(linha.get("cnpjCpfUsuario"))){ | |
244 | 244 | atualizacao.getImovelAtual().addMensagemErro("CPF/CNPJ de usuário inválido."); |
245 | 245 | limparDadosUsuario(linha); |
246 | 246 | } |
247 | 247 | |
248 | - if (Util.cpfCnpjInvalido(linha.get("cnpjCpfProprietario"))){ | |
248 | + if (StringUtils.isNotEmpty(linha.get("cnpjCpfProprietario")) && Util.cpfCnpjInvalido(linha.get("cnpjCpfProprietario"))){ | |
249 | 249 | atualizacao.getImovelAtual().addMensagemErro("CPF/CNPJ de proprietário inválido."); |
250 | 250 | } |
251 | 251 | |
252 | - if (Util.cpfCnpjInvalido(linha.get("cnpjCpfResponsavel"))){ | |
252 | + if (StringUtils.isNotEmpty(linha.get("cnpjCpfResponsavel")) && Util.cpfCnpjInvalido(linha.get("cnpjCpfResponsavel"))){ | |
253 | 253 | atualizacao.getImovelAtual().addMensagemErro("CPF/CNPJ de responsável inválido."); |
254 | 254 | } |
255 | 255 | ... | ... |
src/gcom/cadastro/atualizacaocadastral/command/ParseImovelCommand.java
... | ... | @@ -2,11 +2,13 @@ package gcom.cadastro.atualizacaocadastral.command; |
2 | 2 | |
3 | 3 | import gcom.cadastro.IRepositorioCadastro; |
4 | 4 | import gcom.cadastro.cliente.ControladorClienteLocal; |
5 | +import gcom.cadastro.endereco.LogradouroTipo; | |
5 | 6 | import gcom.cadastro.imovel.ControladorImovelLocal; |
6 | 7 | import gcom.cadastro.imovel.IRepositorioImovel; |
7 | 8 | import gcom.cadastro.imovel.ImagemAtualizacaoCadastral; |
8 | 9 | import gcom.seguranca.transacao.ControladorTransacaoLocal; |
9 | 10 | import gcom.util.ControladorUtilLocal; |
11 | +import gcom.util.ErroRepositorioException; | |
10 | 12 | import gcom.util.ParserUtil; |
11 | 13 | |
12 | 14 | import java.awt.image.BufferedImage; |
... | ... | @@ -17,6 +19,8 @@ import java.util.Map; |
17 | 19 | |
18 | 20 | import javax.imageio.ImageIO; |
19 | 21 | |
22 | +import org.apache.commons.lang.StringUtils; | |
23 | + | |
20 | 24 | public class ParseImovelCommand extends AbstractAtualizacaoCadastralCommand { |
21 | 25 | |
22 | 26 | public ParseImovelCommand(ParserUtil parser, IRepositorioCadastro repositorioCadastro, ControladorUtilLocal controladorUtil, |
... | ... | @@ -166,30 +170,56 @@ public class ParseImovelCommand extends AbstractAtualizacaoCadastralCommand { |
166 | 170 | validaCamposImovel(atualizacao); |
167 | 171 | } |
168 | 172 | |
169 | - private void validaCamposImovel(AtualizacaoCadastral atualizacao) { | |
170 | - Map<String, String> linha = atualizacao.getImovelAtual().getLinhaImovel(); | |
171 | - if (linha.get("latitude") == null || linha.get("longitude") == null){ | |
172 | - atualizacao.getImovelAtual().addMensagemErro("Coordenadas geográficas inválidas"); | |
173 | + private void validaCamposImovel(AtualizacaoCadastral atualizacao) throws Exception { | |
174 | + AtualizacaoCadastralImovel imovel = atualizacao.getImovelAtual(); | |
175 | + Map<String, String> linha = imovel.getLinhaImovel(); | |
176 | + | |
177 | + if (StringUtils.isEmpty(linha.get("latitude"))){ | |
178 | + imovel.addMensagemErro("Latitude inválida"); | |
179 | + }else{ | |
180 | + if (StringUtils.containsOnly(linha.get("latitude").trim(), new char[]{'0'})){ | |
181 | + imovel.addMensagemErro("Latitude inválida"); | |
182 | + } | |
183 | + } | |
184 | + | |
185 | + if (StringUtils.isEmpty(linha.get("longitude"))){ | |
186 | + imovel.addMensagemErro("Longitude inválida"); | |
187 | + } | |
188 | + else{ | |
189 | + if (StringUtils.containsOnly(linha.get("longitude").trim(), new char[]{'0'})){ | |
190 | + imovel.addMensagemErro("Longitude inválida"); | |
191 | + } | |
173 | 192 | } |
174 | 193 | |
175 | 194 | boolean existeEconomia = false; |
176 | 195 | for(String key: linha.keySet()){ |
177 | 196 | if (key.contains("subcategoria")){ |
178 | 197 | String valor = linha.get(key).trim(); |
179 | - if (valor != null && valor.trim().length() > 0 && valor.replace("0", "").trim().length() > 0){ | |
198 | + if (StringUtils.isNotEmpty(valor) && !StringUtils.containsOnly(valor.trim(), new char[]{'0'})){ | |
180 | 199 | existeEconomia = true; |
181 | 200 | |
182 | 201 | char codigo = key.replace("subcategoria", "").charAt(0); |
183 | 202 | TipoEconomia tipo = TipoEconomia.getByCodigo(codigo); |
184 | - if (!atualizacao.getImovelAtual().getDadosImovel().contemTipoEconomia(tipo)){ | |
185 | - atualizacao.getImovelAtual().getDadosImovel().addTipoEconomia(tipo); | |
203 | + if (!imovel.getDadosImovel().contemTipoEconomia(tipo)){ | |
204 | + imovel.getDadosImovel().addTipoEconomia(tipo); | |
186 | 205 | } |
187 | 206 | } |
188 | 207 | } |
189 | 208 | } |
190 | 209 | |
191 | 210 | if (!existeEconomia){ |
192 | - atualizacao.getImovelAtual().addMensagemErro("Imóvel deve ter associado ao menos uma economia."); | |
211 | + imovel.addMensagemErro("Imóvel deve possuir ao menos uma economia."); | |
212 | + } | |
213 | + | |
214 | + String tipoLogradouro = linha.get("idTipoLogradouroImovel"); | |
215 | + | |
216 | + if (StringUtils.isEmpty(tipoLogradouro)){ | |
217 | + imovel.addMensagemErro("Tipo do logradouro do imóvel inválido."); | |
218 | + }else{ | |
219 | + LogradouroTipo tipo = repositorioImovel.pesquisarTipoLogradouro(Integer.valueOf(tipoLogradouro)); | |
220 | + if (tipo == null){ | |
221 | + imovel.addMensagemErro("Tipo do logradouro do imóvel inexistente."); | |
222 | + } | |
193 | 223 | } |
194 | 224 | } |
195 | 225 | } | ... | ... |
src/gcom/cadastro/imovel/IRepositorioImovel.java
... | ... | @@ -86,6 +86,7 @@ import gcom.cadastro.empresa.Empresa; |
86 | 86 | import gcom.cadastro.endereco.Cep; |
87 | 87 | import gcom.cadastro.endereco.LogradouroBairro; |
88 | 88 | import gcom.cadastro.endereco.LogradouroCep; |
89 | +import gcom.cadastro.endereco.LogradouroTipo; | |
89 | 90 | import gcom.cadastro.geografico.Municipio; |
90 | 91 | import gcom.cadastro.imovel.bean.ImovelSubcategoriaHelper; |
91 | 92 | import gcom.cadastro.tarifasocial.TarifaSocialCarta; |
... | ... | @@ -3301,4 +3302,6 @@ public interface IRepositorioImovel { |
3301 | 3302 | public ImovelControleAtualizacaoCadastral pesquisarImovelControleAtualizacaoCadastral(Integer idImovel) throws ErroRepositorioException; |
3302 | 3303 | |
3303 | 3304 | public Collection<Integer> pesquisarIdImoveisAprovados() throws ErroRepositorioException; |
3305 | + | |
3306 | + public LogradouroTipo pesquisarTipoLogradouro(Integer idTipoLogradouro) throws ErroRepositorioException; | |
3304 | 3307 | } |
3305 | 3308 | \ No newline at end of file | ... | ... |
src/gcom/cadastro/imovel/RepositorioImovelHBM.java
... | ... | @@ -90,8 +90,10 @@ import gcom.cadastro.cliente.RamoAtividade; |
90 | 90 | import gcom.cadastro.cliente.bean.ClienteImovelEconomiaHelper; |
91 | 91 | import gcom.cadastro.empresa.Empresa; |
92 | 92 | import gcom.cadastro.endereco.Cep; |
93 | +import gcom.cadastro.endereco.Logradouro; | |
93 | 94 | import gcom.cadastro.endereco.LogradouroBairro; |
94 | 95 | import gcom.cadastro.endereco.LogradouroCep; |
96 | +import gcom.cadastro.endereco.LogradouroTipo; | |
95 | 97 | import gcom.cadastro.geografico.Municipio; |
96 | 98 | import gcom.cadastro.imovel.bean.FiltrarImovelOutrosCriteriosHelper; |
97 | 99 | import gcom.cadastro.imovel.bean.ImovelEconomiaHelper; |
... | ... | @@ -31523,4 +31525,21 @@ public class RepositorioImovelHBM implements IRepositorioImovel { |
31523 | 31525 | HibernateUtil.closeSession(session); |
31524 | 31526 | } |
31525 | 31527 | } |
31528 | + | |
31529 | + public LogradouroTipo pesquisarTipoLogradouro(Integer idTipoLogradouro) throws ErroRepositorioException{ | |
31530 | + Session session = HibernateUtil.getSession(); | |
31531 | + try { | |
31532 | + String consulta = "SELECT tipo " | |
31533 | + + "FROM LogradouroTipo tipo " | |
31534 | + + "WHERE tipo.id = :idTipo "; | |
31535 | + | |
31536 | + return (LogradouroTipo) session.createQuery(consulta) | |
31537 | + .setInteger("idTipo", idTipoLogradouro).uniqueResult(); | |
31538 | + }catch (HibernateException e) { | |
31539 | + throw new ErroRepositorioException("Erro no Hibernate"); | |
31540 | + } finally { | |
31541 | + HibernateUtil.closeSession(session); | |
31542 | + } | |
31543 | + } | |
31544 | + | |
31526 | 31545 | } | ... | ... |
src/gcom/gui/cadastro/CarregarDadosAtualizacaoCadastralAction.java
1 | 1 | package gcom.gui.cadastro; |
2 | 2 | |
3 | 3 | import gcom.cadastro.atualizacaocadastral.command.AtualizacaoCadastral; |
4 | +import gcom.cadastro.atualizacaocadastral.command.AtualizacaoCadastralImovel; | |
4 | 5 | import gcom.fachada.Fachada; |
5 | 6 | import gcom.gui.ActionServletException; |
6 | 7 | import gcom.gui.GcomAction; |
... | ... | @@ -13,14 +14,17 @@ import java.io.FileOutputStream; |
13 | 14 | import java.io.FileReader; |
14 | 15 | import java.io.IOException; |
15 | 16 | import java.util.ArrayList; |
17 | +import java.util.HashMap; | |
16 | 18 | import java.util.Iterator; |
17 | 19 | import java.util.List; |
20 | +import java.util.Map; | |
18 | 21 | import java.util.zip.ZipEntry; |
19 | 22 | import java.util.zip.ZipInputStream; |
20 | 23 | |
21 | 24 | import javax.ejb.EJBException; |
22 | 25 | import javax.servlet.http.HttpServletRequest; |
23 | 26 | import javax.servlet.http.HttpServletResponse; |
27 | +import javax.servlet.http.HttpSession; | |
24 | 28 | |
25 | 29 | import org.apache.commons.fileupload.DiskFileUpload; |
26 | 30 | import org.apache.commons.fileupload.FileItem; |
... | ... | @@ -93,6 +97,25 @@ public class CarregarDadosAtualizacaoCadastralAction extends GcomAction { |
93 | 97 | } |
94 | 98 | |
95 | 99 | AtualizacaoCadastral atualizacao = Fachada.getInstancia().carregarImovelAtualizacaoCadastral(buffer, imagens); |
100 | + | |
101 | + if (atualizacao.existeErroNoCadastro()){ | |
102 | + HttpSession sessao = httpServletRequest.getSession(false); | |
103 | + Map<String, List<String>> mapErros = new HashMap<String, List<String>>(); | |
104 | + | |
105 | + for (AtualizacaoCadastralImovel imovel: atualizacao.getAtualizacoesImovel()){ | |
106 | + List<String> erros = mapErros.get(String.valueOf(imovel.getMatricula())); | |
107 | + if (erros == null){ | |
108 | + erros = new ArrayList<String>(); | |
109 | + mapErros.put(String.valueOf(imovel.getMatricula()), erros); | |
110 | + } | |
111 | + erros.addAll(imovel.getMensagensErro()); | |
112 | + } | |
113 | + | |
114 | + httpServletRequest.setAttribute("colecaoErrosCadastro", mapErros); | |
115 | + | |
116 | + retorno = actionMapping.findForward("CarregarDadosAtualizacaoCadastralAction"); | |
117 | + } | |
118 | + | |
96 | 119 | zipInputStream.close(); |
97 | 120 | }catch (Exception e) { |
98 | 121 | if (e instanceof EJBException){ | ... | ... |