package com.fp.persistence.pgeneral.gene;

import java.io.Serializable;
import java.lang.reflect.Field;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.Version;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import com.fp.dto.hb.HibernateBean;

/** Clase que implementa la entidad de Hibernate que hace referencia a la tabla TGENECATALOGEQUIVALENCEDET */
@Entity(name = "TgeneCatalogEquivalenceDet")
@Table(name = "TGENECATALOGEQUIVALENCEDET")
public class TgeneCatalogEquivalenceDet extends com.fp.dto.AbstractDataTransport implements Serializable, HibernateBean, Cloneable {
    /**
     * HashCode asociado con la Instancia
     */
    @Transient
    private int hashValue = 0;

    /**
     * Version de la Clase
     */
    private static final long serialVersionUID = 1L;

    // CAMPO MANUAL private Long pk;
    /**
     * Clave primaria de la Entidad TgeneCatalogEquivalenceDet
     */
    @Id
    @Column(name = "ID", nullable = false, updatable = false)
    @GenericGenerator(name = "seq_id", strategy = "com.fp.general.keygen.SequenceKey", parameters = {
            @Parameter(name = "name", value = "IDCATALOGEQUIV"), 
            @Parameter(name = "type", value = "java.lang.Long"), 
            @Parameter(name = "fill", value = "0"),
            @Parameter(name = "length", value = "5") })
    
    @GeneratedValue(generator = "seq_id")
    private Long pk;

    @Column(name = "CATALOGCECODE", nullable = false)
    /**
     * CATALOGO DE ENTIDAD DE CONTROL
     */
    private String catalogcecode;

    @Column(name = "CATALOGCE", nullable = false)
    /**
     * VALOR CATALOGO ENTIDAD DE CONTROL
     */
    private String catalogce;

    @Column(name = "DESCATALOGCE", nullable = true)
    /**
     * DESCRIPCION VALOR CATALOGO ENTIDAD DE CONTROL
     */
    private String descatalogce;

    @Column(name = "ORIGINCATALOGCODE", nullable = true)
    /**
     * CATALOGO ORIGEN (MAIA)
     */
    private String origincatalogcode;

    @Column(name = "ORIGINCATALOG", nullable = false)
    /**
     * VALOR CATALOGO ORIGEN (MAIA)
     */
    private String origincatalog;

    @Version
    @Column(name = "RECORDVERSION", nullable = true)
    /**
     * VERSION DEL REGISTRO
     */
    private Integer recordversion;

    @Column(name = "ORIGINCATALOGCODE_N1", nullable = true)
    /**
     * null
     */
    private String origincatalogcode_n1;

    @Column(name = "ORIGINCATALOG_N1", nullable = true)
    /**
     * null
     */
    private String origincatalog_n1;

    @Column(name = "ORIGINCATALOGCODE_N2", nullable = true)
    /**
     * null
     */
    private String origincatalogcode_n2;

    @Column(name = "ORIGINCATALOG_N2", nullable = true)
    /**
     * null
     */
    private String origincatalog_n2;

    @Column(name = "ORIGINCATALOGCODE_N3", nullable = true)
    /**
     * null
     */
    private String origincatalogcode_n3;

    @Column(name = "ORIGINCATALOG_N3", nullable = true)
    /**
     * null
     */
    private String origincatalog_n3;

    /** Contructor por defecto */
    public TgeneCatalogEquivalenceDet() {
    }

    /**
     * Contructor de TgeneCatalogEquivalenceDet
     * 
     * @param pPk Clave Primaria del entity
     * @param pCatalogcecode CATALOGO DE ENTIDAD DE CONTROL
     * @param pCatalogce VALOR CATALOGO ENTIDAD DE CONTROL
     * @param pOrigincatalog VALOR CATALOGO ORIGEN (MAIA)
     */
    public TgeneCatalogEquivalenceDet(Long pPk, String pCatalogcecode, String pCatalogce, String pOrigincatalog) {
        this();
        this.pk = pPk;
        this.catalogcecode = pCatalogcecode;
        this.catalogce = pCatalogce;
        this.origincatalog = pOrigincatalog;
    }

    /**
     * Metodo que entrega datos de la tabla dada la clave primaria.
     * 
     * @param pEntityManager referencia de la session a obtener datos del bean.
     * @param pKey Caleve primaria del bean.
     * @return TgeneCatalogEquivalenceDet
     */
    public static TgeneCatalogEquivalenceDet find(EntityManager pEntityManager, Object pKey) throws Exception {
        TgeneCatalogEquivalenceDet obj = pEntityManager.find(TgeneCatalogEquivalenceDet.class, pKey);
        return obj;
    }

    /**
     * Entrega la Clave primaria de TgeneCatalogEquivalenceDet
     * 
     * @return El objeto que referencia a la Clave primaria de TgeneCatalogEquivalenceDet
     */
    public Long getPk() {
        return this.pk;
    }

    /**
     * Fija un nuevo valor a la Clave primaria de TgeneCatalogEquivalenceDet
     * 
     * @param pPk El objeto que referencia a la nueva Clave primaria de TgeneCatalogEquivalenceDet
     */
    public void setPk(Long pPk) {
        this.pk = pPk;
    }

    /**
     * Obtiene el valor de catalogcecode
     * 
     * @return valor de catalogcecode
     */
    public String getCatalogcecode() {
        return this.catalogcecode;
    }

    /**
     * Fija el valor de catalogcecode
     * 
     * @param pCatalogcecode nuevo Valor de catalogcecode
     */
    public void setCatalogcecode(String pCatalogcecode) {
        this.catalogcecode = pCatalogcecode;
    }

    /**
     * Obtiene el valor de catalogce
     * 
     * @return valor de catalogce
     */
    public String getCatalogce() {
        return this.catalogce;
    }

    /**
     * Fija el valor de catalogce
     * 
     * @param pCatalogce nuevo Valor de catalogce
     */
    public void setCatalogce(String pCatalogce) {
        this.catalogce = pCatalogce;
    }

    /**
     * Obtiene el valor de descatalogce
     * 
     * @return valor de descatalogce
     */
    public String getDescatalogce() {
        return this.descatalogce;
    }

    /**
     * Fija el valor de descatalogce
     * 
     * @param pDescatalogce nuevo Valor de descatalogce
     */
    public void setDescatalogce(String pDescatalogce) {
        this.descatalogce = pDescatalogce;
    }

    /**
     * Obtiene el valor de origincatalogcode
     * 
     * @return valor de origincatalogcode
     */
    public String getOrigincatalogcode() {
        return this.origincatalogcode;
    }

    /**
     * Fija el valor de origincatalogcode
     * 
     * @param pOrigincatalogcode nuevo Valor de origincatalogcode
     */
    public void setOrigincatalogcode(String pOrigincatalogcode) {
        this.origincatalogcode = pOrigincatalogcode;
    }

    /**
     * Obtiene el valor de origincatalog
     * 
     * @return valor de origincatalog
     */
    public String getOrigincatalog() {
        return this.origincatalog;
    }

    /**
     * Fija el valor de origincatalog
     * 
     * @param pOrigincatalog nuevo Valor de origincatalog
     */
    public void setOrigincatalog(String pOrigincatalog) {
        this.origincatalog = pOrigincatalog;
    }

    /**
     * Obtiene el valor de recordversion
     * 
     * @return valor de recordversion
     */
    public Integer getRecordversion() {
        return this.recordversion;
    }

    /**
     * Fija el valor de recordversion
     * 
     * @param pRecordversion nuevo Valor de recordversion
     */
    public void setRecordversion(Integer pRecordversion) {
        this.recordversion = pRecordversion;
    }

    /**
     * Obtiene el valor de origincatalogcode_n1
     * 
     * @return valor de origincatalogcode_n1
     */
    public String getOrigincatalogcode_n1() {
        return this.origincatalogcode_n1;
    }

    /**
     * Fija el valor de origincatalogcode_n1
     * 
     * @param pOrigincatalogcode_n1 nuevo Valor de origincatalogcode_n1
     */
    public void setOrigincatalogcode_n1(String pOrigincatalogcode_n1) {
        this.origincatalogcode_n1 = pOrigincatalogcode_n1;
    }

    /**
     * Obtiene el valor de origincatalog_n1
     * 
     * @return valor de origincatalog_n1
     */
    public String getOrigincatalog_n1() {
        return this.origincatalog_n1;
    }

    /**
     * Fija el valor de origincatalog_n1
     * 
     * @param pOrigincatalog_n1 nuevo Valor de origincatalog_n1
     */
    public void setOrigincatalog_n1(String pOrigincatalog_n1) {
        this.origincatalog_n1 = pOrigincatalog_n1;
    }

    /**
     * Obtiene el valor de origincatalogcode_n2
     * 
     * @return valor de origincatalogcode_n2
     */
    public String getOrigincatalogcode_n2() {
        return this.origincatalogcode_n2;
    }

    /**
     * Fija el valor de origincatalogcode_n2
     * 
     * @param pOrigincatalogcode_n2 nuevo Valor de origincatalogcode_n2
     */
    public void setOrigincatalogcode_n2(String pOrigincatalogcode_n2) {
        this.origincatalogcode_n2 = pOrigincatalogcode_n2;
    }

    /**
     * Obtiene el valor de origincatalog_n2
     * 
     * @return valor de origincatalog_n2
     */
    public String getOrigincatalog_n2() {
        return this.origincatalog_n2;
    }

    /**
     * Fija el valor de origincatalog_n2
     * 
     * @param pOrigincatalog_n2 nuevo Valor de origincatalog_n2
     */
    public void setOrigincatalog_n2(String pOrigincatalog_n2) {
        this.origincatalog_n2 = pOrigincatalog_n2;
    }

    /**
     * Obtiene el valor de origincatalogcode_n3
     * 
     * @return valor de origincatalogcode_n3
     */
    public String getOrigincatalogcode_n3() {
        return this.origincatalogcode_n3;
    }

    /**
     * Fija el valor de origincatalogcode_n3
     * 
     * @param pOrigincatalogcode_n3 nuevo Valor de origincatalogcode_n3
     */
    public void setOrigincatalogcode_n3(String pOrigincatalogcode_n3) {
        this.origincatalogcode_n3 = pOrigincatalogcode_n3;
    }

    /**
     * Obtiene el valor de origincatalog_n3
     * 
     * @return valor de origincatalog_n3
     */
    public String getOrigincatalog_n3() {
        return this.origincatalog_n3;
    }

    /**
     * Fija el valor de origincatalog_n3
     * 
     * @param pOrigincatalog_n3 nuevo Valor de origincatalog_n3
     */
    public void setOrigincatalog_n3(String pOrigincatalog_n3) {
        this.origincatalog_n3 = pOrigincatalog_n3;
    }

    @Override
    public boolean equals(Object rhs) {
        if (rhs == null) {
            return false;
        }
        if (!(rhs instanceof TgeneCatalogEquivalenceDet)) {
            return false;
        }
        TgeneCatalogEquivalenceDet that = (TgeneCatalogEquivalenceDet) rhs;
        if ((this.getPk() == null) || (that.getPk() == null)) {
            return false;
        }
        return (this.getPk().equals(that.getPk()));
    }

    /**
     * Implementacion del metodo hashCode de la la entidad TgeneCatalogEquivalenceDet
     * 
     * @return el hashCode la instancia
     */
    @Override
    public int hashCode() {
        if (this.hashValue == 0) {
            int result = 17;
            if (this.getPk() == null) {
                result = super.hashCode();
            } else {
                result = this.getPk().hashCode();
            }
            this.hashValue = result;
        }
        return this.hashValue;
    }

    /** Implementacion toString */
    @Override
    public String toString() {
        Field[] fs = this.getClass().getDeclaredFields();
        String data = "";
        for (Field f : fs) {
            try {
                String name = f.getName();
                if (f.getType().getName().compareTo("java.util.Set") == 0) {
                    continue;
                }
                if ((name.compareTo("hashValue") == 0) || (name.compareTo("serialVersionUID") == 0)) {
                    continue;
                }
                data += name + "=" + f.get(this) + ";";
            } catch (Exception e) {
                continue;
            }
        }
        if (data.compareTo("") == 0) {
            data = super.toString();
        }
        return data;
    }

    /** Implementacion de la creacion de un bean en blanco TgeneCatalogEquivalenceDet */
    @Override
    public Object createInstance() {
        TgeneCatalogEquivalenceDet instance = new TgeneCatalogEquivalenceDet();
        return instance;
    }

    /**
     * Clona la entidad TgeneCatalogEquivalenceDet
     * 
     * @see com.fp.dto.hb.HibernateBean#cloneMe()
     */
    @Override
    public Object cloneMe() throws CloneNotSupportedException {
        TgeneCatalogEquivalenceDet p = (TgeneCatalogEquivalenceDet) this.clone();
        return p;
    }
}
