1. Fix for the bug NIHVIVO-1775 essentially not displaying collaboratorship links (co-authorship or co-piship) if there are no publications (or grants) for that individual. The affected pages are foaf:Person profile page, co-authorship & co-piship pages for a foaf:Person.

This commit is contained in:
cdtank 2011-01-20 22:49:56 +00:00
parent b1bd6cf652
commit c5709c2c74
7 changed files with 189 additions and 76 deletions

View file

@ -84,6 +84,8 @@ public class VisualizationFrameworkConstants {
public static final String PERSON_LEVEL_UTILS_VIS_MODE = "PERSON_LEVEL_URL";
public static final String COPI_UTILS_VIS_MODE = "COPI_URL";
public static final String IMAGE_UTILS_VIS_MODE = "IMAGE_URL";
public static final String ARE_PUBLICATIONS_AVAILABLE_UTILS_VIS_MODE = "SHOW_AUTHORSHIP_LINK";
public static final String ARE_GRANTS_AVAILABLE_UTILS_VIS_MODE = "SHOW_GRANTS_LINK";
public static final String UNIVERSITY_COMPARISON_VIS_MODE = "UNIVERSITY";
public static final String SCHOOL_COMPARISON_VIS_MODE = "SCHOOL";
public static final String DEPARTMENT_COMPARISON_VIS_MODE = "DEPARTMENT";

View file

@ -406,35 +406,35 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
// Resource uri1 = ResourceFactory.createResource(queryURI);
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
+ "SELECT "
+ " (str(<" + queryURI + ">) as ?" + QueryFieldLabels.AUTHOR_URL + ") "
+ " (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") "
+ " (str(?coAuthorPerson) as ?" + QueryFieldLabels.CO_AUTHOR_URL + ") "
+ " (str(?coAuthorPersonLabel) as ?" + QueryFieldLabels.CO_AUTHOR_LABEL + ") "
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") "
+ " (str(?documentLabel) as ?" + QueryFieldLabels.DOCUMENT_LABEL + ") "
+ " (str(?documentMoniker) as ?" + QueryFieldLabels.DOCUMENT_MONIKER + ") "
+ " (str(?documentBlurb) as ?" + QueryFieldLabels.DOCUMENT_BLURB + ") "
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") "
+ " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") "
+ "WHERE { "
+ "SELECT \n"
+ " (str(<" + queryURI + ">) as ?" + QueryFieldLabels.AUTHOR_URL + ") \n"
+ " (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") \n"
+ " (str(?coAuthorPerson) as ?" + QueryFieldLabels.CO_AUTHOR_URL + ") \n"
+ " (str(?coAuthorPersonLabel) as ?" + QueryFieldLabels.CO_AUTHOR_LABEL + ") \n"
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n"
+ " (str(?documentLabel) as ?" + QueryFieldLabels.DOCUMENT_LABEL + ") \n"
+ " (str(?documentMoniker) as ?" + QueryFieldLabels.DOCUMENT_MONIKER + ") \n"
+ " (str(?documentBlurb) as ?" + QueryFieldLabels.DOCUMENT_BLURB + ") \n"
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") \n"
+ " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") \n"
+ "WHERE { \n"
+ "<" + queryURI + "> rdf:type foaf:Person ;"
+ " rdfs:label ?authorLabel ;"
+ " core:authorInAuthorship ?authorshipNode . "
+ " core:authorInAuthorship ?authorshipNode . \n"
+ "?authorshipNode rdf:type core:Authorship ;"
+ " core:linkedInformationResource ?document . "
+ "?document rdfs:label ?documentLabel . "
+ "?document core:informationResourceInAuthorship ?coAuthorshipNode . "
+ "?coAuthorshipNode core:linkedAuthor ?coAuthorPerson . "
+ "?coAuthorPerson rdfs:label ?coAuthorPersonLabel . "
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . "
+ " ?dateTimeValue core:dateTime ?publicationDate } ."
+ "OPTIONAL { ?document core:year ?publicationYearUsing_1_1_property } ."
+ "OPTIONAL { ?document vitro:moniker ?documentMoniker } . "
+ "OPTIONAL { ?document vitro:blurb ?documentBlurb } . "
+ "OPTIONAL { ?document vitro:description ?documentDescription } "
+ "} "
+ "ORDER BY ?document ?coAuthorPerson";
+ " core:linkedInformationResource ?document . \n"
+ "?document rdfs:label ?documentLabel . \n"
+ "?document core:informationResourceInAuthorship ?coAuthorshipNode . \n"
+ "?coAuthorshipNode core:linkedAuthor ?coAuthorPerson . \n"
+ "?coAuthorPerson rdfs:label ?coAuthorPersonLabel . \n"
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n"
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n"
+ "OPTIONAL { ?document core:year ?publicationYearUsing_1_1_property } .\n"
+ "OPTIONAL { ?document vitro:moniker ?documentMoniker } . \n"
+ "OPTIONAL { ?document vitro:blurb ?documentBlurb } . \n"
+ "OPTIONAL { ?document vitro:description ?documentDescription } \n"
+ "} \n"
+ "ORDER BY ?document ?coAuthorPerson\n";
// System.out.println("COAUTHORSHIP QUERY - " + sparqlQuery);

View file

@ -52,23 +52,23 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
private Log log;
private static final String SPARQL_QUERY_COMMON_SELECT_CLAUSE = ""
+ "SELECT (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") "
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") "
+ " (str(?documentMoniker) as ?" + QueryFieldLabels.DOCUMENT_MONIKER + ") "
+ " (str(?documentLabel) as ?" + QueryFieldLabels.DOCUMENT_LABEL + ") "
+ " (str(?documentBlurb) as ?" + QueryFieldLabels.DOCUMENT_BLURB + ") "
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") "
+ " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") "
+ " (str(?documentDescription) as ?" + QueryFieldLabels.DOCUMENT_DESCRIPTION + ") ";
+ "SELECT (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") \n"
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n"
+ " (str(?documentMoniker) as ?" + QueryFieldLabels.DOCUMENT_MONIKER + ") \n"
+ " (str(?documentLabel) as ?" + QueryFieldLabels.DOCUMENT_LABEL + ") \n"
+ " (str(?documentBlurb) as ?" + QueryFieldLabels.DOCUMENT_BLURB + ") \n"
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") \n"
+ " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") \n"
+ " (str(?documentDescription) as ?" + QueryFieldLabels.DOCUMENT_DESCRIPTION + ") \n";
private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = ""
+ "?document rdfs:label ?documentLabel ."
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . "
+ " ?dateTimeValue core:dateTime ?publicationDate } ."
+ "OPTIONAL { ?document core:year ?publicationYearUsing_1_1_property } ."
+ "OPTIONAL { ?document vitro:moniker ?documentMoniker } ."
+ "OPTIONAL { ?document vitro:blurb ?documentBlurb } ."
+ "OPTIONAL { ?document vitro:description ?documentDescription }";
+ "?document rdfs:label ?documentLabel .\n"
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n"
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n"
+ "OPTIONAL { ?document core:year ?publicationYearUsing_1_1_property } .\n"
+ "OPTIONAL { ?document vitro:moniker ?documentMoniker } .\n"
+ "OPTIONAL { ?document vitro:blurb ?documentBlurb } .\n"
+ "OPTIONAL { ?document vitro:description ?documentDescription }\n";
public PersonPublicationCountQueryRunner(String personURI,
DataSource dataSource, Log log) {
@ -155,15 +155,15 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
+ SPARQL_QUERY_COMMON_SELECT_CLAUSE
+ "(str(<" + queryURI + ">) as ?authPersonLit) "
+ "WHERE { "
+ "<" + queryURI + "> rdf:type foaf:Person ;"
+ " rdfs:label ?authorLabel ;"
+ " core:authorInAuthorship ?authorshipNode . "
+ "(str(<" + queryURI + ">) as ?authPersonLit)\n "
+ "WHERE { \n"
+ "<" + queryURI + "> rdf:type foaf:Person ;\n"
+ " rdfs:label ?authorLabel \n;"
+ " core:authorInAuthorship ?authorshipNode . \n"
+ " ?authorshipNode rdf:type core:Authorship ;"
+ " core:linkedInformationResource ?document . "
+ " core:linkedInformationResource ?document . \n"
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE
+ "}";
+ "}\n";
// System.out.println(sparqlQuery);

View file

@ -110,6 +110,58 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
return getThumbnailInformation(imageQueryHandler.getQueryResult(),
fieldLabelToOutputFieldLabel);
} else if (VisualizationFrameworkConstants.ARE_PUBLICATIONS_AVAILABLE_UTILS_VIS_MODE
.equalsIgnoreCase(visMode)) {
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
String aggregationRules = "(count(DISTINCT ?document) AS ?numOfPublications)";
String whereClause = "<" + individualURI + "> rdf:type foaf:Person ; core:authorInAuthorship ?authorshipNode . \n"
+ "?authorshipNode rdf:type core:Authorship ; core:linkedInformationResource ?document .";
String groupOrderClause = "GROUP BY ?" + QueryFieldLabels.AUTHOR_URL + " \n";
QueryRunner<ResultSet> numberOfPublicationsQueryHandler =
new GenericQueryRunner(fieldLabelToOutputFieldLabel,
aggregationRules,
whereClause,
groupOrderClause,
dataSource, log);
Gson publicationsInformation = new Gson();
return publicationsInformation.toJson(getNumberOfPublicationsForIndividual(
numberOfPublicationsQueryHandler.getQueryResult()));
} else if (VisualizationFrameworkConstants.ARE_GRANTS_AVAILABLE_UTILS_VIS_MODE
.equalsIgnoreCase(visMode)) {
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
String aggregationRules = "(count(DISTINCT ?Grant) AS ?numOfGrants)";
String whereClause = "{ <" + individualURI + "> rdf:type foaf:Person ; core:hasCo-PrincipalInvestigatorRole ?Role . \n"
+ "?Role core:roleIn ?Grant . }"
+ "UNION \n"
+ "{ <" + individualURI + "> rdf:type foaf:Person ; core:hasPrincipalInvestigatorRole ?Role . \n"
+ "?Role core:roleIn ?Grant . }"
+ "UNION \n"
+ "{ <" + individualURI + "> rdf:type foaf:Person ; core:hasInvestigatorRole ?Role . \n"
+ "?Role core:roleIn ?Grant . }";
QueryRunner<ResultSet> numberOfGrantsQueryHandler =
new GenericQueryRunner(fieldLabelToOutputFieldLabel,
aggregationRules,
whereClause,
"",
dataSource, log);
Gson grantsInformation = new Gson();
return grantsInformation.toJson(getNumberOfGrantsForIndividual(
numberOfGrantsQueryHandler.getQueryResult()));
} else if (VisualizationFrameworkConstants.COAUTHOR_UTILS_VIS_MODE
.equalsIgnoreCase(visMode)) {
@ -222,18 +274,6 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
highestLevelOrganizationQueryHandler.getQueryResult(),
fieldLabelToOutputFieldLabel);
/*
GenericQueryMap highestLevelOrganizationToValues = getHighestLevelOrganizationInformation(
highestLevelOrganizationQueryHandler.getQueryResult(),
fieldLabelToOutputFieldLabel);
Gson highestLevelOrganizationInformation = new Gson();
return highestLevelOrganizationInformation.toJson(highestLevelOrganizationToValues);
*/
} else {
ParamMap individualProfileURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
@ -288,10 +328,47 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
}
}
// return queryResult;
return "";
}
private GenericQueryMap getNumberOfGrantsForIndividual (ResultSet resultSet) {
GenericQueryMap queryResult = new GenericQueryMap();
while (resultSet.hasNext()) {
QuerySolution solution = resultSet.nextSolution();
RDFNode numberOfGrantsNode = solution.getLiteral("numOfGrants");
if (numberOfGrantsNode != null) {
queryResult.addEntry("numOfGrants", String.valueOf(numberOfGrantsNode.asLiteral().getInt()));
}
}
return queryResult;
}
private GenericQueryMap getNumberOfPublicationsForIndividual (ResultSet resultSet) {
GenericQueryMap queryResult = new GenericQueryMap();
while (resultSet.hasNext()) {
QuerySolution solution = resultSet.nextSolution();
RDFNode numberOfPublicationsNode = solution.getLiteral("numOfPublications");
if (numberOfPublicationsNode != null) {
queryResult.addEntry("numOfPublications", String.valueOf(numberOfPublicationsNode.asLiteral().getInt()));
}
}
return queryResult;
}
private String getThumbnailInformation(ResultSet resultSet,
Map<String, String> fieldLabelToOutputFieldLabel) {