use of com.hp.hpl.jena.rdf.model.NodeIterator in project irida by phac-nml.
the class InMemoryTaxonomyService method getMatchingParent.
/**
* Get a parent node with the matching search term
*
* @param resource
* The resource to start walking up from
* @param searchTerm
* The search term required
* @return A parent of the given node with the given search term in the
* label.
*/
private Resource getMatchingParent(Resource resource, String searchTerm) {
NodeIterator subClasses = model.listObjectsOfProperty(resource, RDFS.subClassOf);
if (subClasses.hasNext()) {
Resource parentNode = subClasses.next().asResource();
String elementName = parentNode.getProperty(RDFS.label).getObject().asLiteral().getString();
if (elementName.toLowerCase().contains(searchTerm.toLowerCase())) {
return parentNode;
} else {
return getMatchingParent(parentNode, searchTerm);
}
}
return null;
}
Aggregations