Resolving the following:

(NIH-1804) Do investigator grants show up in visualizations of just principal-investigator?
(NIH - 1826) Make sparql queries for Grants related visualizations compliant to 1.2 for the date property

Made changes to the grant queries to include core:dateTime property.
This commit is contained in:
bkoniden 2011-01-20 18:44:13 +00:00
parent 737024a8e0
commit 628d7615f3
3 changed files with 122 additions and 85 deletions

View file

@ -55,6 +55,17 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
private UniqueIDGenerator edgeIDGenerator;
private static final String SPARQL_QUERY_COMMON_OPTIONAL_BLOCK = ""
+ "OPTIONAL {"
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue . "
+ "OPTIONAL {"
+ "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue . "
+ "}"
+ "}" ;
public CoPIGrantCountQueryRunner(String egoURI,
DataSource dataSource, Log log) {
@ -76,8 +87,8 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
+ " (str(?PILabel) as ?" + QueryFieldLabels.PI_LABEL + ") "
+ " (str(?Grant) as ?" + QueryFieldLabels.GRANT_URL + ") "
+ " (str(?GrantLabel) as ?" + QueryFieldLabels.GRANT_LABEL + ") "
+ " (str(?GrantStartDate) as ?" + QueryFieldLabels.GRANT_START_DATE + ") "
+ " (str(?GrantEndDate) as ?" + QueryFieldLabels.GRANT_END_DATE + ") "
+ " (str(?startDateTimeValue) as ?grantStartDateLit) "
+ " (str(?endDateTimeValue) as ?grantEndDateLit) "
+ " (str(?CoPI) as ?" + QueryFieldLabels.CO_PI_URL + ") "
+ " (str(?CoPILabel) as ?" + QueryFieldLabels.CO_PI_LABEL + ") "
+ "WHERE "
@ -97,58 +108,34 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
+ "?CoPI rdfs:label ?CoPILabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . "
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . "
+ "} "
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "} "
+ "UNION "
+ "{ "
// + "{ "
// + "<" + queryURI + "> rdfs:label ?PILabel . "
+ "{ "
+ "<" + queryURI + "> core:hasPrincipalInvestigatorRole ?Role . "
+ "<" + queryURI + "> core:hasCo-PrincipalInvestigatorRole ?Role . "
+ "?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel ; "
+ "core:relatedRole ?RelatedRole . "
+ "?Grant rdfs:label ?GrantLabel ; "
+ "?RelatedRole core:principalInvestigatorRoleOf ?CoPI . "
+ "?CoPI rdfs:label ?CoPILabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . "
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . "
+ "} "
+ "UNION "
+ "{ "
+ "<" + queryURI + "> core:hasPrincipalInvestigatorRole ?Role . "
+ "?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel ; "
+ "core:relatedRole ?RelatedRole . "
+ "?RelatedRole core:investigatorRoleOf ?CoPI . "
+ "?CoPI rdfs:label ?CoPILabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . "
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . "
+ "} "
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "} "
+ "UNION "
+ "{ "
+ "<" + queryURI + "> core:hasCo-PrincipalInvestigatorRole ?Role . "
@ -166,10 +153,51 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . "
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . "
+ "} "
+ "UNION "
+ "{ "
+ "<" + queryURI + "> core:hasPrincipalInvestigatorRole ?Role . "
+ "?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel ; "
+ "core:relatedRole ?RelatedRole . "
+ "?RelatedRole core:principalInvestigatorRoleOf ?CoPI . "
+ "?CoPI rdfs:label ?CoPILabel . "
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "} "
+ "UNION "
+ "{ "
+ "<" + queryURI + "> core:hasPrincipalInvestigatorRole ?Role . "
+ "?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel ; "
+ "core:relatedRole ?RelatedRole . "
+ "?RelatedRole core:investigatorRoleOf ?CoPI . "
+ "?CoPI rdfs:label ?CoPILabel . "
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "} "
+ "UNION "
+ "{ "
@ -185,16 +213,15 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
+ "?CoPI rdfs:label ?CoPILabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . "
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . "
+ "} "
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "} "
+ "UNION "
+ "{ "
+ "<" + queryURI + "> core:hasPrincipalInvestigatorRole ?Role . "
+ "<" + queryURI + "> core:hasInvestigatorRole ?Role . "
+ "?Role core:roleIn ?Grant . "
@ -206,10 +233,10 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
+ "?CoPI rdfs:label ?CoPILabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . "
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . "
+ "} "
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "} "
+ "UNION "
+ "{ "
@ -226,10 +253,9 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
+ "?CoPI rdfs:label ?CoPILabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . "
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . "
+ "} "
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "} "
+ "UNION "
@ -247,15 +273,14 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
+ "?CoPI rdfs:label ?CoPILabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . "
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . "
+ "} "
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "} "
+ "} ";
log.debug("COPI QUERY - " + sparqlQuery);
//System.out.println("\n\nCOPI QUERY - " + sparqlQuery + "\n\n");
System.out.println("\n\nCOPI QUERY - " + sparqlQuery + "\n\n");
return sparqlQuery;
}

View file

@ -56,15 +56,22 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
+ " (str(?SecondaryPositionLabel) as ?SecondaryPositionLabelLit)"
+ " (str(?Grant) as ?grantLit) "
+ " (str(?GrantLabel) as ?grantLabelLit) "
+ " (str(?GrantStartDate) as ?grantStartDateLit) "
+ " (str(?GrantEndDate) as ?grantEndDateLit) ";
+ " (str(?startDateTimeValue) as ?grantStartDateLit) "
+ " (str(?endDateTimeValue) as ?grantEndDateLit) ";
private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = " "
+ " ?SecondaryPosition rdfs:label ?SecondaryPositionLabel . "
+ " ?Role core:roleIn ?Grant . "
+ " ?Grant rdfs:label ?GrantLabel . "
+ " OPTIONAL { ?Grant core:startDate ?GrantStartDate } . "
+ " OPTIONAL { ?Grant core:endDate ?GrantEndDate } .";
+ "OPTIONAL {"
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue . "
+ "OPTIONAL {"
+ "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue . "
+ "}"
+ "}" ;
private static String ENTITY_LABEL = QueryFieldLabels.ORGANIZATION_LABEL;
@ -240,7 +247,7 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE + "}"
+ " } ";
//System.out.println("\n\nEntity Grant Count query is: "+ sparqlQuery);
System.out.println("\n\nEntity Grant Count query is: "+ sparqlQuery);
log.debug("\nThe sparql query is :\n" + sparqlQuery);

View file

@ -53,8 +53,19 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Grant>>{
+ "SELECT (str(?PILabel) as ?PILabelLit) "
+ "(str(?Grant) as ?grantLit)"
+ "(str(?GrantLabel) as ?grantLabelLit)"
+ "(str(?GrantStartDate) as ?grantStartDateLit)"
+ "(str(?GrantEndDate) as ?grantEndDateLit)" ;
+ " (str(?startDateTimeValue) as ?grantStartDateLit) "
+ " (str(?endDateTimeValue) as ?grantEndDateLit) ";
private static final String SPARQL_QUERY_COMMON_OPTIONAL_BLOCK = ""
+ "OPTIONAL {"
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue . "
+ "OPTIONAL {"
+ "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue . "
+ "}"
+ "}" ;
public PersonGrantCountQueryRunner(String personURI, DataSource dataSource, Log log){
@ -135,11 +146,10 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Grant>>{
+ "?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . "
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . "
+ "} "
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "} "
+ "UNION "
@ -150,13 +160,10 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Grant>>{
+ "?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . "
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . "
+ "} "
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "} "
+ "UNION "
@ -167,17 +174,15 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Grant>>{
+ "?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . "
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . "
+ "} "
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "} "
+ "} ";
log.debug("SPARQL query for person grant count -> \n"+ sparqlQuery);
System.out.println("SPARQL query for person grant count -> \n"+ sparqlQuery);
return sparqlQuery;
}