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

@ -40,11 +40,23 @@
$(document).ready(function(){ $(document).ready(function(){
/* $.ajax({
Collaboratorship links do not show up by default. They should show up only if there any data to url: "${urls.base}/visualizationAjax",
show on that page. data: ({vis: "utilities", vis_mode: "SHOW_GRANTS_LINK", uri: '${individual.uri}'}),
*/ dataType: "json",
$("#coinvestigator_link_container").show(); success:function(data){
/*
Collaboratorship links do not show up by default. They should show up only if there any data to
show on that page.
*/
if (data.numOfGrants !== undefined && data.numOfGrants > 0) {
$("#coinvestigator_link_container").show();
}
}
});
}); });

View file

@ -82,11 +82,22 @@ $(document).ready(function(){
</#if> </#if>
/* $.ajax({
Collaboratorship links do not show up by default. They should show up only if there any data to url: "${urls.base}/visualizationAjax",
show on that page. data: ({vis: "utilities", vis_mode: "SHOW_GRANTS_LINK", uri: '${egoURIParam}'}),
*/ dataType: "json",
$("#coinvestigator_link_container").show(); success:function(data){
/*
Collaboratorship links do not show up by default. They should show up only if there any data to
show on that page.
*/
if (data.numOfGrants !== undefined && data.numOfGrants > 0) {
$("#coinvestigator_link_container").show();
}
}
});
}); });
</script> </script>

View file

@ -81,11 +81,22 @@ $(document).ready(function(){
</#if> </#if>
/* $.ajax({
Collaboratorship links do not show up by default. They should show up only if there any data to url: "${urls.base}/visualizationAjax",
show on that page. data: ({vis: "utilities", vis_mode: "SHOW_AUTHORSHIP_LINK", uri: '${egoURIParam}'}),
*/ dataType: "json",
$("#coauthorship_link_container").show(); success:function(data){
/*
Collaboratorship links do not show up by default. They should show up only if there any data to
show on that page.
*/
if (data.numOfPublications !== undefined && data.numOfPublications > 0) {
$("#coauthorship_link_container").show();
}
}
});
}); });
</script> </script>

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 PERSON_LEVEL_UTILS_VIS_MODE = "PERSON_LEVEL_URL";
public static final String COPI_UTILS_VIS_MODE = "COPI_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 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 UNIVERSITY_COMPARISON_VIS_MODE = "UNIVERSITY";
public static final String SCHOOL_COMPARISON_VIS_MODE = "SCHOOL"; public static final String SCHOOL_COMPARISON_VIS_MODE = "SCHOOL";
public static final String DEPARTMENT_COMPARISON_VIS_MODE = "DEPARTMENT"; 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); // Resource uri1 = ResourceFactory.createResource(queryURI);
String sparqlQuery = QueryConstants.getSparqlPrefixQuery() String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
+ "SELECT " + "SELECT \n"
+ " (str(<" + queryURI + ">) as ?" + QueryFieldLabels.AUTHOR_URL + ") " + " (str(<" + queryURI + ">) as ?" + QueryFieldLabels.AUTHOR_URL + ") \n"
+ " (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") " + " (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") \n"
+ " (str(?coAuthorPerson) as ?" + QueryFieldLabels.CO_AUTHOR_URL + ") " + " (str(?coAuthorPerson) as ?" + QueryFieldLabels.CO_AUTHOR_URL + ") \n"
+ " (str(?coAuthorPersonLabel) as ?" + QueryFieldLabels.CO_AUTHOR_LABEL + ") " + " (str(?coAuthorPersonLabel) as ?" + QueryFieldLabels.CO_AUTHOR_LABEL + ") \n"
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") " + " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n"
+ " (str(?documentLabel) as ?" + QueryFieldLabels.DOCUMENT_LABEL + ") " + " (str(?documentLabel) as ?" + QueryFieldLabels.DOCUMENT_LABEL + ") \n"
+ " (str(?documentMoniker) as ?" + QueryFieldLabels.DOCUMENT_MONIKER + ") " + " (str(?documentMoniker) as ?" + QueryFieldLabels.DOCUMENT_MONIKER + ") \n"
+ " (str(?documentBlurb) as ?" + QueryFieldLabels.DOCUMENT_BLURB + ") " + " (str(?documentBlurb) as ?" + QueryFieldLabels.DOCUMENT_BLURB + ") \n"
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") " + " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") \n"
+ " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") " + " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") \n"
+ "WHERE { " + "WHERE { \n"
+ "<" + queryURI + "> rdf:type foaf:Person ;" + "<" + queryURI + "> rdf:type foaf:Person ;"
+ " rdfs:label ?authorLabel ;" + " rdfs:label ?authorLabel ;"
+ " core:authorInAuthorship ?authorshipNode . " + " core:authorInAuthorship ?authorshipNode . \n"
+ "?authorshipNode rdf:type core:Authorship ;" + "?authorshipNode rdf:type core:Authorship ;"
+ " core:linkedInformationResource ?document . " + " core:linkedInformationResource ?document . \n"
+ "?document rdfs:label ?documentLabel . " + "?document rdfs:label ?documentLabel . \n"
+ "?document core:informationResourceInAuthorship ?coAuthorshipNode . " + "?document core:informationResourceInAuthorship ?coAuthorshipNode . \n"
+ "?coAuthorshipNode core:linkedAuthor ?coAuthorPerson . " + "?coAuthorshipNode core:linkedAuthor ?coAuthorPerson . \n"
+ "?coAuthorPerson rdfs:label ?coAuthorPersonLabel . " + "?coAuthorPerson rdfs:label ?coAuthorPersonLabel . \n"
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . " + "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n"
+ " ?dateTimeValue core:dateTime ?publicationDate } ." + " ?dateTimeValue core:dateTime ?publicationDate } .\n"
+ "OPTIONAL { ?document core:year ?publicationYearUsing_1_1_property } ." + "OPTIONAL { ?document core:year ?publicationYearUsing_1_1_property } .\n"
+ "OPTIONAL { ?document vitro:moniker ?documentMoniker } . " + "OPTIONAL { ?document vitro:moniker ?documentMoniker } . \n"
+ "OPTIONAL { ?document vitro:blurb ?documentBlurb } . " + "OPTIONAL { ?document vitro:blurb ?documentBlurb } . \n"
+ "OPTIONAL { ?document vitro:description ?documentDescription } " + "OPTIONAL { ?document vitro:description ?documentDescription } \n"
+ "} " + "} \n"
+ "ORDER BY ?document ?coAuthorPerson"; + "ORDER BY ?document ?coAuthorPerson\n";
// System.out.println("COAUTHORSHIP QUERY - " + sparqlQuery); // System.out.println("COAUTHORSHIP QUERY - " + sparqlQuery);

View file

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

View file

@ -110,6 +110,58 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
return getThumbnailInformation(imageQueryHandler.getQueryResult(), return getThumbnailInformation(imageQueryHandler.getQueryResult(),
fieldLabelToOutputFieldLabel); 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 } else if (VisualizationFrameworkConstants.COAUTHOR_UTILS_VIS_MODE
.equalsIgnoreCase(visMode)) { .equalsIgnoreCase(visMode)) {
@ -222,18 +274,6 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
highestLevelOrganizationQueryHandler.getQueryResult(), highestLevelOrganizationQueryHandler.getQueryResult(),
fieldLabelToOutputFieldLabel); fieldLabelToOutputFieldLabel);
/*
GenericQueryMap highestLevelOrganizationToValues = getHighestLevelOrganizationInformation(
highestLevelOrganizationQueryHandler.getQueryResult(),
fieldLabelToOutputFieldLabel);
Gson highestLevelOrganizationInformation = new Gson();
return highestLevelOrganizationInformation.toJson(highestLevelOrganizationToValues);
*/
} else { } else {
ParamMap individualProfileURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY, ParamMap individualProfileURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
@ -288,10 +328,47 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
} }
} }
// return queryResult;
return ""; 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, private String getThumbnailInformation(ResultSet resultSet,
Map<String, String> fieldLabelToOutputFieldLabel) { Map<String, String> fieldLabelToOutputFieldLabel) {