* @see org.corrib.s3b.mbb.service.MBBService#execute()
*/
@Override
public LocalRepository execute(LocalRepository inGraph) {
LocalRepository lr = RepositoryFactory.getServiceRepository(this.getUri());
try {
if(lr.getGraph().getStatements().hasNext())
return lr;//it means that we already invoked this query
} catch (AccessDeniedException e) {
Repository.logger.warning(e.toString());
}
HttpServletRequest request = this.callBean.getRequest();
String nlq = this.params.get(3).replace('+', ' ');
Integer idx = Integer.parseInt(this.params.get(2));
String slang = this.params.get(1);
//
//
TypedRdfQuery rdfquery = NLQueryTemplates.getInstance().getRdfQuery(nlq, idx, slang);
if (rdfquery != null) {
String rdfq = rdfquery.getQuery();
QueryLanguage ql = rdfquery.getQlanguage();
if (rdfq != null && rdfq.indexOf("<$"+MYSELF+">") > 0) {
Person issuer = FoafRealmHelper.getInstance().getLoggedPerson(request);
if (issuer != null) {
rdfq = rdfq.replaceAll("[$]"+MYSELF, issuer.getUri().toString());
} else if (NLQueryTemplates.getInstance().getSDefaultUser() != null) {
rdfq = rdfq.replaceAll("[$]"+MYSELF, NLQueryTemplates.getInstance().getSDefaultUser());
} else {
rdfq = rdfq.replaceAll("[<][$]"+MYSELF+"[>]", ALLUSERS);
}
} // -- if rdfq
try {
Graph g = SesameWrapper.performGraphQuery(inGraph, ql, rdfq);
lr.addGraph(g);
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
} catch (IOException e) {
Repository.logger.warning("Could not add graph results: "+e);
} catch (AccessDeniedException e) {