/** * finds elements which are the top most in the ontology... * * @return */ private List<OntologyElement> findGenericOntologyElements(Integer max) throws Exception { List<OntologyElement> elements = new ArrayList<OntologyElement>(); Set<String> suggestions = luceneAnnotator.findPropertyURIs(max); // now remove all that are after max List<String> list = new ArrayList<String>(suggestions); if (suggestions != null && suggestions.size() > max) { for (int i = max; i < suggestions.size(); i++) { String prop = list.get(i); suggestions.remove(prop); } } elements.addAll(returnPropertyElements(suggestions)); long start = System.currentTimeMillis(); Set<String> classUris = luceneAnnotator.findTopClasses(); long end = System.currentTimeMillis(); logger.info("Finished searching lucene for top classes for:" + (end - start) + "ms."); if (classUris == null) classUris = new HashSet(); logger.info("Found " + classUris.size() + " top classes."); // now remove all that are after max List<String> newList = new ArrayList<String>(classUris); if (newList.size() > max) { for (int i = max; i < newList.size(); i++) { String classUri = newList.get(i); classUris.remove(classUri); } } for (String euri : classUris) { SerializableURI elementUri = null; try { elementUri = new SerializableURI(euri, false); } catch (Exception e) { e.printStackTrace(); } OntologyElement e = new ClassElement(); e.setData(elementUri); elements.add(e); } return elements; }