@@ -0,0 +1,3024 @@
+/**%0A *  @author georgeda %0A *  %0A *  $Id: EvsTreeUtil.java,v 1.1 2005-09-21 20:34:59 georgeda Exp $  %0A *  %0A *  $Log: not supported by cvs2svn $%0A *  %0A */%0Apackage gov.nih.nci.camod.util;%0A%0Aimport gov.nih.nci.camod.Constants;%0Aimport gov.nih.nci.evs.query.EVSQuery;%0Aimport gov.nih.nci.evs.query.EVSQueryImpl;%0Aimport gov.nih.nci.system.applicationservice.ApplicationService;%0A%0Aimport java.util.*;%0A%0Aimport org.apache.commons.logging.Log;%0Aimport org.apache.commons.logging.LogFactory;%0A%0A/**%0A * Static helper class for caching EVS values.%0A * %0A */%0Apublic class EvsTreeUtil %7B%0A%0A    static private final Log log = LogFactory.getLog(EvsTreeUtil.class);%0A%0A    static private Map ourOrganDescriptions = new HashMap();%0A%0A    private EvsTreeUtil() %7B%0A    %7D%0A%0A    /**%0A     * Get a preferred name based on a concept code. Will return the cached%0A     * value if it has been fetched before.%0A     * %0A     * @param inConceptCode the concept code to get the preferred name for.%0A     * %0A     * @return the preferred name, or an empty string if something goes wrong.%0A     */%0A    public static synchronized String getEVSPreferedOrganDescription(String inConceptCode) %7B%0A%0A        log.trace(%22Entering getEVSPreferedOrganDescription%22);%0A%0A        String theDescription = %22%22;%0A%0A        if (ourOrganDescriptions.containsKey(inConceptCode)) %7B%0A            theDescription = (String) ourOrganDescriptions.get(inConceptCode);%0A        %7D else %7B%0A%0A            try %7B%0A                // Get the app service uri%0A                ResourceBundle theBundle = ResourceBundle.getBundle(%22camod%22);%0A%0A                ApplicationService appService = ApplicationService.getRemoteInstance(theBundle%0A                        .getString(Constants.Evs.URI_KEY));%0A%0A                EVSQuery theConceptNameQuery = new EVSQueryImpl();%0A                theConceptNameQuery.getConceptNameByCode(Constants.Evs.NAMESPACE, inConceptCode);%0A%0A                List theConceptNames = (List) appService.evsSearch(theConceptNameQuery);%0A%0A                // Should only be one%0A                if (theConceptNames.size() %3E 0) %7B%0A%0A                    String theDisplayName = (String) theConceptNames.get(0);%0A%0A                    EVSQuery theDisplayNameQuery = new EVSQueryImpl();%0A                    theDisplayNameQuery.getPropertyValues(Constants.Evs.NAMESPACE, theDisplayName,%0A                            Constants.Evs.DISPLAY_NAME_TAG);%0A%0A                    // Should only be one%0A                    List theDisplayNameList = (List) appService.evsSearch(theDisplayNameQuery);%0A%0A                    if (theDisplayNameList.size() %3E 0) %7B%0A                        theDescription = (String) theDisplayNameList.get(0);%0A%0A                        // Cache for next time%0A                        ourOrganDescriptions.put(inConceptCode, theDescription);%0A                    %7D%0A                %7D%0A%0A            %7D catch (Exception e) %7B%0A                log.error(%22Exception getting preferred description: %22, e);%0A            %7D%0A        %7D%0A        log.trace(%22Exiting getEVSPreferedOrganDescription%22);%0A%0A        return theDescription;%0A    %7D%0A%7D%0A

Create util for fetching/caching EVS data