/*
 * Created on May 5, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package gov.nih.nci.camod.domain;

import gov.nih.nci.evs.query.EVSQuery;
import gov.nih.nci.evs.query.EVSQueryImpl;
import gov.nih.nci.system.applicationservice.ApplicationService;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.builder.*;

/**
 * @author rajputs
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */
public class Organ extends BaseObject implements Serializable {

    private static final long serialVersionUID = 3259095453799404851L;

    private Long id;
    private String name;
    private String conceptCode;
    private List histopathologyCollection = new ArrayList();

    /**
     * @return Returns the histopathologyCollection.
     */
    public List getHistopathologyCollection() {
        return histopathologyCollection;
    }

    /**
     * @param histopathologyCollection
     *            The histopathologyCollection to set.
     */
    public void setHistopathologyCollection(List histopathologyCollection) {
        this.histopathologyCollection = histopathologyCollection;
    }

    /**
     * @param histopatholgy
     *            The histopathology to add.
     */
    public void addHistopathology(Histopathology histopathology) {
        histopathology.setOrgan(this);
        histopathologyCollection.add(histopathology);
    }

    /**
     * @return Returns the conceptCode.
     */
    public String getConceptCode() {
        return conceptCode;
    }

    /**
     * @return Returns the conceptCode.
     */
    public String getEVSPreferredDescription() {

        String thePreferedDesc = "";
        
        ApplicationService appService = ApplicationService
                .getRemoteInstance("http://cabio.nci.nih.gov/cacore30/server/HTTPServer");

        EVSQuery theQuery = new EVSQueryImpl();
        theQuery.getConceptNameByCode("NCI_Thesaurus", conceptCode);
        try {
            List evsResults = (List) appService.evsSearch(theQuery);

            if (evsResults.size() > 0) {
                System.out.println("List: " + evsResults);
                
                String theDisplayName = (String) evsResults.get(0);
                
                EVSQuery theQuery2 = new EVSQueryImpl();
                theQuery2.getPropertyValues("NCI_Thesaurus", theDisplayName, "Display_Name");
                
                List theSecondList = (List) appService.evsSearch(theQuery2);
                
                if (theSecondList.size() > 0)
                {
                    thePreferedDesc = (String) theSecondList.get(0);
                }
            }

        } catch (Exception e) {
            System.out.println("E: " + e);
        }
        return thePreferedDesc;
    }

    /**
     * @param conceptCode
     *            The conceptCode to set.
     */
    public void setConceptCode(String conceptCode) {
        this.conceptCode = conceptCode;
    }

    /**
     * @return Returns the id.
     */
    public Long getId() {
        return id;
    }

    /**
     * @param id
     *            The id to set.
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @return Returns the name.
     */
    public String getName() {
        return name;
    }

    /**
     * @param name
     *            The name to set.
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @see java.lang.Object#equals(Object)
     */
    public boolean equals(Object object) {
        if (!(object instanceof Organ)) {
            return false;
        }
        Organ rhs = (Organ) object;
        return new EqualsBuilder().append(this.histopathologyCollection, rhs.histopathologyCollection).append(
                this.name, rhs.name).append(this.conceptCode, rhs.conceptCode).append(this.id, rhs.id).isEquals();
    }

    /**
     * @see java.lang.Object#hashCode()
     */
    public int hashCode() {
        return new HashCodeBuilder(-5760707, 335803633).append(this.histopathologyCollection).append(this.name).append(
                this.conceptCode).append(this.id).toHashCode();
    }

    /**
     * @see java.lang.Object#toString()
     */
    public String toString() {
        return new ToStringBuilder(this).append("name", this.name).append("conceptCode", this.conceptCode).append("id",
                this.id).append("histopathologyCollection", this.histopathologyCollection).toString();
    }
}

@@ -209,134 +209,30 @@
 nci.
-evs.query.EVSQuery;%0Aimport gov.nih.nci.evs.query.EVSQueryImpl;%0Aimport gov.nih.nci.system.applicationservice.ApplicationService
+camod.util.EvsTreeUtil
 ;%0A%0Ai
@@ -1706,25 +1706,24 @@
 ion() %7B%0A
-%0A
         
 String t
@@ -1718,1143 +1718,70 @@
     
-String thePreferedDesc = %22%22;%0A        %0A        ApplicationService appService = ApplicationService%0A                .getRemoteInstance(%22http://cabio.nci.nih.gov/cacore30/server/HTTPServer%22);%0A%0A        EVSQuery theQuery = new EVSQueryImpl();%0A        theQuery.getConceptNameByCode(%22NCI_Thesaurus%22, conceptCode);%0A        try %7B%0A            List evsResults = (List) appService.evsSearch(theQuery);%0A%0A            if (evsResults.size() %3E 0) %7B%0A                System.out.println(%22List: %22 + evsResults);%0A                %0A                String theDisplayName = (String) evsResults.get(0);%0A                %0A                EVSQuery theQuery2 = new EVSQueryImpl();%0A                theQuery2.getPropertyValues(%22NCI_Thesaurus%22, theDisplayName, %22Display_Name%22);%0A                %0A                List theSecondList = (List) appService.evsSearch(theQuery2);%0A                %0A                if (theSecondList.size() %3E 0)%0A                %7B%0A                    thePreferedDesc = (String) theSecondList.get(0);%0A                %7D%0A            %7D%0A%0A        %7D catch (Exception e) %7B%0A            System.out.println(%22E: %22 + e);%0A        %7D%0A        return thePreferedDesc
+return EvsTreeUtil.getEVSPreferedOrganDescription(conceptCode)
 ;%0A  

Use EvsTreeUtil