Changes to EntityPublicationCountConstructQueryRunner and EntitySubOrganizationTypesConstructQueryRunner to improve temporal visualizations.

This commit is contained in:
bdc34 2011-02-10 16:58:55 +00:00
parent 5a1c1a3e84
commit 57819fa584
2 changed files with 125 additions and 92 deletions

View file

@ -67,7 +67,10 @@ 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 . "
@ -77,8 +80,18 @@ 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 "
+ "{"
+ "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate "
+ "}"
+ "UNION "
+ "{"
+ "?Document core:year ?publicationYearUsing_1_1_property "
+ "}"
+ "}" ; + "}" ;
@ -97,7 +110,10 @@ 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 . "
@ -105,8 +121,18 @@ 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 "
+ "{"
+ "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate "
+ "}"
+ "UNION "
+ "{"
+ "?Document core:year ?publicationYearUsing_1_1_property "
+ "}"
+ "}" ; + "}" ;
@ -114,93 +140,90 @@ public class EntityPublicationCountConstructQueryRunner {
} }
private String generateConstructQueryForDocumentDateTimeValueOneLevelDeep(String queryURI){ // private String generateConstructQueryForDocumentDateTimeValueOneLevelDeep(String queryURI){
//
String sparqlQuery = // String sparqlQuery =
//
"CONSTRUCT { " // "CONSTRUCT { "
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . " // + "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . " // + "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " // + "?Position core:positionForPerson ?Person . "
+ "?Person core:authorInAuthorship ?Resource . " // + "?Person core:authorInAuthorship ?Resource . "
+ "?Resource core:linkedInformationResource ?Document . " // + "?Resource core:linkedInformationResource ?Document . "
+ "?Document rdf:type bibo:Document . " // + "?Document rdf:type bibo:Document . "
+ "?Document core:dateTimeValue ?dateTimeValue . " // + "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate . " // + "?dateTimeValue core:dateTime ?publicationDate . "
+ "?Document core:year ?publicationYearUsing_1_1_property " // + "?Document core:year ?publicationYearUsing_1_1_property "
+"}" // +"}"
+ "WHERE { " // + "WHERE { "
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . " // + "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . " // + "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " // + "?Position core:positionForPerson ?Person . "
+ "?Person core:authorInAuthorship ?Resource . " // + "?Person core:authorInAuthorship ?Resource . "
+ "?Resource core:linkedInformationResource ?Document . " // + "?Resource core:linkedInformationResource ?Document . "
+ "?Document rdf:type bibo: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 "
+ "}" // + "}"
+ "}" ; // + "}" ;
//
//
return sparqlQuery; // return sparqlQuery;
//
// }
} // private String generateConstructQueryForDocumentDateTimeValue(String queryURI){
//
private String generateConstructQueryForDocumentDateTimeValue(String queryURI){ // String sparqlQuery =
//
String sparqlQuery = // "CONSTRUCT { "
// + "<"+queryURI+ "> core:organizationForPosition ?Position . "
"CONSTRUCT { " // + "?Position core:positionForPerson ?Person . "
+ "<"+queryURI+ "> core:organizationForPosition ?Position . " // + "?Person core:authorInAuthorship ?Resource . "
+ "?Position core:positionForPerson ?Person . " // + "?Resource core:linkedInformationResource ?Document . "
+ "?Person core:authorInAuthorship ?Resource . " // + "?Document rdf:type bibo:Document . "
+ "?Resource core:linkedInformationResource ?Document . " // + "?Document core:dateTimeValue ?dateTimeValue . "
+ "?Document rdf:type bibo:Document . " // + "?dateTimeValue core:dateTime ?publicationDate . "
+ "?Document core:dateTimeValue ?dateTimeValue . " // + "?Document core:year ?publicationYearUsing_1_1_property "
+ "?dateTimeValue core:dateTime ?publicationDate . " // +"}"
+ "?Document core:year ?publicationYearUsing_1_1_property " // + "WHERE { "
+"}" // + "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ "WHERE { " // + "?Position core:positionForPerson ?Person . "
+ "<"+queryURI+ "> core:organizationForPosition ?Position . " // + "?Person core:authorInAuthorship ?Resource . "
+ "?Position core:positionForPerson ?Person . " // + "?Resource core:linkedInformationResource ?Document . "
+ "?Person core:authorInAuthorship ?Resource . " // + "?Document rdf:type bibo:Document . "
+ "?Resource core:linkedInformationResource ?Document . " // + "{"
+ "?Document rdf:type bibo:Document . " // + "?Document core:dateTimeValue ?dateTimeValue . "
+ "{" // + "?dateTimeValue core:dateTime ?publicationDate "
+ "?Document core:dateTimeValue ?dateTimeValue . " // + "}"
+ "?dateTimeValue core:dateTime ?publicationDate " // + "UNION "
+ "}" // + "{"
+ "UNION " // + "?Document core:year ?publicationYearUsing_1_1_property "
+ "{" // + "}"
+ "?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 +232,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();
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); // constructedModel.write(System.out);
return constructedModel; return constructedModel;
} }
@ -258,8 +281,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

@ -54,6 +54,9 @@ 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 { "
@ -71,9 +74,13 @@ public class EntitySubOrganizationTypesConstructQueryRunner {
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . " + "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization rdfs:label ?subOrganizationLabel . " + "?subOrganization rdfs:label ?subOrganizationLabel . "
+ "?subOrganization rdf:type ?subOrganizationType . " + "?subOrganization rdf:type ?subOrganizationType . "
+ "?subOrganization core:organizationForPosition ?Position . " + "?subOrganizationType rdfs:label ?subOrganizationTypeLabel . "
+ "?subOrganizationType rdfs:label ?subOrganizationTypeLabel . " + "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person " + "?Position core:positionForPerson ?Person . "
+ "?Person rdfs:label ?PersonLabel ."
+ "?Person rdf:type ?PersonType . "
+ "?PersonType rdfs:label ?PersonTypeLabel "
+ "}" ; + "}" ;
@ -108,10 +115,12 @@ public class EntitySubOrganizationTypesConstructQueryRunner {
private Model executeQuery(Set<String> constructQueries, Dataset Dataset) { private Model executeQuery(Set<String> constructQueries, Dataset Dataset) {
Model constructedModel = ModelFactory.createDefaultModel(); Model constructedModel = ModelFactory.createDefaultModel();
long before = 0;
for (String queryString : constructQueries) { for (String queryString : constructQueries) {
// log.info("CONSTRUCT query string : " + queryString); before = System.currentTimeMillis();
log.debug("CONSTRUCT query string : " + queryString);
Query query = null; Query query = null;
@ -131,6 +140,7 @@ public class EntitySubOrganizationTypesConstructQueryRunner {
qe.close(); qe.close();
} }
log.debug("Time to run " + (before - System.currentTimeMillis()) );
} }
return constructedModel; return constructedModel;