From 63c5b826392b52c53137121019a3ecb752a8b4c6 Mon Sep 17 00:00:00 2001 From: gleimar Date: Fri, 24 Jul 2015 21:08:42 +0000 Subject: [PATCH] fixes bug#6503 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@46294 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/dao/EmpresaDAO.java | 14 +++++++-- .../dao/hibernate/EmpresaHibernateDAO.java | 10 ++++--- .../ventaboletos/service/MarcaService.java | 12 +++++++- .../service/impl/EmpresaServiceImpl.java | 29 +++++++++++++++++-- .../service/impl/MarcaServiceImpl.java | 1 + 5 files changed, 55 insertions(+), 11 deletions(-) diff --git a/src/com/rjconsultores/ventaboletos/dao/EmpresaDAO.java b/src/com/rjconsultores/ventaboletos/dao/EmpresaDAO.java index f940da83f..fa2d2a0fc 100644 --- a/src/com/rjconsultores/ventaboletos/dao/EmpresaDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/EmpresaDAO.java @@ -14,14 +14,22 @@ import com.rjconsultores.ventaboletos.entidad.PuntoVenta; * * @author Administrador */ -public interface EmpresaDAO extends GenericDAO { +public interface EmpresaDAO { + + public List obtenerTodos(); + + public Empresa obtenerID(Integer id); + + public Empresa suscribir(Empresa entidad); + + public Empresa actualizacion(Empresa entidad); + + public Long count(String campo,Object o); public List buscarTodosExceto(List empresa,Integer... idEmpresa); public List obtenerIndExternoFalse(); -// public List obtenerIndTipo1(Usuario usuario); - public List buscar(String nombempresa, Boolean indExterna, Short indTipo); public List obtenerIndTipo2(); diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaHibernateDAO.java index 417bdf035..6dc21ca7d 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaHibernateDAO.java @@ -32,8 +32,7 @@ import com.rjconsultores.ventaboletos.entidad.PuntoVenta; * @author Administrador */ @Repository("empresaDAO") -public class EmpresaHibernateDAO extends GenericHibernateDAO - implements EmpresaDAO { +public class EmpresaHibernateDAO extends GenericHibernateDAO implements EmpresaDAO { @Autowired private DataSource dataSource; @@ -149,8 +148,11 @@ public class EmpresaHibernateDAO extends GenericHibernateDAO @Override public Empresa suscribir(Empresa entity) throws RuntimeException { - super.suscribir(entity); - + + entity = super.suscribir(entity); + + getSession().flush(); + gerarSeqNumFolioSistema(entity.getEmpresaId()); return entity; diff --git a/src/com/rjconsultores/ventaboletos/service/MarcaService.java b/src/com/rjconsultores/ventaboletos/service/MarcaService.java index a24beb18b..cbd92c86b 100644 --- a/src/com/rjconsultores/ventaboletos/service/MarcaService.java +++ b/src/com/rjconsultores/ventaboletos/service/MarcaService.java @@ -14,7 +14,17 @@ import java.util.List; * * @author Administrador */ -public interface MarcaService extends GenericService { +public interface MarcaService { + + public List obtenerTodos(); + + public Marca obtenerID(Short id); + + public Marca suscribir(Marca entidad); + + public Marca actualizacion(Marca entidad); + + public void borrar(Marca entidad); public List buscarPorNome(String nomeMarca); diff --git a/src/com/rjconsultores/ventaboletos/service/impl/EmpresaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/EmpresaServiceImpl.java index 9dac0cb1d..dc7f522aa 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/EmpresaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/EmpresaServiceImpl.java @@ -16,9 +16,11 @@ import com.rjconsultores.ventaboletos.dao.EsquemaCorridaDAO; import com.rjconsultores.ventaboletos.dao.RutaEmpresaDAO; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.InscricaoEstadual; +import com.rjconsultores.ventaboletos.entidad.Marca; import com.rjconsultores.ventaboletos.entidad.PuntoVenta; import com.rjconsultores.ventaboletos.exception.BusinessException; import com.rjconsultores.ventaboletos.service.EmpresaService; +import com.rjconsultores.ventaboletos.service.MarcaService; import com.rjconsultores.ventaboletos.utilerias.RegistroConDependenciaException; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; @@ -31,6 +33,9 @@ public class EmpresaServiceImpl implements EmpresaService { @Autowired private EmpresaDAO empresaDAO; + + @Autowired + private MarcaService marcaService; @Autowired private RutaEmpresaDAO rutaEmpresaDAO; @@ -48,18 +53,36 @@ public class EmpresaServiceImpl implements EmpresaService { @Transactional public Empresa suscribirActualizacion(Empresa entidad) throws BusinessException { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setActivo(Boolean.TRUE); if (entidad.getEmpresaId() == null) { - return empresaDAO.suscribir(entidad); + + entidad = empresaDAO.suscribir(entidad); + + gerarMarca(entidad); + } else { - return empresaDAO.actualizacion(entidad); + entidad = empresaDAO.actualizacion(entidad); } + + return entidad; } - @Transactional + private void gerarMarca(Empresa empresa) { + + Marca marca = new Marca(); + + marca.setEmpresa(empresa); + marca.setDescmarca(empresa.getNombempresa()); + + marcaService.suscribir(marca); + + } + + @Transactional public void borrar(Empresa entidad) throws RegistroConDependenciaException { if ((rutaEmpresaDAO.obtenerPorEmpresa(entidad).size() > 0) || (esquemaCorridaDAO.buscarPorEmpresaCorrida(entidad).size() > 0)){ diff --git a/src/com/rjconsultores/ventaboletos/service/impl/MarcaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/MarcaServiceImpl.java index 49edd8e71..85fceb1e7 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/MarcaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/MarcaServiceImpl.java @@ -36,6 +36,7 @@ public class MarcaServiceImpl implements MarcaService { @Transactional public Marca suscribir(Marca entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setActivo(Boolean.TRUE);