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); 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); RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
if (publicationDateNode != null) { if (publicationDateNode != null) {
biboDocument.setPublicationDate(publicationDateNode.toString()); 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. * 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); // RDFNode publicationYearUsing_1_1_PropertyNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY);
if (publicationYearUsing_1_1_PropertyNode != null) { // if (publicationYearUsing_1_1_PropertyNode != null) {
biboDocument.setPublicationYear(publicationYearUsing_1_1_PropertyNode.toString()); // biboDocument.setPublicationYear(publicationYearUsing_1_1_PropertyNode.toString());
} // }
return biboDocument; return biboDocument;
} }
@ -412,31 +397,24 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
+ " (str(?coAuthorPerson) as ?" + QueryFieldLabels.CO_AUTHOR_URL + ") \n" + " (str(?coAuthorPerson) as ?" + QueryFieldLabels.CO_AUTHOR_URL + ") \n"
+ " (str(?coAuthorPersonLabel) as ?" + QueryFieldLabels.CO_AUTHOR_LABEL + ") \n" + " (str(?coAuthorPersonLabel) as ?" + QueryFieldLabels.CO_AUTHOR_LABEL + ") \n"
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \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(?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" + "WHERE { \n"
+ "<" + queryURI + "> rdf:type foaf:Person ;" + "<" + queryURI + "> rdf:type foaf:Person ;"
+ " rdfs:label ?authorLabel ;" + " rdfs:label ?authorLabel ;"
+ " core:authorInAuthorship ?authorshipNode . \n" + " core:authorInAuthorship ?authorshipNode . \n"
+ "?authorshipNode rdf:type core:Authorship ;" + "?authorshipNode rdf:type core:Authorship ;"
+ " core:linkedInformationResource ?document . \n" + " core:linkedInformationResource ?document . \n"
+ "?document rdfs:label ?documentLabel . \n"
+ "?document core:informationResourceInAuthorship ?coAuthorshipNode . \n" + "?document core:informationResourceInAuthorship ?coAuthorshipNode . \n"
+ "?coAuthorshipNode core:linkedAuthor ?coAuthorPerson . \n" + "?coAuthorshipNode core:linkedAuthor ?coAuthorPerson . \n"
+ "?coAuthorPerson rdfs:label ?coAuthorPersonLabel . \n" + "?coAuthorPerson rdfs:label ?coAuthorPersonLabel . \n"
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n" + "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n"
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n" + " ?dateTimeValue core:dateTime ?publicationDate } .\n"
+ "OPTIONAL { ?document core:year ?publicationYearUsing_1_1_property } .\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"
+ "} \n" + "} \n"
+ "ORDER BY ?document ?coAuthorPerson\n"; + "ORDER BY ?document ?coAuthorPerson\n";
// System.out.println("COAUTHORSHIP QUERY - " + sparqlQuery); log.debug("COAUTHORSHIP QUERY - " + sparqlQuery);
return sparqlQuery; return sparqlQuery;
} }

View file

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

View file

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

View file

@ -54,9 +54,6 @@ public class EntitySubOrganizationTypesConstructQueryRunner {
private String generateConstructQueryForSubOrganizationTypes(String queryURI){ 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 = String sparqlQuery =
"CONSTRUCT { " "CONSTRUCT { "

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.IRI;
import com.hp.hpl.jena.iri.IRIFactory; import com.hp.hpl.jena.iri.IRIFactory;
import com.hp.hpl.jena.iri.Violation; 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.Query;
import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.QueryExecutionFactory;
@ -30,13 +30,13 @@ public class PersonGrantCountConstructQueryRunner {
private String egoURI; private String egoURI;
private DataSource dataSource; private Dataset Dataset;
private Log log = LogFactory.getLog(PersonGrantCountConstructQueryRunner.class.getName()); private Log log = LogFactory.getLog(PersonGrantCountConstructQueryRunner.class.getName());
public PersonGrantCountConstructQueryRunner(String egoURI, DataSource dataSource, Log log){ public PersonGrantCountConstructQueryRunner(String egoURI, Dataset Dataset, Log log){
this.egoURI = egoURI; this.egoURI = egoURI;
this.dataSource = dataSource; this.Dataset = Dataset;
//this.log = log; //this.log = log;
} }
@ -53,16 +53,16 @@ public class PersonGrantCountConstructQueryRunner {
return sparqlQuery; return sparqlQuery;
} }
private String generateConstructQueryForInvestigatorGrants(String queryURI){ private String generateConstructQueryForInvestigatorGrants(String queryURI, String preboundProperty){
String sparqlQuery = "" String sparqlQuery = ""
+ "CONSTRUCT { " + "CONSTRUCT { "
+ "<"+queryURI+ "> ?preboundProperty ?Role . " + "<"+queryURI+ ">" + preboundProperty + " ?Role . "
+ "?Role core:roleIn ?Grant ." + "?Role core:roleIn ?Grant ."
+ "?Grant rdfs:label ?GrantLabel " + "?Grant rdfs:label ?GrantLabel "
+ "} " + "} "
+ "WHERE { " + "WHERE { "
+ "<"+queryURI+ "> ?preboundProperty ?Role . " + "<"+queryURI+ ">" + preboundProperty + " ?Role . "
+ "?Role core:roleIn ?Grant ." + "?Role core:roleIn ?Grant ."
+ "?Grant rdfs:label ?GrantLabel " + "?Grant rdfs:label ?GrantLabel "
+ "} "; + "} ";
@ -71,11 +71,11 @@ public class PersonGrantCountConstructQueryRunner {
} }
private String generateConstructQueryForDateTimeValueofRole(String queryURI){ private String generateConstructQueryForDateTimeValueofRole(String queryURI, String preboundProperty){
String sparqlQuery = String sparqlQuery =
"CONSTRUCT { " "CONSTRUCT { "
+ "<"+queryURI+ "> ?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 . "
@ -84,13 +84,13 @@ public class PersonGrantCountConstructQueryRunner {
+ "}" + "}"
+ "WHERE { " + "WHERE { "
+ "{" + "{"
+ "<"+queryURI+ "> ?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 . "
+ "} 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 . "
@ -100,11 +100,11 @@ public class PersonGrantCountConstructQueryRunner {
return sparqlQuery; return sparqlQuery;
} }
private String generateConstructQueryForDateTimeValueofGrant(String queryURI){ private String generateConstructQueryForDateTimeValueofGrant(String queryURI, String preboundProperty){
String sparqlQuery = String sparqlQuery =
"CONSTRUCT { " "CONSTRUCT { "
+ "<"+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 . "
@ -114,14 +114,14 @@ public class PersonGrantCountConstructQueryRunner {
+ "}" + "}"
+ "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 . "
@ -132,12 +132,12 @@ public class PersonGrantCountConstructQueryRunner {
return sparqlQuery; return sparqlQuery;
} }
private Model executeQuery(Set<String> constructQueries, DataSource dataSource) { private Model executeQuery(Set<String> constructQueries, Dataset Dataset) {
Model constructedModel = ModelFactory.createDefaultModel(); Model constructedModel = ModelFactory.createDefaultModel();
for (String queryString : constructQueries) { for (String queryString : constructQueries) {
long start = System.currentTimeMillis();
log.debug("CONSTRUCT query string : " + queryString); log.debug("CONSTRUCT query string : " + queryString);
Query query = null; Query query = null;
@ -151,13 +151,13 @@ public class PersonGrantCountConstructQueryRunner {
} }
QueryExecution qe = QueryExecutionFactory.create( QueryExecution qe = QueryExecutionFactory.create(
query, dataSource); query, Dataset);
try { try {
qe.execConstruct(constructedModel); qe.execConstruct(constructedModel);
} finally { } finally {
qe.close(); qe.close();
} }
log.debug("time to run construct: " + (System.currentTimeMillis() - start));
} }
return constructedModel; return constructedModel;
@ -187,7 +187,7 @@ public class PersonGrantCountConstructQueryRunner {
populateConstructQueries(constructQueries); populateConstructQueries(constructQueries);
Model model = executeQuery(constructQueries, Model model = executeQuery(constructQueries,
this.dataSource); this.Dataset);
return model; return model;
@ -196,11 +196,18 @@ public class PersonGrantCountConstructQueryRunner {
private void populateConstructQueries(Set<String> constructQueries) { private void populateConstructQueries(Set<String> constructQueries) {
constructQueries.add(generateConstructQueryForInvestigatorLabel(this.egoURI)); constructQueries.add(generateConstructQueryForInvestigatorLabel(this.egoURI));
constructQueries.add(generateConstructQueryForInvestigatorGrants(this.egoURI));
constructQueries.add(generateConstructQueryForDateTimeValueofRole(this.egoURI));
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(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

@ -54,21 +54,14 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
private static final String SPARQL_QUERY_COMMON_SELECT_CLAUSE = "" private static final String SPARQL_QUERY_COMMON_SELECT_CLAUSE = ""
+ "SELECT (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") \n" + "SELECT (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") \n"
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n" + " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n"
+ " (str(?documentMoniker) as ?" + QueryFieldLabels.DOCUMENT_MONIKER + ") \n" + " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") \n";
+ " (str(?documentLabel) as ?" + QueryFieldLabels.DOCUMENT_LABEL + ") \n" // + " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") \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";
private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = "" private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = ""
+ "?document rdfs:label ?documentLabel .\n" + "?document rdfs:label ?documentLabel .\n"
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n" + "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n"
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n" + " ?dateTimeValue core:dateTime ?publicationDate } .\n" ;
+ "OPTIONAL { ?document core:year ?publicationYearUsing_1_1_property } .\n" //+ "OPTIONAL { ?document core:year ?publicationYearUsing_1_1_property } ." ;
+ "OPTIONAL { ?document vitro:moniker ?documentMoniker } .\n"
+ "OPTIONAL { ?document vitro:blurb ?documentBlurb } .\n"
+ "OPTIONAL { ?document vitro:description ?documentDescription }\n";
public PersonPublicationCountQueryRunner(String personURI, public PersonPublicationCountQueryRunner(String personURI,
Dataset Dataset, Log log) { Dataset Dataset, Log log) {
@ -89,27 +82,6 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
solution.get(QueryFieldLabels.DOCUMENT_URL) solution.get(QueryFieldLabels.DOCUMENT_URL)
.toString()); .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); RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
if (publicationDateNode != null) { if (publicationDateNode != null) {
biboDocument.setPublicationDate(publicationDateNode.toString()); 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. * 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); // RDFNode publicationYearUsing_1_1_PropertyNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY);
if (publicationYearUsing_1_1_PropertyNode != null) { // if (publicationYearUsing_1_1_PropertyNode != null) {
biboDocument.setPublicationYear(publicationYearUsing_1_1_PropertyNode.toString()); // biboDocument.setPublicationYear(publicationYearUsing_1_1_PropertyNode.toString());
} // }
/* /*
* Since we are getting publication count for just one author at a time we need * 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 + SPARQL_QUERY_COMMON_WHERE_CLAUSE
+ "}\n"; + "}\n";
// System.out.println(sparqlQuery); log.debug(sparqlQuery);
return sparqlQuery; return sparqlQuery;
} }

View file

@ -6,8 +6,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.joda.time.DateTime; 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.constants.VOConstants;
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions; 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 { public class BiboDocument extends Individual {
private String documentMoniker;
private String documentBlurb;
private String documentDescription;
private String publicationYear; private String publicationYear;
private String publicationDate; private String publicationDate;
private String parsedPublicationYear = VOConstants.DEFAULT_PUBLICATION_YEAR; private String parsedPublicationYear = VOConstants.DEFAULT_PUBLICATION_YEAR;
@ -33,34 +28,6 @@ public class BiboDocument extends Individual {
return this.getIndividualURI(); 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) { private String parsePublicationYear(String documentBlurb) {
/* /*
@ -94,13 +61,6 @@ public class BiboDocument extends Individual {
return publishedYear; 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. * This method will be called to get the final/inferred year for the publication.
* The 3 choices, in order, are, * The 3 choices, in order, are,