1. Removed unused construct query runner.
2. Refactored all construct query runners to implement a common interface. 3. Changed AjaxVis*Controller & DataVisContoller to use Dataset instead of Datasource.
This commit is contained in:
parent
a4223e7ac6
commit
844c8e30be
16 changed files with 303 additions and 589 deletions
|
@ -11,17 +11,14 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.DataSource;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
import com.hp.hpl.jena.query.DatasetFactory;
|
|
||||||
import com.hp.hpl.jena.query.Syntax;
|
import com.hp.hpl.jena.query.Syntax;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
import com.hp.hpl.jena.rdf.model.ModelMaker;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.TemplateProcessingHelper.TemplateProcessingException;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.TemplateProcessingHelper.TemplateProcessingException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VisConstants;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
|
||||||
|
@ -110,14 +107,14 @@ public class AjaxVisualizationController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DataSource dataSource = setupJENADataSource(model, vitroRequest);
|
Dataset dataset = setupJENADataSource(vitroRequest);
|
||||||
|
|
||||||
if (dataSource != null && visRequestHandler != null) {
|
if (dataset != null && visRequestHandler != null) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return visRequestHandler.generateAjaxVisualization(vitroRequest,
|
return visRequestHandler.generateAjaxVisualization(vitroRequest,
|
||||||
log,
|
log,
|
||||||
dataSource);
|
dataset);
|
||||||
} catch (MalformedQueryParametersException e) {
|
} catch (MalformedQueryParametersException e) {
|
||||||
return UtilityFunctions.handleMalformedParameters(
|
return UtilityFunctions.handleMalformedParameters(
|
||||||
"Ajax Visualization Query Error - Individual Publication Count",
|
"Ajax Visualization Query Error - Individual Publication Count",
|
||||||
|
@ -160,16 +157,8 @@ public class AjaxVisualizationController extends FreemarkerHttpServlet {
|
||||||
return visRequestHandler;
|
return visRequestHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DataSource setupJENADataSource(Model model, VitroRequest vreq) {
|
private Dataset setupJENADataSource(VitroRequest vreq) {
|
||||||
|
return vreq.getDataset();
|
||||||
log.debug("rdfResultFormat was: " + VisConstants.RDF_RESULT_FORMAT_PARAM);
|
|
||||||
|
|
||||||
DataSource dataSource = DatasetFactory.create();
|
|
||||||
ModelMaker maker = (ModelMaker) getServletContext().getAttribute("vitroJenaModelMaker");
|
|
||||||
|
|
||||||
dataSource.setDefaultModel(model);
|
|
||||||
|
|
||||||
return dataSource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,9 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.DataSource;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
import com.hp.hpl.jena.query.DatasetFactory;
|
|
||||||
import com.hp.hpl.jena.query.Syntax;
|
import com.hp.hpl.jena.query.Syntax;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
import com.hp.hpl.jena.rdf.model.ModelMaker;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
@ -124,12 +122,12 @@ public class DataVisualizationController extends VitroHttpServlet {
|
||||||
throw new MalformedQueryParametersException(errorMessage);
|
throw new MalformedQueryParametersException(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
DataSource dataSource = setupJENADataSource(model, vitroRequest);
|
Dataset dataset = setupJENADataSource(vitroRequest);
|
||||||
|
|
||||||
if (dataSource != null && visRequestHandler != null) {
|
if (dataset != null && visRequestHandler != null) {
|
||||||
return visRequestHandler.generateDataVisualization(vitroRequest,
|
return visRequestHandler.generateDataVisualization(vitroRequest,
|
||||||
log,
|
log,
|
||||||
dataSource);
|
dataset);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -148,29 +146,24 @@ public class DataVisualizationController extends VitroHttpServlet {
|
||||||
.VIS_TYPE_KEY);
|
.VIS_TYPE_KEY);
|
||||||
VisualizationRequestHandler visRequestHandler = null;
|
VisualizationRequestHandler visRequestHandler = null;
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
visRequestHandler = VisualizationsDependencyInjector
|
visRequestHandler = VisualizationsDependencyInjector
|
||||||
.getVisualizationIDsToClassMap(getServletContext())
|
.getVisualizationIDsToClassMap(getServletContext())
|
||||||
.get(visType);
|
.get(visType);
|
||||||
} catch (NullPointerException nullKeyException) {
|
|
||||||
|
|
||||||
|
} catch (NullPointerException nullKeyException) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return visRequestHandler;
|
return visRequestHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DataSource setupJENADataSource(Model model, VitroRequest vreq) {
|
private Dataset setupJENADataSource(VitroRequest vreq) {
|
||||||
|
|
||||||
log.debug("rdfResultFormat was: " + VisConstants.RDF_RESULT_FORMAT_PARAM);
|
log.debug("rdfResultFormat was: " + VisConstants.RDF_RESULT_FORMAT_PARAM);
|
||||||
|
|
||||||
DataSource dataSource = DatasetFactory.create();
|
return vreq.getDataset();
|
||||||
ModelMaker maker = (ModelMaker) getServletContext().getAttribute("vitroJenaModelMaker");
|
|
||||||
|
|
||||||
dataSource.setDefaultModel(model);
|
|
||||||
|
|
||||||
return dataSource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,9 @@ package edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.DataSource;
|
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
import com.hp.hpl.jena.query.DatasetFactory;
|
|
||||||
import com.hp.hpl.jena.query.Syntax;
|
import com.hp.hpl.jena.query.Syntax;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
import com.hp.hpl.jena.rdf.model.ModelMaker;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
||||||
|
@ -135,11 +132,6 @@ public class StandardVisualizationController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
log.debug("rdfResultFormat was: " + VisConstants.RDF_RESULT_FORMAT_PARAM);
|
log.debug("rdfResultFormat was: " + VisConstants.RDF_RESULT_FORMAT_PARAM);
|
||||||
|
|
||||||
// DataSource dataSource = DatasetFactory.create();
|
|
||||||
// ModelMaker maker = (ModelMaker) getServletContext().getAttribute("vitroJenaModelMaker");
|
|
||||||
//
|
|
||||||
// dataSource.setDefaultModel(model);
|
|
||||||
|
|
||||||
return vreq.getDataset();
|
return vreq.getDataset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,9 @@ import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
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.exceptions.MalformedQueryParametersException;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.ModelConstructor;
|
||||||
|
|
||||||
|
public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
|
||||||
public class CoPIGrantCountConstructQueryRunner {
|
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
|
||||||
|
@ -34,124 +34,129 @@ public class CoPIGrantCountConstructQueryRunner {
|
||||||
|
|
||||||
private long before, after;
|
private long before, after;
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(CoPIGrantCountConstructQueryRunner.class.getName());
|
private Log log = LogFactory
|
||||||
|
.getLog(CoPIGrantCountConstructQueryRunner.class.getName());
|
||||||
|
|
||||||
|
private static final String SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING = "?Role core:roleIn ?Grant . "
|
||||||
private static final String SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING =
|
|
||||||
"?Role core:roleIn ?Grant . "
|
|
||||||
+ "?Grant rdfs:label ?GrantLabel . "
|
+ "?Grant rdfs:label ?GrantLabel . "
|
||||||
+ "?Grant core:relatedRole ?RelatedRole . ";
|
+ "?Grant core:relatedRole ?RelatedRole . ";
|
||||||
|
|
||||||
public CoPIGrantCountConstructQueryRunner(String egoURI, Dataset Dataset, Log log){
|
public CoPIGrantCountConstructQueryRunner(String egoURI, Dataset Dataset,
|
||||||
|
Log log) {
|
||||||
this.egoURI = egoURI;
|
this.egoURI = egoURI;
|
||||||
this.Dataset = Dataset;
|
this.Dataset = Dataset;
|
||||||
//this.log = log;
|
// this.log = log;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateConstructQueryForInvestigatorLabel(String queryURI) {
|
private String generateConstructQueryForInvestigatorLabel(String queryURI) {
|
||||||
|
|
||||||
String sparqlQuery =
|
String sparqlQuery = "CONSTRUCT { " + "<" + queryURI
|
||||||
"CONSTRUCT { "
|
+ "> rdfs:label ?investigatorLabel ." + "}" + "WHERE {" + "<"
|
||||||
+ "<"+queryURI+ "> rdfs:label ?investigatorLabel ."
|
+ queryURI + "> rdfs:label ?investigatorLabel " + "}";
|
||||||
+ "}"
|
|
||||||
+ "WHERE {"
|
|
||||||
+ "<"+queryURI+ "> rdfs:label ?investigatorLabel "
|
|
||||||
+ "}";
|
|
||||||
|
|
||||||
return sparqlQuery;
|
return sparqlQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateConstructQueryForInvestigatorRoleOfProperty(String queryURI, String preboundProperty){
|
private String generateConstructQueryForInvestigatorRoleOfProperty(
|
||||||
|
String queryURI, String preboundProperty) {
|
||||||
|
|
||||||
String sparqlQuery =
|
String sparqlQuery = "CONSTRUCT { " + "<" + queryURI + ">"
|
||||||
"CONSTRUCT { "
|
+ preboundProperty + " ?Role . "
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
|
||||||
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
||||||
+ "?RelatedRole core:investigatorRoleOf ?coInvestigator ."
|
+ "?RelatedRole core:investigatorRoleOf ?coInvestigator ."
|
||||||
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . "
|
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . " + "}"
|
||||||
+ "}"
|
+ "WHERE { " + "<" + queryURI + ">" + preboundProperty
|
||||||
+ "WHERE { "
|
+ " ?Role . " + SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
|
||||||
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
|
||||||
+ "?RelatedRole core:investigatorRoleOf ?coInvestigator ."
|
+ "?RelatedRole core:investigatorRoleOf ?coInvestigator ."
|
||||||
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . "
|
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . " + "}";
|
||||||
+ "}";
|
|
||||||
|
|
||||||
return sparqlQuery;
|
return sparqlQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateConstructQueryForPrincipalInvestigatorRoleOfProperty(String queryURI, String preboundProperty){
|
private String generateConstructQueryForPrincipalInvestigatorRoleOfProperty(
|
||||||
|
String queryURI, String preboundProperty) {
|
||||||
|
|
||||||
String sparqlQuery =
|
String sparqlQuery = "CONSTRUCT { "
|
||||||
"CONSTRUCT { "
|
+ "<"
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
+ queryURI
|
||||||
|
+ ">"
|
||||||
|
+ preboundProperty
|
||||||
|
+ " ?Role . "
|
||||||
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
||||||
+ "?RelatedRole core:principalInvestigatorRoleOf ?coInvestigator ."
|
+ "?RelatedRole core:principalInvestigatorRoleOf ?coInvestigator ."
|
||||||
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . "
|
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . "
|
||||||
+ "}"
|
+ "}"
|
||||||
+ "WHERE { "
|
+ "WHERE { "
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
+ "<"
|
||||||
|
+ queryURI
|
||||||
|
+ ">"
|
||||||
|
+ preboundProperty
|
||||||
|
+ " ?Role . "
|
||||||
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
||||||
+ "?RelatedRole core:principalInvestigatorRoleOf ?coInvestigator ."
|
+ "?RelatedRole core:principalInvestigatorRoleOf ?coInvestigator ."
|
||||||
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . "
|
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . " + "}";
|
||||||
+ "}";
|
|
||||||
|
|
||||||
return sparqlQuery;
|
return sparqlQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(String queryURI, String preboundProperty){
|
private String generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(
|
||||||
|
String queryURI, String preboundProperty) {
|
||||||
|
|
||||||
String sparqlQuery =
|
String sparqlQuery = "CONSTRUCT { "
|
||||||
"CONSTRUCT { "
|
+ "<"
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
+ queryURI
|
||||||
|
+ ">"
|
||||||
|
+ preboundProperty
|
||||||
|
+ " ?Role . "
|
||||||
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
||||||
+ "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?coInvestigator ."
|
+ "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?coInvestigator ."
|
||||||
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . "
|
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . "
|
||||||
+ "}"
|
+ "}"
|
||||||
+ "WHERE { "
|
+ "WHERE { "
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
+ "<"
|
||||||
|
+ queryURI
|
||||||
|
+ ">"
|
||||||
|
+ preboundProperty
|
||||||
|
+ " ?Role . "
|
||||||
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
||||||
+ "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?coInvestigator ."
|
+ "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?coInvestigator ."
|
||||||
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . "
|
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . " + "}";
|
||||||
+ "}";
|
|
||||||
|
|
||||||
return sparqlQuery;
|
return sparqlQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateConstructQueryForDateTimeValueofRole(String queryURI, String preboundProperty){
|
private String generateConstructQueryForDateTimeValueofRole(
|
||||||
|
String queryURI, String preboundProperty) {
|
||||||
|
|
||||||
String sparqlQuery =
|
String sparqlQuery = "CONSTRUCT { " + "<" + queryURI + ">"
|
||||||
"CONSTRUCT { "
|
+ preboundProperty + " ?Role . "
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
|
||||||
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
||||||
+ "?dateTimeIntervalValue core:start ?startDate . "
|
+ "?dateTimeIntervalValue core:start ?startDate . "
|
||||||
+ "?startDate core:dateTime ?startDateTimeValue . "
|
+ "?startDate core:dateTime ?startDateTimeValue . "
|
||||||
+ "?dateTimeIntervalValue core:end ?endDate . "
|
+ "?dateTimeIntervalValue core:end ?endDate . "
|
||||||
+ "?endDate core:dateTime ?endDateTimeValue . "
|
+ "?endDate core:dateTime ?endDateTimeValue . " + "}"
|
||||||
+ "}"
|
+ "WHERE { " + "{" + "<" + queryURI + ">" + preboundProperty
|
||||||
+ "WHERE { "
|
+ " ?Role . "
|
||||||
+ "{"
|
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
|
||||||
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
||||||
+ "?dateTimeIntervalValue core:start ?startDate . "
|
+ "?dateTimeIntervalValue core:start ?startDate . "
|
||||||
+ "?startDate core:dateTime ?startDateTimeValue . "
|
+ "?startDate core:dateTime ?startDateTimeValue . "
|
||||||
+ "} UNION "
|
+ "} UNION " + "{" + "<" + queryURI + ">" + preboundProperty
|
||||||
+ "{"
|
+ " ?Role . "
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
|
||||||
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
||||||
+ "?dateTimeIntervalValue core:end ?endDate . "
|
+ "?dateTimeIntervalValue core:end ?endDate . "
|
||||||
+ "?endDate core:dateTime ?endDateTimeValue . "
|
+ "?endDate core:dateTime ?endDateTimeValue . " + "}" + "}";
|
||||||
+ "}"
|
|
||||||
+ "}";
|
|
||||||
|
|
||||||
return sparqlQuery;
|
return sparqlQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateConstructQueryForDateTimeValueofGrant(String queryURI, String preboundProperty){
|
private String generateConstructQueryForDateTimeValueofGrant(
|
||||||
|
String queryURI, String preboundProperty) {
|
||||||
|
|
||||||
String sparqlQuery =
|
String sparqlQuery = "CONSTRUCT { " + "<"
|
||||||
"CONSTRUCT { "
|
+ queryURI
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
+ ">"
|
||||||
|
+ preboundProperty
|
||||||
|
+ " ?Role . "
|
||||||
+ "?Role core:roleIn ?Grant ."
|
+ "?Role core:roleIn ?Grant ."
|
||||||
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
||||||
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
|
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
|
||||||
|
@ -161,20 +166,27 @@ public class CoPIGrantCountConstructQueryRunner {
|
||||||
+ "}"
|
+ "}"
|
||||||
+ "WHERE { "
|
+ "WHERE { "
|
||||||
+ "{"
|
+ "{"
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
+ "<"
|
||||||
|
+ queryURI
|
||||||
|
+ ">"
|
||||||
|
+ preboundProperty
|
||||||
|
+ " ?Role . "
|
||||||
+ "?Role core:roleIn ?Grant ."
|
+ "?Role core:roleIn ?Grant ."
|
||||||
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
||||||
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
|
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
|
||||||
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
|
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
|
||||||
+ "} UNION "
|
+ "} UNION "
|
||||||
+ "{"
|
+ "{"
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
+ "<"
|
||||||
|
+ queryURI
|
||||||
|
+ ">"
|
||||||
|
+ preboundProperty
|
||||||
|
+ " ?Role . "
|
||||||
+ "?Role core:roleIn ?Grant ."
|
+ "?Role core:roleIn ?Grant ."
|
||||||
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
||||||
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
|
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
|
||||||
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant . "
|
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant . "
|
||||||
+ "}"
|
+ "}" + "}";
|
||||||
+ "}";
|
|
||||||
|
|
||||||
return sparqlQuery;
|
return sparqlQuery;
|
||||||
}
|
}
|
||||||
|
@ -183,7 +195,6 @@ public class CoPIGrantCountConstructQueryRunner {
|
||||||
|
|
||||||
Model constructedModel = ModelFactory.createDefaultModel();
|
Model constructedModel = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
|
|
||||||
for (String queryString : constructQueries) {
|
for (String queryString : constructQueries) {
|
||||||
|
|
||||||
before = System.currentTimeMillis();
|
before = System.currentTimeMillis();
|
||||||
|
@ -192,16 +203,17 @@ public class CoPIGrantCountConstructQueryRunner {
|
||||||
|
|
||||||
Query query = null;
|
Query query = null;
|
||||||
|
|
||||||
try{
|
try {
|
||||||
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + queryString, SYNTAX);
|
query = QueryFactory.create(
|
||||||
}catch(Throwable th){
|
QueryConstants.getSparqlPrefixQuery() + queryString,
|
||||||
log.error("Could not create CONSTRUCT SPARQL query for query " +
|
SYNTAX);
|
||||||
"string. " + th.getMessage());
|
} catch (Throwable th) {
|
||||||
|
log.error("Could not create CONSTRUCT SPARQL query for query "
|
||||||
|
+ "string. " + th.getMessage());
|
||||||
log.error(queryString);
|
log.error(queryString);
|
||||||
}
|
}
|
||||||
|
|
||||||
QueryExecution qe = QueryExecutionFactory.create(
|
QueryExecution qe = QueryExecutionFactory.create(query, Dataset);
|
||||||
query, Dataset);
|
|
||||||
try {
|
try {
|
||||||
qe.execConstruct(constructedModel);
|
qe.execConstruct(constructedModel);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -209,38 +221,39 @@ public class CoPIGrantCountConstructQueryRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
after = System.currentTimeMillis();
|
after = System.currentTimeMillis();
|
||||||
log.debug("Time taken to execute the CONSTRUCT query is in milliseconds: " + (after - before) );
|
log.debug("Time taken to execute the CONSTRUCT query is in milliseconds: "
|
||||||
|
+ (after - before));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return constructedModel;
|
return constructedModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Model getConstructedModel()
|
public Model getConstructedModel() throws MalformedQueryParametersException {
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(this.egoURI)) {
|
if (StringUtils.isNotBlank(this.egoURI)) {
|
||||||
/*
|
/*
|
||||||
* To test for the validity of the URI submitted.
|
* To test for the validity of the URI submitted.
|
||||||
* */
|
*/
|
||||||
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
|
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
|
||||||
IRI iri = iRIFactory.create(this.egoURI);
|
IRI iri = iRIFactory.create(this.egoURI);
|
||||||
if (iri.hasViolation(false)) {
|
if (iri.hasViolation(false)) {
|
||||||
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
|
String errorMsg = ((Violation) iri.violations(false).next())
|
||||||
|
.getShortMessage();
|
||||||
log.error("Ego Co-PI Vis Query " + errorMsg);
|
log.error("Ego Co-PI Vis Query " + errorMsg);
|
||||||
throw new MalformedQueryParametersException(
|
throw new MalformedQueryParametersException(
|
||||||
"URI provided for an individual is malformed.");
|
"URI provided for an individual is malformed.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new MalformedQueryParametersException("URI parameter is either null or empty.");
|
throw new MalformedQueryParametersException(
|
||||||
|
"URI parameter is either null or empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> constructQueries = new HashSet<String>();
|
Set<String> constructQueries = new HashSet<String>();
|
||||||
|
|
||||||
populateConstructQueries(constructQueries);
|
populateConstructQueries(constructQueries);
|
||||||
|
|
||||||
Model model = executeQuery(constructQueries,
|
Model model = executeQuery(constructQueries, this.Dataset);
|
||||||
this.Dataset);
|
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
|
|
||||||
|
@ -248,24 +261,49 @@ public class CoPIGrantCountConstructQueryRunner {
|
||||||
|
|
||||||
private void populateConstructQueries(Set<String> constructQueries) {
|
private void populateConstructQueries(Set<String> constructQueries) {
|
||||||
|
|
||||||
constructQueries.add(generateConstructQueryForInvestigatorLabel(this.egoURI));
|
constructQueries
|
||||||
constructQueries.add(generateConstructQueryForInvestigatorRoleOfProperty(this.egoURI, "core:hasInvestigatorRole"));
|
.add(generateConstructQueryForInvestigatorLabel(this.egoURI));
|
||||||
constructQueries.add(generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(this.egoURI, "core:hasInvestigatorRole"));
|
constructQueries
|
||||||
constructQueries.add(generateConstructQueryForPrincipalInvestigatorRoleOfProperty(this.egoURI, "core:hasInvestigatorRole"));
|
.add(generateConstructQueryForInvestigatorRoleOfProperty(
|
||||||
constructQueries.add(generateConstructQueryForDateTimeValueofRole(this.egoURI, "core:hasInvestigatorRole"));
|
this.egoURI, "core:hasInvestigatorRole"));
|
||||||
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(this.egoURI, "core:hasInvestigatorRole"));
|
constructQueries
|
||||||
|
.add(generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(
|
||||||
|
this.egoURI, "core:hasInvestigatorRole"));
|
||||||
|
constructQueries
|
||||||
|
.add(generateConstructQueryForPrincipalInvestigatorRoleOfProperty(
|
||||||
|
this.egoURI, "core:hasInvestigatorRole"));
|
||||||
|
constructQueries.add(generateConstructQueryForDateTimeValueofRole(
|
||||||
|
this.egoURI, "core:hasInvestigatorRole"));
|
||||||
|
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(
|
||||||
|
this.egoURI, "core:hasInvestigatorRole"));
|
||||||
|
|
||||||
constructQueries.add(generateConstructQueryForInvestigatorRoleOfProperty(this.egoURI, "core:hasPrincipalInvestigatorRole"));
|
constructQueries
|
||||||
constructQueries.add(generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(this.egoURI, "core:hasPrincipalInvestigatorRole"));
|
.add(generateConstructQueryForInvestigatorRoleOfProperty(
|
||||||
constructQueries.add(generateConstructQueryForPrincipalInvestigatorRoleOfProperty(this.egoURI, "core:hasPrincipalInvestigatorRole"));
|
this.egoURI, "core:hasPrincipalInvestigatorRole"));
|
||||||
constructQueries.add(generateConstructQueryForDateTimeValueofRole(this.egoURI, "core:hasPrincipalInvestigatorRole"));
|
constructQueries
|
||||||
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(this.egoURI, "core:hasPrincipalInvestigatorRole"));
|
.add(generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(
|
||||||
|
this.egoURI, "core:hasPrincipalInvestigatorRole"));
|
||||||
|
constructQueries
|
||||||
|
.add(generateConstructQueryForPrincipalInvestigatorRoleOfProperty(
|
||||||
|
this.egoURI, "core:hasPrincipalInvestigatorRole"));
|
||||||
|
constructQueries.add(generateConstructQueryForDateTimeValueofRole(
|
||||||
|
this.egoURI, "core:hasPrincipalInvestigatorRole"));
|
||||||
|
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(
|
||||||
|
this.egoURI, "core:hasPrincipalInvestigatorRole"));
|
||||||
|
|
||||||
constructQueries.add(generateConstructQueryForInvestigatorRoleOfProperty(this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
|
constructQueries
|
||||||
constructQueries.add(generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
|
.add(generateConstructQueryForInvestigatorRoleOfProperty(
|
||||||
constructQueries.add(generateConstructQueryForPrincipalInvestigatorRoleOfProperty(this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
|
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
|
||||||
constructQueries.add(generateConstructQueryForDateTimeValueofRole(this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
|
constructQueries
|
||||||
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
|
.add(generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(
|
||||||
|
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
|
||||||
|
constructQueries
|
||||||
|
.add(generateConstructQueryForPrincipalInvestigatorRoleOfProperty(
|
||||||
|
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
|
||||||
|
constructQueries.add(generateConstructQueryForDateTimeValueofRole(
|
||||||
|
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
|
||||||
|
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(
|
||||||
|
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,15 +13,14 @@ import org.apache.commons.logging.Log;
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker.DataVisualizationController;
|
import edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker.DataVisualizationController;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker.VisualizationFrameworkConstants;
|
import edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker.VisualizationFrameworkConstants;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.collaborationutils.CollaborationData;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.collaborationutils.CollaborationData;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Collaborator;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Collaborator;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.ModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.QueryRunner;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.QueryRunner;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
|
||||||
|
@ -46,7 +45,7 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
|
||||||
String egoURI = vitroRequest.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
|
String egoURI = vitroRequest.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
|
||||||
String visMode = vitroRequest.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY);
|
String visMode = vitroRequest.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY);
|
||||||
|
|
||||||
CoPIGrantCountConstructQueryRunner constructQueryRunner = new CoPIGrantCountConstructQueryRunner(egoURI, Dataset, log);
|
ModelConstructor constructQueryRunner = new CoPIGrantCountConstructQueryRunner(egoURI, Dataset, log);
|
||||||
Model constructedModel = constructQueryRunner.getConstructedModel();
|
Model constructedModel = constructQueryRunner.getConstructedModel();
|
||||||
|
|
||||||
QueryRunner<CollaborationData> queryManager = new CoPIGrantCountQueryRunner(egoURI, constructedModel, log);
|
QueryRunner<CollaborationData> queryManager = new CoPIGrantCountQueryRunner(egoURI, constructedModel, log);
|
||||||
|
@ -104,51 +103,12 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* When the page for person level visualization is requested.
|
|
||||||
* @param egoURI
|
|
||||||
* @param vitroRequest
|
|
||||||
* @param coPIVO
|
|
||||||
*/
|
|
||||||
private TemplateResponseValues prepareStandaloneResponse(String egoURI,
|
|
||||||
CollaborationData coPIVO, VitroRequest vitroRequest) {
|
|
||||||
|
|
||||||
Portal portal = vitroRequest.getPortal();
|
|
||||||
|
|
||||||
String title = "";
|
|
||||||
Map<String, Object> body = new HashMap<String, Object>();
|
|
||||||
|
|
||||||
|
|
||||||
if (coPIVO.getCollaborators() != null
|
|
||||||
&& coPIVO.getCollaborators().size() > 0) {
|
|
||||||
title = coPIVO.getEgoCollaborator().getCollaboratorName() + " - ";
|
|
||||||
body.put("numOfInvestigators", coPIVO.getCollaborators().size());
|
|
||||||
|
|
||||||
title = coPIVO.getEgoCollaborator().getCollaboratorName() + " - ";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (coPIVO.getCollaborations() != null
|
|
||||||
&& coPIVO.getCollaborations().size() > 0) {
|
|
||||||
body.put("numOfCoInvestigations", coPIVO.getCollaborations().size());
|
|
||||||
}
|
|
||||||
|
|
||||||
String standaloneTemplate = "coInvestigation.ftl";
|
|
||||||
|
|
||||||
body.put("portalBean", portal);
|
|
||||||
body.put("egoURIParam", egoURI);
|
|
||||||
body.put("title", title + "Co-PI Visualization");
|
|
||||||
|
|
||||||
return new TemplateResponseValues(standaloneTemplate, body);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private String getCoPIsListCSVContent(CollaborationData coPIData) {
|
private String getCoPIsListCSVContent(CollaborationData coPIData) {
|
||||||
|
|
||||||
StringBuilder csvFileContent = new StringBuilder();
|
StringBuilder csvFileContent = new StringBuilder();
|
||||||
|
|
||||||
csvFileContent.append("Co-investigator, Count\n");
|
csvFileContent.append("Co-investigator, Count\n");
|
||||||
|
|
||||||
// for (Entry<String, Integer> currentEntry : coPIData.entrySet()) {
|
|
||||||
for (Collaborator currNode : coPIData.getCollaborators()) {
|
for (Collaborator currNode : coPIData.getCollaborators()) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -24,6 +24,7 @@ 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.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.GenericQueryMap;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.GenericQueryMap;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.GenericQueryRunner;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.GenericQueryRunner;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.ModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.QueryRunner;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.QueryRunner;
|
||||||
|
|
||||||
public class EntityComparisonUtilityFunctions {
|
public class EntityComparisonUtilityFunctions {
|
||||||
|
@ -102,7 +103,7 @@ public class EntityComparisonUtilityFunctions {
|
||||||
Dataset Dataset, String subjectOrganization)
|
Dataset Dataset, String subjectOrganization)
|
||||||
throws MalformedQueryParametersException {
|
throws MalformedQueryParametersException {
|
||||||
|
|
||||||
EntitySubOrganizationTypesConstructQueryRunner constructQueryRunnerForSubOrganizationTypes = new EntitySubOrganizationTypesConstructQueryRunner(subjectOrganization, Dataset, log) ;
|
ModelConstructor constructQueryRunnerForSubOrganizationTypes = new EntitySubOrganizationTypesConstructQueryRunner(subjectOrganization, Dataset, log) ;
|
||||||
Model constructedModelForSubOrganizationTypes = constructQueryRunnerForSubOrganizationTypes.getConstructedModel();
|
Model constructedModelForSubOrganizationTypes = constructQueryRunnerForSubOrganizationTypes.getConstructedModel();
|
||||||
|
|
||||||
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner(
|
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner(
|
||||||
|
|
|
@ -22,8 +22,9 @@ import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
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.exceptions.MalformedQueryParametersException;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.ModelConstructor;
|
||||||
|
|
||||||
public class EntityPublicationCountConstructQueryRunner {
|
public class EntityPublicationCountConstructQueryRunner implements ModelConstructor{
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import java.util.Set;
|
||||||
import org.apache.commons.lang.StringEscapeUtils;
|
import org.apache.commons.lang.StringEscapeUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
|
@ -29,6 +28,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryP
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Entity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Entity;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.JsonObject;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.JsonObject;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.ModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.QueryRunner;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.QueryRunner;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
|
||||||
|
@ -36,8 +36,6 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.Visual
|
||||||
public class EntityPublicationCountRequestHandler implements
|
public class EntityPublicationCountRequestHandler implements
|
||||||
VisualizationRequestHandler {
|
VisualizationRequestHandler {
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(EntityPublicationCountRequestHandler.class.getName());
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseValues generateStandardVisualization(
|
public ResponseValues generateStandardVisualization(
|
||||||
VitroRequest vitroRequest, Log log, Dataset Dataset)
|
VitroRequest vitroRequest, Log log, Dataset Dataset)
|
||||||
|
@ -59,7 +57,7 @@ public class EntityPublicationCountRequestHandler implements
|
||||||
String subjectEntityURI)
|
String subjectEntityURI)
|
||||||
throws MalformedQueryParametersException {
|
throws MalformedQueryParametersException {
|
||||||
|
|
||||||
EntityPublicationCountConstructQueryRunner constructQueryRunner = new EntityPublicationCountConstructQueryRunner(subjectEntityURI, Dataset, log);
|
ModelConstructor constructQueryRunner = new EntityPublicationCountConstructQueryRunner(subjectEntityURI, Dataset, log);
|
||||||
Model constructedModel = constructQueryRunner.getConstructedModel();
|
Model constructedModel = constructQueryRunner.getConstructedModel();
|
||||||
|
|
||||||
QueryRunner<Entity> queryManager = new EntityPublicationCountQueryRunner(
|
QueryRunner<Entity> queryManager = new EntityPublicationCountQueryRunner(
|
||||||
|
@ -140,7 +138,7 @@ public class EntityPublicationCountRequestHandler implements
|
||||||
* This provides csv download files for the content in the tables.
|
* This provides csv download files for the content in the tables.
|
||||||
* */
|
* */
|
||||||
|
|
||||||
EntityPublicationCountConstructQueryRunner constructQueryRunner = new EntityPublicationCountConstructQueryRunner(entityURI, Dataset, log);
|
ModelConstructor constructQueryRunner = new EntityPublicationCountConstructQueryRunner(entityURI, Dataset, log);
|
||||||
Model constructedModel = constructQueryRunner.getConstructedModel();
|
Model constructedModel = constructQueryRunner.getConstructedModel();
|
||||||
|
|
||||||
QueryRunner<Entity> queryManager = new EntityPublicationCountQueryRunner(
|
QueryRunner<Entity> queryManager = new EntityPublicationCountQueryRunner(
|
||||||
|
@ -232,33 +230,6 @@ public class EntityPublicationCountRequestHandler implements
|
||||||
return new TemplateResponseValues(standaloneTemplate, body);
|
return new TemplateResponseValues(standaloneTemplate, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated This method should not be called anymore although the templates being
|
|
||||||
* called by this method are still in use, so we should not get rid of it.
|
|
||||||
* @param vitroRequest
|
|
||||||
* @param entityURI
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private ResponseValues prepareStandaloneErrorResponse(
|
|
||||||
VitroRequest vitroRequest, String entityURI) {
|
|
||||||
|
|
||||||
Portal portal = vitroRequest.getPortal();
|
|
||||||
String standaloneTemplate = "entityPublicationComparisonError.ftl";
|
|
||||||
Map<String, Object> body = new HashMap<String, Object>();
|
|
||||||
|
|
||||||
String organizationLabel = EntityComparisonUtilityFunctions.getEntityLabelFromDAO(vitroRequest,
|
|
||||||
entityURI);
|
|
||||||
|
|
||||||
body.put("organizationLabel", organizationLabel);
|
|
||||||
body.put("portalBean", portal);
|
|
||||||
body.put("title", organizationLabel + " - Temporal Graph Visualization");
|
|
||||||
body.put("organizationURI", entityURI);
|
|
||||||
|
|
||||||
return new TemplateResponseValues(standaloneTemplate, body);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function to generate a json file for year <-> publication count mapping
|
* function to generate a json file for year <-> publication count mapping
|
||||||
* @param vreq
|
* @param vreq
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.entitycomparison;
|
package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.entitycomparison;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -23,8 +22,9 @@ import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
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.exceptions.MalformedQueryParametersException;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.ModelConstructor;
|
||||||
|
|
||||||
public class EntitySubOrganizationTypesConstructQueryRunner {
|
public class EntitySubOrganizationTypesConstructQueryRunner implements ModelConstructor {
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,9 @@ import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
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.exceptions.MalformedQueryParametersException;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.ModelConstructor;
|
||||||
|
|
||||||
public class EntityGrantCountConstructQueryRunner {
|
public class EntityGrantCountConstructQueryRunner implements ModelConstructor {
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import java.util.Set;
|
||||||
import org.apache.commons.lang.StringEscapeUtils;
|
import org.apache.commons.lang.StringEscapeUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
|
@ -30,6 +29,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.entitycompariso
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Entity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Entity;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.JsonObject;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.JsonObject;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.ModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.QueryRunner;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.QueryRunner;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
|
||||||
|
@ -38,8 +38,6 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.Visual
|
||||||
public class EntityGrantCountRequestHandler implements
|
public class EntityGrantCountRequestHandler implements
|
||||||
VisualizationRequestHandler {
|
VisualizationRequestHandler {
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(EntityGrantCountRequestHandler.class.getName());
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseValues generateStandardVisualization(
|
public ResponseValues generateStandardVisualization(
|
||||||
VitroRequest vitroRequest, Log log, Dataset Dataset)
|
VitroRequest vitroRequest, Log log, Dataset Dataset)
|
||||||
|
@ -66,7 +64,7 @@ public class EntityGrantCountRequestHandler implements
|
||||||
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
|
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This will provide the data in json format mainly used for standalone tmeporal vis.
|
* This will provide the data in json format mainly used for standalone temporal vis.
|
||||||
* */
|
* */
|
||||||
if (VisualizationFrameworkConstants.TEMPORAL_GRAPH_JSON_DATA_VIS_MODE
|
if (VisualizationFrameworkConstants.TEMPORAL_GRAPH_JSON_DATA_VIS_MODE
|
||||||
.equalsIgnoreCase(vitroRequest.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY))) {
|
.equalsIgnoreCase(vitroRequest.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY))) {
|
||||||
|
@ -95,7 +93,7 @@ public class EntityGrantCountRequestHandler implements
|
||||||
* This provides csv download files for the content in the tables.
|
* This provides csv download files for the content in the tables.
|
||||||
* */
|
* */
|
||||||
|
|
||||||
EntityGrantCountConstructQueryRunner constructQueryRunner = new EntityGrantCountConstructQueryRunner(entityURI, Dataset, log);
|
ModelConstructor constructQueryRunner = new EntityGrantCountConstructQueryRunner(entityURI, Dataset, log);
|
||||||
Model constructedModel = constructQueryRunner.getConstructedModel();
|
Model constructedModel = constructQueryRunner.getConstructedModel();
|
||||||
|
|
||||||
QueryRunner<Entity> queryManager = new EntityGrantCountQueryRunner(
|
QueryRunner<Entity> queryManager = new EntityGrantCountQueryRunner(
|
||||||
|
@ -124,7 +122,7 @@ public class EntityGrantCountRequestHandler implements
|
||||||
String subjectEntityURI)
|
String subjectEntityURI)
|
||||||
throws MalformedQueryParametersException {
|
throws MalformedQueryParametersException {
|
||||||
|
|
||||||
EntityGrantCountConstructQueryRunner constructQueryRunner = new EntityGrantCountConstructQueryRunner(subjectEntityURI, Dataset, log);
|
ModelConstructor constructQueryRunner = new EntityGrantCountConstructQueryRunner(subjectEntityURI, Dataset, log);
|
||||||
Model constructedModel = constructQueryRunner.getConstructedModel();
|
Model constructedModel = constructQueryRunner.getConstructedModel();
|
||||||
|
|
||||||
QueryRunner<Entity> queryManager = new EntityGrantCountQueryRunner(
|
QueryRunner<Entity> queryManager = new EntityGrantCountQueryRunner(
|
||||||
|
@ -234,32 +232,6 @@ public class EntityGrantCountRequestHandler implements
|
||||||
return new TemplateResponseValues(standaloneTemplate, body);
|
return new TemplateResponseValues(standaloneTemplate, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated This method should not be called anymore although the templates being
|
|
||||||
* called by this method are still in use, so we should not get rid of it.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private ResponseValues prepareStandaloneErrorResponse(
|
|
||||||
VitroRequest vitroRequest, String entityURI) {
|
|
||||||
|
|
||||||
Portal portal = vitroRequest.getPortal();
|
|
||||||
String standaloneTemplate = "entityGrantComparisonError.ftl";
|
|
||||||
Map<String, Object> body = new HashMap<String, Object>();
|
|
||||||
|
|
||||||
String organizationLabel = EntityComparisonUtilityFunctions.getEntityLabelFromDAO(vitroRequest,
|
|
||||||
entityURI);
|
|
||||||
|
|
||||||
body.put("organizationLabel", organizationLabel);
|
|
||||||
|
|
||||||
|
|
||||||
body.put("portalBean", portal);
|
|
||||||
body.put("title", organizationLabel + " - Temporal Graph Visualization");
|
|
||||||
body.put("organizationURI", entityURI);
|
|
||||||
|
|
||||||
return new TemplateResponseValues(standaloneTemplate, body);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function to generate a json file for year <-> grant count mapping
|
* function to generate a json file for year <-> grant count mapping
|
||||||
* @param vreq
|
* @param vreq
|
||||||
|
@ -293,8 +265,6 @@ public class EntityGrantCountRequestHandler implements
|
||||||
yearGrantCount.add(currentGrantYear);
|
yearGrantCount.add(currentGrantYear);
|
||||||
}
|
}
|
||||||
|
|
||||||
// log.info("entityJson.getLabel() : " + entityJson.getLabel() + " subOrganizationTypesResult " + subOrganizationTypesResult.toString());
|
|
||||||
|
|
||||||
entityJson.setYearToActivityCount(yearGrantCount);
|
entityJson.setYearToActivityCount(yearGrantCount);
|
||||||
entityJson.getOrganizationType().addAll(subOrganizationTypesResult.get(entityJson.getLabel()));
|
entityJson.getOrganizationType().addAll(subOrganizationTypesResult.get(entityJson.getLabel()));
|
||||||
|
|
||||||
|
@ -308,11 +278,9 @@ public class EntityGrantCountRequestHandler implements
|
||||||
entityJson.setVisMode("ORGANIZATION");
|
entityJson.setVisMode("ORGANIZATION");
|
||||||
}
|
}
|
||||||
|
|
||||||
// setEntityVisMode(entityJson);
|
|
||||||
subEntitiesJson.add(entityJson);
|
subEntitiesJson.add(entityJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
// System.out.println("\nStopWords are "+ EntitySubOrganizationTypesQueryRunner.stopWords.toString() + "\n");
|
|
||||||
return json.toJson(subEntitiesJson);
|
return json.toJson(subEntitiesJson);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,213 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.persongrantcount;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
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.Dataset;
|
|
||||||
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.Syntax;
|
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
|
||||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
|
||||||
|
|
||||||
public class PersonGrantCountConstructQueryRunner {
|
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
|
||||||
|
|
||||||
private String egoURI;
|
|
||||||
|
|
||||||
private Dataset Dataset;
|
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(PersonGrantCountConstructQueryRunner.class.getName());
|
|
||||||
|
|
||||||
public PersonGrantCountConstructQueryRunner(String egoURI, Dataset Dataset, Log log){
|
|
||||||
this.egoURI = egoURI;
|
|
||||||
this.Dataset = Dataset;
|
|
||||||
//this.log = log;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String generateConstructQueryForInvestigatorLabel(String queryURI) {
|
|
||||||
|
|
||||||
String sparqlQuery =
|
|
||||||
"CONSTRUCT { "
|
|
||||||
+ "<"+queryURI+ "> rdfs:label ?investigatorLabel ."
|
|
||||||
+ "}"
|
|
||||||
+ "WHERE {"
|
|
||||||
+ "<"+queryURI+ "> rdfs:label ?investigatorLabel "
|
|
||||||
+ "}";
|
|
||||||
|
|
||||||
return sparqlQuery;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String generateConstructQueryForInvestigatorGrants(String queryURI, String preboundProperty){
|
|
||||||
|
|
||||||
String sparqlQuery = ""
|
|
||||||
+ "CONSTRUCT { "
|
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
|
||||||
+ "?Role core:roleIn ?Grant ."
|
|
||||||
+ "?Grant rdfs:label ?GrantLabel "
|
|
||||||
+ "} "
|
|
||||||
+ "WHERE { "
|
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
|
||||||
+ "?Role core:roleIn ?Grant ."
|
|
||||||
+ "?Grant rdfs:label ?GrantLabel "
|
|
||||||
+ "} ";
|
|
||||||
|
|
||||||
return sparqlQuery;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private String generateConstructQueryForDateTimeValueofRole(String queryURI, String preboundProperty){
|
|
||||||
|
|
||||||
String sparqlQuery =
|
|
||||||
"CONSTRUCT { "
|
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
|
||||||
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
|
||||||
+ "?dateTimeIntervalValue core:start ?startDate . "
|
|
||||||
+ "?startDate core:dateTime ?startDateTimeValue . "
|
|
||||||
+ "?dateTimeIntervalValue core:end ?endDate . "
|
|
||||||
+ "?endDate core:dateTime ?endDateTimeValue . "
|
|
||||||
+ "}"
|
|
||||||
+ "WHERE { "
|
|
||||||
+ "{"
|
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
|
||||||
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
|
||||||
+ "?dateTimeIntervalValue core:start ?startDate . "
|
|
||||||
+ "?startDate core:dateTime ?startDateTimeValue . "
|
|
||||||
+ "} UNION "
|
|
||||||
+ "{"
|
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
|
||||||
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
|
||||||
+ "?dateTimeIntervalValue core:end ?endDate . "
|
|
||||||
+ "?endDate core:dateTime ?endDateTimeValue . "
|
|
||||||
+ "}"
|
|
||||||
+ "}";
|
|
||||||
|
|
||||||
return sparqlQuery;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String generateConstructQueryForDateTimeValueofGrant(String queryURI, String preboundProperty){
|
|
||||||
|
|
||||||
String sparqlQuery =
|
|
||||||
"CONSTRUCT { "
|
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
|
||||||
+ "?Role core:roleIn ?Grant ."
|
|
||||||
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
|
||||||
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
|
|
||||||
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
|
|
||||||
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
|
|
||||||
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant . "
|
|
||||||
+ "}"
|
|
||||||
+ "WHERE { "
|
|
||||||
+ "{"
|
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
|
||||||
+ "?Role core:roleIn ?Grant ."
|
|
||||||
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
|
||||||
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
|
|
||||||
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
|
|
||||||
+ "} UNION "
|
|
||||||
+ "{"
|
|
||||||
+ "<"+queryURI+ ">" + preboundProperty + " ?Role . "
|
|
||||||
+ "?Role core:roleIn ?Grant ."
|
|
||||||
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
|
||||||
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
|
|
||||||
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant . "
|
|
||||||
+ "}"
|
|
||||||
+ "}";
|
|
||||||
|
|
||||||
return sparqlQuery;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Model executeQuery(Set<String> constructQueries, Dataset Dataset) {
|
|
||||||
|
|
||||||
Model constructedModel = ModelFactory.createDefaultModel();
|
|
||||||
|
|
||||||
for (String queryString : constructQueries) {
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
log.debug("CONSTRUCT query string : " + queryString);
|
|
||||||
|
|
||||||
Query query = null;
|
|
||||||
|
|
||||||
try{
|
|
||||||
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + queryString, SYNTAX);
|
|
||||||
}catch(Throwable th){
|
|
||||||
log.error("Could not create CONSTRUCT SPARQL query for query " +
|
|
||||||
"string. " + th.getMessage());
|
|
||||||
log.error(queryString);
|
|
||||||
}
|
|
||||||
|
|
||||||
QueryExecution qe = QueryExecutionFactory.create(
|
|
||||||
query, Dataset);
|
|
||||||
try {
|
|
||||||
qe.execConstruct(constructedModel);
|
|
||||||
} finally {
|
|
||||||
qe.close();
|
|
||||||
}
|
|
||||||
log.debug("time to run construct: " + (System.currentTimeMillis() - start));
|
|
||||||
}
|
|
||||||
|
|
||||||
return constructedModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Model getConstructedModel()
|
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(this.egoURI)) {
|
|
||||||
/*
|
|
||||||
* To test for the validity of the URI submitted.
|
|
||||||
* */
|
|
||||||
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
|
|
||||||
IRI iri = iRIFactory.create(this.egoURI);
|
|
||||||
if (iri.hasViolation(false)) {
|
|
||||||
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
|
|
||||||
log.error("Person Grant Count Construct Query " + errorMsg);
|
|
||||||
throw new MalformedQueryParametersException(
|
|
||||||
"URI provided for an individual is malformed.");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new MalformedQueryParametersException("URI parameter is either null or empty.");
|
|
||||||
}
|
|
||||||
|
|
||||||
Set<String> constructQueries = new HashSet<String>();
|
|
||||||
|
|
||||||
populateConstructQueries(constructQueries);
|
|
||||||
|
|
||||||
Model model = executeQuery(constructQueries,
|
|
||||||
this.Dataset);
|
|
||||||
|
|
||||||
return model;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void populateConstructQueries(Set<String> constructQueries) {
|
|
||||||
|
|
||||||
constructQueries.add(generateConstructQueryForInvestigatorLabel(this.egoURI));
|
|
||||||
|
|
||||||
constructQueries.add(generateConstructQueryForInvestigatorGrants(this.egoURI, " core:hasInvestigatorRole "));
|
|
||||||
constructQueries.add(generateConstructQueryForDateTimeValueofRole(this.egoURI, " core:hasInvestigatorRole "));
|
|
||||||
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(this.egoURI, " core:hasInvestigatorRole "));
|
|
||||||
|
|
||||||
constructQueries.add(generateConstructQueryForInvestigatorGrants(this.egoURI, " core:hasPrincipalInvestigatorRole "));
|
|
||||||
constructQueries.add(generateConstructQueryForDateTimeValueofRole(this.egoURI, " core:hasPrincipalInvestigatorRole "));
|
|
||||||
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(this.egoURI, " core:hasPrincipalInvestigatorRole "));
|
|
||||||
|
|
||||||
constructQueries.add(generateConstructQueryForInvestigatorGrants(this.egoURI, " core:hasCo-PrincipalInvestigatorRole "));
|
|
||||||
constructQueries.add(generateConstructQueryForDateTimeValueofRole(this.egoURI, " core:hasCo-PrincipalInvestigatorRole "));
|
|
||||||
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(this.egoURI, " core:hasCo-PrincipalInvestigatorRole "));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -29,6 +29,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.personpubcount.
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.personpubcount.PersonPublicationCountVisCodeGenerator;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.personpubcount.PersonPublicationCountVisCodeGenerator;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Activity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Activity;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SparklineData;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SparklineData;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.ModelConstructor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.QueryRunner;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.QueryRunner;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
|
||||||
|
@ -80,7 +81,7 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
|
||||||
|
|
||||||
if (VisualizationFrameworkConstants.COPI_VIS_MODE.equalsIgnoreCase(visMode)){
|
if (VisualizationFrameworkConstants.COPI_VIS_MODE.equalsIgnoreCase(visMode)){
|
||||||
|
|
||||||
CoPIGrantCountConstructQueryRunner constructQueryRunner = new CoPIGrantCountConstructQueryRunner(egoURI, Dataset, log);
|
ModelConstructor constructQueryRunner = new CoPIGrantCountConstructQueryRunner(egoURI, Dataset, log);
|
||||||
Model constructedModel = constructQueryRunner.getConstructedModel();
|
Model constructedModel = constructQueryRunner.getConstructedModel();
|
||||||
|
|
||||||
QueryRunner<CollaborationData> coPIQueryManager = new CoPIGrantCountQueryRunner(egoURI, constructedModel, log);
|
QueryRunner<CollaborationData> coPIQueryManager = new CoPIGrantCountQueryRunner(egoURI, constructedModel, log);
|
||||||
|
|
|
@ -45,7 +45,7 @@ VisualizationRequestHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log,
|
public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log,
|
||||||
Dataset Dataset) throws MalformedQueryParametersException {
|
Dataset dataset) throws MalformedQueryParametersException {
|
||||||
|
|
||||||
String personURI = vitroRequest
|
String personURI = vitroRequest
|
||||||
.getParameter(
|
.getParameter(
|
||||||
|
@ -61,7 +61,7 @@ VisualizationRequestHandler {
|
||||||
|
|
||||||
QueryRunner<Set<Activity>> queryManager = new PersonPublicationCountQueryRunner(
|
QueryRunner<Set<Activity>> queryManager = new PersonPublicationCountQueryRunner(
|
||||||
personURI,
|
personURI,
|
||||||
Dataset,
|
dataset,
|
||||||
log);
|
log);
|
||||||
|
|
||||||
Set<Activity> authorDocuments = queryManager.getQueryResult();
|
Set<Activity> authorDocuments = queryManager.getQueryResult();
|
||||||
|
@ -97,14 +97,14 @@ VisualizationRequestHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> generateDataVisualization(VitroRequest vitroRequest, Log log,
|
public Map<String, String> generateDataVisualization(VitroRequest vitroRequest, Log log,
|
||||||
Dataset Dataset) throws MalformedQueryParametersException {
|
Dataset dataset) throws MalformedQueryParametersException {
|
||||||
|
|
||||||
String personURI = vitroRequest
|
String personURI = vitroRequest
|
||||||
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
|
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
|
||||||
|
|
||||||
QueryRunner<Set<Activity>> queryManager = new PersonPublicationCountQueryRunner(
|
QueryRunner<Set<Activity>> queryManager = new PersonPublicationCountQueryRunner(
|
||||||
personURI,
|
personURI,
|
||||||
Dataset,
|
dataset,
|
||||||
log);
|
log);
|
||||||
|
|
||||||
Set<Activity> authorDocuments = queryManager.getQueryResult();
|
Set<Activity> authorDocuments = queryManager.getQueryResult();
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||||
|
|
||||||
|
public interface ModelConstructor {
|
||||||
|
|
||||||
|
Model getConstructedModel() throws MalformedQueryParametersException;
|
||||||
|
|
||||||
|
}
|
|
@ -5,7 +5,6 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.DataSource;
|
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
@ -22,7 +21,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryP
|
||||||
*
|
*
|
||||||
* @author cdtank
|
* @author cdtank
|
||||||
*/
|
*/
|
||||||
public interface VisualizationRequestHandler{
|
public interface VisualizationRequestHandler {
|
||||||
|
|
||||||
ResponseValues generateStandardVisualization(VitroRequest vitroRequest,
|
ResponseValues generateStandardVisualization(VitroRequest vitroRequest,
|
||||||
Log log,
|
Log log,
|
||||||
|
@ -34,6 +33,6 @@ public interface VisualizationRequestHandler{
|
||||||
|
|
||||||
Map<String, String> generateDataVisualization(VitroRequest vitroRequest,
|
Map<String, String> generateDataVisualization(VitroRequest vitroRequest,
|
||||||
Log log,
|
Log log,
|
||||||
Dataset dataSource) throws MalformedQueryParametersException;
|
Dataset dataset) throws MalformedQueryParametersException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue