public String getClasses(String location, String meta) throws UnsupportedEncodingException {
System.out.println("Loading Classes...");
String out = "";
String dataLocation = "";
String dataMeta = "";
RepositoryConnection con=null;
try {
if (location == "local") {
out = "<div id='lensesAndClasses'><h3>Local Classes: </h3><hr><menu id='lclasses'>";
con=lenaConfig.getLocalRepository().getConnection();
dataLocation = "&location=local";
} else if (location=="remote"){
out = "<div id='lensesAndClasses'><h3>Remote Classes: </h3><hr><menu id='rclasses'>";
con=lenaConfig.getRemoteRepository().getConnection();
dataLocation = "&location=remote";
}
if (meta.equalsIgnoreCase("true")) {
dataMeta = "&meta=true";
} else if (meta.equalsIgnoreCase("false")){
dataMeta = "&meta=false";
}
if (con!=null) {
try {
String query = "prefix rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT DISTINCT ?o WHERE { ?s rdf:type ?o } ORDER BY ?o";
TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, query);
TupleQueryResult result = tupleQuery.evaluate();
try {
String firstBindingName = result.getBindingNames().get(0);
while (result.hasNext()) {
Value uri = result.next().getBinding(firstBindingName).getValue();
if ((uri instanceof URI) &&
(!uri.toString().contains("http://www.w3.org/2004/03/trix"))){
String uriString = uri.toString();
String classInfo = getClassInfo(uriString, location);
String before = "";
String after = "";
/*
if (uriString == resource) {
before = "<b>";
after = "</b>";
}*/
if (uriString.lastIndexOf("#") == -1) {
out = out.concat("<li><a onClick='setHrefs()' class='tooltip' title='::" + uriString + "' href='?class="
+ URLEncoder.encode(uriString, "UTF-8") + dataLocation + dataMeta +"'>" + before
+ uriString.subSequence(uriString.lastIndexOf("/") + 1, uriString.length()) + " " + classInfo + after + "</a></li>");
} else {
out = out.concat("<li><a onClick='setHrefs()' class='tooltip' title='::" + uriString + "' href='?class="
+ URLEncoder.encode(uriString, "UTF-8") + dataLocation + dataMeta +"'>" + before
+ uriString.subSequence(uriString.lastIndexOf("#") + 1, uriString.length()) + " " + classInfo + after + "</a></li>");
}
}
}
} finally {
result.close();
}
} catch (QueryEvaluationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MalformedQueryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} catch (RepositoryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (con!=null)
try {
con.close();
} catch (RepositoryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}