1. Refactored code

2. Fine tuned the sparkline generators for "person level" vis
3. Modified coauthorship vis code geenrator to fix link bugs
4. Modified front end for the person level so that IE behaves properly. 
5. Modified style to make sure no weirdness when a user's profile image is present or not.
6. Added handler for downloading a list of all the coauthors and its count.
This commit is contained in:
cdtank 2010-07-09 01:05:27 +00:00
parent 4c9f427d5e
commit c30d99692a
9 changed files with 213 additions and 71 deletions

View file

@ -6,6 +6,11 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.Map.Entry;
import org.apache.commons.collections.BidiMap;
import org.apache.commons.collections.MapIterator;
import org.apache.commons.collections.bidimap.TreeBidiMap;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.hp.hpl.jena.iri.IRIFactory; import com.hp.hpl.jena.iri.IRIFactory;
@ -44,18 +49,39 @@ public class TestJava {
System.out.println(sampleBlurns); System.out.println(sampleBlurns);
for (String blurb : sampleBlurns) { for (String blurb : sampleBlurns) {
System.out.println(blurb.substring(0, 10)); // System.out.println(blurb.substring(0, 10));
} }
Map<String, Integer> yearToPublicationCount = new TreeMap<String, Integer>(); Map<String, Integer> yearToPublicationCount = new TreeMap<String, Integer>();
yearToPublicationCount.put("2003", 5); yearToPublicationCount.put("2003", 5);
yearToPublicationCount.put("2001", 5); yearToPublicationCount.put("2005", 3);
yearToPublicationCount.put("2002", 5); yearToPublicationCount.put("2002", 1);
yearToPublicationCount.put("2090", 7); yearToPublicationCount.put("2090", 5);
yearToPublicationCount.put("Unknown", 6); yearToPublicationCount.put("Unknown", 6);
BidiMap map1 = new TreeBidiMap(yearToPublicationCount);
System.out.println(map1 + " --- " + map1.inverseBidiMap());
Node egoNode; Node egoNode;
MapIterator mapIterator = map1.inverseBidiMap().mapIterator();
while(mapIterator.hasNext()) {
Object next = mapIterator.next();
System.out.println(next + " %%% " + next);
}
System.out.println(); System.out.println();
Map<String, Set<Integer>> biboDocumentURLToCoAuthors = new HashMap<String, Set<Integer>>(); Map<String, Set<Integer>> biboDocumentURLToCoAuthors = new HashMap<String, Set<Integer>>();

View file

@ -176,11 +176,11 @@ public class VisualizationCodeGenerator {
"function drawUniqueCoauthorCountVisualization(providedSparklineImgTD) {\n" + "function drawUniqueCoauthorCountVisualization(providedSparklineImgTD) {\n" +
"var data = new google.visualization.DataTable();\n" + "var data = new google.visualization.DataTable();\n" +
"data.addColumn('string', 'Year');\n" + "data.addColumn('string', 'Year');\n" +
"data.addColumn('number', 'Publications');\n" + "data.addColumn('number', 'Unique co-authors');\n" +
"data.addRows(" + numOfYearsToBeRendered + ");\n"); "data.addRows(" + numOfYearsToBeRendered + ");\n");
int publicationCounter = 0; int uniqueCoAuthorCounter = 0;
int totalPublications = 0; int totalUniqueCoAuthors = 0;
int renderedFullSparks = 0; int renderedFullSparks = 0;
@ -194,33 +194,33 @@ public class VisualizationCodeGenerator {
} }
visualizationCode.append("data.setValue(" visualizationCode.append("data.setValue("
+ publicationCounter + uniqueCoAuthorCounter
+ ", 0, '" + ", 0, '"
+ stringPublishedYear + stringPublishedYear
+ "');\n"); + "');\n");
visualizationCode.append("data.setValue(" visualizationCode.append("data.setValue("
+ publicationCounter + uniqueCoAuthorCounter
+ ", 1, " + ", 1, "
+ currentPublications + currentPublications
+ ");\n"); + ");\n");
totalPublications += currentPublications; totalUniqueCoAuthors += currentPublications;
publicationCounter++; uniqueCoAuthorCounter++;
} }
/* /*
* Sparks that will be rendered in full mode will always be the one's which has any year * Sparks that will be rendered in full mode will always be the one's which has any year
* associated with it. Hence. * associated with it. Hence.
* */ * */
renderedFullSparks = totalPublications; renderedFullSparks = totalUniqueCoAuthors;
/* /*
* Total publications will also consider publications that have no year associated with * Total publications will also consider publications that have no year associated with
* it. Hence. * it. Hence.
* */ * */
if (yearToUniqueCoauthorsCount.get(VOConstants.DEFAULT_PUBLICATION_YEAR) != null) { if (yearToUniqueCoauthorsCount.get(VOConstants.DEFAULT_PUBLICATION_YEAR) != null) {
totalPublications += yearToUniqueCoauthorsCount.get(VOConstants.DEFAULT_PUBLICATION_YEAR); totalUniqueCoAuthors += yearToUniqueCoauthorsCount.get(VOConstants.DEFAULT_PUBLICATION_YEAR);
} }
String sparklineDisplayOptions = "{width: 63, height: 21, showAxisLines: false, " + String sparklineDisplayOptions = "{width: 63, height: 21, showAxisLines: false, " +
@ -259,14 +259,14 @@ public class VisualizationCodeGenerator {
shortSparkMinYear, shortSparkMinYear,
visContainerID, visContainerID,
visualizationCode, visualizationCode,
totalPublications, totalUniqueCoAuthors,
sparklineDisplayOptions); sparklineDisplayOptions);
} else { } else {
generateFullSparklineVisualizationContent(currentYear, generateFullSparklineVisualizationContent(currentYear,
minPubYearConsidered, minPubYearConsidered,
visContainerID, visContainerID,
visualizationCode, visualizationCode,
totalPublications, totalUniqueCoAuthors,
renderedFullSparks, renderedFullSparks,
sparklineDisplayOptions); sparklineDisplayOptions);
} }
@ -285,7 +285,7 @@ public class VisualizationCodeGenerator {
private void generateShortSparklineVisualizationContent(int currentYear, private void generateShortSparklineVisualizationContent(int currentYear,
int shortSparkMinYear, String visContainerID, int shortSparkMinYear, String visContainerID,
StringBuilder visualizationCode, int totalPublications, StringBuilder visualizationCode, int totalUniqueCoAuthors,
String sparklineDisplayOptions) { String sparklineDisplayOptions) {
/* /*
@ -330,8 +330,8 @@ public class VisualizationCodeGenerator {
* */ * */
visualizationCode.append("$('#" + visDivNames.get("SHORT_SPARK") + " td.sparkline_number').text(renderedShortSparks);"); visualizationCode.append("$('#" + visDivNames.get("SHORT_SPARK") + " td.sparkline_number').text(renderedShortSparks);");
visualizationCode.append("var shortSparksText = ''" + visualizationCode.append("var shortSparksText = ''" +
"+ ' Papers with year from '" + "+ ' Unique co-authors with year from '" +
"+ ' " + totalPublications + " '" + "+ ' " + totalUniqueCoAuthors + " '" +
"+ ' total " + "+ ' total " +
"<span class=\"sparkline_range\">" + "<span class=\"sparkline_range\">" +
"(" + shortSparkMinYear + " - " + currentYear + ")" + "(" + shortSparkMinYear + " - " + currentYear + ")" +
@ -351,7 +351,7 @@ public class VisualizationCodeGenerator {
private void generateFullSparklineVisualizationContent( private void generateFullSparklineVisualizationContent(
int currentYear, int minPubYearConsidered, String visContainerID, StringBuilder visualizationCode, int currentYear, int minPubYearConsidered, String visContainerID, StringBuilder visualizationCode,
int totalPublications, int renderedFullSparks, int totalUniqueCoAuthors, int renderedFullSparks,
String sparklineDisplayOptions) { String sparklineDisplayOptions) {
String csvDownloadURL = ""; String csvDownloadURL = "";
@ -375,7 +375,7 @@ public class VisualizationCodeGenerator {
visualizationCode.append("var allSparksText = ''" + visualizationCode.append("var allSparksText = ''" +
"+ ' Unique co-authors '" + "+ ' Unique co-authors '" +
"<span class=\"sparkline_range\">" + "+ ' <span class=\"sparkline_range\">" +
"(" + minPubYearConsidered + " - " + currentYear + ")" + "(" + minPubYearConsidered + " - " + currentYear + ")" +
"</span> '" + "</span> '" +
"+ ' <a href=\"" + csvDownloadURL + "\" class=\"inline_href\">(.CSV File)</a>';" + "+ ' <a href=\"" + csvDownloadURL + "\" class=\"inline_href\">(.CSV File)</a>';" +

View file

@ -199,7 +199,7 @@ public class VisualizationRequestHandler {
if (authorNodesAndEdges.getNodes() == null || authorNodesAndEdges.getNodes().size() < 1 ) { if (authorNodesAndEdges.getNodes() == null || authorNodesAndEdges.getNodes().size() < 1 ) {
outputFileName = "no-coauthorship-net" + ".graphml"; outputFileName = "no-coauthors" + ".csv";
} else { } else {
@ -235,8 +235,6 @@ public class VisualizationRequestHandler {
private void generateCsvFileBuffer(Map<String, Set<Node>> yearToCoauthors, PrintWriter printWriter) { private void generateCsvFileBuffer(Map<String, Set<Node>> yearToCoauthors, PrintWriter printWriter) {
// CSVWriter csvWriter = new SimpleWriter(printWriter);
printWriter.append("\"Year\", \"Number of Co-Authors\", \"Co-Author(s)\"\n"); printWriter.append("\"Year\", \"Number of Co-Authors\", \"Co-Author(s)\"\n");
for (Entry<String, Set<Node>> currentEntry : yearToCoauthors.entrySet()) { for (Entry<String, Set<Node>> currentEntry : yearToCoauthors.entrySet()) {

View file

@ -59,6 +59,8 @@ public class VisualizationRequestHandler {
String visMode = vitroRequest.getParameter(VisualizationFrameworkConstants.VIS_MODE_URL_HANDLE); String visMode = vitroRequest.getParameter(VisualizationFrameworkConstants.VIS_MODE_URL_HANDLE);
String coAuthorsListMode = "coauthors";
String egoPubSparklineVisContainerID = "ego_pub_sparkline"; String egoPubSparklineVisContainerID = "ego_pub_sparkline";
String uniqueCoauthorsSparklineVisContainerID = "unique_coauthors_sparkline"; String uniqueCoauthorsSparklineVisContainerID = "unique_coauthors_sparkline";
@ -89,12 +91,29 @@ public class VisualizationRequestHandler {
* */ * */
if (VisualizationFrameworkConstants.DATA_RENDER_MODE_URL_VALUE.equalsIgnoreCase(renderMode)) { if (VisualizationFrameworkConstants.DATA_RENDER_MODE_URL_VALUE.equalsIgnoreCase(renderMode)) {
/* /*
* When just the graphML file is required - based on which actual visualization will * We will be using the same visualization package for providing data for both
* be rendered. * list of unique coauthors & network of coauthors (used in the flash vis). We will
* */ * use "VIS_MODE_URL_HANDLE" as a modifier to differentiate between these two.
prepareVisualizationQueryDataResponse(coAuthorshipVO); * The defualt will be to provide data used to render the coauthorship network vis.
return; * */
if (coAuthorsListMode.equalsIgnoreCase(visMode)) {
/*
* When the csv file is required - containing the unique co-authors vs how many times
* they have co-authored with the ego.
* */
prepareVisualizationQueryListCoauthorsDataResponse(coAuthorshipVO);
return;
} else {
/*
* When the graphML file is required - based on which coauthorship network visualization
* will be rendered.
* */
prepareVisualizationQueryNetworkDataResponse(coAuthorshipVO);
return;
}
} }
@ -227,13 +246,13 @@ public class VisualizationRequestHandler {
return yearToCoAuthors; return yearToCoAuthors;
} }
private void prepareVisualizationQueryDataResponse(VisVOContainer coAuthorsipVO) { private void prepareVisualizationQueryNetworkDataResponse(VisVOContainer coAuthorsipVO) {
String outputFileName = ""; String outputFileName = "";
if (coAuthorsipVO.getNodes() == null || coAuthorsipVO.getNodes().size() < 1) { if (coAuthorsipVO.getNodes() == null || coAuthorsipVO.getNodes().size() < 1) {
outputFileName = "no-coauthorship-net" + ".graphml"; outputFileName = "no-coauthorship-net" + ".csv";
} else { } else {
@ -266,6 +285,82 @@ public class VisualizationRequestHandler {
} }
} }
private void prepareVisualizationQueryListCoauthorsDataResponse(VisVOContainer coAuthorsipVO) {
String outputFileName = "";
Map<String, Integer> coAuthorsToCount = new TreeMap<String, Integer>();
if (coAuthorsipVO.getNodes() == null || coAuthorsipVO.getNodes().size() < 1 ) {
outputFileName = "no-coauthors-list" + ".csv";
} else {
outputFileName = UtilityFunctions.slugify(coAuthorsipVO.getEgoNode().getNodeName())
+ "-coauthors-list" + ".csv";
coAuthorsToCount = getCoAuthorsList(coAuthorsipVO);
}
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + outputFileName);
try {
PrintWriter responseWriter = response.getWriter();
/*
* We are side-effecting responseWriter since we are directly manipulating the response
* object of the servlet.
* */
generateCsvFileBuffer(coAuthorsToCount,
responseWriter);
responseWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private Map<String, Integer> getCoAuthorsList(VisVOContainer coAuthorsipVO) {
Map<String, Integer> coAuthorsToCount = new TreeMap<String, Integer>();
for (Node currNode : coAuthorsipVO.getNodes()) {
/*
* We have already printed the Ego Node info.
* */
if (currNode != coAuthorsipVO.getEgoNode()) {
coAuthorsToCount.put(currNode.getNodeName(), currNode.getNumOfAuthoredWorks());
}
}
return coAuthorsToCount;
}
private void generateCsvFileBuffer(Map<String, Integer> coAuthorsToCount, PrintWriter printWriter) {
printWriter.append("\"Co-Author\", \"Count\"\n");
for (Entry<String, Integer> currentEntry : coAuthorsToCount.entrySet()) {
printWriter.append("\"" + currentEntry.getKey() + "\","
+ "\"" + currentEntry.getValue() + "\"\n"
);
}
printWriter.flush();
}
private void prepareVisualizationQueryStandaloneResponse( private void prepareVisualizationQueryStandaloneResponse(
String egoURIParam, String egoURIParam,
SparklineVOContainer egoPubSparklineVO, SparklineVOContainer egoPubSparklineVO,

View file

@ -600,10 +600,18 @@ public class VisualizationCodeGenerator {
private String generateDataTable() { private String generateDataTable() {
String csvDownloadURL = "";
try {
csvDownloadURL = getCSVDownloadURL();
} catch (UnsupportedEncodingException e) {
csvDownloadURL = "#";
}
StringBuilder dataTable = new StringBuilder(); StringBuilder dataTable = new StringBuilder();
dataTable.append("<table id='sparkline_data_table'>" + dataTable.append("<table id='sparkline_data_table'>" +
"<caption>Publications per year</caption>" + "<caption>Publications per year <a href=\"" + csvDownloadURL + "\">(.CSV File)</a></caption>" +
"<thead>" + "<thead>" +
"<tr>" + "<tr>" +
"<th>Year</th>" + "<th>Year</th>" +

View file

@ -199,10 +199,6 @@ public class VisualizationRequestHandler {
+ VisualizationFrameworkConstants.VIS_TYPE_URL_HANDLE + VisualizationFrameworkConstants.VIS_TYPE_URL_HANDLE
+ "=" + URLEncoder.encode("person_level", + "=" + URLEncoder.encode("person_level",
VisualizationController.URL_ENCODING_SCHEME).toString() VisualizationController.URL_ENCODING_SCHEME).toString()
+ "&"
+ VisualizationFrameworkConstants.VIS_CONTAINER_URL_HANDLE
+ "=" + URLEncoder.encode("ego_sparkline",
VisualizationController.URL_ENCODING_SCHEME).toString()
+ "&" + "&"
+ VisualizationFrameworkConstants.RENDER_MODE_URL_HANDLE + VisualizationFrameworkConstants.RENDER_MODE_URL_HANDLE
+ "=" + URLEncoder.encode(VisualizationFrameworkConstants.STANDALONE_RENDER_MODE_URL_VALUE, + "=" + URLEncoder.encode(VisualizationFrameworkConstants.STANDALONE_RENDER_MODE_URL_VALUE,

View file

@ -176,7 +176,7 @@ function createTable(tableID, tableContainer, tableData) {
var table = $('<table>'); var table = $('<table>');
table.attr('id', tableID); table.attr('id', tableID);
table.append($('<caption>').html("Co-Authorships")); table.append($('<caption>').html("Co-Authors <a href=\"" + egoCoAuthorsListDataFileURL + "\">(.CSV File)</a>"));
var header = $('<thead>'); var header = $('<thead>');
@ -280,7 +280,7 @@ function renderCoAuthorshipVisualization() {
"src", swfLink, "src", swfLink,
"flashVars", "graphmlUrl=" + egoCoAuthorshipDataFeederURL, "flashVars", "graphmlUrl=" + egoCoAuthorshipDataFeederURL,
"width", "600", "width", "600",
"height", "840", "height", "790",
"align", "top", "align", "top",
"id", "CoAuthor", "id", "CoAuthor",
"quality", "high", "quality", "high",

View file

@ -30,10 +30,13 @@
<style type="text/css"> <style type="text/css">
#body h1 {
margin:0.0em;
}
.sparkline_wrapper_table { .sparkline_wrapper_table {
display: inline; display: inline;
vertical-align: bottom; vertical-align: bottom;
} }
.author_name { .author_name {
@ -64,26 +67,31 @@
.inline_href { .inline_href {
} }
#ego_profile { #ego_profile {
padding: 10px; padding-left:10px;
padding-top:10px;
min-height: 100px; min-height: 100px;
} }
#ego_label { #ego_label {
font-size:1.1em; font-size:1.1em;
margin-left:100px; /*margin-left:100px;
margin-top:9px; margin-top:9px;
position:absolute; position:absolute;*/
} }
#ego_moniker { #ego_moniker {
margin-left:100px; /*margin-left:100px;
margin-top:27px; margin-top:27px;
position:absolute; position:absolute;*/
} }
#ego_profile_image { #ego_profile_image {
width: 100px; float:left;
padding-right: 5px;
/*width: 100px;*/
} }
#ego_sparkline { #ego_sparkline {
@ -103,23 +111,34 @@
visibility:hidden;*/ visibility:hidden;*/
} }
.thumbnail {
width: 100px;
}
</style> </style>
<!--[if IE]>
<style type="text/css">
#${egoPubSparklineContainerID},
#${uniqueCoauthorsSparklineVisContainerID} {
padding-bottom:15px;
}
</style>
<![endif]-->
<div id="ego_profile"> <div id="ego_profile">
<%-- Image --%>
<span id="ego_profile_image"></span>
<%-- Label --%> <%-- Label --%>
<h1><span id="ego_label" class="author_name"></span></h1> <h1><span id="ego_label" class="author_name"></span></h1>
<%-- Moniker--%> <%-- Moniker--%>
<span id="ego_moniker" class="author_moniker"></span> <span id="ego_moniker" class="author_moniker"></span>
<%-- Image --%>
<span id="ego_profile_image" class="thumbnail"></span>
<div style="clear:both;"></div>
<%-- Sparkline --%> <%-- Sparkline --%>
<h2 class="sub_headings">General Statistics</h2> <h2 class="sub_headings">General Statistics</h2>
@ -133,13 +152,12 @@
<h2 class="sub_headings">Co-Author Network <a href="${coAuthorshipDownloadFile}">(.GraphML File)</a></h2> <h2 class="sub_headings">Co-Author Network <a href="${coAuthorshipDownloadFile}">(.GraphML File)</a></h2>
</div> </div>
<div id="bodyPannel">
<div id="topShadow"></div>
<div id="bodyPannel" style="height: 900px;">
<br class="spacer" />
<div id="visPanel" style="float: left; width: 600px;"> <div id="visPanel" style="float: left; width: 600px;">
<script language="JavaScript" type="text/javascript"> <script language="JavaScript" type="text/javascript">
@ -170,21 +188,15 @@
<div><a href="#" id="coAuthorshipVisUrl">Co-author network of <span id="coAuthorName"></span></a></div> <div><a href="#" id="coAuthorshipVisUrl">Co-author network of <span id="coAuthorName"></span></a></div>
</div> </div>
<span class="no_href_styles"><a href="${coAuthorshipDownloadFile}">
<img src="${visImageContextPath}download_graphml.png" width="91" height="25" /></a>
</span>
<br class="spacer">
</div> </div>
<div class="vis-stats"> <div class="vis_stats">
<h2 class="sub_headings">Tables</h2>
<div class="vis-tables"> <div class="vis-tables">
<p class="datatable"> <p id="publications_table_container" class="datatable">
${sparkline.table} ${egoPubSparkline.table}
<a href="${egoSparklineDataURL}" class="no_href_styles">
<img src="${visImageContextPath}download_csv.png" width="91" height="25" />
</a>
</p> </p>
</div> </div>
@ -199,7 +211,6 @@
<script language="JavaScript" type="text/javascript"> <script language="JavaScript" type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){

View file

@ -11,6 +11,13 @@
<c:param name="labelField" value="name" /> <c:param name="labelField" value="name" />
</c:url> </c:url>
<c:url var="egoCoAuthorsListDataFileURL" value="/admin/visQuery">
<c:param name="vis" value="person_level" />
<c:param name="render_mode" value="data" />
<c:param name="vis_mode" value="coauthors" />
<c:param name="uri" value="${requestScope.egoURIParam}" />
</c:url>
<c:url var="swfLink" value="/${themeDir}site_icons/visualization/coauthorship/CoAuthor.swf" /> <c:url var="swfLink" value="/${themeDir}site_icons/visualization/coauthorship/CoAuthor.swf" />
<c:url var="jquery" value="/js/jquery.js"/> <c:url var="jquery" value="/js/jquery.js"/>
@ -37,6 +44,7 @@ var requiredRevision = 0;
var swfLink = "${swfLink}"; var swfLink = "${swfLink}";
var egoCoAuthorshipDataFeederURL = "${egoCoAuthorshipDataFeederURL}"; var egoCoAuthorshipDataFeederURL = "${egoCoAuthorshipDataFeederURL}";
var egoCoAuthorsListDataFileURL = "${egoCoAuthorsListDataFileURL}";
var contextPath = "${contextPath}"; var contextPath = "${contextPath}";
// --> // -->