NIHVIVO-3510 fix to sparql query builder to work with empty Vitro
This commit is contained in:
parent
7b422e883b
commit
a30e1d5842
3 changed files with 33 additions and 6 deletions
|
@ -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,19 +76,38 @@ 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>
|
||||
*
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
<%@page import="com.hp.hpl.jena.vocabulary.OWL"%>
|
||||
<%@page import="com.hp.hpl.jena.rdf.model.ModelMaker"%>
|
||||
<%@page import="java.util.Iterator"%>
|
||||
<%@page import="java.util.ArrayList"%>
|
||||
|
@ -40,7 +41,7 @@ td {
|
|||
<tr id="clazz(0)">
|
||||
<td id="subject(0)" width="33%">
|
||||
<select id="subject(0,0)">
|
||||
<option value="">
|
||||
<option value="<%=OWL.Thing.getURI()%>">
|
||||
Thing
|
||||
</option>
|
||||
</select>
|
||||
|
|
|
@ -49,8 +49,8 @@
|
|||
var myPrefixAjax = new Ajax.Request( preurl, {method: "get", parameters: "", onComplete: function(originalRequest){
|
||||
var response = originalRequest.responseXML;
|
||||
var options = response.getElementsByTagName("option");
|
||||
if (options == null || options.length == 0){
|
||||
alert("Error: Cannot get all the prefix.");
|
||||
if (options == null || options.length == 0) {
|
||||
alert("Error: Cannot get all the prefixes.");
|
||||
return;
|
||||
}
|
||||
for(i=0; i<options.length; i++)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue