NIH | National Cancer Institute | NCI Wiki  

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

            //Only want to search properties with a source entry of "CAHUB"
			LocalNameList sourceLnL = new LocalNameList();
			sourceLnL.addEntry("CAHUB");
			
            //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();
		}
	}
  • No labels