/**
  * generate class elements from the set of class uris
  *
  * @param classes
  * @return
  */
 List<OntologyElement> returnClassElements(Set<String> classes) throws Exception {
   List<OntologyElement> elements = new ArrayList<OntologyElement>();
   for (String euri : classes) {
     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;
 }
 /**
  * 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;
 }
 /**
  * generate property elements from the set of property uris, and check whether these properties
  * are datatype so that additional flag can be added to the property elements
  *
  * @param classes
  * @return
  */
 List<OntologyElement> returnPropertyElements(Set<String> properties) throws Exception {
   if (properties == null) return new ArrayList();
   List<OntologyElement> elements = new ArrayList<OntologyElement>();
   for (String euri : properties) {
     // logger.info("Checking if datatypeproperty=true for: " + euri);
     SerializableURI elementUri = null;
     try {
       elementUri = new SerializableURI(euri, false);
     } catch (Exception e) {
       e.printStackTrace();
     }
     OntologyElement e = new PropertyElement();
     // so that later we can distinguish property elements if they refer
     // to datatypes
     if (luceneAnnotator.isItDatatypeProperty(euri)) {
       ((PropertyElement) e).setDatatypeProperty(true);
     }
     e.setData(elementUri);
     elements.add(((PropertyElement) e));
   }
   return elements;
 }