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; @JoinColumn(name = "EMPRESA_ID", referencedColumnName = "EMPRESA_ID") @ManyToOne private Empresa empresa; @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 + "]"; } public Empresa getEmpresa() { return empresa; } public void setEmpresa(Empresa empresa) { this.empresa = empresa; } }