NIHVIVO-1363 Clean up code: remove unused variables and parameters, remove commented code, add generic types to collections.

This commit is contained in:
jeb228 2010-12-13 20:49:46 +00:00
parent d6906af33b
commit ae5de265d8

View file

@ -56,13 +56,10 @@ import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
*
*/
public class SparqlQueryServlet extends BaseEditController {
private static final Log log = LogFactory.getLog(SparqlQueryServlet.class.getName());
private static final String kb2 = "http://vitro.mannlib.cornell.edu/default/vitro-kb-2";
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
protected static HashMap<String,ResultSetFormat>formatSymbols = new HashMap<String,ResultSetFormat>();
static{
formatSymbols.put( ResultSetFormat.syntaxXML.getSymbol(), ResultSetFormat.syntaxXML);
@ -107,18 +104,15 @@ public class SparqlQueryServlet extends BaseEditController {
// rjy7 Allows any editor (including self-editors) access to this servlet.
// This servlet is now requested via Ajax from some custom forms, so anyone
// using the custom form needs access rights.
// TODO Actually, this only allows someone who is logged in to use this servlet.
// If a self-editor is not logged in, they will not have access. -- jb
if( !checkLoginStatus(request, response) ) {
return;
}
VitroRequest vreq = new VitroRequest(request);
Model model = vreq.getJenaOntModel(); // getModel()
Model model = vreq.getJenaOntModel();
if( model == null ){
doNoModelInContext(request,response);
doNoModelInContext(response);
return;
}
@ -175,12 +169,11 @@ public class SparqlQueryServlet extends BaseEditController {
dataSource.setDefaultModel(model) ;
}
}
executeQuery(request, response, resultFormatParam, rdfResultFormatParam, queryParam, (dataset != null) ? dataset : dataSource);
executeQuery(response, resultFormatParam, rdfResultFormatParam, queryParam, (dataset != null) ? dataset : dataSource);
return;
}
private void executeQuery(HttpServletRequest req,
HttpServletResponse response, String resultFormatParam, String rdfResultFormatParam, String queryParam, Dataset dataset ) throws IOException {
private void executeQuery(HttpServletResponse response, String resultFormatParam, String rdfResultFormatParam, String queryParam, Dataset dataset ) throws IOException {
ResultSetFormat rsf = null;
/* BJL23 2008-11-06
@ -227,19 +220,7 @@ public class SparqlQueryServlet extends BaseEditController {
}
}
/*
private Model getModel(){
Model model = null;
try{
model = (Model)getServletContext().getAttribute("jenaOntModel");
}catch(Throwable thr){
log.error("could not cast getServletContext().getAttribute(\"jenaOntModel\") to Model");
}
return model;
}
*/
private void doNoModelInContext(HttpServletRequest request, HttpServletResponse res){
private void doNoModelInContext(HttpServletResponse res){
try {
res.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED);
ServletOutputStream sos = res.getOutputStream();
@ -261,9 +242,9 @@ public class SparqlQueryServlet extends BaseEditController {
while (results.hasNext()) {
QuerySolution solution = (QuerySolution) results.next();
List<String> valueList = new LinkedList<String>();
Iterator varNameIt = solution.varNames();
Iterator<String> varNameIt = solution.varNames();
while (varNameIt.hasNext()) {
String varName = (String) varNameIt.next();
String varName = varNameIt.next();
String value = "";
try {
Literal lit = solution.getLiteral(varName);
@ -328,18 +309,14 @@ public class SparqlQueryServlet extends BaseEditController {
OntologyDao daoObj = vreq.getFullWebappDaoFactory().getOntologyDao();
List ontologiesObj = daoObj.getAllOntologies();
ArrayList prefixList = new ArrayList();
List<Ontology> ontologiesObj = daoObj.getAllOntologies();
ArrayList<String> prefixList = new ArrayList<String>();
if(ontologiesObj !=null && ontologiesObj.size()>0){
Iterator ontItr = ontologiesObj.iterator();
while(ontItr.hasNext()){
Ontology ont = (Ontology) ontItr.next();
for(Ontology ont: ontologiesObj) {
prefixList.add(ont.getPrefix() == null ? "(not yet specified)" : ont.getPrefix());
prefixList.add(ont.getURI() == null ? "" : ont.getURI());
}
}
else{
prefixList.add("<strong>" + "No Ontologies added" + "</strong>");
@ -414,7 +391,8 @@ public class SparqlQueryServlet extends BaseEditController {
"ORDER BY ASC( ?pred )\n";
*/
private String example =
@SuppressWarnings("unused")
private String example =
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"+
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"+
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n"+