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.

This commit is contained in:
tankchintan 2011-07-27 23:44:59 +00:00
parent 9aad3195b4
commit 9a87463e61
2 changed files with 47 additions and 65 deletions

View file

@ -39,7 +39,7 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
private static final String SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING = private static final String SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING =
"?Role core:roleIn ?Grant . " "?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel . " // + "?Grant rdfs:label ?GrantLabel . "
+ "?Grant core:relatedRole ?RelatedRole . "; + "?Grant core:relatedRole ?RelatedRole . ";
public CoPIGrantCountConstructQueryRunner(String egoURI, Dataset dataset, public CoPIGrantCountConstructQueryRunner(String egoURI, Dataset dataset,
@ -134,18 +134,20 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . " + "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . " + "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue . " + "?startDate core:dateTime ?startDateTimeValue . "
+ "?dateTimeIntervalValue core:end ?endDate . " // + "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue . " + "}" // + "?endDate core:dateTime ?endDateTimeValue . "
+ "}"
+ "WHERE { " + "{" + "<" + queryURI + ">" + preboundProperty + "WHERE { " + "{" + "<" + queryURI + ">" + preboundProperty
+ " ?Role . " + " ?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 " + "{" + "<" + queryURI + ">" + preboundProperty // + "} UNION " + "{" + "<" + queryURI + ">" + preboundProperty
+ " ?Role . " // + " ?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 . "
+ "}" + "}";
return sparqlQuery; return sparqlQuery;
} }
@ -162,8 +164,8 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . " + "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . " + "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . " + "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . " // + "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant . " // + "?endDateForGrant core:dateTime ?endDateTimeValueForGrant . "
+ "}" + "}"
+ "WHERE { " + "WHERE { "
+ "{" + "{"
@ -176,17 +178,17 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
+ "?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 // + queryURI
+ ">" // + ">"
+ preboundProperty // + preboundProperty
+ " ?Role . " // + " ?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 . "
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant . " // + "?endDateForGrant core:dateTime ?endDateTimeValueForGrant . "
+ "}" + "}"; + "}" + "}";
return sparqlQuery; return sparqlQuery;

View file

@ -65,10 +65,10 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
+ " ?Role core:dateTimeInterval ?dateTimeIntervalValue . " + " ?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . " + "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue . " + "?startDate core:dateTime ?startDateTimeValue . "
+ "OPTIONAL {" // + "OPTIONAL {"
+ "?dateTimeIntervalValue core:end ?endDate . " // + "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue . " // + "?endDate core:dateTime ?endDateTimeValue . "
+ "}" // + "}"
+ "} . "; + "} . ";
private static final String SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME = "" private static final String SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME = ""
@ -76,10 +76,10 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
+ " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . " + " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . " + "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . " + "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
+ "OPTIONAL {" // + "OPTIONAL {"
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . " // + "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant . " // + "?endDateForGrant core:dateTime ?endDateTimeValueForGrant . "
+ "}" // + "}"
+ "}"; + "}";
@ -101,11 +101,11 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
+ " (str(<" + queryURI + ">) as ?" + QueryFieldLabels.PI_URL + ") " + " (str(<" + queryURI + ">) as ?" + QueryFieldLabels.PI_URL + ") "
+ " (str(?PILabel) as ?" + QueryFieldLabels.PI_LABEL + ") " + " (str(?PILabel) as ?" + QueryFieldLabels.PI_LABEL + ") "
+ " (str(?Grant) as ?" + QueryFieldLabels.GRANT_URL + ") " + " (str(?Grant) as ?" + QueryFieldLabels.GRANT_URL + ") "
+ " (str(?GrantLabel) as ?" + QueryFieldLabels.GRANT_LABEL + ") " // + " (str(?GrantLabel) as ?" + QueryFieldLabels.GRANT_LABEL + ") "
+ " (str(?startDateTimeValue) as ?grantStartDateLit) " + " (str(?startDateTimeValue) as ?grantStartDateLit) "
+ " (str(?endDateTimeValue) as ?grantEndDateLit) " // + " (str(?endDateTimeValue) as ?grantEndDateLit) "
+ " (str(?startDateTimeValueForGrant) as ?grantStartDateForGrantLit) " + " (str(?startDateTimeValueForGrant) as ?grantStartDateForGrantLit) "
+ " (str(?endDateTimeValueForGrant) as ?grantEndDateForGrantLit) " // + " (str(?endDateTimeValueForGrant) as ?grantEndDateForGrantLit) "
+ " (str(?CoPI) as ?" + QueryFieldLabels.CO_PI_URL + ") " + " (str(?CoPI) as ?" + QueryFieldLabels.CO_PI_URL + ") "
+ " (str(?CoPILabel) as ?" + QueryFieldLabels.CO_PI_LABEL + ") " + " (str(?CoPILabel) as ?" + QueryFieldLabels.CO_PI_LABEL + ") "
+ "WHERE " + "WHERE "
@ -117,9 +117,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
+ "?Role core:roleIn ?Grant . " + "?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel ; " + "?Grant core:relatedRole ?RelatedRole . "
+ "core:relatedRole ?RelatedRole . "
+ "?RelatedRole core:principalInvestigatorRoleOf ?CoPI . " + "?RelatedRole core:principalInvestigatorRoleOf ?CoPI . "
@ -139,9 +137,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
+ "?Role core:roleIn ?Grant . " + "?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel ; " + "?Grant core:relatedRole ?RelatedRole . "
+ "core:relatedRole ?RelatedRole . "
+ "?RelatedRole core:investigatorRoleOf ?CoPI . " + "?RelatedRole core:investigatorRoleOf ?CoPI . "
@ -162,9 +158,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
+ "?Role core:roleIn ?Grant . " + "?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel ; " + "?Grant core:relatedRole ?RelatedRole . "
+ "core:relatedRole ?RelatedRole . "
+ "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?CoPI . " + "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?CoPI . "
@ -186,9 +180,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
+ "?Role core:roleIn ?Grant . " + "?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel ; " + "?Grant core:relatedRole ?RelatedRole . "
+ "core:relatedRole ?RelatedRole . "
+ "?RelatedRole core:principalInvestigatorRoleOf ?CoPI . " + "?RelatedRole core:principalInvestigatorRoleOf ?CoPI . "
@ -209,9 +201,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
+ "?Role core:roleIn ?Grant . " + "?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel ; " + "?Grant core:relatedRole ?RelatedRole . "
+ "core:relatedRole ?RelatedRole . "
+ "?RelatedRole core:investigatorRoleOf ?CoPI . " + "?RelatedRole core:investigatorRoleOf ?CoPI . "
@ -232,9 +222,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
+ "?Role core:roleIn ?Grant . " + "?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel ; " + "?Grant core:relatedRole ?RelatedRole . "
+ "core:relatedRole ?RelatedRole . "
+ "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?CoPI . " + "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?CoPI . "
@ -255,9 +243,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
+ "?Role core:roleIn ?Grant . " + "?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel ; " + "?Grant core:relatedRole ?RelatedRole . "
+ "core:relatedRole ?RelatedRole . "
+ "?RelatedRole core:investigatorRoleOf ?CoPI . " + "?RelatedRole core:investigatorRoleOf ?CoPI . "
@ -278,9 +264,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
+ "?Role core:roleIn ?Grant . " + "?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel ; " + "?Grant core:relatedRole ?RelatedRole . "
+ "core:relatedRole ?RelatedRole . "
+ "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?CoPI . " + "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?CoPI . "
@ -301,9 +285,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
+ "?Role core:roleIn ?Grant . " + "?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel ; " + "?Grant core:relatedRole ?RelatedRole . "
+ "core:relatedRole ?RelatedRole . "
+ "?RelatedRole core:principalInvestigatorRoleOf ?CoPI . " + "?RelatedRole core:principalInvestigatorRoleOf ?CoPI . "
@ -316,8 +298,6 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
+ "} " + "} "
+ "} "; + "} ";
//System.out.println("\n\nCOPI QUERY - " + sparqlQuery + "\n\n");
return sparqlQuery; return sparqlQuery;
} }
@ -647,10 +627,10 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
Activity grant = new Activity(grantURL); Activity grant = new Activity(grantURL);
RDFNode grantLabelNode = solution.get(QueryFieldLabels.GRANT_LABEL); // RDFNode grantLabelNode = solution.get(QueryFieldLabels.GRANT_LABEL);
if (grantLabelNode != null) { // if (grantLabelNode != null) {
grant.setIndividualLabel(grantLabelNode.toString()); // grant.setIndividualLabel(grantLabelNode.toString());
} // }
RDFNode grantStartYear = solution.get(QueryFieldLabels.ROLE_START_DATE); RDFNode grantStartYear = solution.get(QueryFieldLabels.ROLE_START_DATE);