diff --git a/webapp/config/web.xml b/webapp/config/web.xml
index 53295b74c..d1f602bee 100644
--- a/webapp/config/web.xml
+++ b/webapp/config/web.xml
@@ -1292,6 +1292,62 @@
/generic_delete
+
+
+
+ SparlQueryBuilder
+ edu.cornell.mannlib.vitro.webapp.controller.SparqlQueryBuilderServlet
+
+
+ SparlQueryBuilder
+ /admin/sparqlquerybuilder
+
+
+
+ GetAllClasses
+ edu.cornell.mannlib.vitro.webapp.sparql.GetAllClasses
+
+
+ GetAllClasses
+ /admin/getAllClasses
+
+
+
+ GetAllPrefix
+ edu.cornell.mannlib.vitro.webapp.sparql.GetAllPrefix
+
+
+ GetAllPrefix
+ /admin/getAllPrefix
+
+
+
+ GetClazzDataProperties
+ edu.cornell.mannlib.vitro.webapp.sparql.GetClazzDataProperties
+
+
+ GetClazzDataProperties
+ /admin/getClazzDataProperties
+
+
+
+ GetClazzObjectProperties
+ edu.cornell.mannlib.vitro.webapp.sparql.GetClazzObjectProperties
+
+
+ GetClazzObjectProperties
+ /admin/getClazzObjectProperties
+
+
+
+ GetObjectClasses
+ edu.cornell.mannlib.vitro.webapp.sparql.GetObjectClasses
+
+
+ GetObjectClasses
+ /admin/getObjectClasses
+
+
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryBuilderServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryBuilderServlet.java
new file mode 100644
index 000000000..a4773b835
--- /dev/null
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryBuilderServlet.java
@@ -0,0 +1,175 @@
+/*
+Copyright (c) 2010, Cornell University
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Cornell University nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package edu.cornell.mannlib.vitro.webapp.controller;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.hp.hpl.jena.query.DataSource;
+import com.hp.hpl.jena.query.DatasetFactory;
+import com.hp.hpl.jena.query.Query;
+import com.hp.hpl.jena.query.QueryExecution;
+import com.hp.hpl.jena.query.QueryExecutionFactory;
+import com.hp.hpl.jena.query.QueryFactory;
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.query.ResultSet;
+import com.hp.hpl.jena.query.ResultSetFormatter;
+import com.hp.hpl.jena.query.Syntax;
+import com.hp.hpl.jena.rdf.model.Literal;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelMaker;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.sparql.resultset.ResultSetFormat;
+import com.hp.hpl.jena.vocabulary.XSD;
+
+import edu.cornell.mannlib.vedit.beans.LoginFormBean;
+import edu.cornell.mannlib.vedit.controller.BaseEditController;
+import edu.cornell.mannlib.vitro.webapp.beans.Portal;
+
+/* @author ass92 */
+
+import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
+import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
+
+
+/**
+ * This servlet works as a RequestDispatcher to direct to the sparl query builder page.
+ * @author yuysun
+ */
+
+public class SparqlQueryBuilderServlet extends BaseEditController {
+
+ private static final Log log = LogFactory.getLog(SparqlQueryBuilderServlet.class.getName());
+
+ protected static final Syntax SYNTAX = Syntax.syntaxARQ;
+
+ protected static HashMapformatSymbols = new HashMap();
+ static{
+ formatSymbols.put( ResultSetFormat.syntaxXML.getSymbol(), ResultSetFormat.syntaxXML);
+ formatSymbols.put( ResultSetFormat.syntaxRDF_XML.getSymbol(), ResultSetFormat.syntaxRDF_XML);
+ formatSymbols.put( ResultSetFormat.syntaxRDF_N3.getSymbol(), ResultSetFormat.syntaxRDF_N3);
+ formatSymbols.put( ResultSetFormat.syntaxText.getSymbol() , ResultSetFormat.syntaxText);
+ formatSymbols.put( ResultSetFormat.syntaxJSON.getSymbol() , ResultSetFormat.syntaxJSON);
+ formatSymbols.put( "vitro:csv", null);
+ }
+
+ protected static HashMap rdfFormatSymbols = new HashMap();
+ static {
+ rdfFormatSymbols.put( "RDF/XML", "application/rdf+xml" );
+ rdfFormatSymbols.put( "RDF/XML-ABBREV", "application/rdf+xml" );
+ rdfFormatSymbols.put( "N3", "text/n3" );
+ rdfFormatSymbols.put( "N-TRIPLE", "text/plain" );
+ rdfFormatSymbols.put( "TTL", "application/x-turtle" );
+ }
+
+ protected static HashMapmimeTypes = new HashMap();
+ static{
+ mimeTypes.put( ResultSetFormat.syntaxXML.getSymbol() , "text/xml" );
+ mimeTypes.put( ResultSetFormat.syntaxRDF_XML.getSymbol(), "application/rdf+xml" );
+ mimeTypes.put( ResultSetFormat.syntaxRDF_N3.getSymbol(), "text/plain" );
+ mimeTypes.put( ResultSetFormat.syntaxText.getSymbol() , "text/plain");
+ mimeTypes.put( ResultSetFormat.syntaxJSON.getSymbol(), "application/javascript" );
+ mimeTypes.put( "vitro:csv", "text/csv");
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ this.doGet(request,response);
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ super.doGet(request, response);
+ if( !checkLoginStatus(request, response) )
+ return;
+
+ VitroRequest vreq = new VitroRequest(request);
+
+
+ Model model = vreq.getJenaOntModel(); // getModel()
+ if( model == null ){
+ doNoModelInContext(request,response);
+ return;
+ }
+
+ doHelp(request,response);
+ return;
+ }
+
+ private void doNoModelInContext(HttpServletRequest request, HttpServletResponse res){
+ try {
+ res.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED);
+ ServletOutputStream sos = res.getOutputStream();
+ sos.println("this service is not supporeted by the current " +
+ "webapp configuration. A jena model is required in the servlet context." );
+ } catch (IOException e) {
+ log.error("Could not write to ServletOutputStream");
+ }
+ }
+
+ private void doHelp(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
+
+ //res.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+
+ VitroRequest vreq = new VitroRequest(req);
+ Portal portal = vreq.getPortal();
+
+ /* Code change completed */
+
+ req.setAttribute("portalBean",portal);
+ // nac26: 2009-09-25 - this was causing problems in safari on localhost installations because the href did not include the context. The edit.css is not being used here anyway (or anywhere else for that matter)
+ // req.setAttribute("css", "");
+ req.setAttribute("title","SPARQL Query Builder");
+ req.setAttribute("bodyJsp", "/admin/sparql.jsp");
+
+ RequestDispatcher rd = req.getRequestDispatcher("/"+Controllers.BASIC_JSP);
+ rd.forward(req,res);
+ }
+}
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/sparql/GetAllClasses.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/sparql/GetAllClasses.java
new file mode 100644
index 000000000..af660aef0
--- /dev/null
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/sparql/GetAllClasses.java
@@ -0,0 +1,144 @@
+package edu.cornell.mannlib.vitro.webapp.sparql;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import edu.cornell.mannlib.vedit.beans.EditProcessObject;
+import edu.cornell.mannlib.vedit.beans.FormObject;
+import edu.cornell.mannlib.vedit.beans.LoginFormBean;
+import edu.cornell.mannlib.vedit.controller.BaseEditController;
+import edu.cornell.mannlib.vitro.webapp.beans.VClass;
+import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
+import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
+import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
+import edu.cornell.mannlib.vitro.webapp.controller.edit.SiteAdminController;
+
+/**
+ * This servlet gets all the classes for initizing the sparql query builder.
+ *
+ * @author yuysun
+ */
+
+public class GetAllClasses extends BaseEditController {
+
+ private static final Log log = LogFactory.getLog(SiteAdminController.class
+ .getName());
+
+ /**
+ * The doGet method of the servlet.
+ *
+ * This method is called when a form has its tag value method equals to get.
+ *
+ * @param request
+ * the request send by the client to the server
+ * @param response
+ * the response send by the server to the client
+ * @throws ServletException
+ * if an error occurred
+ * @throws IOException
+ * if an error occurred
+ */
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ try {
+ super.doGet(request, response);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ VitroRequest vreq = new VitroRequest(request);
+
+ Object obj = vreq.getSession().getAttribute("loginHandler");
+ LoginFormBean loginHandler = null;
+ if (obj != null && obj instanceof LoginFormBean)
+ loginHandler = ((LoginFormBean) obj);
+ if (loginHandler == null
+ || !"authenticated".equalsIgnoreCase(loginHandler
+ .getLoginStatus()) ||
+ // 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.
+ Integer.parseInt(loginHandler.getLoginRole()) < LoginFormBean.NON_EDITOR) {
+ HttpSession session = request.getSession(true);
+
+ session.setAttribute("postLoginRequest", vreq.getRequestURI()
+ + (vreq.getQueryString() != null ? ('?' + vreq
+ .getQueryString()) : ""));
+ String redirectURL = request.getContextPath()
+ + Controllers.SITE_ADMIN + "?login=block";
+ response.sendRedirect(redirectURL);
+ return;
+ }
+
+ // EditProcessObject epo = super.createEpo(request);
+
+ List classGroups = vreq.getFullWebappDaoFactory().getVClassGroupDao()
+ .getPublicGroupsWithVClasses(true, true, false); // order by
+ // displayRank,
+ // include
+ // uninstantiated
+ // classes,
+ // don't get
+ // the
+ // counts of
+ // individuals
+
+ Iterator classGroupIt = classGroups.iterator();
+
+ response.setContentType("text/xml");
+ response.setCharacterEncoding("UTF-8");
+ PrintWriter out = response.getWriter();
+ String respo = "";
+ respo += "";
+
+ while (classGroupIt.hasNext()) {
+ VClassGroup group = (VClassGroup) classGroupIt.next();
+ List classes = group.getVitroClassList();
+ Iterator classIt = classes.iterator();
+ while (classIt.hasNext()) {
+ VClass clazz = (VClass) classIt.next();
+ respo += "";
+ }
+ }
+ respo += "";
+ out.println(respo);
+ out.flush();
+ out.close();
+ }
+
+ /**
+ * The doPost method of the servlet.
+ *
+ * This method is called when a form has its tag value method equals to
+ * post.
+ *
+ * @param request
+ * the request send by the client to the server
+ * @param response
+ * the response send by the server to the client
+ * @throws ServletException
+ * if an error occurred
+ * @throws IOException
+ * if an error occurred
+ */
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ doGet(request, response);
+ }
+
+}
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/sparql/GetAllPrefix.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/sparql/GetAllPrefix.java
new file mode 100644
index 000000000..be1d84866
--- /dev/null
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/sparql/GetAllPrefix.java
@@ -0,0 +1,139 @@
+package edu.cornell.mannlib.vitro.webapp.sparql;
+
+import java.io.IOException;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import edu.cornell.mannlib.vedit.beans.EditProcessObject;
+import edu.cornell.mannlib.vedit.beans.FormObject;
+import edu.cornell.mannlib.vedit.beans.LoginFormBean;
+import edu.cornell.mannlib.vedit.controller.BaseEditController;
+import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
+import edu.cornell.mannlib.vitro.webapp.beans.VClass;
+import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
+import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
+import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
+import edu.cornell.mannlib.vitro.webapp.controller.edit.SiteAdminController;
+import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
+
+/**
+ * This servlet gets all the prefix for initizing the sparql query builder.
+ *
+ * @author yuysun
+ */
+
+public class GetAllPrefix extends BaseEditController {
+
+ private static final Log log = LogFactory.getLog(SiteAdminController.class
+ .getName());
+
+ /**
+ * The doGet method of the servlet.
+ *
+ * This method is called when a form has its tag value method equals to get.
+ *
+ * @param request
+ * the request send by the client to the server
+ * @param response
+ * the response send by the server to the client
+ * @throws ServletException
+ * if an error occurred
+ * @throws IOException
+ * if an error occurred
+ */
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ try {
+ super.doGet(request, response);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ VitroRequest vreq = new VitroRequest(request);
+
+ Object obj = vreq.getSession().getAttribute("loginHandler");
+ LoginFormBean loginHandler = null;
+ if (obj != null && obj instanceof LoginFormBean)
+ loginHandler = ((LoginFormBean) obj);
+ if (loginHandler == null
+ || !"authenticated".equalsIgnoreCase(loginHandler
+ .getLoginStatus()) ||
+ // 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.
+ Integer.parseInt(loginHandler.getLoginRole()) < LoginFormBean.NON_EDITOR) {
+ HttpSession session = request.getSession(true);
+
+ session.setAttribute("postLoginRequest", vreq.getRequestURI()
+ + (vreq.getQueryString() != null ? ('?' + vreq
+ .getQueryString()) : ""));
+ String redirectURL = request.getContextPath()
+ + Controllers.SITE_ADMIN + "?login=block";
+ response.sendRedirect(redirectURL);
+ return;
+ }
+
+ // EditProcessObject epo = super.createEpo(request);
+ OntologyDao daoObj = vreq.getFullWebappDaoFactory().getOntologyDao();
+ List ontologiesObj = daoObj.getAllOntologies();
+ ArrayList prefixList = new ArrayList();
+
+ response.setContentType("text/xml");
+ response.setCharacterEncoding("UTF-8");
+ PrintWriter out = response.getWriter();
+ String respo = "";
+ respo += "";
+ if (ontologiesObj != null && ontologiesObj.size() > 0) {
+
+ Iterator ontItr = ontologiesObj.iterator();
+ while (ontItr.hasNext()) {
+ Ontology ont = (Ontology) ontItr.next();
+ if (ont.getPrefix() != null) {
+ respo += "";
+ }
+ }
+
+ }
+ respo += "";
+ out.println(respo);
+ out.flush();
+ out.close();
+ }
+
+ /**
+ * The doPost method of the servlet.
+ *
+ * This method is called when a form has its tag value method equals to
+ * post.
+ *
+ * @param request
+ * the request send by the client to the server
+ * @param response
+ * the response send by the server to the client
+ * @throws ServletException
+ * if an error occurred
+ * @throws IOException
+ * if an error occurred
+ */
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ doGet(request, response);
+ }
+
+}
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/sparql/GetClazzDataProperties.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/sparql/GetClazzDataProperties.java
new file mode 100644
index 000000000..53a4cbaa0
--- /dev/null
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/sparql/GetClazzDataProperties.java
@@ -0,0 +1,147 @@
+package edu.cornell.mannlib.vitro.webapp.sparql;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import edu.cornell.mannlib.vedit.beans.LoginFormBean;
+import edu.cornell.mannlib.vedit.controller.BaseEditController;
+import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
+import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
+import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance;
+import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
+import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
+import edu.cornell.mannlib.vitro.webapp.controller.edit.SiteAdminController;
+import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
+import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao;
+import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
+import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
+import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao;
+import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
+
+/**
+ * This servlet gets all the data properties for a given subject.
+ *
+ * @param vClassURI
+ * @author yuysun
+ */
+
+public class GetClazzDataProperties extends BaseEditController {
+
+ private static final Log log = LogFactory.getLog(SiteAdminController.class
+ .getName());
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ try {
+ super.doGet(request, response);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ VitroRequest vreq = new VitroRequest(request);
+
+ Object obj = vreq.getSession().getAttribute("loginHandler");
+ LoginFormBean loginHandler = null;
+ if (obj != null && obj instanceof LoginFormBean)
+ loginHandler = ((LoginFormBean) obj);
+ if (loginHandler == null
+ || !"authenticated".equalsIgnoreCase(loginHandler
+ .getLoginStatus()) ||
+ // 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.
+ Integer.parseInt(loginHandler.getLoginRole()) < LoginFormBean.NON_EDITOR) {
+ HttpSession session = request.getSession(true);
+
+ session.setAttribute("postLoginRequest", vreq.getRequestURI()
+ + (vreq.getQueryString() != null ? ('?' + vreq
+ .getQueryString()) : ""));
+ String redirectURL = request.getContextPath()
+ + Controllers.SITE_ADMIN + "?login=block";
+ response.sendRedirect(redirectURL);
+ return;
+ }
+
+ String vClassURI = vreq.getParameter("vClassURI");
+ if (vClassURI == null || vClassURI.trim().equals("")) {
+ return;
+ }
+
+ String respo = "";
+ respo += "";
+
+ // Add rdfs:label to the list
+ respo += "";
+
+ DataPropertyDao ddao = vreq.getFullWebappDaoFactory()
+ .getDataPropertyDao();
+
+ Collection dataProps = ddao
+ .getDataPropertiesForVClass(vClassURI);
+ Iterator dataPropIt = dataProps.iterator();
+ HashSet dpropURIs = new HashSet();
+ while (dataPropIt.hasNext()) {
+ DataProperty dp = dataPropIt.next();
+ if (!(dpropURIs.contains(dp.getURI()))) {
+ dpropURIs.add(dp.getURI());
+ DataProperty dprop = (DataProperty) ddao
+ .getDataPropertyByURI(dp.getURI());
+ if (dprop != null) {
+ respo += "";
+ }
+ }
+ }
+ respo += "";
+ response.setContentType("text/xml");
+ response.setCharacterEncoding("UTF-8");
+ PrintWriter out = response.getWriter();
+
+ out.println(respo);
+ out.flush();
+ out.close();
+ }
+
+ /**
+ * The doPost method of the servlet.
+ *
+ * This method is called when a form has its tag value method equals to
+ * post.
+ *
+ * @param request
+ * the request send by the client to the server
+ * @param response
+ * the response send by the server to the client
+ * @throws ServletException
+ * if an error occurred
+ * @throws IOException
+ * if an error occurred
+ */
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ doGet(request, response);
+ }
+}
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/sparql/GetClazzObjectProperties.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/sparql/GetClazzObjectProperties.java
new file mode 100644
index 000000000..c125b947b
--- /dev/null
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/sparql/GetClazzObjectProperties.java
@@ -0,0 +1,159 @@
+package edu.cornell.mannlib.vitro.webapp.sparql;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import edu.cornell.mannlib.vedit.beans.LoginFormBean;
+import edu.cornell.mannlib.vedit.controller.BaseEditController;
+import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
+import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance;
+import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
+import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
+import edu.cornell.mannlib.vitro.webapp.controller.edit.SiteAdminController;
+import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
+import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao;
+import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
+
+/**
+ * This servlet gets all the object properties for a given subject.
+ *
+ * @param vClassURI
+ * @author yuysun
+ */
+
+public class GetClazzObjectProperties extends BaseEditController {
+ private static final Log log = LogFactory.getLog(SiteAdminController.class
+ .getName());
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ try {
+ super.doGet(request, response);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ VitroRequest vreq = new VitroRequest(request);
+
+ Object obj = vreq.getSession().getAttribute("loginHandler");
+ LoginFormBean loginHandler = null;
+ if (obj != null && obj instanceof LoginFormBean)
+ loginHandler = ((LoginFormBean) obj);
+ if (loginHandler == null
+ || !"authenticated".equalsIgnoreCase(loginHandler
+ .getLoginStatus()) ||
+ // 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.
+ Integer.parseInt(loginHandler.getLoginRole()) < LoginFormBean.NON_EDITOR) {
+ HttpSession session = request.getSession(true);
+
+ session.setAttribute("postLoginRequest", vreq.getRequestURI()
+ + (vreq.getQueryString() != null ? ('?' + vreq
+ .getQueryString()) : ""));
+ String redirectURL = request.getContextPath()
+ + Controllers.SITE_ADMIN + "?login=block";
+ response.sendRedirect(redirectURL);
+ return;
+ }
+
+ String vClassURI = vreq.getParameter("vClassURI");
+ if (vClassURI == null || vClassURI.trim().equals("")) {
+ return;
+ }
+
+ String respo = "";
+ respo += "";
+
+ ObjectPropertyDao odao = vreq.getFullWebappDaoFactory()
+ .getObjectPropertyDao();
+ PropertyInstanceDao piDao = vreq.getFullWebappDaoFactory()
+ .getPropertyInstanceDao();
+ VClassDao vcDao = vreq.getFullWebappDaoFactory().getVClassDao();
+
+ // incomplete list of classes to check, but better than before
+ List superclassURIs = vcDao.getAllSuperClassURIs(vClassURI);
+ superclassURIs.add(vClassURI);
+ superclassURIs.addAll(vcDao.getEquivalentClassURIs(vClassURI));
+
+ Map propInstMap = new HashMap();
+ for (String classURI : superclassURIs) {
+ Collection propInsts = piDao
+ .getAllPropInstByVClass(classURI);
+ try {
+ for (PropertyInstance propInst : propInsts) {
+ propInstMap.put(propInst.getPropertyURI(), propInst);
+ }
+ } catch (NullPointerException ex) {
+ continue;
+ }
+ }
+ List propInsts = new ArrayList();
+ propInsts.addAll(propInstMap.values());
+ Collections.sort(propInsts);
+
+ Iterator propInstIt = propInsts.iterator();
+ HashSet opropURIs = new HashSet();
+ while (propInstIt.hasNext()) {
+ PropertyInstance pi = (PropertyInstance) propInstIt.next();
+ if (!(opropURIs.contains(pi.getPropertyURI()))) {
+ opropURIs.add(pi.getPropertyURI());
+ ObjectProperty oprop = (ObjectProperty) odao
+ .getObjectPropertyByURI(pi.getPropertyURI());
+ if (oprop != null) {
+ respo += "";
+ }
+ }
+ }
+ respo += "";
+ response.setContentType("text/xml");
+ response.setCharacterEncoding("UTF-8");
+ PrintWriter out = response.getWriter();
+
+ out.println(respo);
+ out.flush();
+ out.close();
+ }
+
+ /**
+ * The doPost method of the servlet.
+ *
+ * This method is called when a form has its tag value method equals to
+ * post.
+ *
+ * @param request
+ * the request send by the client to the server
+ * @param response
+ * the response send by the server to the client
+ * @throws ServletException
+ * if an error occurred
+ * @throws IOException
+ * if an error occurred
+ */
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ doGet(request, response);
+ }
+}
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/sparql/GetObjectClasses.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/sparql/GetObjectClasses.java
new file mode 100644
index 000000000..673bc2ed1
--- /dev/null
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/sparql/GetObjectClasses.java
@@ -0,0 +1,181 @@
+package edu.cornell.mannlib.vitro.webapp.sparql;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import edu.cornell.mannlib.vedit.beans.LoginFormBean;
+import edu.cornell.mannlib.vedit.controller.BaseEditController;
+import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
+import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
+import edu.cornell.mannlib.vitro.webapp.beans.VClass;
+import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
+import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
+import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
+import edu.cornell.mannlib.vitro.webapp.controller.edit.SiteAdminController;
+import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
+import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
+
+/**
+ * This servlet gets all the range classes for a given predicate.
+ *
+ * @param predicate
+ * @author yuysun
+ */
+
+public class GetObjectClasses extends BaseEditController {
+
+ private static final Log log = LogFactory.getLog(SiteAdminController.class
+ .getName());
+
+ /**
+ * The doGet method of the servlet.
+ *
+ * This method is called when a form has its tag value method equals to get.
+ *
+ * @param request
+ * the request send by the client to the server
+ * @param response
+ * the response send by the server to the client
+ * @throws ServletException
+ * if an error occurred
+ * @throws IOException
+ * if an error occurred
+ */
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ try {
+ super.doGet(request, response);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ VitroRequest vreq = new VitroRequest(request);
+
+ Object obj = vreq.getSession().getAttribute("loginHandler");
+ LoginFormBean loginHandler = null;
+ if (obj != null && obj instanceof LoginFormBean)
+ loginHandler = ((LoginFormBean) obj);
+ if (loginHandler == null
+ || !"authenticated".equalsIgnoreCase(loginHandler
+ .getLoginStatus()) ||
+ // 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.
+ Integer.parseInt(loginHandler.getLoginRole()) < LoginFormBean.NON_EDITOR) {
+ HttpSession session = request.getSession(true);
+
+ session.setAttribute("postLoginRequest", vreq.getRequestURI()
+ + (vreq.getQueryString() != null ? ('?' + vreq
+ .getQueryString()) : ""));
+ String redirectURL = request.getContextPath()
+ + Controllers.SITE_ADMIN + "?login=block";
+ response.sendRedirect(redirectURL);
+ return;
+ }
+
+ String predicate = vreq.getParameter("predicate");
+ if (predicate == null || predicate.trim().equals("")) {
+ return;
+ }
+
+ ObjectPropertyDao odao = vreq.getFullWebappDaoFactory()
+ .getObjectPropertyDao();
+ ObjectProperty oprop = (ObjectProperty) odao
+ .getObjectPropertyByURI(predicate);
+
+ VClassDao vcDao = vreq.getFullWebappDaoFactory().getVClassDao();
+ VClass vClass = (oprop.getRangeVClassURI() != null) ? vcDao
+ .getVClassByURI(oprop.getRangeVClassURI()) : null;
+
+ response.setContentType("text/xml");
+ response.setCharacterEncoding("UTF-8");
+ PrintWriter out = response.getWriter();
+ String respo = "";
+ respo += "";
+ if (vClass != null) {
+ respo += "";
+ } else {
+ List classGroups = vreq.getFullWebappDaoFactory()
+ .getVClassGroupDao().getPublicGroupsWithVClasses(true,
+ true, false); // order by displayRank, include
+ // uninstantiated classes, don't get
+ // the counts of individuals
+
+ Iterator classGroupIt = classGroups.iterator();
+ while (classGroupIt.hasNext()) {
+ VClassGroup group = (VClassGroup) classGroupIt.next();
+ List classes = group.getVitroClassList();
+ Iterator classIt = classes.iterator();
+ while (classIt.hasNext()) {
+ VClass clazz = (VClass) classIt.next();
+ respo += "";
+ }
+ }
+ }
+
+ /*
+ * VClass clazz = oprop.getRangeVClass();
+ * response.setContentType("text/xml");
+ * response.setCharacterEncoding("UTF-8"); PrintWriter out =
+ * response.getWriter(); String respo =
+ * ""; respo += "";
+ *
+ * if (clazz != null) { respo += ""; } else{ List classGroups =
+ * vreq.getFullWebappDaoFactory
+ * ().getVClassGroupDao().getPublicGroupsWithVClasses(true,true,false);
+ * // order by displayRank, include uninstantiated classes, don't get
+ * the counts of individuals Iterator classGroupIt =
+ * classGroups.iterator(); while (classGroupIt.hasNext()) { VClassGroup
+ * group = (VClassGroup)classGroupIt.next(); List classes =
+ * group.getVitroClassList(); Iterator classIt = classes.iterator();
+ * while (classIt.hasNext()) { clazz = (VClass) classIt.next();
+ * System.out.println(clazz.getPickListName()); respo += ""; } }
+ *
+ * }
+ */
+ respo += "";
+ out.println(respo);
+ out.flush();
+ out.close();
+ }
+
+ /**
+ * The doPost method of the servlet.
+ *
+ * This method is called when a form has its tag value method equals to
+ * post.
+ *
+ * @param request
+ * the request send by the client to the server
+ * @param response
+ * the response send by the server to the client
+ * @throws ServletException
+ * if an error occurred
+ * @throws IOException
+ * if an error occurred
+ */
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ doGet(request, response);
+ }
+
+}
diff --git a/webapp/web/admin/sparql.jsp b/webapp/web/admin/sparql.jsp
new file mode 100644
index 000000000..48053fb26
--- /dev/null
+++ b/webapp/web/admin/sparql.jsp
@@ -0,0 +1,165 @@
+<%@page import="com.hp.hpl.jena.rdf.model.ModelMaker"%>
+<%@page import="java.util.Iterator"%>
+<%@page import="java.util.ArrayList"%>
+<%@page import="java.util.List"%>
+
+
+
+
+
+
+
+ SPARQL Query Builder
+
+
+
+
+ Subject
+ |
+
+ Predicate
+ |
+
+ Object
+ |
+
+
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+