NIH | National Cancer Institute | NCI Wiki  

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 void testFullSynBySource(){
		try {
						String searchTerm = "gene";			
			CodedNodeSet nodeSet = 

<ac:macro ac:name="code">
  <ac:parameter ac:name="title">Java Code Snippet</ac:parameter>
  <ac:parameter ac:name="language">Java</ac:parameter>
  <ac:plain-text-body><![CDATA[     public void testFullSynBySource(){

        try {

            String searchTerm = "gene";

...

lbSvc.getNodeSet("HUBt", null, null);

...



			//Tell the api that you want to

...

 search only the PRESENTATION

...

 type properties                   
			CodedNodeSet.PropertyType[] types = new CodedNodeSet.PropertyType[1];

...

                
			types[0] = CodedNodeSet.PropertyType.PRESENTATION;

...

            LocalNameList sourceLnL = new LocalNameList();

...



            //Only want to search properties with a source entry of "CAHUB"
			LocalNameList sourceLnL = new LocalNameList();
			sourceLnL.addEntry("CAHUB");

...

            

            LocalNameList propLnL = new LocalNameList();

...


			
            //Only want to search properties with the property name of "FULL_SYN"
			LocalNameList propLnL = new LocalNameList();
			propLnL.addEntry("FULL_SYN");

...



			nodeSet = nodeSet.restrictToMatchingProperties(propLnL,types,sourceLnL,null, null,searchTerm,LBConstants.MatchAlgorithms.contains.name(),null);

...



			ResolvedConceptReferenceList rcl = nodeSet.resolveToList(null, null, null,

...

 100);
			int count = rcl.getResolvedConceptReferenceCount();

            //Now iterate through the returned entities and display the FULL_SYN PT property with source=CAHUB
			for (int i=0; i<rcl.getResolvedConceptReferenceCount();i++){

...


				ResolvedConceptReference rcr = rcl.getResolvedConceptReference(i);

...


				Entity entity = rcr.getReferencedEntry();

...


				Presentation[] presProps = entity.getPresentation();

...


				for(int y=0;y<presProps.length;y++){

...


					Presentation pres = presProps[y];

...


					if(pres.getPropertyName().equals("FULL_SYN")&& pres.getRepresentationalForm().equals("PT") && pres.getSource(0).getContent().equals("CAHUB")){

...


					System.out.println(pres.getValue().getContent());

...

                    }

                }               

            }

        } catch (IndexOutOfBoundsException e) {

            // TODO Auto-generated catch block

            e.printStackTrace();

        } catch (LBInvocationException e) {

            // TODO Auto-generated catch block

            e.printStackTrace();

        } catch (LBParameterException e) {

            // TODO Auto-generated catch block

            e.printStackTrace();

        } catch (LBException e) {

            // TODO Auto-generated catch block

            e.printStackTrace();

        }

...

					
					}
				}
			}

		} catch (IndexOutOfBoundsException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (LBInvocationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (LBParameterException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (LBException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}