diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountConstructQueryRunner.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountConstructQueryRunner.java index 9700c5b1..c62c3c37 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountConstructQueryRunner.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountConstructQueryRunner.java @@ -67,7 +67,10 @@ 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 . " @@ -77,8 +80,18 @@ public class EntityPublicationCountConstructQueryRunner { + "?Person core:authorInAuthorship ?Resource . " + "?Person rdfs:label ?PersonLabel . " + "?Resource core:linkedInformationResource ?Document . " - + "?Document rdf:type bibo:Document . " - + "?Document rdfs:label ?DocumentLabel " +// + "?Document rdf:type bibo:Document . " + + "?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 . " + "?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 . " @@ -105,8 +121,18 @@ public class EntityPublicationCountConstructQueryRunner { + "?Person core:authorInAuthorship ?Resource . " + "?Person rdfs:label ?PersonLabel . " + "?Resource core:linkedInformationResource ?Document . " - + "?Document rdf:type bibo:Document . " - + "?Document rdfs:label ?DocumentLabel " +// + "?Document rdf:type bibo:Document . " + + "?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){ - - 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 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 +232,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 +281,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)); } } diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntitySubOrganizationTypesConstructQueryRunner.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntitySubOrganizationTypesConstructQueryRunner.java index 17536d55..65ef14ba 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntitySubOrganizationTypesConstructQueryRunner.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntitySubOrganizationTypesConstructQueryRunner.java @@ -54,6 +54,9 @@ 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 = "CONSTRUCT { " @@ -71,9 +74,13 @@ public class EntitySubOrganizationTypesConstructQueryRunner { + "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . " + "?subOrganization rdfs:label ?subOrganizationLabel . " + "?subOrganization rdf:type ?subOrganizationType . " - + "?subOrganization core:organizationForPosition ?Position . " - + "?subOrganizationType rdfs:label ?subOrganizationTypeLabel . " - + "?Position core:positionForPerson ?Person " + + "?subOrganizationType rdfs:label ?subOrganizationTypeLabel . " + + "?subOrganization core:organizationForPosition ?Position . " + + "?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 constructQueries, Dataset Dataset) { Model constructedModel = ModelFactory.createDefaultModel(); - + long before = 0; + for (String queryString : constructQueries) { - // log.info("CONSTRUCT query string : " + queryString); + before = System.currentTimeMillis(); + log.debug("CONSTRUCT query string : " + queryString); Query query = null; @@ -131,6 +140,7 @@ public class EntitySubOrganizationTypesConstructQueryRunner { qe.close(); } + log.debug("Time to run " + (before - System.currentTimeMillis()) ); } return constructedModel;