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.
Code Block
languageJava
titleJava Code Snippet
      

    public void testTransitiveClosuregetTransitiveClosure() {

        //*

Calculate the transitive       * Check for all descendantsclosure (all subconcepts) of a given concept

        ResolvedConceptReferencesIterator *iterator         
= null;
        try */
{
        System.out.println("***********************");

     String codingSchemeName = System.out.println("Testing transitive closure");
"NCI Thesaurus";
        System.out.println("***********************");

        String schemecode = "NCI ThesaurusC20181";

            String codeassociationName = "C20181subClassOf";

            ConceptReferenceboolean crresolveForward = ConvenienceMethods.createConceptReference(code,
false;
            boolean excludeAnonymous =  scheme)true;

            CodingSchemeVersionOrTag vtcsvt = new CodingSchemeVersionOrTag();

            vtcsvt.setTag("PRODUCTION");

        try {

   ConceptReference graphFocus = new ConceptReference();
       NameAndValueList   nvList = ConstructorsgraphFocus.createNameAndValueListsetConceptCode("subClassOf"code);

            CodedNodeGraph cng =  lbSvc.getNodeGraph(schemecodingSchemeName, vtcsvt, null);
            NameAndValueList asso_list =
                    Constructors.createNameAndValueList(new String[] { associationName }, null);
            cng = cng.restrictToAssociations(nvListasso_list, null);
            boolean resolveBackward = false;
            if (!resolveForward) {
                resolveBackward = true;
            }
            int resolveAssociationDepth = -1;
            int maxReturns = -1;
            CodedNodeSet nodesetcns = cng.toNodeList(ConvenienceMethods.createConceptReference(codegraphFocus, scheme)resolveForward, falseresolveBackward, true,-1, -1);


                    resolveAssociationDepth, maxReturns);
            if (excludeAnonymous) {
                CodedNodeSet.AnonymousOption restrictToAnonymous = CodedNodeSet.AnonymousOption.NON_ANONYMOUS_ONLY;

                nodesetcns = nodesetcns.restrictToAnonymous(restrictToAnonymous);

             }
           ResolvedConceptReferencesIterator iterator = nodesetcns.resolve(null, null,  null, null, false);

            while (iterator.hasNext()){

                ResolvedConceptReference rcr = iterator.next();

                String codeReturn = rcr.getCode();

                System.out.println(codeReturn);

            }

        } catch (Exception eex) {

            eex.printStackTrace();

        }

    }