package org.mskcc.cbio.oncokb.model;
// Generated Dec 19, 2013 1:33:26 AM by Hibernate Tools 3.2.1.GA


import io.swagger.annotations.ApiModelProperty;

import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

/**
 * @author jgao, Hongxin ZHang
 */

@NamedQueries({
    @NamedQuery(
        name = "findGeneByHugoSymbol",
        query = "select g from Gene g where g.hugoSymbol=?"
    ),
    @NamedQuery(
        name = "findGenesByAlias",
        query = "select g from Gene g join g.geneAliases ga where ga=?"
    )
})

@Entity
@Table(name = "gene")
public class Gene implements Serializable {

    @Id
    @Column(name = "entrez_gene_id")
    private Integer entrezGeneId;

    @Column(name = "hugo_symbol", length = 50, nullable = true, unique = true)
    private String hugoSymbol;

    @Column(length = 500)
    private String name;

    @Column()
    @ApiModelProperty(value = "tumorSuppressorGene")
    private Boolean TSG;
    private Boolean oncogene;

    @Column(length = 100)
    private String curatedIsoform;

    @Column(length = 100)
    private String curatedRefSeq;

    @ElementCollection(fetch = FetchType.EAGER)
    @CollectionTable(name = "gene_alias", joinColumns = @JoinColumn(name = "entrez_gene_id", nullable = false))
    @Column(name = "alias")
    private Set<String> geneAliases = new HashSet<String>(0);

    public Gene() {
    }


    public Gene(int entrezGeneId, String hugoSymbol, String name) {
        this.entrezGeneId = entrezGeneId;
        this.hugoSymbol = hugoSymbol;
        this.name = name;
    }

    public Gene(int entrezGeneId, String hugoSymbol, String name, String summary, Set<String> geneLabels, Set<String> geneAliases) {
        this.entrezGeneId = entrezGeneId;
        this.hugoSymbol = hugoSymbol;
        this.name = name;
        this.geneAliases = geneAliases;
    }


    public Integer getEntrezGeneId() {
        return this.entrezGeneId;
    }


    public void setEntrezGeneId(Integer entrezGeneId) {
        this.entrezGeneId = entrezGeneId;
    }

    public String getHugoSymbol() {
        return this.hugoSymbol;
    }


    public void setHugoSymbol(String hugoSymbol) {
        this.hugoSymbol = hugoSymbol;
    }

    public String getName() {
        return this.name;
    }


    public void setName(String name) {
        this.name = name;
    }

    public Set<String> getGeneAliases() {
        return this.geneAliases;
    }


    public void setGeneAliases(Set<String> geneAliases) {
        this.geneAliases = geneAliases;
    }

    public Boolean getTSG() {
        return TSG;
    }

    public void setTSG(Boolean TSG) {
        this.TSG = TSG;
    }

    public Boolean getOncogene() {
        return oncogene;
    }

    public void setOncogene(Boolean oncogene) {
        this.oncogene = oncogene;
    }

    public String getCuratedIsoform() {
        return curatedIsoform;
    }

    public void setCuratedIsoform(String curatedIsoform) {
        this.curatedIsoform = curatedIsoform;
    }

    public String getCuratedRefSeq() {
        return curatedRefSeq;
    }

    public void setCuratedRefSeq(String curatedRefSeq) {
        this.curatedRefSeq = curatedRefSeq;
    }

    public int hashCode() {
        int hash = 3;
        hash = 53 * hash + this.entrezGeneId;
        return hash;
    }


    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Gene other = (Gene) obj;
        if (this.entrezGeneId != other.entrezGeneId) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return hugoSymbol;
    }

}


@@ -3330,32 +3330,45 @@
 rn hash;%0A    %7D%0A%0A
+    @Override
 %0A    public bool
@@ -3386,18 +3386,16 @@
 Object o
-bj
 ) %7B%0A    
@@ -3406,42 +3406,26 @@
 if (
-obj == null) %7B%0A           
+this == o)
  return 
 fals
@@ -3412,36 +3412,35 @@
 is == o) return 
-fals
+tru
 e;%0A        %7D%0A   
@@ -3438,65 +3438,33 @@
     
-%7D%0A        if (getClass() != obj.getClass()) %7B%0A           
+if (!(o instanceof Gene))
  ret
@@ -3470,33 +3470,24 @@
 turn false;%0A
-        %7D
 %0A        fin
@@ -3487,24 +3487,17 @@
     
-final 
 Gene 
-other
+gene
  = (
@@ -3507,11 +3507,10 @@
 e) o
-bj
 ;
+%0A
 %0A   
@@ -3518,18 +3518,19 @@
     
-if (this.e
+return getE
 ntre
@@ -3540,89 +3540,102 @@
 neId
+()
  != 
-other.entrezGeneId) %7B%0A            return false;%0A        %7D%0A        return true
+null ? getEntrezGeneId().equals(gene.getEntrezGeneId()) : gene.getEntrezGeneId() == null
 ;%0A  

Update gene equals method based on primary data type