1. Added a generic query handler. It will be used to get all (or a subset) of the properties for a particular URI. This will be helpful in getting image paths & other info on the fly.
2. Made changes to the test bed to include more samples.
This commit is contained in:
parent
ee2b141687
commit
32bbd519c2
11 changed files with 564 additions and 36 deletions
|
@ -36,7 +36,6 @@ 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;
|
||||
|
@ -201,7 +200,7 @@ public class VisualizationController extends BaseEditController {
|
|||
* This is side-effecting because the visualization content is added
|
||||
* to the request object.
|
||||
* */
|
||||
visRequestHandler.generateVisualization(dataSource);
|
||||
visRequestHandler.generateVisualization(this, dataSource);
|
||||
|
||||
} else {
|
||||
log.error("ERROR! data model empoty");
|
||||
|
|
|
@ -3,20 +3,17 @@ package edu.cornell.mannlib.vitro.webapp.controller.visualization;
|
|||
public class VisualizationFrameworkConstants {
|
||||
|
||||
public static final String VIS_CONTAINER_URL_HANDLE = "container";
|
||||
|
||||
public static final String INDIVIDUAL_URI_URL_HANDLE = "uri";
|
||||
|
||||
public static final String VIS_MODE_URL_HANDLE = "vis_mode";
|
||||
|
||||
public static final String RENDER_MODE_URL_HANDLE = "render_mode";
|
||||
|
||||
|
||||
|
||||
public static final String STANDALONE_RENDER_MODE_URL_VALUE = "standalone";
|
||||
|
||||
public static final String DYNAMIC_RENDER_MODE_URL_VALUE = "dynamic";
|
||||
|
||||
public static final String DATA_RENDER_MODE_URL_VALUE = "data";
|
||||
|
||||
public static final String PDF_RENDER_MODE_URL_VALUE = "pdf";
|
||||
public static final String IMAGE_VIS_MODE_URL_VALUE = "image";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -161,6 +161,8 @@ public class QueryHandler {
|
|||
egoCoAuthorEdge = new Edge(egoNode, coAuthorNode, biboDocument, edgeIDGenerator);
|
||||
edges.add(egoCoAuthorEdge);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -326,7 +328,7 @@ public class QueryHandler {
|
|||
private String generateEgoCoAuthorshipSparqlQuery(String queryURI) {
|
||||
// Resource uri1 = ResourceFactory.createResource(queryURI);
|
||||
|
||||
String sparqlQuery = QueryConstants.SPARQL_QUERY_PREFIXES
|
||||
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
|
||||
+ "SELECT "
|
||||
+ " (str(<" + queryURI + ">) as ?" + QueryFieldLabels.AUTHOR_URL + ") "
|
||||
+ " (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") "
|
||||
|
@ -347,7 +349,7 @@ public class QueryHandler {
|
|||
+ "OPTIONAL { ?document vitro:moniker ?documentMoniker } . "
|
||||
+ "OPTIONAL { ?document vitro:blurb ?documentBlurb } . "
|
||||
+ "OPTIONAL { ?document vitro:description ?documentDescription } "
|
||||
+ "FILTER (<" + queryURI + "> != ?coAuthorPerson ) . "
|
||||
// + "FILTER (<" + queryURI + "> != ?coAuthorPerson ) . "
|
||||
+ "}";
|
||||
|
||||
System.out.println(sparqlQuery);
|
||||
|
|
|
@ -1,35 +1,28 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.visualization.coauthorship;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import com.hp.hpl.jena.query.DataSource;
|
||||
import com.itextpdf.text.Document;
|
||||
import com.itextpdf.text.DocumentException;
|
||||
import com.itextpdf.text.pdf.PdfWriter;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.visualization.VisualizationController;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.visualization.VisualizationFrameworkConstants;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.PDFDocument;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VisConstants;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.BiboDocument;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.utils.GenericQueryHandler;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.GenericQueryMap;
|
||||
|
||||
public class VisualizationRequestHandler {
|
||||
|
||||
|
@ -48,7 +41,7 @@ public class VisualizationRequestHandler {
|
|||
|
||||
}
|
||||
|
||||
public void generateVisualization(DataSource dataSource) {
|
||||
public void generateVisualization(VisualizationController visualizationController, DataSource dataSource) {
|
||||
|
||||
String resultFormatParam = "RS_TEXT";
|
||||
String rdfResultFormatParam = "RDF/XML-ABBREV";
|
||||
|
@ -61,6 +54,103 @@ public class VisualizationRequestHandler {
|
|||
|
||||
String visContainer = vitroRequest.getParameter(VisualizationFrameworkConstants.VIS_CONTAINER_URL_HANDLE);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* If the data being requested is about a standalone image, which is used when we want
|
||||
* to render an image & other info for a co-author OR ego for that matter.
|
||||
* */
|
||||
if (VisualizationFrameworkConstants.DATA_RENDER_MODE_URL_VALUE.equalsIgnoreCase(renderMode)
|
||||
&& VisualizationFrameworkConstants.IMAGE_VIS_MODE_URL_VALUE.equalsIgnoreCase(visMode) ) {
|
||||
|
||||
|
||||
String filterRule = "?predicate = vitro:imageThumb";
|
||||
GenericQueryHandler imageQueryHandler = new GenericQueryHandler(egoURIParam,
|
||||
filterRule,
|
||||
resultFormatParam,
|
||||
rdfResultFormatParam,
|
||||
dataSource,
|
||||
log);
|
||||
|
||||
try {
|
||||
|
||||
GenericQueryMap imagePropertyToValues = imageQueryHandler.getJavaValueObjects();
|
||||
|
||||
String imagePath = "";
|
||||
/*
|
||||
* If there is no imageThumb property we want to give the link to "No Image" snap.
|
||||
* */
|
||||
if (imagePropertyToValues.size() > 0) {
|
||||
|
||||
String vitroSparqlNamespace = QueryConstants.PREFIX_TO_NAMESPACE.get("vitro");
|
||||
String imageThumbProperty = vitroSparqlNamespace + "imageThumb";
|
||||
|
||||
Set<String> personImageThumbPaths = imagePropertyToValues.get(imageThumbProperty);
|
||||
|
||||
/*
|
||||
* Although we know that there can be only one imagePath we are restricted by Java's
|
||||
* expression power.
|
||||
* */
|
||||
for (String providedImagePath : personImageThumbPaths) {
|
||||
imagePath = "/images/" + providedImagePath;
|
||||
}
|
||||
|
||||
String imageServerPath = visualizationController.getServletContext().getRealPath(imagePath);
|
||||
|
||||
File imageFile = new File(imageServerPath) ;
|
||||
|
||||
if (imageFile == null) {
|
||||
|
||||
Portal portal = vitroRequest.getPortal();
|
||||
String themeDir = portal != null ? portal.getThemeDir() : Portal.DEFAULT_THEME_DIR_FROM_CONTEXT;
|
||||
|
||||
System.out.println("bfore cxtpth " + themeDir);
|
||||
|
||||
themeDir = vitroRequest.getContextPath() + '/' + themeDir;
|
||||
|
||||
System.out.println("bfore cxtpth " + themeDir);
|
||||
|
||||
imagePath = themeDir + "site_icons/visualization/coauthorship/no_image.png";
|
||||
|
||||
System.out.println(imagePath);
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
Portal portal = vitroRequest.getPortal();
|
||||
String themeDir = portal != null ? portal.getThemeDir() : Portal.DEFAULT_THEME_DIR_FROM_CONTEXT;
|
||||
|
||||
System.out.println("bfore cxtpth " + themeDir);
|
||||
|
||||
themeDir = vitroRequest.getContextPath() + '/' + themeDir;
|
||||
|
||||
System.out.println("bfore cxtpth " + themeDir);
|
||||
|
||||
imagePath = themeDir + "site_icons/visualization/coauthorship/no_image.png";
|
||||
|
||||
System.out.println(imagePath);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
} catch (MalformedQueryParametersException e) {
|
||||
try {
|
||||
handleMalformedParameters(e.getMessage());
|
||||
} catch (ServletException e1) {
|
||||
log.error(e1.getStackTrace());
|
||||
} catch (IOException e1) {
|
||||
log.error(e1.getStackTrace());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
QueryHandler queryManager =
|
||||
new QueryHandler(egoURIParam,
|
||||
resultFormatParam,
|
||||
|
@ -80,13 +170,17 @@ public class VisualizationRequestHandler {
|
|||
* It is ugly!
|
||||
* */
|
||||
if (VisualizationFrameworkConstants.DATA_RENDER_MODE_URL_VALUE.equalsIgnoreCase(renderMode)) {
|
||||
prepareVisualizationQueryDataResponse(authorNodesAndEdges);
|
||||
|
||||
return;
|
||||
/*
|
||||
* When just the graphML file is required - based on which actual visualization will
|
||||
* be rendered.
|
||||
* */
|
||||
prepareVisualizationQueryDataResponse(authorNodesAndEdges);
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Computations required to generate HTML for the sparklines & related context.
|
||||
* */
|
||||
|
@ -170,6 +264,23 @@ public class VisualizationRequestHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private void prepareVisualizationQueryImageResponse(String imageURL) {
|
||||
|
||||
response.setContentType("text/plain");
|
||||
|
||||
try {
|
||||
|
||||
PrintWriter responseWriter = response.getWriter();
|
||||
|
||||
responseWriter.append(imageURL);
|
||||
|
||||
responseWriter.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareVisualizationQueryStandaloneResponse(String egoURIParam,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
|
|
|
@ -240,7 +240,7 @@ public class QueryHandler {
|
|||
private String generateCollegeEmployeeSparqlQuery(String queryURI) {
|
||||
// Resource uri1 = ResourceFactory.createResource(queryURI);
|
||||
|
||||
String sparqlQuery = QueryConstants.SPARQL_QUERY_PREFIXES
|
||||
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
|
||||
+ "SELECT (str(?collegeLabel) as ?" + QueryFieldLabels.COLLEGE_LABEL + ") "
|
||||
+ " (str(?department) as ?" + QueryFieldLabels.DEPARTMENT_URL + ") "
|
||||
+ " (str(?departmentLabel) as ?" + QueryFieldLabels.DEPARTMENT_LABEL + ") "
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.visualization.constants;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class QueryConstants {
|
||||
|
||||
public static final String SPARQL_QUERY_PREFIXES = "" +
|
||||
/*
|
||||
* This is not supposed to be used. Will remove after verifying that the dynamic prefix
|
||||
* section generation works.
|
||||
* */
|
||||
public static final String SPARQL_QUERY_PREFIXES_DEP = "" +
|
||||
"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 vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#>\n" +
|
||||
|
@ -10,7 +17,78 @@ public class QueryConstants {
|
|||
"PREFIX core: <http://vivoweb.org/ontology/core#>\n" +
|
||||
"PREFIX bibo: <http://purl.org/ontology/bibo/>\n" +
|
||||
"PREFIX foaf: <http://xmlns.com/foaf/0.1/>\n" +
|
||||
"PREFIX aktp: <http://www.aktors.org/ontology/portal#>\n";
|
||||
"PREFIX aktp: <http://www.aktors.org/ontology/portal#>\n" +
|
||||
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n" +
|
||||
"PREFIX owl: <http://www.w3.org/2002/07/owl#>\n" +
|
||||
"PREFIX swrl: <http://www.w3.org/2003/11/swrl#>\n" +
|
||||
"PREFIX swrlb: <http://www.w3.org/2003/11/swrlb#>\n" +
|
||||
"PREFIX far: <http://vitro.mannlib.cornell.edu/ns/reporting#>\n" +
|
||||
"PREFIX ai: <http://vitro.mannlib.cornell.edu/ns/hotel#>\n" +
|
||||
"PREFIX akts: <http://www.aktors.org/ontology/support#>\n" +
|
||||
"PREFIX hr: <http://vivo.cornell.edu/ns/hr/0.9/hr.owl#>\n" +
|
||||
"PREFIX dcterms: <http://purl.org/dc/terms/>\n" +
|
||||
"PREFIX dcelem: <http://purl.org/dc/elements/1.1/>\n" +
|
||||
"PREFIX event: <http://purl.org/NET/c4dm/event.owl#>\n" +
|
||||
"PREFIX geo: <http://aims.fao.org/aos/geopolitical.owl#>\n" +
|
||||
"PREFIX mann: <http://vivo.cornell.edu/ns/mannadditions/0.1#>\n" +
|
||||
"PREFIX pubmed: <http://vitro.mannlib.cornell.edu/ns/pubmed#>\n" +
|
||||
"PREFIX rdfsyn: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" +
|
||||
"PREFIX skos: <http://www.w3.org/2004/02/skos/core#>\n" +
|
||||
"PREFIX socsci: <http://vivo.library.cornell.edu/ns/vivo/socsci/0.1#>\n" +
|
||||
"PREFIX stars: <http://vitro.mannlib.cornell.edu/ns/cornell/stars/classes#>\n" +
|
||||
"PREFIX temp: <http://vitro.mannlib.cornell.edu/ns/temp#>\n" +
|
||||
"PREFIX wos: <http://vivo.mannlib.cornell.edu/ns/ThomsonWOS/0.1#>\n";
|
||||
|
||||
|
||||
public static final Map<String, String> PREFIX_TO_NAMESPACE = new HashMap<String, String>() {{
|
||||
|
||||
put("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
|
||||
put("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
|
||||
put("xsd", "http://www.w3.org/2001/XMLSchema#");
|
||||
put("owl", "http://www.w3.org/2002/07/owl#");
|
||||
put("swrl", "http://www.w3.org/2003/11/swrl#");
|
||||
put("swrlb", "http://www.w3.org/2003/11/swrlb#");
|
||||
put("vitro", "http://vitro.mannlib.cornell.edu/ns/vitro/0.7#");
|
||||
put("far", "http://vitro.mannlib.cornell.edu/ns/reporting#");
|
||||
put("ai", "http://vitro.mannlib.cornell.edu/ns/hotel#");
|
||||
put("aktp", "http://www.aktors.org/ontology/portal#");
|
||||
put("akts", "http://www.aktors.org/ontology/support#");
|
||||
put("bibo", "http://purl.org/ontology/bibo/");
|
||||
put("hr", "http://vivo.cornell.edu/ns/hr/0.9/hr.owl#");
|
||||
put("dcterms", "http://purl.org/dc/terms/");
|
||||
put("dcelem", "http://purl.org/dc/elements/1.1/");
|
||||
put("event", "http://purl.org/NET/c4dm/event.owl#");
|
||||
put("foaf", "http://xmlns.com/foaf/0.1/");
|
||||
put("geo", "http://aims.fao.org/aos/geopolitical.owl#");
|
||||
put("mann", "http://vivo.cornell.edu/ns/mannadditions/0.1#");
|
||||
put("pubmed", "http://vitro.mannlib.cornell.edu/ns/pubmed#");
|
||||
put("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
|
||||
put("rdfsyn", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
|
||||
put("skos", "http://www.w3.org/2004/02/skos/core#");
|
||||
put("socsci", "http://vivo.library.cornell.edu/ns/vivo/socsci/0.1#");
|
||||
put("stars", "http://vitro.mannlib.cornell.edu/ns/cornell/stars/classes#");
|
||||
put("temp", "http://vitro.mannlib.cornell.edu/ns/temp#");
|
||||
put("wos", "http://vivo.mannlib.cornell.edu/ns/ThomsonWOS/0.1#");
|
||||
put("core", "http://vivoweb.org/ontology/core#");
|
||||
put("vivo", "http://vivo.library.cornell.edu/ns/0.1#");
|
||||
|
||||
}};
|
||||
|
||||
|
||||
public static String getSparqlPrefixQuery() {
|
||||
|
||||
StringBuilder prefixSection = new StringBuilder();
|
||||
|
||||
for (Map.Entry prefixEntry : PREFIX_TO_NAMESPACE.entrySet()) {
|
||||
prefixSection.append("PREFIX " + prefixEntry.getKey() + ": <" + prefixEntry.getValue() + ">\n");
|
||||
}
|
||||
|
||||
|
||||
return prefixSection.toString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,13 @@ package edu.cornell.mannlib.vitro.webapp.visualization.constants;
|
|||
|
||||
public class QueryFieldLabels {
|
||||
|
||||
/*
|
||||
* Generic Query related field labels
|
||||
* */
|
||||
public static final String PREDICATE = "predicateLit";
|
||||
public static final String OBJECT = "objectLit";
|
||||
|
||||
|
||||
/*
|
||||
* Document related field labels
|
||||
* */
|
||||
|
|
|
@ -162,7 +162,7 @@ public class QueryHandler {
|
|||
private String generateSparqlQuery(String queryURI) {
|
||||
// Resource uri1 = ResourceFactory.createResource(queryURI);
|
||||
|
||||
String sparqlQuery = QueryConstants.SPARQL_QUERY_PREFIXES
|
||||
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
|
||||
+ SPARQL_QUERY_COMMON_SELECT_CLAUSE
|
||||
+ "(str(<" + queryURI + ">) as ?authPersonLit) "
|
||||
+ "WHERE { "
|
||||
|
|
|
@ -0,0 +1,161 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.visualization.utils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import com.hp.hpl.jena.iri.IRI;
|
||||
import com.hp.hpl.jena.iri.IRIFactory;
|
||||
import com.hp.hpl.jena.iri.Violation;
|
||||
import com.hp.hpl.jena.query.DataSource;
|
||||
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.Syntax;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.GenericQueryMap;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Very dumb name of the class. change it.
|
||||
* @author cdtank
|
||||
*
|
||||
*/
|
||||
public class GenericQueryHandler {
|
||||
|
||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||
|
||||
private String filterRule, individualURLParam, resultFormatParam, rdfResultFormatParam;
|
||||
private DataSource dataSource;
|
||||
|
||||
private Log log;
|
||||
|
||||
public GenericQueryHandler(String individualURLParam,
|
||||
String filterRule,
|
||||
String resultFormatParam,
|
||||
String rdfResultFormatParam,
|
||||
DataSource dataSource,
|
||||
Log log) {
|
||||
|
||||
this.individualURLParam = individualURLParam;
|
||||
this.filterRule = filterRule;
|
||||
this.resultFormatParam = resultFormatParam;
|
||||
this.rdfResultFormatParam = rdfResultFormatParam;
|
||||
this.dataSource = dataSource;
|
||||
this.log = log;
|
||||
|
||||
}
|
||||
|
||||
private GenericQueryMap createJavaValueObjects(ResultSet resultSet) {
|
||||
|
||||
GenericQueryMap queryResultVO = new GenericQueryMap();
|
||||
|
||||
while (resultSet.hasNext()) {
|
||||
QuerySolution solution = resultSet.nextSolution();
|
||||
|
||||
|
||||
/*
|
||||
* We only want to create only ONE ego node.
|
||||
* */
|
||||
RDFNode predicateNode = solution.get(QueryFieldLabels.PREDICATE);
|
||||
RDFNode objectNode = solution.get(QueryFieldLabels.OBJECT);
|
||||
|
||||
if (predicateNode != null && objectNode != null) {
|
||||
queryResultVO.addEntry(predicateNode.toString(),
|
||||
objectNode.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return queryResultVO;
|
||||
}
|
||||
|
||||
|
||||
private ResultSet executeQuery(String queryText,
|
||||
String resultFormatParam,
|
||||
String rdfResultFormatParam,
|
||||
DataSource dataSource) {
|
||||
|
||||
QueryExecution queryExecution = null;
|
||||
try{
|
||||
Query query = QueryFactory.create(queryText, SYNTAX);
|
||||
|
||||
// QuerySolutionMap qs = new QuerySolutionMap();
|
||||
// qs.add("authPerson", queryParam); // bind resource to s
|
||||
|
||||
queryExecution = QueryExecutionFactory.create(query, dataSource);
|
||||
|
||||
|
||||
//remocve this if loop after knowing what is describe & construct sparql stuff.
|
||||
if (query.isSelectType()){
|
||||
return queryExecution.execSelect();
|
||||
}
|
||||
} finally {
|
||||
if(queryExecution != null) {
|
||||
queryExecution.close();
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String generateGenericSparqlQuery(String queryURI, String filterRule) {
|
||||
// Resource uri1 = ResourceFactory.createResource(queryURI);
|
||||
String filterClause;
|
||||
|
||||
if (filterRule == null || filterRule.trim().isEmpty()) {
|
||||
filterClause = "";
|
||||
} else {
|
||||
filterClause = "FILTER ( " + filterRule + " ) . ";
|
||||
}
|
||||
|
||||
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
|
||||
+ "SELECT "
|
||||
+ " (str(?predicate) as ?" + QueryFieldLabels.PREDICATE + ") "
|
||||
+ " (str(?object) as ?" + QueryFieldLabels.OBJECT + ") "
|
||||
+ "WHERE { "
|
||||
+ "<" + queryURI + "> ?predicate ?object. "
|
||||
+ filterClause
|
||||
+ "}";
|
||||
|
||||
System.out.println(sparqlQuery);
|
||||
|
||||
return sparqlQuery;
|
||||
}
|
||||
|
||||
|
||||
public GenericQueryMap getJavaValueObjects()
|
||||
throws MalformedQueryParametersException {
|
||||
|
||||
if (this.individualURLParam == null || "".equals(individualURLParam)) {
|
||||
throw new MalformedQueryParametersException("URI parameter is either null or empty.");
|
||||
} else {
|
||||
|
||||
/*
|
||||
* To test for the validity of the URI submitted.
|
||||
* */
|
||||
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
|
||||
IRI iri = iRIFactory.create(this.individualURLParam);
|
||||
if (iri.hasViolation(false)) {
|
||||
String errorMsg = ((Violation)iri.violations(false).next()).getShortMessage()+" ";
|
||||
log.error("Generic Query " + errorMsg);
|
||||
throw new MalformedQueryParametersException("URI provided for an individual is malformed.");
|
||||
}
|
||||
}
|
||||
|
||||
ResultSet resultSet = executeQuery(generateGenericSparqlQuery(this.individualURLParam, this.filterRule),
|
||||
this.resultFormatParam,
|
||||
this.rdfResultFormatParam,
|
||||
this.dataSource);
|
||||
|
||||
return createJavaValueObjects(resultSet);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.visualization.valueobjects;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Right now this is just acting as a hashmap but in future we would want to provide
|
||||
* more detailed info other than just what properties had what values. E.g. we
|
||||
* could parse properties (& its values) to look for what namespaces are used.
|
||||
* @author cdtank
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class GenericQueryMap extends HashMap<String, Set<String>> {
|
||||
|
||||
public GenericQueryMap() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void addEntry(String property, String value) {
|
||||
|
||||
Set<String> values;
|
||||
|
||||
if (this.containsKey(property)) {
|
||||
|
||||
values = this.get(property);
|
||||
values.add(value);
|
||||
|
||||
} else {
|
||||
|
||||
values = new HashSet<String>();
|
||||
values.add(value);
|
||||
this.put(property, values);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -93,12 +93,124 @@
|
|||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual5748"/>
|
||||
</c:url>
|
||||
|
||||
<c:url var="coAuthorship2Data" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="data"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual5156"/>
|
||||
</c:url>
|
||||
|
||||
<c:url var="coAuthorship3Data" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="data"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual5611"/>
|
||||
</c:url>
|
||||
|
||||
|
||||
<c:url var="coAuthorship4Data" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="data"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual5412"/>
|
||||
</c:url>
|
||||
|
||||
<c:url var="coAuthorship1" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="standalone"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual5748"/>
|
||||
</c:url>
|
||||
|
||||
<c:url var="coAuthorship2" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="standalone"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual5156"/>
|
||||
</c:url>
|
||||
|
||||
<c:url var="coAuthorship3" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="standalone"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual5611"/>
|
||||
</c:url>
|
||||
|
||||
<c:url var="coAuthorship4" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="standalone"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual5412"/>
|
||||
</c:url>
|
||||
|
||||
|
||||
<c:url var="coAuthorship5" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="standalone"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual5714"/>
|
||||
</c:url>
|
||||
|
||||
<c:url var="coAuthorship5Data" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="data"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual5714"/>
|
||||
</c:url>
|
||||
|
||||
|
||||
<c:url var="coAuthorship6" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="standalone"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual240"/>
|
||||
</c:url>
|
||||
|
||||
<c:url var="coAuthorship6Data" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="data"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual240"/>
|
||||
</c:url>
|
||||
|
||||
<c:url var="coAuthorship7" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="standalone"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual37"/>
|
||||
</c:url>
|
||||
|
||||
<c:url var="coAuthorship7Data" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="data"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual37"/>
|
||||
</c:url>
|
||||
|
||||
<c:url var="coAuthorship8" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="standalone"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual5355"/>
|
||||
</c:url>
|
||||
|
||||
<c:url var="coAuthorship8Data" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="data"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual5355"/>
|
||||
</c:url>
|
||||
|
||||
<c:url var="coAuthorship9" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="standalone"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual5734"/>
|
||||
</c:url>
|
||||
|
||||
|
||||
<c:url var="coAuthorship9Data" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="data"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual5734"/>
|
||||
</c:url>
|
||||
|
||||
<c:url var="coAuthorship10" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="standalone"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual12053"/>
|
||||
</c:url>
|
||||
|
||||
<c:url var="coAuthorship10Data" value="/admin/visQuery">
|
||||
<c:param name="vis" value="coauthorship"/>
|
||||
<c:param name="render_mode" value="data"/>
|
||||
<c:param name="uri" value="http://vivo.library.cornell.edu/ns/0.1#individual12053"/>
|
||||
</c:url>
|
||||
|
||||
<c:url var="loadingImageLink" value="/${themeDir}site_icons/visualization/ajax-loader.gif"></c:url>
|
||||
|
||||
<style type="text/css">
|
||||
|
@ -188,8 +300,30 @@ $(document).ready(function() {
|
|||
|
||||
<h1 id="test-bed">Visualization Testbed (Not to be seen by eventual end users)</h1>
|
||||
|
||||
<a href='<c:out value="${coAuthorship1}"/>'>vis link for coauthorship -> "Erb, Hollis Nancy"</a><br />
|
||||
<a href='<c:out value="${coAuthorship1Data}"/>'>vis data query for coauthorship -> "Erb, Hollis Nancy"</a><br />
|
||||
<a href='<c:out value="${coAuthorship1}"/>'>vis link for coauthorship -> "Erb, Hollis Nancy"</a>
|
||||
<a href='<c:out value="${coAuthorship1Data}"/>'>Data</a>
|
||||
<br />
|
||||
<a href='<c:out value="${coAuthorship2}"/>'>vis link for coauthorship -> "Not Working" {"Crane, Brian"}</a>
|
||||
<a href='<c:out value="${coAuthorship2Data}"/>'>Data</a><br />
|
||||
<a href='<c:out value="${coAuthorship3}"/>'>vis link for coauthorship -> "Merwin, Ian A"</a>
|
||||
<a href='<c:out value="${coAuthorship3Data}"/>'>Data</a><br />
|
||||
<a href='<c:out value="${coAuthorship4}"/>'>vis link for coauthorship -> "Thies, Janice"</a>
|
||||
<a href='<c:out value="${coAuthorship4Data}"/>'>Data</a><br />
|
||||
<a href='<c:out value="${coAuthorship5}"/>'>vis link for coauthorship -> "Not Working"</a>
|
||||
<a href='<c:out value="${coAuthorship5Data}"/>'>Data</a><br />
|
||||
<a href='<c:out value="${coAuthorship6}"/>'>vis link for coauthorship -> "Boor, Kathryn Jean"</a>
|
||||
<a href='<c:out value="${coAuthorship6Data}"/>'>Data</a><br />
|
||||
<a href='<c:out value="${coAuthorship7}"/>'>vis link for coauthorship -> "Wiedmann, Martin"</a>
|
||||
<a href='<c:out value="${coAuthorship7Data}"/>'>Data</a><br />
|
||||
<a href='<c:out value="${coAuthorship8}"/>'>vis link for coauthorship -> "Not Working"</a>
|
||||
<a href='<c:out value="${coAuthorship8Data}"/>'>Data</a><br />
|
||||
<a href='<c:out value="${coAuthorship9}"/>'>vis link for coauthorship -> "Not Working"</a>
|
||||
<a href='<c:out value="${coAuthorship9Data}"/>'>Data</a><br />
|
||||
<a href='<c:out value="${coAuthorship10}"/>'>vis link for coauthorship -> "Not Working"</a>
|
||||
<a href='<c:out value="${coAuthorship10Data}"/>'>Data</a><br />
|
||||
|
||||
<br /><br /><br />
|
||||
|
||||
<a href='<c:out value="${collegeCSV}"/>'>vis data query for college -> "School of Industrial and Labor Relations (ILR)"</a><br />
|
||||
<a href='<c:out value="${collegeCSV2}"/>'>vis data query for college -> "College of Agriculture and Life Sciences (CALS)"</a><br />
|
||||
<a href='<c:out value="${collegeCSV3}"/>'>vis data query for college -> "College of Arts and Sciences"</a><br />
|
||||
|
|
Loading…
Add table
Reference in a new issue