159 lines
4.5 KiB
Java
159 lines
4.5 KiB
Java
/*
|
|
* To change this template, choose Tools | Templates
|
|
* and open the template in the editor.
|
|
*/
|
|
package com.rjconsultores.ventaboletos.service.impl;
|
|
|
|
import com.rjconsultores.ventaboletos.dao.ConstanteDAO;
|
|
import com.rjconsultores.ventaboletos.entidad.Constante;
|
|
import com.rjconsultores.ventaboletos.service.ConstanteService;
|
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
|
|
|
import java.util.Calendar;
|
|
import java.util.List;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
/**
|
|
*
|
|
* @author Administrador
|
|
*/
|
|
@Service("constanteService")
|
|
public class ConstanteServiceImpl implements ConstanteService {
|
|
@Autowired
|
|
private ConstanteDAO constanteDAO;
|
|
|
|
public static final String URL_PAINEL_BPE = "URL_PAINEL_BPE";
|
|
public static final String URL_API = "URL_API";
|
|
public static final String URL_API_EMB = "URL_API_EMB";
|
|
|
|
public List<Constante> obtenerTodos() {
|
|
return constanteDAO.obtenerTodos();
|
|
}
|
|
|
|
public Constante obtenerID(Integer id) {
|
|
return constanteDAO.obtenerID(id);
|
|
}
|
|
|
|
@Transactional
|
|
public Constante suscribir(Constante entidad) {
|
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
|
entidad.setActivo(Boolean.TRUE);
|
|
|
|
return constanteDAO.suscribir(entidad);
|
|
}
|
|
|
|
@Transactional
|
|
public Constante actualizacion(Constante entidad) {
|
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
|
entidad.setActivo(Boolean.TRUE);
|
|
|
|
return constanteDAO.actualizacion(entidad);
|
|
}
|
|
|
|
@Transactional
|
|
public void borrar(Constante entidad) {
|
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
|
entidad.setActivo(Boolean.FALSE);
|
|
|
|
constanteDAO.actualizacion(entidad);
|
|
}
|
|
|
|
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
|
|
public Constante buscarPorNomeConstante(String nomeConstante) {
|
|
return constanteDAO.buscarPorNomeConstante(nomeConstante);
|
|
}
|
|
|
|
@Override
|
|
public Integer buscarValorConstantePorNomeConstante(String nomeConstante){
|
|
Constante constante = buscarPorNomeConstante(nomeConstante);
|
|
try {
|
|
if(constante!=null && StringUtils.isNotEmpty(constante.getValorconstante()) ) {
|
|
return Integer.valueOf(constante.getValorconstante().trim());
|
|
}
|
|
}catch (Exception e) {
|
|
return null;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public List<Constante> buscar(String nombconstante) {
|
|
return constanteDAO.buscar(nombconstante);
|
|
}
|
|
|
|
@Override
|
|
public String buscarNombreAmbiente(){
|
|
Constante constante = constanteDAO.buscarPorNomeConstante("NOMBRE_AMBIENTE");
|
|
if (constante == null){
|
|
return "";
|
|
}
|
|
|
|
return constante.getValorconstante();
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
public String buscarNomeConstanteURLPainelBPe(){
|
|
return URL_PAINEL_BPE;
|
|
}
|
|
@Override
|
|
public String buscarURLPainelBPe(){
|
|
Constante constante = constanteDAO.buscarPorNomeConstante(URL_PAINEL_BPE);
|
|
if (constante == null){
|
|
return "";
|
|
}
|
|
|
|
return constante.getValorconstante();
|
|
}
|
|
|
|
@Override
|
|
public boolean pafActivo(){
|
|
List<Constante> list = constanteDAO.buscar("HOMOLOGACAO_PAF");
|
|
if (list.isEmpty()){
|
|
return false;
|
|
}
|
|
|
|
Constante constante = list.get(0);
|
|
|
|
if (StringUtils.isBlank(constante.getValorconstante())){
|
|
return false;
|
|
}
|
|
|
|
return constante.getValorconstante().equalsIgnoreCase("true");
|
|
}
|
|
|
|
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
|
|
public List<Constante> buscarPorNomeConstanteLike(String nombconstante) {
|
|
return constanteDAO.buscarPorNomeConstanteLike(nombconstante);
|
|
}
|
|
|
|
@Override
|
|
public String buscarURLAPI(){
|
|
Constante constante = constanteDAO.buscarPorNomeConstante(URL_API);
|
|
|
|
if (constante == null) {
|
|
return "";
|
|
}
|
|
|
|
return constante.getValorconstante();
|
|
}
|
|
@Override
|
|
public String buscarURLAPIEmb(){
|
|
Constante constante = constanteDAO.buscarPorNomeConstante(URL_API_EMB);
|
|
|
|
if (constante == null) {
|
|
return "";
|
|
}
|
|
|
|
return constante.getValorconstante();
|
|
}
|
|
}
|