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-87c2c4800839master
parent
1085f41ce0
commit
767da88f6f
|
@ -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";
|
||||
|
||||
}
|
||||
|
|
|
@ -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<Custom, Integer> {
|
||||
|
||||
public Custom buscar(String chave);
|
||||
|
||||
public Custom buscar(Integer sistema, String chave);
|
||||
|
||||
}
|
||||
|
|
|
@ -41,4 +41,13 @@ public class CustomHibernateDAO extends GenericHibernateDAO<Custom, Integer>
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<Custom, Integer> {
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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<Object, Object> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue