diff --git a/src/com/rjconsultores/ventaboletos/dao/PtovtaAntifraudeDAO.java b/src/com/rjconsultores/ventaboletos/dao/PtovtaAntifraudeDAO.java new file mode 100644 index 000000000..1d4b52416 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/PtovtaAntifraudeDAO.java @@ -0,0 +1,7 @@ +package com.rjconsultores.ventaboletos.dao; + +import com.rjconsultores.ventaboletos.entidad.PtovtaAntifraude; + +public interface PtovtaAntifraudeDAO extends GenericDAO { + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/PtovtaAntifraudeHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/PtovtaAntifraudeHibernateDAO.java new file mode 100644 index 000000000..391c482c6 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/PtovtaAntifraudeHibernateDAO.java @@ -0,0 +1,20 @@ +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.PtovtaAntifraudeDAO; +import com.rjconsultores.ventaboletos.entidad.PtovtaAntifraude; + +@Repository("ptovtaAntifraudeHibernateDAO") +public class PtovtaAntifraudeHibernateDAO extends GenericHibernateDAO implements PtovtaAntifraudeDAO { + + @Autowired + public PtovtaAntifraudeHibernateDAO( + @Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/PtovtaAntifraude.java b/src/com/rjconsultores/ventaboletos/entidad/PtovtaAntifraude.java new file mode 100644 index 000000000..5d03e7ee0 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/PtovtaAntifraude.java @@ -0,0 +1,163 @@ +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.EnumType; +import javax.persistence.Enumerated; +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 com.rjconsultores.ventaboletos.enums.TipoAntifraude; + +/** + * @author Wilian + */ +@Entity +@SequenceGenerator(name = "PTOVTA_ANTIFRAUDE_SEQ", sequenceName = "PTOVTA_ANTIFRAUDE_SEQ", allocationSize = 1) +@Table(name = "PTOVTA_ANTIFRAUDE") +public class PtovtaAntifraude implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "PTOVTA_ANTIFRAUDE_SEQ") + @Column(name = "PTOVTAANTIFRAUDE_ID") + private Integer ptovtaAntifraudeId; + + @ManyToOne + @JoinColumn(name = "PUNTOVENTA_ID") + private PuntoVenta puntoventa; + + @ManyToOne + @JoinColumn(name = "EMPRESA_ID") + private Empresa empresa; + + @Enumerated(EnumType.STRING) + @Column(name = "tipo") + private TipoAntifraude tipo; + + @Column(name = "CHAVE") + private String chave; + + @Column(name = "ACTIVO") + private Boolean activo; + + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + + @Column(name = "USUARIO_ID") + private int usuarioId; + + public PtovtaAntifraude() { + super(); + this.activo = true; + this.fecmodif = new Date(); + } + + public PtovtaAntifraude(Integer ptovtaAntifraudeId) { + this.ptovtaAntifraudeId = ptovtaAntifraudeId; + } + + public Integer getPtovtaAntifraudeId() { + return ptovtaAntifraudeId; + } + + public void setPtovtaAntifraudeId(Integer ptovtaAntifraudeId) { + this.ptovtaAntifraudeId = ptovtaAntifraudeId; + } + + public PuntoVenta getPuntoventa() { + return puntoventa; + } + + public void setPuntoventa(PuntoVenta puntoventa) { + this.puntoventa = puntoventa; + } + + public Empresa getEmpresa() { + return empresa; + } + + public void setEmpresa(Empresa empresa) { + this.empresa = empresa; + } + + public TipoAntifraude getTipo() { + return tipo; + } + + public void setTipo(TipoAntifraude tipo) { + this.tipo = tipo; + } + + public String getChave() { + return chave; + } + + public void setChave(String chave) { + this.chave = chave; + } + + 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 int getUsuarioId() { + return usuarioId; + } + + public void setUsuarioId(int usuarioId) { + this.usuarioId = usuarioId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((ptovtaAntifraudeId == null) ? 0 : ptovtaAntifraudeId.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; + PtovtaAntifraude other = (PtovtaAntifraude) obj; + if (ptovtaAntifraudeId == null) { + if (other.ptovtaAntifraudeId != null) + return false; + } else if (!ptovtaAntifraudeId.equals(other.ptovtaAntifraudeId)) + return false; + return true; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java b/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java index 12fa85e5f..20b73acde 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java +++ b/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java @@ -31,6 +31,7 @@ import javax.persistence.TemporalType; import org.apache.commons.lang.BooleanUtils; import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollectionOption; +import org.hibernate.annotations.Where; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; @@ -234,6 +235,11 @@ public class PuntoVenta implements Serializable { @Column(name = "INDREPASSAUTR") private Boolean indRepassaUTR; + + @OneToMany(mappedBy = "puntoventa", cascade = CascadeType.ALL) + @LazyCollection(LazyCollectionOption.FALSE) + @Where(clause = "activo = 1") + private List ptovtaAntifraudes; public PtovtaEmpresaBloqueada addEmpresaBloqueada(Empresa e) { PtovtaEmpresaBloqueada eb = new PtovtaEmpresaBloqueada(); @@ -1068,4 +1074,25 @@ public class PuntoVenta implements Serializable { public void setIndRepassaUTR(Boolean indRepassaUTR) { this.indRepassaUTR = indRepassaUTR; } + + public List getPtovtaAntifraudes() { + return ptovtaAntifraudes; + } + + public void setPtovtaAntifraudes(List ptovtaAntifraudes) { + this.ptovtaAntifraudes = ptovtaAntifraudes; + } + + public void addChaveAntifurto(PtovtaAntifraude cat){ + if(this.ptovtaAntifraudes == null) { + this.ptovtaAntifraudes = new ArrayList(); + } + this.ptovtaAntifraudes.add(cat); + } + + public void removeChaveAntifurto(PtovtaAntifraude cat){ + if(this.ptovtaAntifraudes != null) { + this.ptovtaAntifraudes.remove(cat); + } + } } diff --git a/src/com/rjconsultores/ventaboletos/enums/TipoAntifraude.java b/src/com/rjconsultores/ventaboletos/enums/TipoAntifraude.java new file mode 100644 index 000000000..70d0dc6a4 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/enums/TipoAntifraude.java @@ -0,0 +1,7 @@ +package com.rjconsultores.ventaboletos.enums; + +public enum TipoAntifraude { + + KONDUTO; + +} diff --git a/src/com/rjconsultores/ventaboletos/service/PtovtaAntifraudeService.java b/src/com/rjconsultores/ventaboletos/service/PtovtaAntifraudeService.java new file mode 100644 index 000000000..c564a647a --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/PtovtaAntifraudeService.java @@ -0,0 +1,7 @@ +package com.rjconsultores.ventaboletos.service; + +import com.rjconsultores.ventaboletos.entidad.PtovtaAntifraude; + +public interface PtovtaAntifraudeService extends GenericService { + +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/PtovtaAntifraudeServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/PtovtaAntifraudeServiceImpl.java new file mode 100644 index 000000000..4900d9cc4 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/PtovtaAntifraudeServiceImpl.java @@ -0,0 +1,57 @@ +package com.rjconsultores.ventaboletos.service.impl; + +import java.util.Date; +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.PtovtaAntifraudeDAO; +import com.rjconsultores.ventaboletos.entidad.PtovtaAntifraude; +import com.rjconsultores.ventaboletos.service.PtovtaAntifraudeService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("ptovtaAntifraudeService") +public class PtovtaAntifraudeServiceImpl implements PtovtaAntifraudeService { + + @Autowired + PtovtaAntifraudeDAO ptovtaAntifraudeServiceDAO; + + @Override + public List obtenerTodos() { + return ptovtaAntifraudeServiceDAO.obtenerTodos(); + } + + @Override + public PtovtaAntifraude obtenerID(Integer id) { + return ptovtaAntifraudeServiceDAO.obtenerID(id); + } + + @Override + @Transactional + public PtovtaAntifraude suscribir(PtovtaAntifraude entidad) { + entidad.setActivo(true); + entidad.setFecmodif(new Date()); + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + return ptovtaAntifraudeServiceDAO.suscribir(entidad); + } + + @Override + @Transactional + public PtovtaAntifraude actualizacion(PtovtaAntifraude entidad) { + entidad.setFecmodif(new Date()); + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + return ptovtaAntifraudeServiceDAO.actualizacion(entidad); + } + + @Override + @Transactional + public void borrar(PtovtaAntifraude entidad) { + entidad.setActivo(false); + entidad.setFecmodif(new Date()); + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + ptovtaAntifraudeServiceDAO.actualizacion(entidad); + } + +}