DroolsConceptService implements ConceptService { @Override public Set<String> findStatedAncestorsOfConcept(Concept concept) { if(concept == null || concept.getId().equals(Constants.ROOT_CONCEPT)) { return Collections.emptySet(); } DroolsConcept droolsConcept = repository.getConcept(concept.getId()); Set<String> statedParents = new HashSet<>(); for (DroolsRelationship relationship : droolsConcept.getRelationships()) { if(relationship.isActive() && !relationship.isAxiomGCI() && Constants.IS_A.equals(relationship.getTypeId()) && Constants.STATED_RELATIONSHIP.equals(relationship.getCharacteristicTypeId())) { statedParents.add(relationship.getDestinationId()); } } Set<String> resultSet = new HashSet<>(statedParents); for (String statedParent : statedParents) { resultSet.addAll(findStatedAncestorsOfConcept(repository.getConcept(statedParent))); } return resultSet; } DroolsConceptService(SnomedDroolsComponentRepository repository); @Override boolean isActive(String conceptId); @Override Concept findById(String conceptId); @Override Set<String> getAllTopLevelHierarchies(); @Override Set<String> findStatedAncestorsOfConcept(Concept concept); @Override Set<String> findTopLevelHierarchiesOfConcept(Concept concept); @Override Set<String> findStatedAncestorsOfConcepts(List<String> conceptIds);  }
@Test public void testFindStatedAncestorsOfConcept() { Concept concept = new DroolsConcept("1263005", true, "900000000000207008", "900000000000073002", true, true); Set<String> results = droolsConceptService.findStatedAncestorsOfConcept(concept); Assert.assertEquals(7, results.size()); concept = new DroolsConcept("91832008", true, "900000000000207008", "900000000000073002", true, true); results = droolsConceptService.findStatedAncestorsOfConcept(concept); Assert.assertEquals(2, results.size()); }