diff --git a/src/com/rjconsultores/ventaboletos/dao/RutaIcmsExcepcionDAO.java b/src/com/rjconsultores/ventaboletos/dao/RutaIcmsExcepcionDAO.java new file mode 100644 index 000000000..21d5b1f6b --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/RutaIcmsExcepcionDAO.java @@ -0,0 +1,15 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.dao; + +import com.rjconsultores.ventaboletos.entidad.RutaIcmsExcepcion; + +/** + * + * @author Administrador + */ +public interface RutaIcmsExcepcionDAO extends GenericDAO { + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/RutaIcmsExcepcionHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/RutaIcmsExcepcionHibernateDAO.java new file mode 100644 index 000000000..2777c65e2 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/RutaIcmsExcepcionHibernateDAO.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.RutaIcmsExcepcionDAO; +import com.rjconsultores.ventaboletos.entidad.RutaIcmsExcepcion; + +@Repository("rutaIcmsExcepcionDAO") +public class RutaIcmsExcepcionHibernateDAO extends GenericHibernateDAO implements RutaIcmsExcepcionDAO { + + @Autowired + public RutaIcmsExcepcionHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/Ruta.java b/src/com/rjconsultores/ventaboletos/entidad/Ruta.java index b2fdbba39..15d61f103 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/Ruta.java +++ b/src/com/rjconsultores/ventaboletos/entidad/Ruta.java @@ -26,6 +26,8 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; +import org.hibernate.annotations.Where; + /** * * @author Rafius @@ -134,6 +136,10 @@ public class Ruta implements Serializable, Comparable { @OneToMany(mappedBy = "ruta", cascade = CascadeType.ALL) private List lsRutaEmbarqueDesembarque; + + @OneToMany(mappedBy = "ruta", cascade = CascadeType.ALL) + @Where(clause = "activo = 1") + private List lsRutaIcmsExcepcions; @Transient private Boolean isClone; @@ -575,4 +581,12 @@ public class Ruta implements Serializable, Comparable { public void setIndVendaEmbarcada(Boolean indVendaEmbarcada) { this.indVendaEmbarcada = indVendaEmbarcada; } + + public List getLsRutaIcmsExcepcions() { + return lsRutaIcmsExcepcions; + } + + public void setLsRutaIcmsExcepcions(List lsRutaIcmsExcepcions) { + this.lsRutaIcmsExcepcions = lsRutaIcmsExcepcions; + } } \ No newline at end of file diff --git a/src/com/rjconsultores/ventaboletos/entidad/RutaIcmsExcepcion.java b/src/com/rjconsultores/ventaboletos/entidad/RutaIcmsExcepcion.java new file mode 100644 index 000000000..0a7706b90 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/RutaIcmsExcepcion.java @@ -0,0 +1,168 @@ +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; + +import org.apache.commons.lang.BooleanUtils; + +@Entity +@SequenceGenerator(name = "RUTA_ICMS_EXCEPCION_SEQ", sequenceName = "RUTA_ICMS_EXCEPCION_SEQ", allocationSize = 1) +@Table(name = "RUTA_ICMS_EXCEPCION") +public class RutaIcmsExcepcion implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "RUTA_ICMS_EXCEPCION_SEQ") + @Column(name = "RUTAICMSEXCEPCION_ID") + private Integer rutaIcmsExcepcionId; + + @Column(name = "INDTRIBTARIFA") + private Boolean indTribTarifa; + + @Column(name = "INDTRIBTAXAEMBARQUE") + private Boolean indTribTaxaEmbarque; + + @Column(name = "INDTRIBPEDAGIO") + private Boolean indTribPedagio; + + @ManyToOne + @JoinColumn(name = "RUTA_ID") + private Ruta ruta; + + @ManyToOne + @JoinColumn(name = "ORIGEN_ID") + private Parada origen; + + @ManyToOne + @JoinColumn(name = "DESTINO_ID") + private Parada destino; + + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + + public Integer getRutaIcmsExcepcionId() { + return rutaIcmsExcepcionId; + } + + public void setRutaIcmsExcepcionId(Integer rutaIcmsExcepcionId) { + this.rutaIcmsExcepcionId = rutaIcmsExcepcionId; + } + + public Boolean getIndTribTarifa() { + return BooleanUtils.toBooleanObject(indTribTarifa); + } + + public void setIndTribTarifa(Boolean indTribTarifa) { + this.indTribTarifa = indTribTarifa; + } + + public Boolean getIndTribTaxaEmbarque() { + return BooleanUtils.toBooleanObject(indTribTaxaEmbarque); + } + + public void setIndTribTaxaEmbarque(Boolean indTribTaxaEmbarque) { + this.indTribTaxaEmbarque = indTribTaxaEmbarque; + } + + public Boolean getIndTribPedagio() { + return BooleanUtils.toBooleanObject(indTribPedagio); + } + + public void setIndTribPedagio(Boolean indTribPedagio) { + this.indTribPedagio = indTribPedagio; + } + + public Ruta getRuta() { + return ruta; + } + + public void setRuta(Ruta ruta) { + this.ruta = ruta; + } + + public Parada getOrigen() { + return origen; + } + + public void setOrigen(Parada origen) { + this.origen = origen; + } + + public Parada getDestino() { + return destino; + } + + public void setDestino(Parada destino) { + this.destino = destino; + } + + 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 + ((getRutaIcmsExcepcionId() == null) ? 0 : getRutaIcmsExcepcionId().hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (!(obj instanceof RutaIcmsExcepcion)) + return false; + RutaIcmsExcepcion other = (RutaIcmsExcepcion) obj; + if (getRutaIcmsExcepcionId() == null) { + if (other.getRutaIcmsExcepcionId() != null) + return false; + } else if (!getRutaIcmsExcepcionId().equals(other.getRutaIcmsExcepcionId())) + return false; + return true; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/service/RutaIcmsExcepcionService.java b/src/com/rjconsultores/ventaboletos/service/RutaIcmsExcepcionService.java new file mode 100644 index 000000000..5c22404b2 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/RutaIcmsExcepcionService.java @@ -0,0 +1,6 @@ +package com.rjconsultores.ventaboletos.service; + +import com.rjconsultores.ventaboletos.entidad.RutaIcmsExcepcion; + +public interface RutaIcmsExcepcionService extends GenericService { +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/RutaIcmsExcepcionServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/RutaIcmsExcepcionServiceImpl.java new file mode 100644 index 000000000..8bd09bab9 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/RutaIcmsExcepcionServiceImpl.java @@ -0,0 +1,58 @@ +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.RutaIcmsExcepcionDAO; +import com.rjconsultores.ventaboletos.entidad.RutaIcmsExcepcion; +import com.rjconsultores.ventaboletos.service.RutaIcmsExcepcionService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("rutaIcmsExcepcionService") +public class RutaIcmsExcepcionServiceImpl implements RutaIcmsExcepcionService { + + @Autowired + private RutaIcmsExcepcionDAO rutaIcmsExcepcionDAO; + + @Override + public List obtenerTodos() { + return rutaIcmsExcepcionDAO.obtenerTodos(); + } + + @Override + public RutaIcmsExcepcion obtenerID(Integer id) { + return rutaIcmsExcepcionDAO.obtenerID(id); + } + + @Override + @Transactional + public RutaIcmsExcepcion suscribir(RutaIcmsExcepcion entidad) { + entidad.setActivo(Boolean.TRUE); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + return rutaIcmsExcepcionDAO.suscribir(entidad); + } + + @Override + @Transactional + public RutaIcmsExcepcion actualizacion(RutaIcmsExcepcion entidad) { + entidad.setActivo(Boolean.TRUE); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + return rutaIcmsExcepcionDAO.actualizacion(entidad); + } + + @Override + @Transactional + public void borrar(RutaIcmsExcepcion entidad) { + entidad.setActivo(Boolean.FALSE); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + rutaIcmsExcepcionDAO.actualizacion(entidad); + } + +}