NIH | National Cancer Institute | NCI Wiki  

Error rendering macro 'rw-search'

null

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Code Block
languageJava
titleJava Code Snippet
public class Test {
/**
 * Initialize program variables
 */
        
    private String codingScheme = null;
    private String version = null;
         
    LexBIGService lbSvc;
        
    public Test(String codingScheme, String version)  {
        //Set the LexEVS URL (for remote access)
        String evsUrl = "http://lexevsapi.nci.nih.gov/lexevsapi50/http/remoteService";
        boolean isRemote = true;
        this.codingScheme = codingScheme;
        this.version = version;
        
        // Get the LexBIG service reference from LexEVS Application Service 
        lbSvc = (LexEVSApplicationService)ApplicationServiceProvider.getApplicationServiceFromUrl(evsUrl, "EvsServiceInfo");
        
        // Set the vocabulary to work with
        Boolean retval = adapter.setVocabulary(codingScheme);
        
        codingSchemeMap = new HashMap();
        try {
            // Using the LexBIG service, get the supported coding schemes
            CodingSchemeRenderingList csrl = lbSvc.getSupportedCodingSchemes();
        
            // Get the coding scheme rendering
            CodingSchemeRendering[] csrs = csrl.getCodingSchemeRendering();
         
            // For each coding scheme rendering...
            for (int i=0; i<csrs.length; i++) {
                CodingSchemeRendering csr = csrs[i];
        
                // Determine whether the coding scheme rendering is active or not
                Boolean isActive = csr.getRenderingDetail().getVersionStatus().equals(CodingSchemeVersionStatus.ACTIVE);
                if (isActive != null && isActive.equals(Boolean.TRUE)) {
                    // Get the coding scheme summary
                    CodingSchemeSummary css = csr.getCodingSchemeSummary();
        
                    // Get the coding scheme formal name
                    String formalname = css.getFormalName();
                    
                    //Get the coding scheme version
                    String representsVersion = css.getRepresentsVersion();
                    CodingSchemeVersionOrTag vt = new;
                    CodingSchemeVersionOrTag();
                    vt.setVersion(representsVersion);
        
                    // Resolve coding scheme based on the formal name
                    CodingScheme scheme = null;
         
                    try {
                        scheme =lbSvc.resolveCodingScheme(formalname, vt);
                        if (scheme != null){
                            codingSchemeMap.put((Object) formalname, (Object) scheme);
                        }
                    } catch (Exception e) {
                        // Resolve coding scheme based on the URI
                        String uri = css.getCodingSchemeURI();
                        try {
                            scheme = lbSvc.resolveCodingScheme(uri, vt);
                            if (scheme != null) {
                                 codingSchemeMap.put((Object) formalname, (Object) scheme);
                            }
                        } catch (Exception ex) {
                            String localname = css.getLocalName();
        
                            // Resolve coding scheme based on the local name
                            try {
                                scheme = lbSvc.resolveCodingScheme(localname, vt);
                                if(scheme != null){
                                    codingSchemeMap.put((Object) formalname, (Object) scheme);
                                }
                            } catch (Exception e2) {
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
     
    /**
     *Main
     */
    public static void main (String[] args)
    {
        String name = "NCI Thesaurus";
        String version = "06.12d";
    
        // Instantiate the Test Class
        Test test = new Test(name, version);
    }
}