NIHVIVO-3510 fix to sparql query builder to work with empty Vitro

This commit is contained in:
brianjlowe 2011-12-14 21:31:46 +00:00
parent 7b422e883b
commit a30e1d5842
3 changed files with 33 additions and 6 deletions

View file

@ -13,6 +13,12 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mindswap.pellet.jena.vocabulary.SWRL;
import org.openrdf.model.vocabulary.OWL;
import org.openrdf.model.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.RDFS;
import com.hp.hpl.jena.vocabulary.XSD;
import edu.cornell.mannlib.vedit.controller.BaseEditController;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
@ -20,6 +26,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.UseMiscell
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
/**
* This servlet gets all the prefix for initizing the sparql query builder.
@ -69,18 +76,37 @@ public class GetAllPrefix extends BaseEditController {
while (ontItr.hasNext()) {
Ontology ont = (Ontology) ontItr.next();
if (ont.getPrefix() != null) {
respo += "<option>" + "<key>" + ont.getPrefix() + "</key>"
+ "<value>" + ont.getURI() + "</value>"
+ "</option>";
respo += makeOption(ont.getPrefix(), ont.getURI());
}
}
}
;
respo += makeOption("owl", OWL.NAMESPACE);
respo += makeOption("rdf", RDF.NAMESPACE);
respo += makeOption("rdfs", RDFS.getURI());
respo += makeOption("swrl", "http://www.w3.org/2003/11/swrl#");
respo += makeOption("swrlb", "http://www.w3.org/2003/11/swrlb#");
respo += makeOption("xsd", XSD.getURI());
respo += makeOption("vitro", VitroVocabulary.vitroURI);
respo += "</options>";
out.println(respo);
out.flush();
out.close();
}
/**
* Makes the markup for a prefix option
* @param prefix
* @param URI
* @return option string
*/
private String makeOption(String prefix, String URI) {
return "<option>" + "<key>" + prefix + "</key>"
+ "<value>" + URI + "</value>"
+ "</option>";
}
/**
* The doPost method of the servlet. <br>