diff --git a/src/com/rjconsultores/ventaboletos/dao/ItemAdicionalDAO.java b/src/com/rjconsultores/ventaboletos/dao/ItemAdicionalDAO.java new file mode 100644 index 000000000..4c207290f --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/ItemAdicionalDAO.java @@ -0,0 +1,12 @@ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.ItemAdicional; +import com.rjconsultores.ventaboletos.entidad.Pacote; + +public interface ItemAdicionalDAO extends GenericDAO { + + public List buscaItemAdicionalPacote(Pacote pacote); + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/PacoteDAO.java b/src/com/rjconsultores/ventaboletos/dao/PacoteDAO.java new file mode 100644 index 000000000..4cf7455ae --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/PacoteDAO.java @@ -0,0 +1,7 @@ +package com.rjconsultores.ventaboletos.dao; + +import com.rjconsultores.ventaboletos.entidad.Pacote; + +public interface PacoteDAO extends GenericDAO { + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/PacoteItemDAO.java b/src/com/rjconsultores/ventaboletos/dao/PacoteItemDAO.java new file mode 100644 index 000000000..935581093 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/PacoteItemDAO.java @@ -0,0 +1,15 @@ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.ItemAdicional; +import com.rjconsultores.ventaboletos.entidad.Pacote; +import com.rjconsultores.ventaboletos.entidad.PacoteItem; + +public interface PacoteItemDAO extends GenericDAO { + + public PacoteItem buscaPacoteItem(Pacote pacote, ItemAdicional item); + + public List buscaItensPacote(Pacote pacote); + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/PacoteTarifaDAO.java b/src/com/rjconsultores/ventaboletos/dao/PacoteTarifaDAO.java new file mode 100644 index 000000000..dc571f460 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/PacoteTarifaDAO.java @@ -0,0 +1,15 @@ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.Pacote; +import com.rjconsultores.ventaboletos.entidad.PacoteTarifa; +import com.rjconsultores.ventaboletos.entidad.TipoTarifaPacote; + +public interface PacoteTarifaDAO extends GenericDAO { + + public PacoteTarifa buscaPacoteTarifa(Pacote pacote, TipoTarifaPacote tipoTarifaPacote); + + public List buscaTarifasPacote(Pacote pacote); + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/TipoTarifaPacoteDAO.java b/src/com/rjconsultores/ventaboletos/dao/TipoTarifaPacoteDAO.java new file mode 100644 index 000000000..b2918fed2 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/TipoTarifaPacoteDAO.java @@ -0,0 +1,12 @@ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.Pacote; +import com.rjconsultores.ventaboletos.entidad.TipoTarifaPacote; + +public interface TipoTarifaPacoteDAO extends GenericDAO { + + public List buscaTipoTarifaPacote(Pacote pacote); + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/ItemAdicionalHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/ItemAdicionalHibernateDAO.java new file mode 100644 index 000000000..47ad84de6 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/ItemAdicionalHibernateDAO.java @@ -0,0 +1,52 @@ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import java.util.List; + +import org.hibernate.Criteria; +import org.hibernate.Query; +import org.hibernate.SessionFactory; +import org.hibernate.criterion.Order; +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.ItemAdicionalDAO; +import com.rjconsultores.ventaboletos.entidad.ItemAdicional; +import com.rjconsultores.ventaboletos.entidad.Pacote; + +@Repository("itemAdicionalDAO") +public class ItemAdicionalHibernateDAO extends GenericHibernateDAO implements ItemAdicionalDAO { + + @Autowired + public ItemAdicionalHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @SuppressWarnings("unchecked") + @Override + public List obtenerTodos() { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.addOrder(Order.asc("descitemadicional")); + + return c.list(); + } + + @SuppressWarnings("unchecked") + @Override + public List buscaItemAdicionalPacote(Pacote pacote) { + + StringBuilder sb = new StringBuilder(); + sb.append(" select pi.itemAdicional "); + sb.append(" from PacoteItem pi "); + sb.append(" where pi.pacote.pacoteId = :pacoteId "); + sb.append(" and pi.activo = 1 "); + + Query query = getSession().createQuery(sb.toString()); + query.setInteger("pacoteId", pacote.getPacoteId()); + + return query.list(); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/PacoteHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/PacoteHibernateDAO.java new file mode 100644 index 000000000..79f398510 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/PacoteHibernateDAO.java @@ -0,0 +1,19 @@ +package com.rjconsultores.ventaboletos.dao.hibernate; + +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.PacoteDAO; +import com.rjconsultores.ventaboletos.entidad.Pacote; + +@Repository("pacoteDAO") +public class PacoteHibernateDAO extends GenericHibernateDAO implements PacoteDAO { + + @Autowired + public PacoteHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/PacoteItemHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/PacoteItemHibernateDAO.java new file mode 100644 index 000000000..d6def7222 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/PacoteItemHibernateDAO.java @@ -0,0 +1,55 @@ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import java.util.List; + +import org.hibernate.Query; +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.PacoteItemDAO; +import com.rjconsultores.ventaboletos.entidad.ItemAdicional; +import com.rjconsultores.ventaboletos.entidad.Pacote; +import com.rjconsultores.ventaboletos.entidad.PacoteItem; + +@Repository("pacoteItemDAO") +public class PacoteItemHibernateDAO extends GenericHibernateDAO implements PacoteItemDAO { + + @Autowired + public PacoteItemHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @Override + public PacoteItem buscaPacoteItem(Pacote pacote, ItemAdicional item) { + + StringBuilder sb = new StringBuilder(); + sb.append(" from PacoteItem pi "); + sb.append(" where pi.pacote.pacoteId = :pacoteId "); + sb.append(" and pi.itemAdicional.itemadicionalId = :itemadicionalId "); + sb.append(" and pi.activo = 1 "); + + Query query = getSession().createQuery(sb.toString()); + query.setInteger("pacoteId", pacote.getPacoteId()); + query.setInteger("itemadicionalId", item.getItemadicionalId()); + + return (PacoteItem) query.uniqueResult(); + } + + @SuppressWarnings("unchecked") + @Override + public List buscaItensPacote(Pacote pacote) { + + StringBuilder sb = new StringBuilder(); + sb.append(" from PacoteItem pi "); + sb.append(" where pi.pacote.pacoteId = :pacoteId "); + sb.append(" and pi.activo = 1 "); + + Query query = getSession().createQuery(sb.toString()); + query.setInteger("pacoteId", pacote.getPacoteId()); + + return query.list(); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/PacoteTarifaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/PacoteTarifaHibernateDAO.java new file mode 100644 index 000000000..aac48e171 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/PacoteTarifaHibernateDAO.java @@ -0,0 +1,55 @@ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import java.util.List; + +import org.hibernate.Query; +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.PacoteTarifaDAO; +import com.rjconsultores.ventaboletos.entidad.Pacote; +import com.rjconsultores.ventaboletos.entidad.PacoteTarifa; +import com.rjconsultores.ventaboletos.entidad.TipoTarifaPacote; + +@Repository("pacoteTarifaDAO") +public class PacoteTarifaHibernateDAO extends GenericHibernateDAO implements PacoteTarifaDAO { + + @Autowired + public PacoteTarifaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @Override + public PacoteTarifa buscaPacoteTarifa(Pacote pacote, TipoTarifaPacote tipoTarifaPacote) { + + StringBuilder sb = new StringBuilder(); + sb.append(" from PacoteTarifa pt "); + sb.append(" where pt.pacote.pacoteId = :pacoteId "); + sb.append(" and pt.tipoTarifaPacote.tipotarifapacoteId = :tipotarifapacoteId "); + sb.append(" and pt.activo = 1 "); + + Query query = getSession().createQuery(sb.toString()); + query.setInteger("pacoteId", pacote.getPacoteId()); + query.setInteger("tipotarifapacoteId", tipoTarifaPacote.getTipotarifapacoteId()); + + return (PacoteTarifa) query.uniqueResult(); + } + + @SuppressWarnings("unchecked") + @Override + public List buscaTarifasPacote(Pacote pacote) { + + StringBuilder sb = new StringBuilder(); + sb.append(" from PacoteTarifa pt "); + sb.append(" where pt.pacote.pacoteId = :pacoteId "); + sb.append(" and pt.activo = 1 "); + + Query query = getSession().createQuery(sb.toString()); + query.setInteger("pacoteId", pacote.getPacoteId()); + + return query.list(); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/TipoTarifaPacoteHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/TipoTarifaPacoteHibernateDAO.java new file mode 100644 index 000000000..605fd37f4 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/TipoTarifaPacoteHibernateDAO.java @@ -0,0 +1,52 @@ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import java.util.List; + +import org.hibernate.Criteria; +import org.hibernate.Query; +import org.hibernate.SessionFactory; +import org.hibernate.criterion.Order; +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.TipoTarifaPacoteDAO; +import com.rjconsultores.ventaboletos.entidad.Pacote; +import com.rjconsultores.ventaboletos.entidad.TipoTarifaPacote; + +@Repository("tipoTarifaPacoteDAO") +public class TipoTarifaPacoteHibernateDAO extends GenericHibernateDAO + implements TipoTarifaPacoteDAO { + + @Autowired + public TipoTarifaPacoteHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @SuppressWarnings("unchecked") + @Override + public List obtenerTodos() { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.addOrder(Order.asc("desctipotarifa")); + + return c.list(); + } + + @SuppressWarnings("unchecked") + @Override + public List buscaTipoTarifaPacote(Pacote pacote) { + + StringBuilder sb = new StringBuilder(); + sb.append(" select pt.tipoTarifaPacote "); + sb.append(" from PacoteTarifa pt "); + sb.append(" where pt.pacote.pacoteId = :pacoteId "); + sb.append(" and pt.activo = 1 "); + + Query query = getSession().createQuery(sb.toString()); + query.setInteger("pacoteId", pacote.getPacoteId()); + + return query.list(); + } +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/ItemAdicional.java b/src/com/rjconsultores/ventaboletos/entidad/ItemAdicional.java new file mode 100644 index 000000000..28e80731a --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/ItemAdicional.java @@ -0,0 +1,136 @@ +package com.rjconsultores.ventaboletos.entidad; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +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.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name = "ITEM_ADICIONAL") +@SequenceGenerator(name = "ITEM_ADICIONAL_SEQ", sequenceName = "ITEM_ADICIONAL_SEQ", allocationSize = 1) +public class ItemAdicional implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "ITEM_ADICIONAL_SEQ") + @Column(name = "ITEMADICIONAL_ID") + private Integer itemadicionalId; + @Column(name = "DESCITEMADICIONAL") + private String descitemadicional; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + @ManyToMany + @JoinTable(name = "PACOTE_ITEM", joinColumns = { @JoinColumn(name = "ITEMADICIONAL_ID") }, + inverseJoinColumns = { @JoinColumn(name = "PACOTE_ID") }) + private List pacoteList; + + public ItemAdicional() { + } + + public ItemAdicional(Integer itemadicionalId, String descitemadicional, Boolean activo, Date fecmodif, Integer usuarioId) { + super(); + this.itemadicionalId = itemadicionalId; + this.descitemadicional = descitemadicional; + this.activo = activo; + this.fecmodif = fecmodif; + this.usuarioId = usuarioId; + } + + public Integer getItemadicionalId() { + return itemadicionalId; + } + + public void setItemadicionalId(Integer itemadicionalId) { + this.itemadicionalId = itemadicionalId; + } + + public String getDescitemadicional() { + return descitemadicional; + } + + public void setDescitemadicional(String descitemadicional) { + this.descitemadicional = descitemadicional; + } + + 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 List getPacoteList() { + return pacoteList; + } + + public void setPacoteList(List pacoteList) { + this.pacoteList = pacoteList; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((itemadicionalId == null) ? 0 : itemadicionalId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ItemAdicional other = (ItemAdicional) obj; + if (itemadicionalId == null) { + if (other.itemadicionalId != null) + return false; + } else if (!itemadicionalId.equals(other.itemadicionalId)) + return false; + return true; + } + + @Override + public String toString() { + return this.getDescitemadicional() + " - " + this.getItemadicionalId(); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/Pacote.java b/src/com/rjconsultores/ventaboletos/entidad/Pacote.java new file mode 100644 index 000000000..4a2f24434 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/Pacote.java @@ -0,0 +1,200 @@ +package com.rjconsultores.ventaboletos.entidad; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +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.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name = "PACOTE") +@SequenceGenerator(name = "PACOTE_SEQ", sequenceName = "PACOTE_SEQ", allocationSize = 1) +public class Pacote implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "PACOTE_SEQ") + @Column(name = "PACOTE_ID") + private Integer pacoteId; + @Column(name = "NOMPACOTE") + private String nompacote; + @Column(name = "DESCPACOTE") + private String descpacote; + @Column(name = "INDVENDAAGENCIA") + private Boolean indvendaagencia; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + @JoinColumn(name = "RUTA_ID", referencedColumnName = "RUTA_ID") + @ManyToOne + private Ruta ruta; + @ManyToMany + @JoinTable(name = "PACOTE_ITEM", joinColumns = { @JoinColumn(name = "PACOTE_ID") }, + inverseJoinColumns = { @JoinColumn(name = "ITEMADICIONAL_ID") }) + private List itemAdicionalList; + + @ManyToMany + @JoinTable(name = "PACOTE_TARIFA", joinColumns = { @JoinColumn(name = "PACOTE_ID") }, + inverseJoinColumns = { @JoinColumn(name = "TIPOTARIFAPACOTE_ID") }) + private List tipoTarifaPacoteList; + + public Pacote() { + } + + public Pacote(Integer pacoteId, String nompacote, String descpacote, Boolean indvendaagencia, Boolean activo, Date fecmodif, Integer usuarioId, Ruta ruta) { + this.pacoteId = pacoteId; + this.nompacote = nompacote; + this.descpacote = descpacote; + this.indvendaagencia = indvendaagencia; + this.activo = activo; + this.fecmodif = fecmodif; + this.usuarioId = usuarioId; + this.ruta = ruta; + } + + public Integer getPacoteId() { + return pacoteId; + } + + public void setPacoteId(Integer pacoteId) { + this.pacoteId = pacoteId; + } + + public String getNompacote() { + return nompacote; + } + + public void setNompacote(String nompacote) { + this.nompacote = nompacote; + } + + public String getDescpacote() { + return descpacote; + } + + public void setDescpacote(String descpacote) { + this.descpacote = descpacote; + } + + public Boolean getIndvendaagencia() { + return indvendaagencia; + } + + public void setIndvendaagencia(Boolean indvendaagencia) { + this.indvendaagencia = indvendaagencia; + } + + 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 Ruta getRuta() { + return ruta; + } + + public void setRuta(Ruta ruta) { + this.ruta = ruta; + } + + public List getItemAdicionalList() { + if (this.itemAdicionalList == null || this.itemAdicionalList.isEmpty()) + return new ArrayList(); + + List aux = new ArrayList(); + for (ItemAdicional item : this.itemAdicionalList) { + if (item.getActivo()) + aux.add(item); + } + return aux; + } + + public void setItemAdicionalList(List itemAdicionalList) { + this.itemAdicionalList = itemAdicionalList; + } + + public List getTipoTarifaPacoteList() { + if (this.tipoTarifaPacoteList == null || this.tipoTarifaPacoteList.isEmpty()) + return new ArrayList(); + + List aux = new ArrayList(); + for (TipoTarifaPacote item : this.tipoTarifaPacoteList) { + if (item.getActivo()) + aux.add(item); + } + return aux; + } + + public void setTipoTarifaPacoteList(List tipoTarifaPacoteList) { + this.tipoTarifaPacoteList = tipoTarifaPacoteList; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((pacoteId == null) ? 0 : pacoteId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Pacote other = (Pacote) obj; + if (pacoteId == null) { + if (other.pacoteId != null) + return false; + } else if (!pacoteId.equals(other.pacoteId)) + return false; + return true; + } + + @Override + public String toString() { + return "Pacote [pacoteId=" + pacoteId + ", nompacote=" + nompacote + ", descpacote=" + descpacote + ", indvendaagencia=" + indvendaagencia + ", activo=" + activo + ", fecmodif=" + fecmodif + ", usuarioId=" + usuarioId + ", ruta=" + ruta + "]"; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/PacoteItem.java b/src/com/rjconsultores/ventaboletos/entidad/PacoteItem.java new file mode 100644 index 000000000..f501de97f --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/PacoteItem.java @@ -0,0 +1,126 @@ +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 +@Table(name = "PACOTE_ITEM") +@SequenceGenerator(name = "PACOTE_ITEM_SEQ", sequenceName = "PACOTE_ITEM_SEQ", allocationSize = 1) +public class PacoteItem implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "PACOTE_ITEM_SEQ") + @Column(name = "PACOTEITEM_ID") + private Integer pacoteItemId; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + @JoinColumn(name = "PACOTE_ID", referencedColumnName = "PACOTE_ID") + @ManyToOne + private Pacote pacote; + @JoinColumn(name = "ITEMADICIONAL_ID", referencedColumnName = "ITEMADICIONAL_ID") + @ManyToOne + private ItemAdicional itemAdicional; + + public PacoteItem() { + super(); + } + + public Integer getPacoteItemId() { + return pacoteItemId; + } + + public void setPacoteItemId(Integer pacoteItemId) { + this.pacoteItemId = pacoteItemId; + } + + 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; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((pacoteItemId == null) ? 0 : pacoteItemId.hashCode()); + return result; + } + + public Pacote getPacote() { + return pacote; + } + + public void setPacote(Pacote pacote) { + this.pacote = pacote; + } + + public ItemAdicional getItemAdicional() { + return itemAdicional; + } + + public void setItemAdicional(ItemAdicional itemAdicional) { + this.itemAdicional = itemAdicional; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PacoteItem other = (PacoteItem) obj; + if (pacoteItemId == null) { + if (other.pacoteItemId != null) + return false; + } else if (!pacoteItemId.equals(other.pacoteItemId)) + return false; + return true; + } + + @Override + public String toString() { + return "PacoteItem [pacoteItemId=" + pacoteItemId + ", activo=" + activo + ", fecmodif=" + fecmodif + ", usuarioId=" + usuarioId + ", pacoteId=" + pacote + ", itemadicionalId=" + itemAdicional + "]"; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/PacoteTarifa.java b/src/com/rjconsultores/ventaboletos/entidad/PacoteTarifa.java new file mode 100644 index 000000000..ce33bbc70 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/PacoteTarifa.java @@ -0,0 +1,145 @@ +package com.rjconsultores.ventaboletos.entidad; + +import java.io.Serializable; +import java.math.BigDecimal; +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 = "PACOTE_TARIFA") +@SequenceGenerator(name = "PACOTE_TARIFA_SEQ", sequenceName = "PACOTE_TARIFA_SEQ", allocationSize = 1) +public class PacoteTarifa implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "PACOTE_TARIFA_SEQ") + @Column(name = "PACOTETARIFA_ID ") + private Integer pacotetarifaId; + @Column(name = "TARIFA") + private BigDecimal tarifa; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + @JoinColumn(name = "PACOTE_ID", referencedColumnName = "PACOTE_ID") + @ManyToOne + private Pacote pacote; + @JoinColumn(name = "TIPOTARIFAPACOTE_ID", referencedColumnName = "TIPOTARIFAPACOTE_ID") + @ManyToOne + private TipoTarifaPacote tipoTarifaPacote; + + public PacoteTarifa() { + super(); + } + + public PacoteTarifa(Integer pacotetarifaId, Boolean activo, Date fecmodif, Integer usuarioId) { + super(); + this.pacotetarifaId = pacotetarifaId; + this.activo = activo; + this.fecmodif = fecmodif; + this.usuarioId = usuarioId; + } + + public Integer getPacotetarifaId() { + return pacotetarifaId; + } + + public void setPacotetarifaId(Integer pacotetarifaId) { + this.pacotetarifaId = pacotetarifaId; + } + + public BigDecimal getTarifa() { + return tarifa; + } + + public void setTarifa(BigDecimal tarifa) { + this.tarifa = tarifa; + } + + 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 Pacote getPacote() { + return pacote; + } + + public void setPacote(Pacote pacote) { + this.pacote = pacote; + } + + public TipoTarifaPacote getTipoTarifaPacote() { + return tipoTarifaPacote; + } + + public void setTipoTarifaPacote(TipoTarifaPacote tipoTarifaPacote) { + this.tipoTarifaPacote = tipoTarifaPacote; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((pacotetarifaId == null) ? 0 : pacotetarifaId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PacoteTarifa other = (PacoteTarifa) obj; + if (pacotetarifaId == null) { + if (other.pacotetarifaId != null) + return false; + } else if (!pacotetarifaId.equals(other.pacotetarifaId)) + return false; + return true; + } + + @Override + public String toString() { + return "PacoteTarifa [pacotetarifaId=" + pacotetarifaId + ", activo=" + activo + ", fecmodif=" + fecmodif + ", usuarioId=" + usuarioId + ", pacote=" + pacote + ", tipoTarifaPacote=" + tipoTarifaPacote + "]"; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/TipoTarifaPacote.java b/src/com/rjconsultores/ventaboletos/entidad/TipoTarifaPacote.java new file mode 100644 index 000000000..b10562273 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/TipoTarifaPacote.java @@ -0,0 +1,137 @@ +package com.rjconsultores.ventaboletos.entidad; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +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.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name = "TIPO_TARIFA_PACOTE") +@SequenceGenerator(name = "TIPO_TARIFA_PACOTE_SEQ", sequenceName = "TIPO_TARIFA_PACOTE_SEQ", allocationSize = 1) +public class TipoTarifaPacote implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "TIPO_TARIFA_PACOTE_SEQ") + @Column(name = "TIPOTARIFAPACOTE_ID") + private Integer tipotarifapacoteId; + @Column(name = "DESCTIPOTARIFA") + private String desctipotarifa; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + @ManyToMany + @JoinTable(name = "PACOTE_TARIFA", joinColumns = { @JoinColumn(name = "TIPOTARIFAPACOTE_ID") }, + inverseJoinColumns = { @JoinColumn(name = "PACOTE_ID") }) + private List pacoteList; + + public TipoTarifaPacote() { + super(); + } + + public TipoTarifaPacote(Integer tipotarifapacoteId, String desctipotarifa, Boolean activo, Date fecmodif, Integer usuarioId) { + super(); + this.tipotarifapacoteId = tipotarifapacoteId; + this.desctipotarifa = desctipotarifa; + this.activo = activo; + this.fecmodif = fecmodif; + this.usuarioId = usuarioId; + } + + public Integer getTipotarifapacoteId() { + return tipotarifapacoteId; + } + + public void setTipotarifapacoteId(Integer tipotarifapacoteId) { + this.tipotarifapacoteId = tipotarifapacoteId; + } + + public String getDesctipotarifa() { + return desctipotarifa; + } + + public void setDesctipotarifa(String desctipotarifa) { + this.desctipotarifa = desctipotarifa; + } + + 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 List getPacoteList() { + return pacoteList; + } + + public void setPacoteList(List pacoteList) { + this.pacoteList = pacoteList; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((tipotarifapacoteId == null) ? 0 : tipotarifapacoteId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TipoTarifaPacote other = (TipoTarifaPacote) obj; + if (tipotarifapacoteId == null) { + if (other.tipotarifapacoteId != null) + return false; + } else if (!tipotarifapacoteId.equals(other.tipotarifapacoteId)) + return false; + return true; + } + + @Override + public String toString() { + return getDesctipotarifa() + " - " + getTipotarifapacoteId(); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/service/ItemAdicionalService.java b/src/com/rjconsultores/ventaboletos/service/ItemAdicionalService.java new file mode 100644 index 000000000..308ee14a4 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/ItemAdicionalService.java @@ -0,0 +1,11 @@ +package com.rjconsultores.ventaboletos.service; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.ItemAdicional; +import com.rjconsultores.ventaboletos.entidad.Pacote; + +public interface ItemAdicionalService extends GenericService { + + public List buscaItemAdicionalPacote(Pacote pacote); +} diff --git a/src/com/rjconsultores/ventaboletos/service/PacoteItemService.java b/src/com/rjconsultores/ventaboletos/service/PacoteItemService.java new file mode 100644 index 000000000..c41240ef4 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/PacoteItemService.java @@ -0,0 +1,17 @@ +package com.rjconsultores.ventaboletos.service; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.ItemAdicional; +import com.rjconsultores.ventaboletos.entidad.Pacote; +import com.rjconsultores.ventaboletos.entidad.PacoteItem; + +public interface PacoteItemService extends GenericService { + + public PacoteItem vincularItemPacote(PacoteItem pacoteItem, Pacote pacote, ItemAdicional item); + + public PacoteItem buscaPacoteItem(Pacote pacote, ItemAdicional item); + + public List buscaItensPacote(Pacote pacote); + +} diff --git a/src/com/rjconsultores/ventaboletos/service/PacoteService.java b/src/com/rjconsultores/ventaboletos/service/PacoteService.java new file mode 100644 index 000000000..1c93206dd --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/PacoteService.java @@ -0,0 +1,6 @@ +package com.rjconsultores.ventaboletos.service; + +import com.rjconsultores.ventaboletos.entidad.Pacote; + +public interface PacoteService extends GenericService { +} diff --git a/src/com/rjconsultores/ventaboletos/service/PacoteTarifaService.java b/src/com/rjconsultores/ventaboletos/service/PacoteTarifaService.java new file mode 100644 index 000000000..880a3eaff --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/PacoteTarifaService.java @@ -0,0 +1,18 @@ +package com.rjconsultores.ventaboletos.service; + +import java.math.BigDecimal; +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.Pacote; +import com.rjconsultores.ventaboletos.entidad.PacoteTarifa; +import com.rjconsultores.ventaboletos.entidad.TipoTarifaPacote; + +public interface PacoteTarifaService extends GenericService { + + public PacoteTarifa vincularPacoteTarifa(PacoteTarifa pacoteTarifa, Pacote pacote, TipoTarifaPacote tipoTarifaPacote, BigDecimal tarifa); + + public PacoteTarifa buscaPacoteTarifa(Pacote pacote, TipoTarifaPacote tipoTarifaPacote); + + public List buscaTarifasPacote(Pacote pacote); + +} diff --git a/src/com/rjconsultores/ventaboletos/service/TipoTarifaPacoteService.java b/src/com/rjconsultores/ventaboletos/service/TipoTarifaPacoteService.java new file mode 100644 index 000000000..fec103b14 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/TipoTarifaPacoteService.java @@ -0,0 +1,12 @@ +package com.rjconsultores.ventaboletos.service; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.Pacote; +import com.rjconsultores.ventaboletos.entidad.TipoTarifaPacote; + +public interface TipoTarifaPacoteService extends GenericService { + + public List buscaTipoTarifaPacote(Pacote pacote); + +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/ItemAdicionalServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/ItemAdicionalServiceImpl.java new file mode 100644 index 000000000..f7d6fca3a --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/ItemAdicionalServiceImpl.java @@ -0,0 +1,66 @@ +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.ItemAdicionalDAO; +import com.rjconsultores.ventaboletos.entidad.ItemAdicional; +import com.rjconsultores.ventaboletos.entidad.Pacote; +import com.rjconsultores.ventaboletos.service.ItemAdicionalService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("itemAdicionalService") +public class ItemAdicionalServiceImpl implements ItemAdicionalService { + + @Autowired + private ItemAdicionalDAO itemAdicionalDAO; + + @Override + public List obtenerTodos() { + return itemAdicionalDAO.obtenerTodos(); + } + + @Override + public ItemAdicional obtenerID(Integer id) { + return itemAdicionalDAO.obtenerID(id); + } + + @Transactional + @Override + public ItemAdicional suscribir(ItemAdicional entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return itemAdicionalDAO.suscribir(entidad); + } + + @Transactional + @Override + public ItemAdicional actualizacion(ItemAdicional entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return itemAdicionalDAO.actualizacion(entidad); + } + + @Transactional + @Override + public void borrar(ItemAdicional entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + itemAdicionalDAO.actualizacion(entidad); + } + + @Override + public List buscaItemAdicionalPacote(Pacote pacote) { + return itemAdicionalDAO.buscaItemAdicionalPacote(pacote); + } +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/PacoteItemServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/PacoteItemServiceImpl.java new file mode 100644 index 000000000..1a7eb4c8f --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/PacoteItemServiceImpl.java @@ -0,0 +1,91 @@ +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.PacoteItemDAO; +import com.rjconsultores.ventaboletos.entidad.ItemAdicional; +import com.rjconsultores.ventaboletos.entidad.Pacote; +import com.rjconsultores.ventaboletos.entidad.PacoteItem; +import com.rjconsultores.ventaboletos.service.PacoteItemService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("pacoteItemService") +public class PacoteItemServiceImpl implements PacoteItemService { + + @Autowired + private PacoteItemDAO pacoteItemDAO; + + @Override + public List obtenerTodos() { + return pacoteItemDAO.obtenerTodos(); + } + + @Override + public PacoteItem obtenerID(Integer id) { + return pacoteItemDAO.obtenerID(id); + } + + @Transactional + @Override + public PacoteItem suscribir(PacoteItem entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return pacoteItemDAO.suscribir(entidad); + } + + @Transactional + @Override + public PacoteItem actualizacion(PacoteItem entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return pacoteItemDAO.actualizacion(entidad); + } + + @Transactional + @Override + public void borrar(PacoteItem entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + pacoteItemDAO.actualizacion(entidad); + } + + @Transactional(readOnly = false) + @Override + public PacoteItem vincularItemPacote(PacoteItem pacoteItem, Pacote pacote, ItemAdicional item) { + + if (pacoteItem == null) { + pacoteItem = new PacoteItem(); + } + + pacoteItem.setItemAdicional(item); + pacoteItem.setPacote(pacote); + + if (pacoteItem.getPacoteItemId() == null) { + return suscribir(pacoteItem); + } else { + return actualizacion(pacoteItem); + } + } + + @Override + public PacoteItem buscaPacoteItem(Pacote pacote, ItemAdicional item) { + return pacoteItemDAO.buscaPacoteItem(pacote, item); + } + + @Override + public List buscaItensPacote(Pacote pacote) { + return pacoteItemDAO.buscaItensPacote(pacote); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/PacoteServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/PacoteServiceImpl.java new file mode 100644 index 000000000..48fbde920 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/PacoteServiceImpl.java @@ -0,0 +1,59 @@ +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.PacoteDAO; +import com.rjconsultores.ventaboletos.entidad.Pacote; +import com.rjconsultores.ventaboletos.service.PacoteService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("pacoteService") +public class PacoteServiceImpl implements PacoteService { + + @Autowired + private PacoteDAO pacoteDAO; + + @Override + public List obtenerTodos() { + return pacoteDAO.obtenerTodos(); + } + + @Override + public Pacote obtenerID(Integer id) { + return pacoteDAO.obtenerID(id); + } + + @Transactional + @Override + public Pacote suscribir(Pacote entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + + return pacoteDAO.suscribir(entidad); + } + + @Transactional + @Override + public Pacote actualizacion(Pacote entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + + return pacoteDAO.actualizacion(entidad); + } + + @Transactional + @Override + public void borrar(Pacote entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + pacoteDAO.actualizacion(entidad); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/PacoteTarifaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/PacoteTarifaServiceImpl.java new file mode 100644 index 000000000..2e4c31ddf --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/PacoteTarifaServiceImpl.java @@ -0,0 +1,92 @@ +package com.rjconsultores.ventaboletos.service.impl; + +import java.math.BigDecimal; +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.PacoteTarifaDAO; +import com.rjconsultores.ventaboletos.entidad.Pacote; +import com.rjconsultores.ventaboletos.entidad.PacoteTarifa; +import com.rjconsultores.ventaboletos.entidad.TipoTarifaPacote; +import com.rjconsultores.ventaboletos.service.PacoteTarifaService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("pacoteTarifaService") +public class PacoteTarifaServiceImpl implements PacoteTarifaService { + + @Autowired + private PacoteTarifaDAO pacoteTarifaDAO; + + @Override + public List obtenerTodos() { + return pacoteTarifaDAO.obtenerTodos(); + } + + @Override + public PacoteTarifa obtenerID(Integer id) { + return pacoteTarifaDAO.obtenerID(id); + } + + @Transactional + @Override + public PacoteTarifa suscribir(PacoteTarifa entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return pacoteTarifaDAO.suscribir(entidad); + } + + @Transactional + @Override + public PacoteTarifa actualizacion(PacoteTarifa entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return pacoteTarifaDAO.actualizacion(entidad); + } + + @Transactional + @Override + public void borrar(PacoteTarifa entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + pacoteTarifaDAO.actualizacion(entidad); + } + + @Transactional(readOnly = false) + @Override + public PacoteTarifa vincularPacoteTarifa(PacoteTarifa pacoteTarifa, Pacote pacote, TipoTarifaPacote tipoTarifaPacote, BigDecimal tarifa) { + + if (pacoteTarifa == null) { + pacoteTarifa = new PacoteTarifa(); + } + + pacoteTarifa.setTarifa(tarifa); + pacoteTarifa.setTipoTarifaPacote(tipoTarifaPacote); + pacoteTarifa.setPacote(pacote); + + if (pacoteTarifa.getPacotetarifaId() == null) { + return suscribir(pacoteTarifa); + } else { + return actualizacion(pacoteTarifa); + } + } + + @Override + public PacoteTarifa buscaPacoteTarifa(Pacote pacote, TipoTarifaPacote tipoTarifaPacote) { + return pacoteTarifaDAO.buscaPacoteTarifa(pacote, tipoTarifaPacote); + } + + @Override + public List buscaTarifasPacote(Pacote pacote) { + return pacoteTarifaDAO.buscaTarifasPacote(pacote); + } +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/TipoTarifaPacoteServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/TipoTarifaPacoteServiceImpl.java new file mode 100644 index 000000000..d98797aec --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/TipoTarifaPacoteServiceImpl.java @@ -0,0 +1,66 @@ +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.TipoTarifaPacoteDAO; +import com.rjconsultores.ventaboletos.entidad.Pacote; +import com.rjconsultores.ventaboletos.entidad.TipoTarifaPacote; +import com.rjconsultores.ventaboletos.service.TipoTarifaPacoteService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("tipoTarifaPacoteService") +public class TipoTarifaPacoteServiceImpl implements TipoTarifaPacoteService { + + @Autowired + private TipoTarifaPacoteDAO tipoTarifaPacoteDAO; + + @Override + public List obtenerTodos() { + return tipoTarifaPacoteDAO.obtenerTodos(); + } + + @Override + public TipoTarifaPacote obtenerID(Integer id) { + return tipoTarifaPacoteDAO.obtenerID(id); + } + + @Transactional + @Override + public TipoTarifaPacote suscribir(TipoTarifaPacote entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return tipoTarifaPacoteDAO.suscribir(entidad); + } + + @Transactional + @Override + public TipoTarifaPacote actualizacion(TipoTarifaPacote entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return tipoTarifaPacoteDAO.actualizacion(entidad); + } + + @Transactional + @Override + public void borrar(TipoTarifaPacote entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + tipoTarifaPacoteDAO.actualizacion(entidad); + } + + @Override + public List buscaTipoTarifaPacote(Pacote pacote) { + return tipoTarifaPacoteDAO.buscaTipoTarifaPacote(pacote); + } +}