/*
 * 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.math.BigDecimal;
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;
//import org.codehaus.jackson.annotate.JsonIgnore;

/**
 * @author obper
 */
@Entity
@Table(name = "articulo")
@XmlRootElement
@NamedQueries({
        @NamedQuery(name = "Articulo.findAll", query = "SELECT a FROM Articulo a"),
        @NamedQuery(name = "Articulo.findByArticuloCodigo", query = "SELECT a FROM Articulo a WHERE a.articuloCodigo = :articuloCodigo"),
        @NamedQuery(name = "Articulo.findByArticuloNombre", query = "SELECT a FROM Articulo a WHERE a.articuloNombre = :articuloNombre"),
        @NamedQuery(name = "Articulo.findByArticuloDetalle", query = "SELECT a FROM Articulo a WHERE a.articuloDetalle = :articuloDetalle"),
        @NamedQuery(name = "Articulo.findByArticuloPrecioVenta", query = "SELECT a FROM Articulo a WHERE a.articuloPrecioVenta = :articuloPrecioVenta"),
        @NamedQuery(name = "Articulo.findByArticuloPrecioCompra", query = "SELECT a FROM Articulo a WHERE a.articuloPrecioCompra = :articuloPrecioCompra"),
        @NamedQuery(name = "Articulo.findByArticuloEnvio", query = "SELECT a FROM Articulo a WHERE a.articuloEnvio = :articuloEnvio"),
        @NamedQuery(name = "Articulo.findByArticuloMuestra", query = "SELECT a FROM Articulo a WHERE a.articuloMuestra = :articuloMuestra")})
public class Articulo implements Serializable {
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "articuloCodigo")
    private Collection<ArticulosZonasTotal> articulosZonasTotalCollection;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 4)
    @Column(name = "articulo_codigo")
    private String articuloCodigo;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "articulo_nombre")
    private String articuloNombre;
    @Size(max = 150)
    @Column(name = "articulo_detalle")
    private String articuloDetalle;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "articulo_precio_venta")
    private BigDecimal articuloPrecioVenta;
    @Column(name = "articulo_precio_compra")
    private BigDecimal articuloPrecioCompra;
    @Column(name = "articulo_envio")
    private Boolean articuloEnvio;
    @Column(name = "articulo_muestra")
    private Boolean articuloMuestra;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "articulo")
    private Collection<ArticuloSala> articuloSalaCollection;

    public Articulo() {
    }

    public Articulo(String articuloCodigo) {
        this.articuloCodigo = articuloCodigo;
    }

    public Articulo(String articuloCodigo, String articuloNombre) {
        this.articuloCodigo = articuloCodigo;
        this.articuloNombre = articuloNombre;
    }

    public String getArticuloCodigo() {
        return articuloCodigo;
    }

    public void setArticuloCodigo(String articuloCodigo) {
        this.articuloCodigo = articuloCodigo;
    }

    public String getArticuloNombre() {
        return articuloNombre;
    }

    public void setArticuloNombre(String articuloNombre) {
        this.articuloNombre = articuloNombre;
    }

    public String getArticuloDetalle() {
        return articuloDetalle;
    }

    public void setArticuloDetalle(String articuloDetalle) {
        this.articuloDetalle = articuloDetalle;
    }

    public BigDecimal getArticuloPrecioVenta() {
        return articuloPrecioVenta;
    }

    public void setArticuloPrecioVenta(BigDecimal articuloPrecioVenta) {
        this.articuloPrecioVenta = articuloPrecioVenta;
    }

    public BigDecimal getArticuloPrecioCompra() {
        return articuloPrecioCompra;
    }

    public void setArticuloPrecioCompra(BigDecimal articuloPrecioCompra) {
        this.articuloPrecioCompra = articuloPrecioCompra;
    }

    public Boolean getArticuloEnvio() {
        return articuloEnvio;
    }

    public void setArticuloEnvio(Boolean articuloEnvio) {
        this.articuloEnvio = articuloEnvio;
    }

    public Boolean getArticuloMuestra() {
        return articuloMuestra;
    }

    public void setArticuloMuestra(Boolean articuloMuestra) {
        this.articuloMuestra = articuloMuestra;
    }

    @XmlTransient
    //@JsonIgnore
    public Collection<ArticuloSala> getArticuloSalaCollection() {
        return articuloSalaCollection;
    }

    public void setArticuloSalaCollection(Collection<ArticuloSala> articuloSalaCollection) {
        this.articuloSalaCollection = articuloSalaCollection;
    }

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

    @Override
    public String toString() {
        return "com.cosmodas.dbcon.Articulo[ articuloCodigo=" + articuloCodigo + " ]";
    }

    @XmlTransient
    public Collection<ArticulosZonasTotal> getArticulosZonasTotalCollection() {
        return articulosZonasTotalCollection;
    }

    public void setArticulosZonasTotalCollection(Collection<ArticulosZonasTotal> articulosZonasTotalCollection) {
        this.articulosZonasTotalCollection = articulosZonasTotalCollection;
    }

}
