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 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, public CoPIGrantCountQueryRunner(String egoURI,
DataSource dataSource, Log log) { DataSource dataSource, Log log) {
@ -76,8 +87,8 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
+ " (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(?GrantStartDate) as ?" + QueryFieldLabels.GRANT_START_DATE + ") " + " (str(?startDateTimeValue) as ?grantStartDateLit) "
+ " (str(?GrantEndDate) as ?" + QueryFieldLabels.GRANT_END_DATE + ") " + " (str(?endDateTimeValue) as ?grantEndDateLit) "
+ " (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 "
@ -97,39 +108,17 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
+ "?CoPI rdfs:label ?CoPILabel . " + "?CoPI rdfs:label ?CoPILabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . " + SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . " + "} "
+ "} "
+ "UNION " + "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 . "
+ "?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 . " + "?Role core:roleIn ?Grant . "
@ -141,11 +130,9 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
+ "?CoPI rdfs:label ?CoPILabel . " + "?CoPI rdfs:label ?CoPILabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . " + SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . " + "} "
+ "} "
+ "UNION " + "UNION "
@ -171,6 +158,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
+ "UNION " + "UNION "
+ "{ " + "{ "
+ "<" + queryURI + "> core:hasPrincipalInvestigatorRole ?Role . " + "<" + queryURI + "> core:hasPrincipalInvestigatorRole ?Role . "
@ -181,14 +169,13 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
+ "core:relatedRole ?RelatedRole . " + "core:relatedRole ?RelatedRole . "
+ "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?CoPI . " + "?RelatedRole core:principalInvestigatorRoleOf ?CoPI . "
+ "?CoPI rdfs:label ?CoPILabel . " + "?CoPI rdfs:label ?CoPILabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . " + SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . " + "} "
+ "} "
+ "UNION " + "UNION "
@ -206,10 +193,50 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
+ "?CoPI rdfs:label ?CoPILabel . " + "?CoPI rdfs:label ?CoPILabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . " + SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "} "
+ "UNION "
+ "{ "
+ "<" + queryURI + "> core:hasPrincipalInvestigatorRole ?Role . "
+ "?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel ; "
+ "core:relatedRole ?RelatedRole . "
+ "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?CoPI . "
+ "?CoPI rdfs:label ?CoPILabel . "
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "} "
+ "UNION "
+ "{ "
+ "<" + queryURI + "> core:hasInvestigatorRole ?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
+ "} "
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . "
+ "} "
+ "UNION " + "UNION "
+ "{ " + "{ "
@ -226,10 +253,9 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
+ "?CoPI rdfs:label ?CoPILabel . " + "?CoPI rdfs:label ?CoPILabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . " + SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . " + "} "
+ "} "
+ "UNION " + "UNION "
@ -247,15 +273,14 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
+ "?CoPI rdfs:label ?CoPILabel . " + "?CoPI rdfs:label ?CoPILabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . " + SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . " + "} "
+ "} "
+ "} "; + "} ";
log.debug("COPI QUERY - " + sparqlQuery); 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; return sparqlQuery;
} }

View file

@ -56,15 +56,22 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
+ " (str(?SecondaryPositionLabel) as ?SecondaryPositionLabelLit)" + " (str(?SecondaryPositionLabel) as ?SecondaryPositionLabelLit)"
+ " (str(?Grant) as ?grantLit) " + " (str(?Grant) as ?grantLit) "
+ " (str(?GrantLabel) as ?grantLabelLit) " + " (str(?GrantLabel) as ?grantLabelLit) "
+ " (str(?GrantStartDate) as ?grantStartDateLit) " + " (str(?startDateTimeValue) as ?grantStartDateLit) "
+ " (str(?GrantEndDate) as ?grantEndDateLit) "; + " (str(?endDateTimeValue) as ?grantEndDateLit) ";
private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = " " private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = " "
+ " ?SecondaryPosition rdfs:label ?SecondaryPositionLabel . " + " ?SecondaryPosition rdfs:label ?SecondaryPositionLabel . "
+ " ?Role core:roleIn ?Grant . " + " ?Role core:roleIn ?Grant . "
+ " ?Grant rdfs:label ?GrantLabel . " + " ?Grant rdfs:label ?GrantLabel . "
+ " OPTIONAL { ?Grant core:startDate ?GrantStartDate } . " + "OPTIONAL {"
+ " OPTIONAL { ?Grant core:endDate ?GrantEndDate } ."; + "?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; private static String ENTITY_LABEL = QueryFieldLabels.ORGANIZATION_LABEL;
@ -240,7 +247,7 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE + "}" + 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); 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) " + "SELECT (str(?PILabel) as ?PILabelLit) "
+ "(str(?Grant) as ?grantLit)" + "(str(?Grant) as ?grantLit)"
+ "(str(?GrantLabel) as ?grantLabelLit)" + "(str(?GrantLabel) as ?grantLabelLit)"
+ "(str(?GrantStartDate) as ?grantStartDateLit)" + " (str(?startDateTimeValue) as ?grantStartDateLit) "
+ "(str(?GrantEndDate) as ?grantEndDateLit)" ; + " (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){ public PersonGrantCountQueryRunner(String personURI, DataSource dataSource, Log log){
@ -136,10 +147,9 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Grant>>{
+ "?Grant rdfs:label ?GrantLabel . " + "?Grant rdfs:label ?GrantLabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . " + SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . " + "} "
+ "} "
+ "UNION " + "UNION "
@ -151,12 +161,9 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Grant>>{
+ "?Grant rdfs:label ?GrantLabel . " + "?Grant rdfs:label ?GrantLabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . " + SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . " + "} "
+ "} "
+ "UNION " + "UNION "
@ -168,16 +175,14 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Grant>>{
+ "?Grant rdfs:label ?GrantLabel . " + "?Grant rdfs:label ?GrantLabel . "
+ "OPTIONAL { ?Grant core:startDate ?GrantStartDate } . " + SPARQL_QUERY_COMMON_OPTIONAL_BLOCK
+ "OPTIONAL { ?Grant core:endDate ?GrantEndDate } . " + "} "
+ "} "
+ "} "; + "} ";
log.debug("SPARQL query for person grant count -> \n"+ sparqlQuery); log.debug("SPARQL query for person grant count -> \n"+ sparqlQuery);
System.out.println("SPARQL query for person grant count -> \n"+ sparqlQuery);
return sparqlQuery; return sparqlQuery;
} }