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
|
* @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> buscarTodosExceto(List<Empresa> empresa,Integer... idEmpresa);
|
||||||
|
|
||||||
public List<Empresa> obtenerIndExternoFalse();
|
public List<Empresa> obtenerIndExternoFalse();
|
||||||
|
|
||||||
// public List<Empresa> obtenerIndTipo1(Usuario usuario);
|
|
||||||
|
|
||||||
public List<Empresa> buscar(String nombempresa, Boolean indExterna, Short indTipo);
|
public List<Empresa> buscar(String nombempresa, Boolean indExterna, Short indTipo);
|
||||||
|
|
||||||
public List<Empresa> obtenerIndTipo2();
|
public List<Empresa> obtenerIndTipo2();
|
||||||
|
|
|
@ -32,8 +32,7 @@ import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||||
* @author Administrador
|
* @author Administrador
|
||||||
*/
|
*/
|
||||||
@Repository("empresaDAO")
|
@Repository("empresaDAO")
|
||||||
public class EmpresaHibernateDAO extends GenericHibernateDAO<Empresa, Integer>
|
public class EmpresaHibernateDAO extends GenericHibernateDAO<Empresa, Integer> implements EmpresaDAO {
|
||||||
implements EmpresaDAO {
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
@ -149,7 +148,10 @@ public class EmpresaHibernateDAO extends GenericHibernateDAO<Empresa, Integer>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Empresa suscribir(Empresa entity) throws RuntimeException {
|
public Empresa suscribir(Empresa entity) throws RuntimeException {
|
||||||
super.suscribir(entity);
|
|
||||||
|
entity = super.suscribir(entity);
|
||||||
|
|
||||||
|
getSession().flush();
|
||||||
|
|
||||||
gerarSeqNumFolioSistema(entity.getEmpresaId());
|
gerarSeqNumFolioSistema(entity.getEmpresaId());
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,17 @@ import java.util.List;
|
||||||
*
|
*
|
||||||
* @author Administrador
|
* @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);
|
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.dao.RutaEmpresaDAO;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.InscricaoEstadual;
|
import com.rjconsultores.ventaboletos.entidad.InscricaoEstadual;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Marca;
|
||||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||||
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||||
import com.rjconsultores.ventaboletos.service.EmpresaService;
|
import com.rjconsultores.ventaboletos.service.EmpresaService;
|
||||||
|
import com.rjconsultores.ventaboletos.service.MarcaService;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.RegistroConDependenciaException;
|
import com.rjconsultores.ventaboletos.utilerias.RegistroConDependenciaException;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
|
|
||||||
|
@ -32,6 +34,9 @@ public class EmpresaServiceImpl implements EmpresaService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private EmpresaDAO empresaDAO;
|
private EmpresaDAO empresaDAO;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MarcaService marcaService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RutaEmpresaDAO rutaEmpresaDAO;
|
private RutaEmpresaDAO rutaEmpresaDAO;
|
||||||
|
|
||||||
|
@ -48,18 +53,36 @@ public class EmpresaServiceImpl implements EmpresaService {
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Empresa suscribirActualizacion(Empresa entidad) throws BusinessException {
|
public Empresa suscribirActualizacion(Empresa entidad) throws BusinessException {
|
||||||
|
|
||||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
entidad.setActivo(Boolean.TRUE);
|
entidad.setActivo(Boolean.TRUE);
|
||||||
|
|
||||||
if (entidad.getEmpresaId() == null) {
|
if (entidad.getEmpresaId() == null) {
|
||||||
return empresaDAO.suscribir(entidad);
|
|
||||||
|
entidad = empresaDAO.suscribir(entidad);
|
||||||
|
|
||||||
|
gerarMarca(entidad);
|
||||||
|
|
||||||
} else {
|
} 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 {
|
public void borrar(Empresa entidad) throws RegistroConDependenciaException {
|
||||||
if ((rutaEmpresaDAO.obtenerPorEmpresa(entidad).size() > 0) ||
|
if ((rutaEmpresaDAO.obtenerPorEmpresa(entidad).size() > 0) ||
|
||||||
(esquemaCorridaDAO.buscarPorEmpresaCorrida(entidad).size() > 0)){
|
(esquemaCorridaDAO.buscarPorEmpresaCorrida(entidad).size() > 0)){
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class MarcaServiceImpl implements MarcaService {
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Marca suscribir(Marca entidad) {
|
public Marca suscribir(Marca entidad) {
|
||||||
|
|
||||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
entidad.setActivo(Boolean.TRUE);
|
entidad.setActivo(Boolean.TRUE);
|
||||||
|
|
Loading…
Reference in New Issue