/** * Resolve the Iterator * * @param iterator * @param maxToReturn * @param code * @return */ public Vector<Entity> resolveIterator( ResolvedConceptReferencesIterator iterator, int maxToReturn, String code) { Vector<Entity> v = new Vector<Entity>(); if (iterator == null) { _logger.warn("No match."); return v; } try { int iteration = 0; while (iterator.hasNext()) { iteration++; iterator = iterator.scroll(maxToReturn); ResolvedConceptReferenceList rcrl = iterator.getNext(); ResolvedConceptReference[] rcra = rcrl.getResolvedConceptReference(); for (int i = 0; i < rcra.length; i++) { ResolvedConceptReference rcr = rcra[i]; Entity ce = rcr.getReferencedEntry(); if (code == null) { v.add(ce); } else { if (ce.getEntityCode().compareTo(code) != 0) v.add(ce); } } } } catch (Exception e) { _logger.warn(e.getMessage()); } return v; }
@Test public void testGetTargetCodesToNodeList() throws Exception { LexBIGService lbs = ServiceHolder.instance().getLexBIGService(); CodedNodeGraph mappingGraph = lbs.getNodeGraph(MAPPING_SCHEME_URI, null, null); CodedNodeSet cns = mappingGraph.restrictToTargetCodeSystem(PARTS_SCHEME).toNodeList(null, false, true, 0, -1); ResolvedConceptReferencesIterator itr = cns.resolve(null, null, null); int count = 0; Set<String> foundCodes = new HashSet<String>(); while (itr.hasNext()) { count++; foundCodes.add(itr.next().getCode()); } assertEquals(3, foundCodes.size()); assertTrue(foundCodes.contains("R0001")); assertTrue(foundCodes.contains("E0001")); assertTrue(foundCodes.contains("P0001")); }
/** Removes the empty iterators. */ private void removeEmptyIterators() { List<ResolvedConceptReferencesIterator> newList = new ArrayList<ResolvedConceptReferencesIterator>(); for (ResolvedConceptReferencesIterator itr : _iterators) { try { if (itr.hasNext()) { newList.add(itr); } } catch (LBResourceUnavailableException e) { throw new RuntimeException(e); } } _iterators = newList; }
/** * Gets the next from list. * * @return the next from list */ private ResolvedConceptReference getNextFromList() { try { while (hasNext()) { int iterator = _currentIterator % _iterators.size(); ResolvedConceptReferencesIterator itr = _iterators.get(iterator); if (itr.hasNext()) { _currentIterator++; return itr.next(); } else { _currentIterator++; } } return null; } catch (Exception e) { throw new RuntimeException(e); } }
public void run() throws LBException { ValueSetDefinition vsd = Util.promptForValueSetDefinition(message); if (vsd != null) { AbsoluteCodingSchemeVersionReferenceList acsvList = null; Util.displayMessage("Now select Code System to use to resolve Value Set Definition"); CodingSchemeSummary css = Util.promptForCodeSystem(); if (css != null) { acsvList = new AbsoluteCodingSchemeVersionReferenceList(); acsvList.addAbsoluteCodingSchemeVersionReference( Constructors.createAbsoluteCodingSchemeVersionReference( css.getCodingSchemeURI(), css.getRepresentsVersion())); } LexEVSValueSetDefinitionServices vsdServ = LexEVSValueSetDefinitionServicesImpl.defaultInstance(); ResolvedValueSetDefinition rVSD = null; try { rVSD = vsdServ.resolveValueSetDefinition( new URI(vsd.getValueSetDefinitionURI()), null, acsvList, null, null); } catch (URISyntaxException e) { e.printStackTrace(); } if (rVSD != null) { Util.displayMessage( "Member of Value Set Definition (" + vsd.getValueSetDefinitionURI() + ") are :"); ResolvedConceptReferencesIterator conceptItr = rVSD.getResolvedConceptReferenceIterator(); while (conceptItr.hasNext()) { ResolvedConceptReference concept = conceptItr.next(); Util.displayMessage("Concept code : " + concept.getCode()); Util.displayMessage("\tCoding Scheme Name...: " + concept.getCodingSchemeName()); Util.displayMessage("\tCoding Scheme URI....: " + concept.getCodingSchemeURI()); Util.displayMessage("\tCoding Scheme Version: " + concept.getCodingSchemeVersion()); } } else { Util.displayMessage( "No members found for Value Set Definition : '" + vsd.getValueSetDefinitionURI() + "'"); } } }
public void testNext() { try { LexBIGService lbs = ServiceHolder.instance().getLexBIGService(); CodedNodeSet cns = lbs.getCodingSchemeConcepts("NCI Thesaurus", null); cns = cns.restrictToMatchingDesignations("heart", null, "startsWith", null); ResolvedConceptReferencesIterator rcrl = cns.resolve(null, null, null, null, false); String conceptCode = null; while (rcrl.hasNext()) { ResolvedConceptReference ref = rcrl.next(); String currentCode = ref.getConceptCode(); assertFalse(currentCode.equals(conceptCode)); conceptCode = currentCode; } } catch (Exception e) { fail("Exception Thrown: " + e.getMessage()); e.printStackTrace(); } }