W2i - Parametrizar Serie por Empresa (fixed bug #5522)

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@36808 d1611594-4594-4d17-8e1d-87c2c4800839
master
leonardo 2014-07-24 13:32:14 +00:00
parent cd558ad4e2
commit c77d923683
5 changed files with 192 additions and 0 deletions

View File

@ -0,0 +1,8 @@
package com.rjconsultores.ventaboletos.dao;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.SeguradoraEmpresa;
public interface SeguradoraEmpresaDAO extends GenericDAO<SeguradoraEmpresa, Integer> {
public boolean existe(Empresa empresa, String serie);
}

View File

@ -0,0 +1,39 @@
package com.rjconsultores.ventaboletos.dao.hibernate;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import com.rjconsultores.ventaboletos.dao.SeguradoraEmpresaDAO;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.SeguradoraEmpresa;
@Repository("seguradoraEmpresaDAO")
public class SeguradoraEmpresaHibernateDAO extends GenericHibernateDAO<SeguradoraEmpresa, Integer> implements SeguradoraEmpresaDAO {
@Autowired
public SeguradoraEmpresaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
setSessionFactory(factory);
}
public List<SeguradoraEmpresa> obtenerTodos() {
Criteria c = makeCriteria();
c.add(Restrictions.eq("activo", Boolean.TRUE));
return c.list();
}
public boolean existe(Empresa empresa, String serie){
Criteria c = makeCriteria();
c.add(Restrictions.eq("activo", Boolean.TRUE));
c.add(Restrictions.eq("empresa", empresa));
c.add(Restrictions.eq("serie", serie));
return !c.list().isEmpty();
}
}

View File

@ -0,0 +1,80 @@
package com.rjconsultores.ventaboletos.entidad;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@SequenceGenerator(name = "SEGURADORA_EMPRESA_SEQ", sequenceName = "SEGURADORA_EMPRESA_SEQ", allocationSize = 1)
@Table(name = "SEGURADORA_EMPRESA")
public class SeguradoraEmpresa implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEGURADORA_EMPRESA_SEQ")
@Column(name = "SEGURADORAEMPRESA_ID ")
private Integer seguradoraEmpresaId;
@JoinColumn(name = "EMPRESA_ID", referencedColumnName = "EMPRESA_ID")
@ManyToOne
private Empresa empresa;
@Column(name = "SERIESEGURADORA")
private String serie;
@Column(name = "ACTIVO")
private Boolean activo;
@Column(name = "FECMODIF")
@Temporal(TemporalType.TIMESTAMP)
private Date fecmodif;
@Column(name = "USUARIO_ID")
private Integer usuarioId;
public Integer getSeguradoraEmpresaId() {
return seguradoraEmpresaId;
}
public void setSeguradoraEmpresaId(Integer seguradoraEmpresaId) {
this.seguradoraEmpresaId = seguradoraEmpresaId;
}
public Empresa getEmpresa() {
return empresa;
}
public void setEmpresa(Empresa empresa) {
this.empresa = empresa;
}
public Boolean getActivo() {
return activo;
}
public void setActivo(Boolean activo) {
this.activo = activo;
}
public Date getFecmodif() {
return fecmodif;
}
public void setFecmodif(Date fecmodif) {
this.fecmodif = fecmodif;
}
public Integer getUsuarioId() {
return usuarioId;
}
public void setUsuarioId(Integer usuarioId) {
this.usuarioId = usuarioId;
}
public String getSerie() {
return serie;
}
public void setSerie(String serie) {
this.serie = serie;
}
}

View File

@ -0,0 +1,9 @@
package com.rjconsultores.ventaboletos.service;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.SeguradoraEmpresa;
public interface SeguradoraEmpresaService extends GenericService<SeguradoraEmpresa, Integer>{
public boolean existe(Empresa empresa, String serie);
}

View File

@ -0,0 +1,56 @@
package com.rjconsultores.ventaboletos.service.impl;
import java.util.Calendar;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.rjconsultores.ventaboletos.dao.SeguradoraEmpresaDAO;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.SeguradoraEmpresa;
import com.rjconsultores.ventaboletos.service.SeguradoraEmpresaService;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
@Service("seguradoraEmpresaService")
public class SeguradoraEmpresaServiceImpl implements SeguradoraEmpresaService {
@Autowired
private SeguradoraEmpresaDAO seguradoraEmpresaDAO;
public List<SeguradoraEmpresa> obtenerTodos() {
return seguradoraEmpresaDAO.obtenerTodos();
}
public SeguradoraEmpresa obtenerID(Integer id) {
return seguradoraEmpresaDAO.obtenerID(id);
}
public boolean existe(Empresa empresa, String serie){
return seguradoraEmpresaDAO.existe(empresa, serie);
}
@Transactional
public SeguradoraEmpresa suscribir(SeguradoraEmpresa entidad) {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE);
return seguradoraEmpresaDAO.suscribir(entidad);
}
@Transactional
public SeguradoraEmpresa actualizacion(SeguradoraEmpresa entidad) {
return seguradoraEmpresaDAO.actualizacion(entidad);
}
@Transactional
public void borrar(SeguradoraEmpresa entidad) {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.FALSE);
seguradoraEmpresaDAO.borrar(entidad);
}
}