/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cosmodas.EntCosmos;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 * @author obper
 */
@Entity
@Table(name = "ofertas")
@XmlRootElement
@NamedQueries({
        @NamedQuery(name = "Ofertas.findAll", query = "SELECT o FROM Ofertas o"),
        @NamedQuery(name = "Ofertas.findByOfertaCodigo", query = "SELECT o FROM Ofertas o WHERE o.ofertaCodigo = :ofertaCodigo"),
        @NamedQuery(name = "Ofertas.findByOfertaDescripcion", query = "SELECT o FROM Ofertas o WHERE o.ofertaDescripcion = :ofertaDescripcion"),
        @NamedQuery(name = "Ofertas.findByProgramaCodigo", query = "SELECT o FROM Ofertas o WHERE o.programaCodigo = :programaCodigo"),
        @NamedQuery(name = "Ofertas.findByOfertaLlave", query = "SELECT o FROM Ofertas o WHERE o.ofertaLlave = :ofertaLlave"),
        @NamedQuery(name = "Ofertas.findByOfertaEnvio", query = "SELECT o FROM Ofertas o WHERE o.ofertaEnvio = :ofertaEnvio")})
public class Ofertas implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 4)
    @Column(name = "oferta_codigo")
    private String ofertaCodigo;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "oferta_descripcion")
    private String ofertaDescripcion;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 3)
    @Column(name = "programa_codigo")
    private String programaCodigo;
    @Basic(optional = false)
    @NotNull
    @Column(name = "oferta_llave")
    private boolean ofertaLlave;
    @Basic(optional = false)
    @NotNull
    @Column(name = "oferta_envio")
    private boolean ofertaEnvio;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ofertas")
    private Collection<DetalleOferta> detalleOfertaCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ofertas")
    private Collection<Precioprograma> precioprogramaCollection;

    public Ofertas() {
    }

    public Ofertas(String ofertaCodigo) {
        this.ofertaCodigo = ofertaCodigo;
    }

    public Ofertas(String ofertaCodigo, String ofertaDescripcion, String programaCodigo, boolean ofertaLlave, boolean ofertaEnvio) {
        this.ofertaCodigo = ofertaCodigo;
        this.ofertaDescripcion = ofertaDescripcion;
        this.programaCodigo = programaCodigo;
        this.ofertaLlave = ofertaLlave;
        this.ofertaEnvio = ofertaEnvio;
    }

    public String getOfertaCodigo() {
        return ofertaCodigo;
    }

    public void setOfertaCodigo(String ofertaCodigo) {
        this.ofertaCodigo = ofertaCodigo;
    }

    public String getOfertaDescripcion() {
        return ofertaDescripcion;
    }

    public void setOfertaDescripcion(String ofertaDescripcion) {
        this.ofertaDescripcion = ofertaDescripcion;
    }

    public String getProgramaCodigo() {
        return programaCodigo;
    }

    public void setProgramaCodigo(String programaCodigo) {
        this.programaCodigo = programaCodigo;
    }

    public boolean getOfertaLlave() {
        return ofertaLlave;
    }

    public void setOfertaLlave(boolean ofertaLlave) {
        this.ofertaLlave = ofertaLlave;
    }

    public boolean getOfertaEnvio() {
        return ofertaEnvio;
    }

    public void setOfertaEnvio(boolean ofertaEnvio) {
        this.ofertaEnvio = ofertaEnvio;
    }

    @XmlTransient
    public Collection<DetalleOferta> getDetalleOfertaCollection() {
        return detalleOfertaCollection;
    }

    public void setDetalleOfertaCollection(Collection<DetalleOferta> detalleOfertaCollection) {
        this.detalleOfertaCollection = detalleOfertaCollection;
    }

    @XmlTransient
    public Collection<Precioprograma> getPrecioprogramaCollection() {
        return precioprogramaCollection;
    }

    public void setPrecioprogramaCollection(Collection<Precioprograma> precioprogramaCollection) {
        this.precioprogramaCollection = precioprogramaCollection;
    }

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

    @Override
    public String toString() {
        return "dbCon.Ofertas[ ofertaCodigo=" + ofertaCodigo + " ]";
    }

}
