[VIVO-1031] Convert Co-Investigator graph to RDFService
This commit is contained in:
parent
d5b3058f44
commit
2519914833
4 changed files with 65 additions and 197 deletions
|
@ -1,9 +1,13 @@
|
||||||
/* $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.coprincipalinvestigator;
|
package edu.cornell.mannlib.vitro.webapp.visualization.coprincipalinvestigator;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
||||||
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 org.apache.commons.logging.LogFactory;
|
||||||
|
@ -30,7 +34,7 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
|
||||||
|
|
||||||
private String egoURI;
|
private String egoURI;
|
||||||
|
|
||||||
private Dataset dataset;
|
private RDFService rdfService;
|
||||||
|
|
||||||
private long before, after;
|
private long before, after;
|
||||||
|
|
||||||
|
@ -42,10 +46,9 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
|
||||||
+ "?Grant rdf:type core:Grant ."
|
+ "?Grant rdf:type core:Grant ."
|
||||||
+ "?Grant core:relates ?RelatedRole . ";
|
+ "?Grant core:relates ?RelatedRole . ";
|
||||||
|
|
||||||
public CoPIGrantCountConstructQueryRunner(String egoURI, Dataset dataset,
|
public CoPIGrantCountConstructQueryRunner(String egoURI, RDFService rdfService, Log log) {
|
||||||
Log log) {
|
|
||||||
this.egoURI = egoURI;
|
this.egoURI = egoURI;
|
||||||
this.dataset = dataset;
|
this.rdfService = rdfService;
|
||||||
// this.log = log;
|
// this.log = log;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,38 +223,29 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
|
||||||
return sparqlQuery;
|
return sparqlQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Model executeQuery(Set<String> constructQueries, Dataset dataset) {
|
private Model executeQuery(Set<String> constructQueries, RDFService rdfService) {
|
||||||
|
|
||||||
Model constructedModel = ModelFactory.createDefaultModel();
|
Model constructedModel = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
for (String queryString : constructQueries) {
|
for (String queryString : constructQueries) {
|
||||||
|
|
||||||
before = System.currentTimeMillis();
|
before = System.currentTimeMillis();
|
||||||
|
|
||||||
log.debug("CONSTRUCT query string : " + queryString);
|
log.debug("CONSTRUCT query string : " + queryString);
|
||||||
|
|
||||||
Query query = null;
|
InputStream is = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
query = QueryFactory.create(
|
is = rdfService.sparqlConstructQuery(QueryConstants.getSparqlPrefixQuery() + queryString, RDFService.ModelSerializationFormat.N3);
|
||||||
QueryConstants.getSparqlPrefixQuery() + queryString,
|
constructedModel.read(is, null, RDFServiceUtils.getSerializationFormatString(RDFService.ModelSerializationFormat.N3));
|
||||||
SYNTAX);
|
} catch (RDFServiceException e) {
|
||||||
} catch (Throwable th) {
|
log.error("Unable to execute query", e);
|
||||||
log.error("Could not create CONSTRUCT SPARQL query for query "
|
throw new RuntimeException(e);
|
||||||
+ "string. " + th.getMessage());
|
|
||||||
log.error(queryString);
|
|
||||||
}
|
|
||||||
|
|
||||||
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
|
|
||||||
try {
|
|
||||||
qe.execConstruct(constructedModel);
|
|
||||||
} finally {
|
} finally {
|
||||||
qe.close();
|
if (is != null) {
|
||||||
|
try { is.close(); } catch (Throwable t) { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
after = System.currentTimeMillis();
|
after = System.currentTimeMillis();
|
||||||
log.debug("Time taken to execute the CONSTRUCT query is in milliseconds: "
|
log.debug("Time taken to execute the CONSTRUCT query is in milliseconds: " + (after - before));
|
||||||
+ (after - before));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +276,7 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
|
||||||
|
|
||||||
populateConstructQueries(constructQueries);
|
populateConstructQueries(constructQueries);
|
||||||
|
|
||||||
Model model = executeQuery(constructQueries, this.dataset);
|
Model model = executeQuery(constructQueries, this.rdfService);
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.coprincipalinvestigator;
|
package edu.cornell.mannlib.vitro.webapp.visualization.coprincipalinvestigator;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -12,6 +13,9 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.query.ResultSetFactory;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||||
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 org.apache.commons.logging.LogFactory;
|
||||||
|
@ -52,7 +56,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
|
||||||
|
|
||||||
private String egoURI;
|
private String egoURI;
|
||||||
|
|
||||||
private Model dataSource;
|
private RDFService rdfService;
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(CoPIGrantCountQueryRunner.class.getName());
|
private Log log = LogFactory.getLog(CoPIGrantCountQueryRunner.class.getName());
|
||||||
|
|
||||||
|
@ -86,10 +90,10 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
|
||||||
|
|
||||||
|
|
||||||
public CoPIGrantCountQueryRunner(String egoURI,
|
public CoPIGrantCountQueryRunner(String egoURI,
|
||||||
Model dataSource, Log log) {
|
RDFService rdfService, Log log) {
|
||||||
|
|
||||||
this.egoURI = egoURI;
|
this.egoURI = egoURI;
|
||||||
this.dataSource = dataSource;
|
this.rdfService = rdfService;
|
||||||
// this.log = log;
|
// this.log = log;
|
||||||
|
|
||||||
this.nodeIDGenerator = new UniqueIDGenerator();
|
this.nodeIDGenerator = new UniqueIDGenerator();
|
||||||
|
@ -114,276 +118,134 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
|
||||||
+ "{ "
|
+ "{ "
|
||||||
+ "<" + queryURI + "> rdfs:label ?PILabel . "
|
+ "<" + queryURI + "> rdfs:label ?PILabel . "
|
||||||
+ "{ "
|
+ "{ "
|
||||||
|
|
||||||
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
|
|
||||||
+ "?Role rdf:type core:CoPrincipalInvestigatorRole . "
|
+ "?Role rdf:type core:CoPrincipalInvestigatorRole . "
|
||||||
|
|
||||||
+ "?Role core:relatedBy ?Grant . "
|
+ "?Role core:relatedBy ?Grant . "
|
||||||
|
|
||||||
+ "?Grant rdf:type core:Grant . "
|
+ "?Grant rdf:type core:Grant . "
|
||||||
|
|
||||||
+ "?Grant core:relates ?RelatedRole . "
|
+ "?Grant core:relates ?RelatedRole . "
|
||||||
|
+ "?RelatedRole rdf:type core:PrincipalInvestigatorRole . "
|
||||||
+ "?RelatedRole rdf:type core:PrincipalInvestigatorRole . "
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
||||||
|
|
||||||
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
|
||||||
|
|
||||||
+ "?CoPI rdf:type foaf:Person . "
|
+ "?CoPI rdf:type foaf:Person . "
|
||||||
|
|
||||||
+ "?CoPI rdfs:label ?CoPILabel . "
|
+ "?CoPI rdfs:label ?CoPILabel . "
|
||||||
|
|
||||||
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
|
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
|
||||||
|
|
||||||
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME
|
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME
|
||||||
|
|
||||||
+ "} "
|
+ "} "
|
||||||
|
|
||||||
+ "UNION "
|
+ "UNION "
|
||||||
|
|
||||||
+ "{ "
|
+ "{ "
|
||||||
|
|
||||||
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
|
|
||||||
+ "?Role rdf:type core:CoPrincipalInvestigatorRole . "
|
+ "?Role rdf:type core:CoPrincipalInvestigatorRole . "
|
||||||
|
|
||||||
+ "?Role core:relatedBy ?Grant . "
|
+ "?Role core:relatedBy ?Grant . "
|
||||||
|
|
||||||
+ "?Grant rdf:type core:Grant . "
|
+ "?Grant rdf:type core:Grant . "
|
||||||
|
|
||||||
+ "?Grant core:relates ?RelatedRole . "
|
+ "?Grant core:relates ?RelatedRole . "
|
||||||
|
+ "?RelatedRole rdf:type core:InvestigatorRole . "
|
||||||
+ "?RelatedRole rdf:type core:InvestigatorRole . "
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
||||||
|
|
||||||
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
|
||||||
|
|
||||||
+ "?CoPI rdf:type foaf:Person . "
|
+ "?CoPI rdf:type foaf:Person . "
|
||||||
|
|
||||||
+ "?CoPI rdfs:label ?CoPILabel . "
|
+ "?CoPI rdfs:label ?CoPILabel . "
|
||||||
|
|
||||||
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
|
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
|
||||||
|
|
||||||
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME
|
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME
|
||||||
|
|
||||||
|
|
||||||
+ "} "
|
+ "} "
|
||||||
|
|
||||||
+ "UNION "
|
+ "UNION "
|
||||||
|
|
||||||
+ "{ "
|
+ "{ "
|
||||||
|
|
||||||
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
|
|
||||||
+ "?Role rdf:type core:CoPrincipalInvestigatorRole . "
|
+ "?Role rdf:type core:CoPrincipalInvestigatorRole . "
|
||||||
|
|
||||||
+ "?Role core:relatedBy ?Grant . "
|
+ "?Role core:relatedBy ?Grant . "
|
||||||
|
|
||||||
+ "?Grant rdf:type core:Grant . "
|
+ "?Grant rdf:type core:Grant . "
|
||||||
|
|
||||||
+ "?Grant core:relates ?RelatedRole . "
|
+ "?Grant core:relates ?RelatedRole . "
|
||||||
|
+ "?RelatedRole rdf:type core:CoPrincipalInvestigatorRole . "
|
||||||
+ "?RelatedRole rdf:type core:CoPrincipalInvestigatorRole . "
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
||||||
|
|
||||||
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
|
||||||
|
|
||||||
+ "?CoPI rdf:type foaf:Person . "
|
+ "?CoPI rdf:type foaf:Person . "
|
||||||
|
|
||||||
+ "?CoPI rdfs:label ?CoPILabel . "
|
+ "?CoPI rdfs:label ?CoPILabel . "
|
||||||
|
|
||||||
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
|
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
|
||||||
|
|
||||||
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME
|
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME
|
||||||
|
|
||||||
|
|
||||||
+ "} "
|
+ "} "
|
||||||
|
|
||||||
+ "UNION "
|
+ "UNION "
|
||||||
|
|
||||||
|
|
||||||
+ "{ "
|
+ "{ "
|
||||||
|
|
||||||
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
|
|
||||||
+ "?Role rdf:type core:PrincipalInvestigatorRole . "
|
+ "?Role rdf:type core:PrincipalInvestigatorRole . "
|
||||||
|
|
||||||
+ "?Role core:relatedBy ?Grant . "
|
+ "?Role core:relatedBy ?Grant . "
|
||||||
|
|
||||||
+ "?Grant rdf:type core:Grant . "
|
+ "?Grant rdf:type core:Grant . "
|
||||||
|
|
||||||
+ "?Grant core:relates ?RelatedRole . "
|
+ "?Grant core:relates ?RelatedRole . "
|
||||||
|
+ "?RelatedRole rdf:type core:PrincipalInvestigatorRole . "
|
||||||
+ "?RelatedRole rdf:type core:PrincipalInvestigatorRole . "
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
||||||
|
+ "?CoPI rdf:type foaf:Person . "
|
||||||
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
|
||||||
|
|
||||||
+ "?CoPI rdf:type foaf:Person . "
|
|
||||||
|
|
||||||
+ "?CoPI rdfs:label ?CoPILabel . "
|
+ "?CoPI rdfs:label ?CoPILabel . "
|
||||||
|
|
||||||
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
|
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
|
||||||
|
|
||||||
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME
|
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME
|
||||||
|
|
||||||
|
|
||||||
+ "} "
|
+ "} "
|
||||||
|
|
||||||
+ "UNION "
|
+ "UNION "
|
||||||
|
|
||||||
+ "{ "
|
+ "{ "
|
||||||
|
|
||||||
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
|
|
||||||
+ "?Role rdf:type core:PrincipalInvestigatorRole . "
|
+ "?Role rdf:type core:PrincipalInvestigatorRole . "
|
||||||
|
|
||||||
+ "?Role core:relatedBy ?Grant . "
|
+ "?Role core:relatedBy ?Grant . "
|
||||||
|
|
||||||
+ "?Grant rdf:type core:Grant . "
|
+ "?Grant rdf:type core:Grant . "
|
||||||
|
|
||||||
+ "?Grant core:relates ?RelatedRole . "
|
+ "?Grant core:relates ?RelatedRole . "
|
||||||
|
+ "?RelatedRole rdf:type core:InvestigatorRole . "
|
||||||
+ "?RelatedRole rdf:type core:InvestigatorRole . "
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
||||||
|
|
||||||
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
|
||||||
|
|
||||||
+ "?CoPI rdf:type foaf:Person . "
|
+ "?CoPI rdf:type foaf:Person . "
|
||||||
|
|
||||||
+ "?CoPI rdfs:label ?CoPILabel . "
|
+ "?CoPI rdfs:label ?CoPILabel . "
|
||||||
|
|
||||||
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
|
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
|
||||||
|
|
||||||
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME
|
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME
|
||||||
|
|
||||||
|
|
||||||
+ "} "
|
+ "} "
|
||||||
|
|
||||||
+ "UNION "
|
+ "UNION "
|
||||||
|
|
||||||
+ "{ "
|
+ "{ "
|
||||||
|
|
||||||
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
|
|
||||||
+ "?Role rdf:type core:PrincipalInvestigatorRole . "
|
+ "?Role rdf:type core:PrincipalInvestigatorRole . "
|
||||||
|
|
||||||
+ "?Role core:relatedBy ?Grant . "
|
+ "?Role core:relatedBy ?Grant . "
|
||||||
|
|
||||||
+ "?Grant rdf:type core:Grant . "
|
+ "?Grant rdf:type core:Grant . "
|
||||||
|
|
||||||
+ "?Grant core:relates ?RelatedRole . "
|
+ "?Grant core:relates ?RelatedRole . "
|
||||||
|
+ "?RelatedRole rdf:type core:CoPrincipalInvestigatorRole . "
|
||||||
+ "?RelatedRole rdf:type core:CoPrincipalInvestigatorRole . "
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
||||||
|
|
||||||
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
|
||||||
|
|
||||||
+ "?CoPI rdf:type foaf:Person . "
|
+ "?CoPI rdf:type foaf:Person . "
|
||||||
|
|
||||||
+ "?CoPI rdfs:label ?CoPILabel . "
|
+ "?CoPI rdfs:label ?CoPILabel . "
|
||||||
|
|
||||||
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
|
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
|
||||||
|
|
||||||
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME
|
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME
|
||||||
|
|
||||||
|
|
||||||
+ "} "
|
+ "} "
|
||||||
|
|
||||||
+ "UNION "
|
+ "UNION "
|
||||||
|
|
||||||
+ "{ "
|
+ "{ "
|
||||||
|
|
||||||
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
|
|
||||||
+ "?Role rdf:type core:InvestigatorRole . "
|
+ "?Role rdf:type core:InvestigatorRole . "
|
||||||
|
|
||||||
+ "?Role core:relatedBy ?Grant . "
|
+ "?Role core:relatedBy ?Grant . "
|
||||||
|
|
||||||
+ "?Grant rdf:type core:Grant . "
|
+ "?Grant rdf:type core:Grant . "
|
||||||
|
|
||||||
+ "?Grant core:relates ?RelatedRole . "
|
+ "?Grant core:relates ?RelatedRole . "
|
||||||
|
+ "?RelatedRole rdf:type core:InvestigatorRole . "
|
||||||
+ "?RelatedRole rdf:type core:InvestigatorRole . "
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
||||||
|
|
||||||
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
|
||||||
|
|
||||||
+ "?CoPI rdf:type foaf:Person . "
|
+ "?CoPI rdf:type foaf:Person . "
|
||||||
|
|
||||||
+ "?CoPI rdfs:label ?CoPILabel . "
|
+ "?CoPI rdfs:label ?CoPILabel . "
|
||||||
|
|
||||||
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
|
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
|
||||||
|
|
||||||
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME
|
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME
|
||||||
|
|
||||||
|
|
||||||
+ "} "
|
+ "} "
|
||||||
|
|
||||||
+ "UNION "
|
+ "UNION "
|
||||||
|
|
||||||
+ "{ "
|
+ "{ "
|
||||||
|
|
||||||
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
|
|
||||||
+ "?Role rdf:type core:InvestigatorRole . "
|
+ "?Role rdf:type core:InvestigatorRole . "
|
||||||
|
|
||||||
+ "?Role core:relatedBy ?Grant . "
|
+ "?Role core:relatedBy ?Grant . "
|
||||||
|
|
||||||
+ "?Grant rdf:type core:Grant . "
|
+ "?Grant rdf:type core:Grant . "
|
||||||
|
|
||||||
+ "?Grant core:relates ?RelatedRole . "
|
+ "?Grant core:relates ?RelatedRole . "
|
||||||
|
+ "?RelatedRole rdf:type core:CoPrincipalInvestigatorRole . "
|
||||||
+ "?RelatedRole rdf:type core:CoPrincipalInvestigatorRole . "
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
||||||
|
|
||||||
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
|
||||||
|
|
||||||
+ "?CoPI rdf:type foaf:Person . "
|
+ "?CoPI rdf:type foaf:Person . "
|
||||||
|
|
||||||
+ "?CoPI rdfs:label ?CoPILabel . "
|
+ "?CoPI rdfs:label ?CoPILabel . "
|
||||||
|
|
||||||
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
|
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
|
||||||
|
|
||||||
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME
|
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME
|
||||||
|
|
||||||
|
|
||||||
+ "} "
|
+ "} "
|
||||||
|
|
||||||
+ "UNION "
|
+ "UNION "
|
||||||
|
|
||||||
+ "{ "
|
+ "{ "
|
||||||
|
|
||||||
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
|
|
||||||
+ "?Role rdf:type core:InvestigatorRole . "
|
+ "?Role rdf:type core:InvestigatorRole . "
|
||||||
|
|
||||||
+ "?Role core:relatedBy ?Grant . "
|
+ "?Role core:relatedBy ?Grant . "
|
||||||
|
|
||||||
+ "?Grant rdf:type core:Grant . "
|
+ "?Grant rdf:type core:Grant . "
|
||||||
|
|
||||||
+ "?Grant core:relates ?RelatedRole . "
|
+ "?Grant core:relates ?RelatedRole . "
|
||||||
|
+ "?RelatedRole rdf:type core:PrincipalInvestigatorRole . "
|
||||||
+ "?RelatedRole rdf:type core:PrincipalInvestigatorRole . "
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
||||||
|
|
||||||
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
|
||||||
|
|
||||||
+ "?CoPI rdf:type foaf:Person . "
|
+ "?CoPI rdf:type foaf:Person . "
|
||||||
|
|
||||||
+ "?CoPI rdfs:label ?CoPILabel . "
|
+ "?CoPI rdfs:label ?CoPILabel . "
|
||||||
|
|
||||||
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
|
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
|
||||||
|
|
||||||
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME
|
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME
|
||||||
|
+ "} "
|
||||||
|
|
||||||
+ "} "
|
|
||||||
+ "} ";
|
+ "} ";
|
||||||
return sparqlQuery;
|
return sparqlQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResultSet executeQuery(String queryText, Model dataSource) {
|
|
||||||
|
|
||||||
QueryExecution queryExecution = null;
|
|
||||||
Query query = QueryFactory.create(queryText, SYNTAX);
|
|
||||||
|
|
||||||
queryExecution = QueryExecutionFactory.create(query, dataSource);
|
|
||||||
return queryExecution.execSelect();
|
|
||||||
}
|
|
||||||
|
|
||||||
public CollaborationData getQueryResult()
|
public CollaborationData getQueryResult()
|
||||||
throws MalformedQueryParametersException {
|
throws MalformedQueryParametersException {
|
||||||
|
|
||||||
|
@ -431,13 +293,25 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
|
||||||
}
|
}
|
||||||
|
|
||||||
before = System.currentTimeMillis();
|
before = System.currentTimeMillis();
|
||||||
ResultSet resultSet = executeQuery(generateEgoCoPIquery(this.egoURI), this.dataSource);
|
|
||||||
|
InputStream is = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
try {
|
||||||
|
is = rdfService.sparqlSelectQuery(generateEgoCoPIquery(this.egoURI), RDFService.ResultFormat.JSON);
|
||||||
|
rs = ResultSetFactory.fromJSON(is);
|
||||||
|
data = createQueryResult(rs);
|
||||||
|
} catch (RDFServiceException e) {
|
||||||
|
log.error("Unable to execute query", e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
if (is != null) {
|
||||||
|
try { is.close(); } catch (Throwable t) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
after = System.currentTimeMillis();
|
after = System.currentTimeMillis();
|
||||||
|
|
||||||
log.debug("Time taken to execute the SELECT queries is in milliseconds: " + (after - before));
|
log.debug("Time taken to execute the SELECT queries is in milliseconds: " + (after - before));
|
||||||
|
|
||||||
data = createQueryResult(resultSet);
|
|
||||||
|
|
||||||
CollaborationDataCacheEntry newEntry = new CollaborationDataCacheEntry();
|
CollaborationDataCacheEntry newEntry = new CollaborationDataCacheEntry();
|
||||||
|
|
||||||
newEntry.uri = this.egoURI;
|
newEntry.uri = this.egoURI;
|
||||||
|
|
|
@ -54,11 +54,11 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
|
||||||
String visMode = vitroRequest.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY);
|
String visMode = vitroRequest.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY);
|
||||||
|
|
||||||
ModelConstructor constructQueryRunner =
|
ModelConstructor constructQueryRunner =
|
||||||
new CoPIGrantCountConstructQueryRunner(egoURI, dataset, log);
|
new CoPIGrantCountConstructQueryRunner(egoURI, vitroRequest.getRDFService(), log);
|
||||||
Model constructedModel = constructQueryRunner.getConstructedModel();
|
Model constructedModel = constructQueryRunner.getConstructedModel();
|
||||||
|
|
||||||
QueryRunner<CollaborationData> queryManager =
|
QueryRunner<CollaborationData> queryManager =
|
||||||
new CoPIGrantCountQueryRunner(egoURI, constructedModel, log);
|
new CoPIGrantCountQueryRunner(egoURI, vitroRequest.getRDFService(), log);
|
||||||
|
|
||||||
CollaborationData investigatorNodesAndEdges = queryManager.getQueryResult();
|
CollaborationData investigatorNodesAndEdges = queryManager.getQueryResult();
|
||||||
|
|
||||||
|
|
|
@ -104,11 +104,11 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
|
||||||
|
|
||||||
|
|
||||||
ModelConstructor constructQueryRunner =
|
ModelConstructor constructQueryRunner =
|
||||||
new CoPIGrantCountConstructQueryRunner(egoURI, dataset, log);
|
new CoPIGrantCountConstructQueryRunner(egoURI, vitroRequest.getRDFService(), log);
|
||||||
Model constructedModel = constructQueryRunner.getConstructedModel();
|
Model constructedModel = constructQueryRunner.getConstructedModel();
|
||||||
|
|
||||||
QueryRunner<CollaborationData> coPIQueryManager =
|
QueryRunner<CollaborationData> coPIQueryManager =
|
||||||
new CoPIGrantCountQueryRunner(egoURI, constructedModel, log);
|
new CoPIGrantCountQueryRunner(egoURI, vitroRequest.getRDFService(), log);
|
||||||
|
|
||||||
CollaborationData coPIData = coPIQueryManager.getQueryResult();
|
CollaborationData coPIData = coPIQueryManager.getQueryResult();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue