fixes bug#6503
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@46294 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
b481b5d120
commit
63c5b82639
|
@ -14,14 +14,22 @@ import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
|||
*
|
||||
* @author Administrador
|
||||
*/
|
||||
public interface EmpresaDAO extends GenericDAO<Empresa, Integer> {
|
||||
public interface EmpresaDAO {
|
||||
|
||||
public List<Empresa> 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<Empresa> buscarTodosExceto(List<Empresa> empresa,Integer... idEmpresa);
|
||||
|
||||
public List<Empresa> obtenerIndExternoFalse();
|
||||
|
||||
// public List<Empresa> obtenerIndTipo1(Usuario usuario);
|
||||
|
||||
public List<Empresa> buscar(String nombempresa, Boolean indExterna, Short indTipo);
|
||||
|
||||
public List<Empresa> obtenerIndTipo2();
|
||||
|
|
|
@ -32,8 +32,7 @@ import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
|||
* @author Administrador
|
||||
*/
|
||||
@Repository("empresaDAO")
|
||||
public class EmpresaHibernateDAO extends GenericHibernateDAO<Empresa, Integer>
|
||||
implements EmpresaDAO {
|
||||
public class EmpresaHibernateDAO extends GenericHibernateDAO<Empresa, Integer> implements EmpresaDAO {
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
@ -149,8 +148,11 @@ public class EmpresaHibernateDAO extends GenericHibernateDAO<Empresa, Integer>
|
|||
|
||||
@Override
|
||||
public Empresa suscribir(Empresa entity) throws RuntimeException {
|
||||
super.suscribir(entity);
|
||||
|
||||
|
||||
entity = super.suscribir(entity);
|
||||
|
||||
getSession().flush();
|
||||
|
||||
gerarSeqNumFolioSistema(entity.getEmpresaId());
|
||||
|
||||
return entity;
|
||||
|
|
|
@ -14,7 +14,17 @@ import java.util.List;
|
|||
*
|
||||
* @author Administrador
|
||||
*/
|
||||
public interface MarcaService extends GenericService<Marca, Short> {
|
||||
public interface MarcaService {
|
||||
|
||||
public List<Marca> obtenerTodos();
|
||||
|
||||
public Marca obtenerID(Short id);
|
||||
|
||||
public Marca suscribir(Marca entidad);
|
||||
|
||||
public Marca actualizacion(Marca entidad);
|
||||
|
||||
public void borrar(Marca entidad);
|
||||
|
||||
public List<Marca> buscarPorNome(String nomeMarca);
|
||||
|
||||
|
|
|
@ -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)){
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue