From 767da88f6f88c85664f338c754bb902097b9d02b Mon Sep 17 00:00:00 2001 From: wilian Date: Thu, 10 Sep 2020 20:00:34 +0000 Subject: [PATCH] fixes bug#20284 dev:thiago qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@103259 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../constantes/ConstantesFuncionSistema.java | 1 + .../ventaboletos/dao/CustomDAO.java | 5 ++- .../dao/hibernate/CustomHibernateDAO.java | 9 ++++ .../ventaboletos/service/CustomService.java | 13 ++++++ .../service/impl/CustomServiceImpl.java | 42 +++++++++++++++++++ 5 files changed, 68 insertions(+), 2 deletions(-) diff --git a/src/com/rjconsultores/ventaboletos/constantes/ConstantesFuncionSistema.java b/src/com/rjconsultores/ventaboletos/constantes/ConstantesFuncionSistema.java index eb47a15c3..6f54efb9b 100644 --- a/src/com/rjconsultores/ventaboletos/constantes/ConstantesFuncionSistema.java +++ b/src/com/rjconsultores/ventaboletos/constantes/ConstantesFuncionSistema.java @@ -28,5 +28,6 @@ public class ConstantesFuncionSistema { public static final String CLAVE_CONFIG_EMITE_SOMENTE_CUPOM_EMBARQUE = "COM.RJCONSULTORES.ADMINISTRACION.GUI.CONFIGURACIONECCOMERCIALES.CONFIGTIPOPASSAGEM.EMITESOMENTECPEMB"; public static final String CLAVE_ADM_PRICING_MODIFICACAOMASSIVAWS = "COM.RJCONSULTORES.ADMINISTRACION.GUI.PRICING.MODIFICACAOMASSIVAWS"; public static final String CLAVE_ESTOQUE_W2I = "COM.RJCONSULTORES.ADMINISTRACION.GUI.ESQUEMAOPERACIONAL.ESTOQUEW2I"; + public static final String CLAVE_UPLOAD_ARQUIVO_CONFIGURACAO = "COM.RJCONSULTORES.ADMINISTRACION.GUI.SEGURIDAD.CUSTOMSISTEMA.UPLOADARQUIVOCONFIGURACAO"; } diff --git a/src/com/rjconsultores/ventaboletos/dao/CustomDAO.java b/src/com/rjconsultores/ventaboletos/dao/CustomDAO.java index 8093baebf..0d8242303 100644 --- a/src/com/rjconsultores/ventaboletos/dao/CustomDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/CustomDAO.java @@ -1,7 +1,5 @@ package com.rjconsultores.ventaboletos.dao; -import java.util.List; - import com.rjconsultores.ventaboletos.entidad.Custom; /** @@ -11,4 +9,7 @@ import com.rjconsultores.ventaboletos.entidad.Custom; public interface CustomDAO extends GenericDAO { public Custom buscar(String chave); + + public Custom buscar(Integer sistema, String chave); + } diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/CustomHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/CustomHibernateDAO.java index 367c8d405..a1349e276 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/CustomHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/CustomHibernateDAO.java @@ -41,4 +41,13 @@ public class CustomHibernateDAO extends GenericHibernateDAO return c.list().isEmpty() ? null : (Custom) c.list().get(0); } + + public Custom buscar(Integer sistema, String chave) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("sistema", sistema)); + c.add(Restrictions.ilike("chave", chave)); + return c.list().isEmpty() ? null : (Custom) c.list().get(0); + } + } diff --git a/src/com/rjconsultores/ventaboletos/service/CustomService.java b/src/com/rjconsultores/ventaboletos/service/CustomService.java index 7ac7e85ba..7a478c78e 100644 --- a/src/com/rjconsultores/ventaboletos/service/CustomService.java +++ b/src/com/rjconsultores/ventaboletos/service/CustomService.java @@ -4,7 +4,10 @@ */ package com.rjconsultores.ventaboletos.service; +import java.util.Properties; + import com.rjconsultores.ventaboletos.entidad.Custom; +import com.rjconsultores.ventaboletos.enums.SistemaEnum; /** * @@ -13,4 +16,14 @@ import com.rjconsultores.ventaboletos.entidad.Custom; public interface CustomService extends GenericService { public Custom buscar(String chave); + + /** + * Carrega para o banco os parāmetros do arquivo properties. + * Mantis #20284 + * @param sistema + * @param arquivo + * @param substituirExistente + */ + public void carregarArquivoProperties(SistemaEnum sistema, Properties arquivo, boolean substituirExistente); + } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/CustomServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/CustomServiceImpl.java index 447f7dcc1..4ea2789d8 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/CustomServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/CustomServiceImpl.java @@ -6,6 +6,8 @@ package com.rjconsultores.ventaboletos.service.impl; import java.util.Calendar; import java.util.List; +import java.util.Map.Entry; +import java.util.Properties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -14,6 +16,8 @@ import org.springframework.transaction.annotation.Transactional; import com.rjconsultores.ventaboletos.dao.CustomDAO; import com.rjconsultores.ventaboletos.entidad.Custom; +import com.rjconsultores.ventaboletos.enums.CustomTipo; +import com.rjconsultores.ventaboletos.enums.SistemaEnum; import com.rjconsultores.ventaboletos.service.CustomService; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; @@ -66,4 +70,42 @@ public class CustomServiceImpl implements CustomService { public Custom buscar(String chave) { return customDAO.buscar(chave); } + + @Override + @Transactional + public void carregarArquivoProperties(SistemaEnum sistema, Properties arquivo, boolean substituirExistente) { + if(arquivo != null) { + for (Entry config : arquivo.entrySet()) { + Custom custom = customDAO.buscar(sistema.getValor(), config.getKey().toString()); + + if(custom != null && !substituirExistente) { + continue; + } + + if(custom == null) { + custom = new Custom(); + custom.setSistema(sistema.getValor()); + custom.setOrdem(0); + custom.setChave(config.getKey().toString()); + if(sistema.equals(SistemaEnum.VENDA_SERVIDOR)) { + custom.setTipo(CustomTipo.TIPO_SERVIDOR.getValor()); + } else if(sistema.equals(SistemaEnum.VENDA_CLIENTE)) { + custom.setTipo(CustomTipo.TIPO_CLIENTE.getValor()); + } + } + + custom.setValor(config.getValue().toString()); + suscribirOrActualizacion(custom); + } + } + } + + @Transactional + private Custom suscribirOrActualizacion(Custom custom) { + if(custom.getCustomId() == null) { + return suscribir(custom); + } else { + return actualizacion(custom); + } + } }