Navigation Menu

Skip to content

Commit

Permalink
Catch exception and throw when CBD query fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzBuehmann committed Sep 4, 2016
1 parent 8811641 commit ee0867f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Expand Up @@ -75,17 +75,18 @@ public TreeBasedConciseBoundedDescriptionGenerator(QueryExecutionFactory qef) {
/* (non-Javadoc)
* @see org.dllearner.kb.sparql.ConciseBoundedDescriptionGenerator#getConciseBoundedDescription(java.lang.String, int, boolean)
*/
public Model getConciseBoundedDescription(String resourceURI, CBDStructureTree structureTree) {
public Model getConciseBoundedDescription(String resourceURI, CBDStructureTree structureTree) throws Exception {
logger.trace("Computing CBD for {} ...", resourceURI);
long start = System.currentTimeMillis();
String query = generateQuery(resourceURI, structureTree);
System.out.println(query);
QueryExecution qe = qef.createQueryExecution(query);
Model model = qe.execConstruct();
qe.close();
long end = System.currentTimeMillis();
logger.trace("Got {} triples in {} ms.", model.size(), (end - start));
return model;
try(QueryExecution qe = qef.createQueryExecution(query)) {
Model model = qe.execConstruct();
long end = System.currentTimeMillis();
logger.trace("Got {} triples in {} ms.", model.size(), (end - start));
return model;
} catch(Exception e) {
throw new Exception("CBD retrieval failed when using query\n" + query, e);
}
}

@Override
Expand All @@ -109,8 +110,7 @@ public void addAllowedObjectNamespaces(Set<String> namespaces) {
* @return the SPARQL query
*/
private String generateQuery(String resource, CBDStructureTree structureTree){


reset();
StringBuilder sb = new StringBuilder();
sb.append("CONSTRUCT {\n");
append(sb, structureTree, "<" + resource + ">");
Expand All @@ -119,7 +119,6 @@ private String generateQuery(String resource, CBDStructureTree structureTree){
append(sb, structureTree, "<" + resource + ">");
sb.append("}");


return sb.toString();
}

Expand Down
Empty file.

0 comments on commit ee0867f

Please sign in to comment.