diff --git a/src/com/rjconsultores/ventaboletos/dao/TipoEventoExtraPtovtaDAO.java b/src/com/rjconsultores/ventaboletos/dao/TipoEventoExtraPtovtaDAO.java new file mode 100644 index 000000000..4e0d83542 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/TipoEventoExtraPtovtaDAO.java @@ -0,0 +1,6 @@ +package com.rjconsultores.ventaboletos.dao; + +import com.rjconsultores.ventaboletos.entidad.TipoEventoExtraPtoVta; + +public interface TipoEventoExtraPtovtaDAO extends GenericDAO { +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/TipoEventoExtraPtovtaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/TipoEventoExtraPtovtaHibernateDAO.java new file mode 100644 index 000000000..1976a0870 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/TipoEventoExtraPtovtaHibernateDAO.java @@ -0,0 +1,31 @@ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import java.util.List; + +import org.hibernate.Criteria; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; + +import com.rjconsultores.ventaboletos.dao.TipoEventoExtraPtovtaDAO; +import com.rjconsultores.ventaboletos.entidad.TipoEventoExtraPtoVta; + +@Repository("tipoEventoExtraPtovtaDAO") +public class TipoEventoExtraPtovtaHibernateDAO extends GenericHibernateDAO implements +TipoEventoExtraPtovtaDAO { + + @Autowired + public TipoEventoExtraPtovtaHibernateDAO ( + @Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @Override + public List obtenerTodos() { + Criteria c = getSession().createCriteria(getPersistentClass()); + + return c.list(); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/TipoEventoExtra.java b/src/com/rjconsultores/ventaboletos/entidad/TipoEventoExtra.java index fa0f6b987..7acd93a72 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/TipoEventoExtra.java +++ b/src/com/rjconsultores/ventaboletos/entidad/TipoEventoExtra.java @@ -109,6 +109,10 @@ public class TipoEventoExtra implements Serializable { @Column(name="CVESISTEMA") private String cveSistema; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "tipoeventoextra") + @LazyCollection(LazyCollectionOption.FALSE) + private List pontosventa = new ArrayList(); public TipoEventoExtraEmpresa addEmpresa(Empresa e) { TipoEventoExtraEmpresa t = new TipoEventoExtraEmpresa(); @@ -125,6 +129,29 @@ public class TipoEventoExtra implements Serializable { this.empresas.remove(t); } + public TipoEventoExtraPtoVta addPuntoVenta(PuntoVenta p) { + TipoEventoExtraPtoVta t = new TipoEventoExtraPtoVta(); + t.setPuntoventa(p); + t.setTipoeventoextra(this); + t.setActivo(Boolean.TRUE); + t.setFecmodif(Calendar.getInstance().getTime()); + t.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + this.pontosventa.add(t); + return t; + } + + public void removePuntoVenta(PuntoVenta p) { + for (TipoEventoExtraPtoVta t : this.pontosventa){ + if (t.getPuntoventa().equals(p)){ + this.pontosventa.remove(t); + } + } + } + + public void removePuntoVenta(TipoEventoExtraPtoVta t){ + this.pontosventa.remove(t); + } + public String getDescTipoEvento() { return descTipoEvento; } @@ -402,5 +429,13 @@ public class TipoEventoExtra implements Serializable { public void setCveSistema(String cveSistema) { this.cveSistema = cveSistema; } + + public List getPontosventa() { + return pontosventa; + } + + public void setPontosventa(List pontosventa) { + this.pontosventa = pontosventa; + } } diff --git a/src/com/rjconsultores/ventaboletos/entidad/TipoEventoExtraPtoVta.java b/src/com/rjconsultores/ventaboletos/entidad/TipoEventoExtraPtoVta.java new file mode 100644 index 000000000..3d1188a49 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/TipoEventoExtraPtoVta.java @@ -0,0 +1,102 @@ +package com.rjconsultores.ventaboletos.entidad; + +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 +@Table(name = "TIPO_EVENTO_EXTRA_PTOVTA") +@SequenceGenerator(name = "TIPOEVENTOEXTRAPTOVTA_SEQ", sequenceName = "TIPOEVENTOEXTRAPTOVTA_SEQ", allocationSize = 1) +public class TipoEventoExtraPtoVta { + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "TIPOEVENTOEXTRAPTOVTA_SEQ") + @Column(name = "TIPOEVENTOEXTRAPTOVTA_ID") + private Integer tipoeventoextraptovtaId; + @ManyToOne + @JoinColumn(name = "TIPOEVENTOEXTRA_ID") + private TipoEventoExtra tipoeventoextra; + @ManyToOne + @JoinColumn(name = "PUNTOVENTA_ID") + private PuntoVenta puntoventa; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "ACTIVO") + private Boolean activo; + + public Integer getTipoeventoextraptovtaId() { + return tipoeventoextraptovtaId; + } + public void setTipoeventoextraptovtaId(Integer tipoeventoextraptovtaId) { + this.tipoeventoextraptovtaId = tipoeventoextraptovtaId; + } + public TipoEventoExtra getTipoeventoextra() { + return tipoeventoextra; + } + public void setTipoeventoextra(TipoEventoExtra tipoeventoextra) { + this.tipoeventoextra = tipoeventoextra; + } + public PuntoVenta getPuntoventa() { + return puntoventa; + } + public void setPuntoventa(PuntoVenta puntoventa) { + this.puntoventa = puntoventa; + } + public Integer getUsuarioId() { + return usuarioId; + } + public void setUsuarioId(Integer usuarioId) { + this.usuarioId = usuarioId; + } + public Date getFecmodif() { + return fecmodif; + } + public void setFecmodif(Date fecmodif) { + this.fecmodif = fecmodif; + } + public Boolean getActivo() { + return activo; + } + public void setActivo(Boolean activo) { + this.activo = activo; + } + + @Override + public String toString(){ + return this.puntoventa.getNombpuntoventa(); + } + + @Override + public int hashCode() { + int hash = 0; + hash += (tipoeventoextraptovtaId != null ? tipoeventoextraptovtaId.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof TipoEventoExtraPtoVta)) { + return false; + } + TipoEventoExtraPtoVta other = (TipoEventoExtraPtoVta) object; + if ((this.tipoeventoextraptovtaId == null && other.tipoeventoextraptovtaId != null) || (this.tipoeventoextraptovtaId != null && !this.tipoeventoextraptovtaId.equals(other.tipoeventoextraptovtaId))) { + return false; + } + return true; + } +} diff --git a/src/com/rjconsultores/ventaboletos/service/TipoEventoExtraPtovtaService.java b/src/com/rjconsultores/ventaboletos/service/TipoEventoExtraPtovtaService.java new file mode 100644 index 000000000..48e43a0ab --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/TipoEventoExtraPtovtaService.java @@ -0,0 +1,6 @@ +package com.rjconsultores.ventaboletos.service; + +import com.rjconsultores.ventaboletos.entidad.TipoEventoExtraPtoVta; + +public interface TipoEventoExtraPtovtaService extends GenericService { +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/TipoEventoExtraPtovtaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/TipoEventoExtraPtovtaServiceImpl.java new file mode 100644 index 000000000..9a8eefb3d --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/TipoEventoExtraPtovtaServiceImpl.java @@ -0,0 +1,53 @@ +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.TipoEventoExtraPtovtaDAO; +import com.rjconsultores.ventaboletos.entidad.TipoEventoExtraPtoVta; +import com.rjconsultores.ventaboletos.service.TipoEventoExtraPtovtaService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("tipoEventoExtraPtovtaService") +public class TipoEventoExtraPtovtaServiceImpl implements TipoEventoExtraPtovtaService { + @Autowired + private TipoEventoExtraPtovtaDAO TipoEventoExtraPtovtaDAO; + + + @Transactional + public TipoEventoExtraPtoVta suscribir(TipoEventoExtraPtoVta entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return TipoEventoExtraPtovtaDAO.suscribir(entidad); + } + + @Override + public List obtenerTodos() { + return TipoEventoExtraPtovtaDAO.obtenerTodos(); + } + + @Override + public TipoEventoExtraPtoVta obtenerID(Integer id) { + return TipoEventoExtraPtovtaDAO.obtenerID(id); + } + + @Transactional + public TipoEventoExtraPtoVta actualizacion(TipoEventoExtraPtoVta entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return TipoEventoExtraPtovtaDAO.actualizacion(entidad); + } + + @Transactional + public void borrar(TipoEventoExtraPtoVta entidad) { + TipoEventoExtraPtovtaDAO.borrar(entidad); + } +}