Fixing problem with FM dump directive. Working on SparqlQueryDataGetter.

This commit is contained in:
briancaruso 2012-02-29 19:51:33 +00:00
parent 558985d542
commit d9669acddb
8 changed files with 159 additions and 80 deletions

View file

@ -443,6 +443,7 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
map.put("url", new edu.cornell.mannlib.vitro.webapp.web.directives.UrlDirective());
map.put("widget", new edu.cornell.mannlib.vitro.webapp.web.directives.WidgetDirective());
map.putAll( FreemarkerConfiguration.getDirectives() );
// Add these accumulator objects. They will collect tags so the template can write them
// at the appropriate location.

View file

@ -11,6 +11,7 @@ import com.hp.hpl.jena.rdf.model.Model;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.jena.JenaIngestController;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroJenaModelMaker;
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroJenaSDBModelMaker;
@ -26,7 +27,9 @@ public abstract class DataGetterBase implements DataGetter {
}else if(REQUEST_DISPLAY_MODEL.equals(modelName)){
return vreq.getDisplayModel();
}else if( REQUEST_JENA_ONT_MODEL.equals(modelName)){
return vreq.getJenaOntModel();
return vreq.getJenaOntModel();
}else if( CONTEXT_DISPLAY_MODEL.equals(modelName)){
return (Model)context.getAttribute( DisplayVocabulary.DISPLAY_ONT_MODEL);
}else if( ! StringUtils.isEmpty( modelName)){
Model model = JenaIngestController.getModel( modelName, vreq, context);
if( model == null )
@ -41,5 +44,6 @@ public abstract class DataGetterBase implements DataGetter {
public final static String REQUEST_DISPLAY_MODEL = "vitro:requestDisplayModel";
public final static String REQUEST_JENA_ONT_MODEL = "vitro:requestJenaOntModel";
public final static String CONTEXT_DISPLAY_MODEL = "vitro:contextDisplayModel";
}

View file

@ -83,8 +83,8 @@ public class SparqlQueryDataGetter extends DataGetterBase implements DataGetter{
else
this.queryText = value.getLexicalForm();
//model is OPTIONAL
RDFNode node = soln.getResource("model");
//model is OPTIONAL
RDFNode node = soln.get("queryModel");
if( node != null && node.isURIResource() ){
this.modelURI = node.asResource().getURI();
}else if( node != null && node.isLiteral() ){
@ -116,7 +116,7 @@ public class SparqlQueryDataGetter extends DataGetterBase implements DataGetter{
return Collections.emptyMap();
}
//this may throw an error
//this may throw a SPARQL syntax error
Query query = QueryFactory.create( this.queryText );
//build query bindings
@ -206,14 +206,14 @@ public class SparqlQueryDataGetter extends DataGetterBase implements DataGetter{
public static final String defaultVarNameForResults = "results";
/**
* Query to get the definition of the SparqlDataGetter for a given data getter URI.
* Query to get the definition of the SparqlDataGetter for a given URI.
*/
private static final String dataGetterQuery =
"PREFIX display: <" + DisplayVocabulary.DISPLAY_NS +"> \n" +
"SELECT ?query ?saveToVar ?model WHERE { \n" +
" ?dataGetterUri "+queryPropertyURI+" ?query . \n" +
" OPTIONAL{ ?dataGetterUri "+saveToVarPropertyURI+" ?saveToVar } \n " +
" OPTIONAL{ ?dataGetterUri "+queryModelPropertyURI+" ?model } \n" +
"SELECT ?query ?saveToVar ?queryModel WHERE { \n" +
" ?dataGetterURI "+queryPropertyURI+" ?query . \n" +
" OPTIONAL{ ?dataGetterURI "+saveToVarPropertyURI+" ?saveToVar } \n " +
" OPTIONAL{ ?dataGetterURI "+queryModelPropertyURI+" ?queryModel } \n" +
"}";