Removed publication_year_using_1_1_property from the queries for better response times with visualizations and fixed the issue with publications with unknown dates not appearing with temporal vis for publications.

This commit is contained in:
bkoniden 2011-02-11 19:47:28 +00:00
parent ad3497d0bc
commit e41a4522f7
8 changed files with 310 additions and 410 deletions

View file

@ -361,21 +361,6 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
BiboDocument biboDocument = new BiboDocument(documentURL);
RDFNode documentLabelNode = solution.get(QueryFieldLabels.DOCUMENT_LABEL);
if (documentLabelNode != null) {
biboDocument.setDocumentLabel(documentLabelNode.toString());
}
RDFNode documentBlurbNode = solution.get(QueryFieldLabels.DOCUMENT_BLURB);
if (documentBlurbNode != null) {
biboDocument.setDocumentBlurb(documentBlurbNode.toString());
}
RDFNode documentMonikerNode = solution.get(QueryFieldLabels.DOCUMENT_MONIKER);
if (documentMonikerNode != null) {
biboDocument.setDocumentMoniker(documentMonikerNode.toString());
}
RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
if (publicationDateNode != null) {
biboDocument.setPublicationDate(publicationDateNode.toString());
@ -384,10 +369,10 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
/*
* This is being used so that date in the data from pre-1.2 ontology can be captured.
* */
RDFNode publicationYearUsing_1_1_PropertyNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY);
if (publicationYearUsing_1_1_PropertyNode != null) {
biboDocument.setPublicationYear(publicationYearUsing_1_1_PropertyNode.toString());
}
// RDFNode publicationYearUsing_1_1_PropertyNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY);
// if (publicationYearUsing_1_1_PropertyNode != null) {
// biboDocument.setPublicationYear(publicationYearUsing_1_1_PropertyNode.toString());
// }
return biboDocument;
}
@ -412,31 +397,24 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
+ " (str(?coAuthorPerson) as ?" + QueryFieldLabels.CO_AUTHOR_URL + ") \n"
+ " (str(?coAuthorPersonLabel) as ?" + QueryFieldLabels.CO_AUTHOR_LABEL + ") \n"
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n"
+ " (str(?documentLabel) as ?" + QueryFieldLabels.DOCUMENT_LABEL + ") \n"
+ " (str(?documentMoniker) as ?" + QueryFieldLabels.DOCUMENT_MONIKER + ") \n"
+ " (str(?documentBlurb) as ?" + QueryFieldLabels.DOCUMENT_BLURB + ") \n"
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") \n"
+ " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") \n"
// + " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") \n"
+ "WHERE { \n"
+ "<" + queryURI + "> rdf:type foaf:Person ;"
+ " rdfs:label ?authorLabel ;"
+ " core:authorInAuthorship ?authorshipNode . \n"
+ "?authorshipNode rdf:type core:Authorship ;"
+ " core:linkedInformationResource ?document . \n"
+ "?document rdfs:label ?documentLabel . \n"
+ "?document core:informationResourceInAuthorship ?coAuthorshipNode . \n"
+ "?coAuthorshipNode core:linkedAuthor ?coAuthorPerson . \n"
+ "?coAuthorPerson rdfs:label ?coAuthorPersonLabel . \n"
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n"
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n"
+ "OPTIONAL { ?document core:year ?publicationYearUsing_1_1_property } .\n"
+ "OPTIONAL { ?document vitro:moniker ?documentMoniker } . \n"
+ "OPTIONAL { ?document vitro:blurb ?documentBlurb } . \n"
+ "OPTIONAL { ?document vitro:description ?documentDescription } \n"
// + "OPTIONAL { ?document core:year ?publicationYearUsing_1_1_property } .\n"
+ "} \n"
+ "ORDER BY ?document ?coAuthorPerson\n";
// System.out.println("COAUTHORSHIP QUERY - " + sparqlQuery);
log.debug("COAUTHORSHIP QUERY - " + sparqlQuery);
return sparqlQuery;
}

View file

@ -67,18 +67,33 @@ public class EntityPublicationCountConstructQueryRunner {
+ "?Person rdfs:label ?PersonLabel . "
+ "?Resource core:linkedInformationResource ?Document . "
+ "?Document rdf:type bibo:Document . "
+ "?Document rdfs:label ?DocumentLabel "
+ "?Document rdfs:label ?DocumentLabel . "
+ "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate . "
// + "?Document core:year ?publicationYearUsing_1_1_property "
+"}"
+ "WHERE { "
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization rdfs:label ?subOrganizationLabel . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person core:authorInAuthorship ?Resource . "
+ "?Person rdfs:label ?PersonLabel . "
+ "?Resource core:linkedInformationResource ?Document . "
+ "?Document rdf:type bibo:Document . "
+ "?Document rdfs:label ?DocumentLabel "
+ "{"
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization rdfs:label ?subOrganizationLabel . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person core:authorInAuthorship ?Resource . "
+ "?Person rdfs:label ?PersonLabel . "
+ "?Resource core:linkedInformationResource ?Document . "
// + "?Document rdf:type bibo:Document . "
+ "?Document rdfs:label ?DocumentLabel "
+ "}"
+ "UNION "
+ "{"
+ "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate "
+ "}"
// + "UNION "
// + "{"
// + "?Document core:year ?publicationYearUsing_1_1_property "
// + "}"
+ "}" ;
@ -97,16 +112,31 @@ public class EntityPublicationCountConstructQueryRunner {
+ "?Person rdfs:label ?PersonLabel . "
+ "?Resource core:linkedInformationResource ?Document . "
+ "?Document rdf:type bibo:Document . "
+ "?Document rdfs:label ?DocumentLabel "
+ "?Document rdfs:label ?DocumentLabel . "
+ "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate . "
// + "?Document core:year ?publicationYearUsing_1_1_property ."
+"}"
+ "WHERE { "
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person core:authorInAuthorship ?Resource . "
+ "?Person rdfs:label ?PersonLabel . "
+ "?Resource core:linkedInformationResource ?Document . "
+ "?Document rdf:type bibo:Document . "
+ "?Document rdfs:label ?DocumentLabel "
+ "{"
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person core:authorInAuthorship ?Resource . "
+ "?Person rdfs:label ?PersonLabel . "
+ "?Resource core:linkedInformationResource ?Document . "
// + "?Document rdf:type bibo:Document . "
+ "?Document rdfs:label ?DocumentLabel "
+ "}"
+ "UNION"
+ "{"
+ "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate "
+ "}"
// + "UNION "
// + "{"
// + "?Document core:year ?publicationYearUsing_1_1_property "
// + "}"
+ "}" ;
@ -114,93 +144,90 @@ public class EntityPublicationCountConstructQueryRunner {
}
private String generateConstructQueryForDocumentDateTimeValueOneLevelDeep(String queryURI){
String sparqlQuery =
"CONSTRUCT { "
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person core:authorInAuthorship ?Resource . "
+ "?Resource core:linkedInformationResource ?Document . "
+ "?Document rdf:type bibo:Document . "
+ "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate . "
+ "?Document core:year ?publicationYearUsing_1_1_property "
+"}"
+ "WHERE { "
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person core:authorInAuthorship ?Resource . "
+ "?Resource core:linkedInformationResource ?Document . "
+ "?Document rdf:type bibo:Document . "
+ "{"
+ "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate "
+ "}"
+ "UNION "
+ "{"
+ "?Document core:year ?publicationYearUsing_1_1_property "
+ "}"
+ "}" ;
return sparqlQuery;
// private String generateConstructQueryForDocumentDateTimeValueOneLevelDeep(String queryURI){
//
// String sparqlQuery =
//
// "CONSTRUCT { "
// + "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
// + "?subOrganization core:organizationForPosition ?Position . "
// + "?Position core:positionForPerson ?Person . "
// + "?Person core:authorInAuthorship ?Resource . "
// + "?Resource core:linkedInformationResource ?Document . "
// + "?Document rdf:type bibo:Document . "
// + "?Document core:dateTimeValue ?dateTimeValue . "
// + "?dateTimeValue core:dateTime ?publicationDate . "
// + "?Document core:year ?publicationYearUsing_1_1_property "
// +"}"
// + "WHERE { "
// + "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
// + "?subOrganization core:organizationForPosition ?Position . "
// + "?Position core:positionForPerson ?Person . "
// + "?Person core:authorInAuthorship ?Resource . "
// + "?Resource core:linkedInformationResource ?Document . "
// + "?Document rdf:type bibo:Document . "
// + "{"
// + "?Document core:dateTimeValue ?dateTimeValue . "
// + "?dateTimeValue core:dateTime ?publicationDate "
// + "}"
// + "UNION "
// + "{"
// + "?Document core:year ?publicationYearUsing_1_1_property "
// + "}"
// + "}" ;
//
//
// return sparqlQuery;
//
// }
}
private String generateConstructQueryForDocumentDateTimeValue(String queryURI){
String sparqlQuery =
"CONSTRUCT { "
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person core:authorInAuthorship ?Resource . "
+ "?Resource core:linkedInformationResource ?Document . "
+ "?Document rdf:type bibo:Document . "
+ "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate . "
+ "?Document core:year ?publicationYearUsing_1_1_property "
+"}"
+ "WHERE { "
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person core:authorInAuthorship ?Resource . "
+ "?Resource core:linkedInformationResource ?Document . "
+ "?Document rdf:type bibo:Document . "
+ "{"
+ "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate "
+ "}"
+ "UNION "
+ "{"
+ "?Document core:year ?publicationYearUsing_1_1_property "
+ "}"
+ "}" ;
return sparqlQuery;
}
// private String generateConstructQueryForDocumentDateTimeValue(String queryURI){
//
// String sparqlQuery =
//
// "CONSTRUCT { "
// + "<"+queryURI+ "> core:organizationForPosition ?Position . "
// + "?Position core:positionForPerson ?Person . "
// + "?Person core:authorInAuthorship ?Resource . "
// + "?Resource core:linkedInformationResource ?Document . "
// + "?Document rdf:type bibo:Document . "
// + "?Document core:dateTimeValue ?dateTimeValue . "
// + "?dateTimeValue core:dateTime ?publicationDate . "
// + "?Document core:year ?publicationYearUsing_1_1_property "
// +"}"
// + "WHERE { "
// + "<"+queryURI+ "> core:organizationForPosition ?Position . "
// + "?Position core:positionForPerson ?Person . "
// + "?Person core:authorInAuthorship ?Resource . "
// + "?Resource core:linkedInformationResource ?Document . "
// + "?Document rdf:type bibo:Document . "
// + "{"
// + "?Document core:dateTimeValue ?dateTimeValue . "
// + "?dateTimeValue core:dateTime ?publicationDate "
// + "}"
// + "UNION "
// + "{"
// + "?Document core:year ?publicationYearUsing_1_1_property "
// + "}"
// + "}" ;
//
//
// return sparqlQuery;
//
// }
private Model executeQuery(Set<String> constructQueries, Dataset Dataset) {
Model constructedModel = ModelFactory.createDefaultModel();
before = System.currentTimeMillis();
for (String queryString : constructQueries) {
before = System.currentTimeMillis();
log.debug("CONSTRUCT query string : " + queryString);
Query query = null;
try{
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + queryString, SYNTAX);
//log.info("query: "+ queryString);
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + queryString, SYNTAX);
}catch(Throwable th){
log.error("Could not create CONSTRUCT SPARQL query for query " +
"string. " + th.getMessage());
@ -209,16 +236,16 @@ public class EntityPublicationCountConstructQueryRunner {
QueryExecution qe = QueryExecutionFactory.create(
query, Dataset);
try {
qe.execConstruct(constructedModel);
} finally {
qe.close();
}
after = System.currentTimeMillis();
log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: " + (after - before) );
}
after = System.currentTimeMillis();
log.info("Time taken to execute the CONSTRUCT queries is in milliseconds: " + (after - before) );
// constructedModel.write(System.out);
return constructedModel;
}
@ -258,8 +285,8 @@ public class EntityPublicationCountConstructQueryRunner {
constructQueries.add(generateConstructQueryForOrganizationLabel(this.egoURI));
constructQueries.add(generateConstructQueryForSubOrganizations(this.egoURI));
constructQueries.add(generateConstructQueryForPersons(this.egoURI));
constructQueries.add(generateConstructQueryForDocumentDateTimeValueOneLevelDeep(this.egoURI));
constructQueries.add(generateConstructQueryForDocumentDateTimeValue(this.egoURI));
// constructQueries.add(generateConstructQueryForDocumentDateTimeValueOneLevelDeep(this.egoURI));
// constructQueries.add(generateConstructQueryForDocumentDateTimeValue(this.egoURI));
}
}

View file

@ -108,11 +108,11 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
biboDocument = new BiboDocument(documentNode.toString());
biboDocumentURLToVO.put(documentNode.toString(), biboDocument);
RDFNode documentLabelNode = solution
.get(QueryFieldLabels.DOCUMENT_LABEL);
if (documentLabelNode != null) {
biboDocument.setDocumentLabel(documentLabelNode.toString());
}
// RDFNode documentLabelNode = solution
// .get(QueryFieldLabels.DOCUMENT_LABEL);
// if (documentLabelNode != null) {
// biboDocument.setDocumentLabel(documentLabelNode.toString());
// }
RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
if (publicationDateNode != null) {

View file

@ -53,9 +53,6 @@ public class EntitySubOrganizationTypesConstructQueryRunner {
}
private String generateConstructQueryForSubOrganizationTypes(String queryURI){
//bdc34: this query was lacking the personLabel, personType, and personTypeLabel in the WHERE clause
//it seems like they are needed since they are referenced in the CONSTRUCT clause.
String sparqlQuery =

View file

@ -12,7 +12,7 @@ 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.DataSource;
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;
@ -26,181 +26,188 @@ import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryP
public class PersonGrantCountConstructQueryRunner {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String egoURI;
private DataSource dataSource;
private Log log = LogFactory.getLog(PersonGrantCountConstructQueryRunner.class.getName());
public PersonGrantCountConstructQueryRunner(String egoURI, DataSource dataSource, Log log){
this.egoURI = egoURI;
this.dataSource = dataSource;
//this.log = log;
}
private String generateConstructQueryForInvestigatorLabel(String queryURI) {
String sparqlQuery =
"CONSTRUCT { "
+ "<"+queryURI+ "> rdfs:label ?investigatorLabel ."
+ "}"
+ "WHERE {"
+ "<"+queryURI+ "> rdfs:label ?investigatorLabel "
+ "}";
return sparqlQuery;
}
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 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 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 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 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, DataSource dataSource) {
}
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) {
log.debug("CONSTRUCT query string : " + queryString);
Query query = null;
try{
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + queryString, SYNTAX);
}catch(Throwable th){
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, dataSource);
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 {
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 (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.");
"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.dataSource);
return model;
}
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));
constructQueries.add(generateConstructQueryForDateTimeValueofRole(this.egoURI));
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(this.egoURI));
}
}
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 "));
}
}

View file

@ -1,41 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.personpubcount;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.Syntax;
public class PersonPublicationCountConstructQueryRunner {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String egoURI;
private Dataset Dataset;
private Log log = LogFactory.getLog(PersonPublicationCountConstructQueryRunner.class.getName());
private long before, after;
public PersonPublicationCountConstructQueryRunner(String egoURI, Dataset Dataset, Log log){
this.egoURI = egoURI;
this.Dataset = Dataset;
//this.log = log;
}
private String generateConstructQueryForAuthorLabel(String queryURI) {
String sparqlQuery =
"CONSTRUCT { "
+ "<"+queryURI+ "> rdfs:label ?authorLabel ."
+ "}"
+ "WHERE {"
+ "<"+queryURI+ "> rdfs:label ?authorLabel ."
+ "}";
return sparqlQuery;
}
}

View file

@ -53,22 +53,15 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
private static final String SPARQL_QUERY_COMMON_SELECT_CLAUSE = ""
+ "SELECT (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") \n"
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n"
+ " (str(?documentMoniker) as ?" + QueryFieldLabels.DOCUMENT_MONIKER + ") \n"
+ " (str(?documentLabel) as ?" + QueryFieldLabels.DOCUMENT_LABEL + ") \n"
+ " (str(?documentBlurb) as ?" + QueryFieldLabels.DOCUMENT_BLURB + ") \n"
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") \n"
+ " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") \n"
+ " (str(?documentDescription) as ?" + QueryFieldLabels.DOCUMENT_DESCRIPTION + ") \n";
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n"
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") \n";
// + " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") \n";
private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = ""
+ "?document rdfs:label ?documentLabel .\n"
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n"
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n"
+ "OPTIONAL { ?document core:year ?publicationYearUsing_1_1_property } .\n"
+ "OPTIONAL { ?document vitro:moniker ?documentMoniker } .\n"
+ "OPTIONAL { ?document vitro:blurb ?documentBlurb } .\n"
+ "OPTIONAL { ?document vitro:description ?documentDescription }\n";
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n" ;
//+ "OPTIONAL { ?document core:year ?publicationYearUsing_1_1_property } ." ;
public PersonPublicationCountQueryRunner(String personURI,
Dataset Dataset, Log log) {
@ -89,27 +82,6 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
solution.get(QueryFieldLabels.DOCUMENT_URL)
.toString());
RDFNode documentLabelNode = solution.get(QueryFieldLabels.DOCUMENT_LABEL);
if (documentLabelNode != null) {
biboDocument.setDocumentLabel(documentLabelNode.toString());
}
RDFNode documentBlurbNode = solution.get(QueryFieldLabels.DOCUMENT_BLURB);
if (documentBlurbNode != null) {
biboDocument.setDocumentBlurb(documentBlurbNode.toString());
}
RDFNode documentmonikerNode = solution.get(QueryFieldLabels.DOCUMENT_MONIKER);
if (documentmonikerNode != null) {
biboDocument.setDocumentMoniker(documentmonikerNode.toString());
}
RDFNode documentDescriptionNode = solution.get(QueryFieldLabels.DOCUMENT_DESCRIPTION);
if (documentDescriptionNode != null) {
biboDocument.setDocumentDescription(documentDescriptionNode.toString());
}
RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
if (publicationDateNode != null) {
biboDocument.setPublicationDate(publicationDateNode.toString());
@ -118,10 +90,10 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
/*
* This is being used so that date in the data from pre-1.2 ontology can be captured.
* */
RDFNode publicationYearUsing_1_1_PropertyNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY);
if (publicationYearUsing_1_1_PropertyNode != null) {
biboDocument.setPublicationYear(publicationYearUsing_1_1_PropertyNode.toString());
}
// RDFNode publicationYearUsing_1_1_PropertyNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY);
// if (publicationYearUsing_1_1_PropertyNode != null) {
// biboDocument.setPublicationYear(publicationYearUsing_1_1_PropertyNode.toString());
// }
/*
* Since we are getting publication count for just one author at a time we need
@ -165,7 +137,7 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE
+ "}\n";
// System.out.println(sparqlQuery);
log.debug(sparqlQuery);
return sparqlQuery;
}

View file

@ -6,8 +6,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
@ -18,9 +16,6 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.Utilit
*/
public class BiboDocument extends Individual {
private String documentMoniker;
private String documentBlurb;
private String documentDescription;
private String publicationYear;
private String publicationDate;
private String parsedPublicationYear = VOConstants.DEFAULT_PUBLICATION_YEAR;
@ -31,35 +26,7 @@ public class BiboDocument extends Individual {
public String getDocumentURL() {
return this.getIndividualURI();
}
public String getDocumentMoniker() {
return documentMoniker;
}
public void setDocumentMoniker(String documentMoniker) {
this.documentMoniker = documentMoniker;
}
public String getDocumentLabel() {
return this.getIndividualLabel();
}
public void setDocumentLabel(String documentLabel) {
this.setIndividualLabel(documentLabel);
}
public String getDocumentBlurb() {
return documentBlurb;
}
public void setDocumentBlurb(String documentBlurb) {
this.documentBlurb = documentBlurb;
// if (documentBlurb != null) {
// this.setParsedPublicationYear(parsePublicationYear(documentBlurb));
// }
}
}
private String parsePublicationYear(String documentBlurb) {
@ -94,13 +61,6 @@ public class BiboDocument extends Individual {
return publishedYear;
}
public String getDocumentDescription() {
return documentDescription;
}
public void setDocumentDescription(String documentDescription) {
this.documentDescription = documentDescription;
}
/**
* This method will be called to get the final/inferred year for the publication.
* The 3 choices, in order, are,