From 9a87463e61a4aecebf9edde8c5edfd8f3e31ce73 Mon Sep 17 00:00:00 2001 From: tankchintan Date: Wed, 27 Jul 2011 23:44:59 +0000 Subject: [PATCH] 1. Improvement of response time for co-pi visualization. In future remove the custom contruct queries and make use of cached, at least for the gramnts since they are very expensive. --- .../CoPIGrantCountConstructQueryRunner.java | 44 ++++++------ .../CoPIGrantCountQueryRunner.java | 68 +++++++------------ 2 files changed, 47 insertions(+), 65 deletions(-) diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/coprincipalinvestigator/CoPIGrantCountConstructQueryRunner.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/coprincipalinvestigator/CoPIGrantCountConstructQueryRunner.java index 256e1b29..5b38b8a3 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/coprincipalinvestigator/CoPIGrantCountConstructQueryRunner.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/coprincipalinvestigator/CoPIGrantCountConstructQueryRunner.java @@ -39,7 +39,7 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor { private static final String SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING = "?Role core:roleIn ?Grant . " - + "?Grant rdfs:label ?GrantLabel . " +// + "?Grant rdfs:label ?GrantLabel . " + "?Grant core:relatedRole ?RelatedRole . "; public CoPIGrantCountConstructQueryRunner(String egoURI, Dataset dataset, @@ -134,18 +134,20 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor { + "?Role core:dateTimeInterval ?dateTimeIntervalValue . " + "?dateTimeIntervalValue core:start ?startDate . " + "?startDate core:dateTime ?startDateTimeValue . " - + "?dateTimeIntervalValue core:end ?endDate . " - + "?endDate core:dateTime ?endDateTimeValue . " + "}" +// + "?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 . " + "}" + "}"; +// + "} UNION " + "{" + "<" + queryURI + ">" + preboundProperty +// + " ?Role . " +// + "?Role core:dateTimeInterval ?dateTimeIntervalValue . " +// + "?dateTimeIntervalValue core:end ?endDate . " +// + "?endDate core:dateTime ?endDateTimeValue . " + + "}" + "}"; return sparqlQuery; } @@ -162,8 +164,8 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor { + "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . " + "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . " + "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . " - + "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . " - + "?endDateForGrant core:dateTime ?endDateTimeValueForGrant . " +// + "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . " +// + "?endDateForGrant core:dateTime ?endDateTimeValueForGrant . " + "}" + "WHERE { " + "{" @@ -176,17 +178,17 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor { + "?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 . " +// + "} UNION " +// + "{" +// + "<" +// + queryURI +// + ">" +// + preboundProperty +// + " ?Role . " +// + "?Role core:roleIn ?Grant ." +// + "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . " +// + "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . " +// + "?endDateForGrant core:dateTime ?endDateTimeValueForGrant . " + "}" + "}"; return sparqlQuery; diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/coprincipalinvestigator/CoPIGrantCountQueryRunner.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/coprincipalinvestigator/CoPIGrantCountQueryRunner.java index 4f6924c0..a9242629 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/coprincipalinvestigator/CoPIGrantCountQueryRunner.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/coprincipalinvestigator/CoPIGrantCountQueryRunner.java @@ -65,10 +65,10 @@ public class CoPIGrantCountQueryRunner implements QueryRunner + " ?Role core:dateTimeInterval ?dateTimeIntervalValue . " + "?dateTimeIntervalValue core:start ?startDate . " + "?startDate core:dateTime ?startDateTimeValue . " - + "OPTIONAL {" - + "?dateTimeIntervalValue core:end ?endDate . " - + "?endDate core:dateTime ?endDateTimeValue . " - + "}" +// + "OPTIONAL {" +// + "?dateTimeIntervalValue core:end ?endDate . " +// + "?endDate core:dateTime ?endDateTimeValue . " +// + "}" + "} . "; private static final String SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME = "" @@ -76,10 +76,10 @@ public class CoPIGrantCountQueryRunner implements QueryRunner + " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . " + "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . " + "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . " - + "OPTIONAL {" - + "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . " - + "?endDateForGrant core:dateTime ?endDateTimeValueForGrant . " - + "}" +// + "OPTIONAL {" +// + "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . " +// + "?endDateForGrant core:dateTime ?endDateTimeValueForGrant . " +// + "}" + "}"; @@ -101,11 +101,11 @@ public class CoPIGrantCountQueryRunner implements QueryRunner + " (str(<" + queryURI + ">) as ?" + QueryFieldLabels.PI_URL + ") " + " (str(?PILabel) as ?" + QueryFieldLabels.PI_LABEL + ") " + " (str(?Grant) as ?" + QueryFieldLabels.GRANT_URL + ") " - + " (str(?GrantLabel) as ?" + QueryFieldLabels.GRANT_LABEL + ") " +// + " (str(?GrantLabel) as ?" + QueryFieldLabels.GRANT_LABEL + ") " + " (str(?startDateTimeValue) as ?grantStartDateLit) " - + " (str(?endDateTimeValue) as ?grantEndDateLit) " +// + " (str(?endDateTimeValue) as ?grantEndDateLit) " + " (str(?startDateTimeValueForGrant) as ?grantStartDateForGrantLit) " - + " (str(?endDateTimeValueForGrant) as ?grantEndDateForGrantLit) " +// + " (str(?endDateTimeValueForGrant) as ?grantEndDateForGrantLit) " + " (str(?CoPI) as ?" + QueryFieldLabels.CO_PI_URL + ") " + " (str(?CoPILabel) as ?" + QueryFieldLabels.CO_PI_LABEL + ") " + "WHERE " @@ -117,9 +117,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner + "?Role core:roleIn ?Grant . " - + "?Grant rdfs:label ?GrantLabel ; " - - + "core:relatedRole ?RelatedRole . " + + "?Grant core:relatedRole ?RelatedRole . " + "?RelatedRole core:principalInvestigatorRoleOf ?CoPI . " @@ -139,9 +137,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner + "?Role core:roleIn ?Grant . " - + "?Grant rdfs:label ?GrantLabel ; " - - + "core:relatedRole ?RelatedRole . " + + "?Grant core:relatedRole ?RelatedRole . " + "?RelatedRole core:investigatorRoleOf ?CoPI . " @@ -162,9 +158,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner + "?Role core:roleIn ?Grant . " - + "?Grant rdfs:label ?GrantLabel ; " - - + "core:relatedRole ?RelatedRole . " + + "?Grant core:relatedRole ?RelatedRole . " + "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?CoPI . " @@ -186,9 +180,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner + "?Role core:roleIn ?Grant . " - + "?Grant rdfs:label ?GrantLabel ; " - - + "core:relatedRole ?RelatedRole . " + + "?Grant core:relatedRole ?RelatedRole . " + "?RelatedRole core:principalInvestigatorRoleOf ?CoPI . " @@ -209,9 +201,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner + "?Role core:roleIn ?Grant . " - + "?Grant rdfs:label ?GrantLabel ; " - - + "core:relatedRole ?RelatedRole . " + + "?Grant core:relatedRole ?RelatedRole . " + "?RelatedRole core:investigatorRoleOf ?CoPI . " @@ -232,9 +222,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner + "?Role core:roleIn ?Grant . " - + "?Grant rdfs:label ?GrantLabel ; " - - + "core:relatedRole ?RelatedRole . " + + "?Grant core:relatedRole ?RelatedRole . " + "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?CoPI . " @@ -255,9 +243,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner + "?Role core:roleIn ?Grant . " - + "?Grant rdfs:label ?GrantLabel ; " - - + "core:relatedRole ?RelatedRole . " + + "?Grant core:relatedRole ?RelatedRole . " + "?RelatedRole core:investigatorRoleOf ?CoPI . " @@ -278,9 +264,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner + "?Role core:roleIn ?Grant . " - + "?Grant rdfs:label ?GrantLabel ; " - - + "core:relatedRole ?RelatedRole . " + + "?Grant core:relatedRole ?RelatedRole . " + "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?CoPI . " @@ -301,9 +285,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner + "?Role core:roleIn ?Grant . " - + "?Grant rdfs:label ?GrantLabel ; " - - + "core:relatedRole ?RelatedRole . " + + "?Grant core:relatedRole ?RelatedRole . " + "?RelatedRole core:principalInvestigatorRoleOf ?CoPI . " @@ -316,8 +298,6 @@ public class CoPIGrantCountQueryRunner implements QueryRunner + "} " + "} "; - - //System.out.println("\n\nCOPI QUERY - " + sparqlQuery + "\n\n"); return sparqlQuery; } @@ -647,10 +627,10 @@ public class CoPIGrantCountQueryRunner implements QueryRunner Activity grant = new Activity(grantURL); - RDFNode grantLabelNode = solution.get(QueryFieldLabels.GRANT_LABEL); - if (grantLabelNode != null) { - grant.setIndividualLabel(grantLabelNode.toString()); - } +// RDFNode grantLabelNode = solution.get(QueryFieldLabels.GRANT_LABEL); +// if (grantLabelNode != null) { +// grant.setIndividualLabel(grantLabelNode.toString()); +// } RDFNode grantStartYear = solution.get(QueryFieldLabels.ROLE_START_DATE);