/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
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.CascadeType;
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.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * 
 * @author Administrador
 */
@Entity
@SequenceGenerator(name = "TIPO_PTOVTA_SEQ", sequenceName = "TIPO_PTOVTA_SEQ", allocationSize = 1)
@Table(name = "TIPO_PTOVTA")
public class TipoPuntoVenta implements Serializable {

	public static final Short TODOS = -1;

	private static final long serialVersionUID = 1L;
	@Id
	@Basic(optional = false)
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "TIPO_PTOVTA_SEQ")
	@Column(name = "TIPOPTOVTA_ID")
	private Short tipoptovtaId;
	@Column(name = "DESCTIPO")
	private String desctipo;
	@Column(name = "ACTIVO")
	private Boolean activo;
	@Column(name = "FECMODIF")
	@Temporal(TemporalType.TIMESTAMP)
	private Date fecmodif;
	@Column(name = "USUARIO_ID")
	private Integer usuarioId;
	@Column(name = "EQUIVALENCIA_ID")
	private String equivalenciaId;
	@OneToMany(cascade = CascadeType.ALL)
	@JoinColumn(name = "TIPOPTOVTA_ID")
	private List<CategoriaTipoPtoVta> lsCategoriaTipoPtoVta;

	public TipoPuntoVenta() {
	}

	public TipoPuntoVenta(Short tipoptovtaId) {
		this.tipoptovtaId = tipoptovtaId;
	}

	public Short getTipoptovtaId() {
		return tipoptovtaId;
	}

	public void setTipoptovtaId(Short tipoptovtaId) {
		this.tipoptovtaId = tipoptovtaId;
	}

	public String getDesctipo() {
		return desctipo;
	}

	public void setDesctipo(String desctipo) {
		this.desctipo = desctipo;
	}

	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 String getEquivalenciaId() {
		return equivalenciaId;
	}

	public void setEquivalenciaId(String equivalenciaId) {
		this.equivalenciaId = equivalenciaId;
	}

	public List<CategoriaTipoPtoVta> getLsCategoriaTipoPtoVta() {
		List<CategoriaTipoPtoVta> tmp = new ArrayList<CategoriaTipoPtoVta>();
		if (lsCategoriaTipoPtoVta != null) {
			for (CategoriaTipoPtoVta cp : this.lsCategoriaTipoPtoVta) {
				if (cp.getActivo()) {
					tmp.add(cp);
				}
			}
		}

		return tmp;
	}

	public void setLsCategoriaTipoPtoVta(List<CategoriaTipoPtoVta> lsCategoriaTipoPtoVta) {
		this.lsCategoriaTipoPtoVta = lsCategoriaTipoPtoVta;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (getTipoptovtaId() != null ? getTipoptovtaId().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 TipoPuntoVenta)) {
			return false;
		}
		TipoPuntoVenta other = (TipoPuntoVenta) object;
		if ((this.getTipoptovtaId() == null && other.getTipoptovtaId() != null) || (this.getTipoptovtaId() != null && !this.getTipoptovtaId().equals(other.getTipoptovtaId()))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return this.getDesctipo();
	}
}
