package edu.duke.cabig.c3pr.domain;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

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

/**
 * @author Priyatam
 */
@Entity
@Table(name = "disease_terms")
@GenericGenerator(name = "id-generator", strategy = "native", parameters = { @Parameter(name = "sequence", value = "DISEASE_TERMS_ID_SEQ") })
public class DiseaseTerm extends AbstractMutableDeletableDomainObject {
    private String term;

    // private String select;
    private String ctepTerm;

    private long medraCode;

    private DiseaseCategory category;

    // private boolean otherRequired;

    // //// LOGIC

    // //// BEAN PROPERTIES

    public void setMedraCode(long medraCode) {
        this.medraCode = medraCode;
    }

    public long getMedraCode() {
        return medraCode;
    }

    public String getTerm() {
        return term;
    }

    public void setTerm(String term) {
        this.term = term;
    }

    public String getCtepTerm() {
        return ctepTerm;
    }

    public void setCtepTerm(String ctepTerm) {
        this.ctepTerm = ctepTerm;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "category_id", nullable = false)
    public DiseaseCategory getCategory() {
        return category;
    }

    public void setCategory(DiseaseCategory category) {
        this.category = category;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        final DiseaseTerm that = (DiseaseTerm) o;

        if (ctepTerm != null ? !ctepTerm.equals(that.ctepTerm) : that.ctepTerm != null) return false;
        return true;
    }

    public int hashCode() {
        int result;
        result = (ctepTerm != null ? ctepTerm.hashCode() : 0);
        return result;
    }

}

@@ -721,25 +721,32 @@
 aseCategory 
-c
+diseaseC
 ategory;%0A%0A  
@@ -1288,32 +1288,8 @@
 oOne
-(fetch = FetchType.LAZY)
 %0A   
@@ -1371,16 +1371,23 @@
 gory get
+Disease
 Category
@@ -1406,17 +1406,24 @@
  return 
-c
+diseaseC
 ategory;
@@ -1449,16 +1449,23 @@
 void set
+Disease
 Category
@@ -1481,17 +1481,24 @@
 ategory 
-c
+diseaseC
 ategory)
@@ -1513,17 +1513,24 @@
    this.
-c
+diseaseC
 ategory 
@@ -1531,17 +1531,24 @@
 egory = 
-c
+diseaseC
 ategory;

changed category to diseaseCategory