1. Made changes to logic for getting the counter for total unique co-authors sparkline. Per Micah's request.
2. Word changes.
This commit is contained in:
parent
74edbcd45c
commit
d3af6d949e
2 changed files with 32 additions and 26 deletions
|
@ -18,6 +18,7 @@ import org.apache.commons.logging.Log;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.visualization.VisualizationController;
|
import edu.cornell.mannlib.vitro.webapp.controller.visualization.VisualizationController;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.visualization.VisualizationFrameworkConstants;
|
import edu.cornell.mannlib.vitro.webapp.controller.visualization.VisualizationFrameworkConstants;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
|
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Node;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.SparklineVOContainer;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.SparklineVOContainer;
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ public class VisualizationCodeGenerator {
|
||||||
|
|
||||||
public static final String FULL_SPARKLINE_MODE_URL_HANDLE = "full";
|
public static final String FULL_SPARKLINE_MODE_URL_HANDLE = "full";
|
||||||
|
|
||||||
private Map<String, Integer> yearToUniqueCoauthorsCount;
|
private Map<String, Set<Node>> yearToUniqueCoauthors;
|
||||||
|
|
||||||
private Log log;
|
private Log log;
|
||||||
|
|
||||||
|
@ -52,14 +53,14 @@ public class VisualizationCodeGenerator {
|
||||||
String individualURIParam,
|
String individualURIParam,
|
||||||
String visMode,
|
String visMode,
|
||||||
String visContainer,
|
String visContainer,
|
||||||
Map<String, Integer> yearToUniqueCoauthorsCount,
|
Map<String, Set<Node>> yearToUniqueCoauthors,
|
||||||
SparklineVOContainer valueObjectContainer,
|
SparklineVOContainer valueObjectContainer,
|
||||||
Log log) {
|
Log log) {
|
||||||
|
|
||||||
this.contextPath = contextPath;
|
this.contextPath = contextPath;
|
||||||
this.individualURIParam = individualURIParam;
|
this.individualURIParam = individualURIParam;
|
||||||
|
|
||||||
this.yearToUniqueCoauthorsCount = yearToUniqueCoauthorsCount;
|
this.yearToUniqueCoauthors = yearToUniqueCoauthors;
|
||||||
this.valueObjectContainer = valueObjectContainer;
|
this.valueObjectContainer = valueObjectContainer;
|
||||||
|
|
||||||
this.log = log;
|
this.log = log;
|
||||||
|
@ -93,7 +94,7 @@ public class VisualizationCodeGenerator {
|
||||||
* This is required because when deciding the range of years over which the vis
|
* This is required because when deciding the range of years over which the vis
|
||||||
* was rendered we dont want to be influenced by the "DEFAULT_PUBLICATION_YEAR".
|
* was rendered we dont want to be influenced by the "DEFAULT_PUBLICATION_YEAR".
|
||||||
* */
|
* */
|
||||||
Set<String> publishedYears = new HashSet(yearToUniqueCoauthorsCount.keySet());
|
Set<String> publishedYears = new HashSet(yearToUniqueCoauthors.keySet());
|
||||||
publishedYears.remove(VOConstants.DEFAULT_PUBLICATION_YEAR);
|
publishedYears.remove(VOConstants.DEFAULT_PUBLICATION_YEAR);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -108,13 +109,13 @@ public class VisualizationCodeGenerator {
|
||||||
StringBuilder visualizationCode = new StringBuilder();
|
StringBuilder visualizationCode = new StringBuilder();
|
||||||
|
|
||||||
// System.out.println(yearToPublicationCount);
|
// System.out.println(yearToPublicationCount);
|
||||||
if (yearToUniqueCoauthorsCount.size() > 0) {
|
if (yearToUniqueCoauthors.size() > 0) {
|
||||||
try {
|
try {
|
||||||
minPublishedYear = Integer.parseInt(Collections.min(publishedYears));
|
minPublishedYear = Integer.parseInt(Collections.min(publishedYears));
|
||||||
} catch (NoSuchElementException e1) {
|
} catch (NoSuchElementException e1) {
|
||||||
log.debug("vis: " + e1.getMessage() + " error occurred for " + yearToUniqueCoauthorsCount.toString());
|
log.debug("vis: " + e1.getMessage() + " error occurred for " + yearToUniqueCoauthors.toString());
|
||||||
} catch (NumberFormatException e2) {
|
} catch (NumberFormatException e2) {
|
||||||
log.debug("vis: " + e2.getMessage() + " error occurred for " + yearToUniqueCoauthorsCount.toString());
|
log.debug("vis: " + e2.getMessage() + " error occurred for " + yearToUniqueCoauthors.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,15 +187,18 @@ public class VisualizationCodeGenerator {
|
||||||
int uniqueCoAuthorCounter = 0;
|
int uniqueCoAuthorCounter = 0;
|
||||||
int totalUniqueCoAuthors = 0;
|
int totalUniqueCoAuthors = 0;
|
||||||
int renderedFullSparks = 0;
|
int renderedFullSparks = 0;
|
||||||
|
Set<Node> allCoAuthorsWithKnownAuthorshipYears = new HashSet<Node>();
|
||||||
|
|
||||||
|
|
||||||
for (int publicationYear = minPubYearConsidered; publicationYear <= currentYear; publicationYear++) {
|
for (int publicationYear = minPubYearConsidered; publicationYear <= currentYear; publicationYear++) {
|
||||||
|
|
||||||
String stringPublishedYear = String.valueOf(publicationYear);
|
String stringPublishedYear = String.valueOf(publicationYear);
|
||||||
Integer currentPublications = yearToUniqueCoauthorsCount.get(stringPublishedYear);
|
Integer currentUniqueCoAuthors = yearToUniqueCoauthors.get(stringPublishedYear).size();
|
||||||
|
|
||||||
if (currentPublications == null) {
|
if (currentUniqueCoAuthors == null) {
|
||||||
currentPublications = 0;
|
currentUniqueCoAuthors = 0;
|
||||||
|
} else {
|
||||||
|
allCoAuthorsWithKnownAuthorshipYears.addAll(yearToUniqueCoauthors.get(stringPublishedYear));
|
||||||
}
|
}
|
||||||
|
|
||||||
visualizationCode.append("data.setValue("
|
visualizationCode.append("data.setValue("
|
||||||
|
@ -206,13 +210,15 @@ public class VisualizationCodeGenerator {
|
||||||
visualizationCode.append("data.setValue("
|
visualizationCode.append("data.setValue("
|
||||||
+ uniqueCoAuthorCounter
|
+ uniqueCoAuthorCounter
|
||||||
+ ", 1, "
|
+ ", 1, "
|
||||||
+ currentPublications
|
+ currentUniqueCoAuthors
|
||||||
+ ");\n");
|
+ ");\n");
|
||||||
|
|
||||||
totalUniqueCoAuthors += currentPublications;
|
|
||||||
uniqueCoAuthorCounter++;
|
uniqueCoAuthorCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
totalUniqueCoAuthors = allCoAuthorsWithKnownAuthorshipYears.size();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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.
|
||||||
|
@ -224,9 +230,9 @@ public class VisualizationCodeGenerator {
|
||||||
* it. Hence.
|
* it. Hence.
|
||||||
* */
|
* */
|
||||||
Integer unknownYearCoauthors = 0;
|
Integer unknownYearCoauthors = 0;
|
||||||
if (yearToUniqueCoauthorsCount.get(VOConstants.DEFAULT_PUBLICATION_YEAR) != null) {
|
if (yearToUniqueCoauthors.get(VOConstants.DEFAULT_PUBLICATION_YEAR) != null) {
|
||||||
totalUniqueCoAuthors += yearToUniqueCoauthorsCount.get(VOConstants.DEFAULT_PUBLICATION_YEAR);
|
totalUniqueCoAuthors += yearToUniqueCoauthors.get(VOConstants.DEFAULT_PUBLICATION_YEAR).size();
|
||||||
unknownYearCoauthors = yearToUniqueCoauthorsCount.get(VOConstants.DEFAULT_PUBLICATION_YEAR);
|
unknownYearCoauthors = yearToUniqueCoauthors.get(VOConstants.DEFAULT_PUBLICATION_YEAR).size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -344,7 +350,7 @@ public class VisualizationCodeGenerator {
|
||||||
|
|
||||||
visualizationCode.append("$('#" + visDivNames.get("SHORT_SPARK") + " td.sparkline_number').text(parseInt(renderedShortSparks) + parseInt(" + unknownYearCoauthors + "));");
|
visualizationCode.append("$('#" + visDivNames.get("SHORT_SPARK") + " td.sparkline_number').text(parseInt(renderedShortSparks) + parseInt(" + unknownYearCoauthors + "));");
|
||||||
visualizationCode.append("var shortSparksText = ''" +
|
visualizationCode.append("var shortSparksText = ''" +
|
||||||
"+ ' unique co-author(s) within the last 10 years '" +
|
"+ ' co-author(s) within the last 10 years '" +
|
||||||
"<span class=\"incomplete-data-holder\" title=\"" + imcompleteDataText + "\">incomplete data</span>'" +
|
"<span class=\"incomplete-data-holder\" title=\"" + imcompleteDataText + "\">incomplete data</span>'" +
|
||||||
/*"+ ' " + totalUniqueCoAuthors + " '" +
|
/*"+ ' " + totalUniqueCoAuthors + " '" +
|
||||||
"+ ' total " +
|
"+ ' total " +
|
||||||
|
@ -391,7 +397,6 @@ public class VisualizationCodeGenerator {
|
||||||
"fullSparklineView.setColumns([1]);\n");
|
"fullSparklineView.setColumns([1]);\n");
|
||||||
|
|
||||||
visualizationCode.append("var full_spark = new google.visualization.ImageSparkLine(" +
|
visualizationCode.append("var full_spark = new google.visualization.ImageSparkLine(" +
|
||||||
// "document.getElementById('" + visDivNames.get("FULL_SPARK") + "')" +
|
|
||||||
"providedSparklineImgTD[0]" +
|
"providedSparklineImgTD[0]" +
|
||||||
");\n" +
|
");\n" +
|
||||||
"full_spark.draw(fullSparklineView, " + sparklineDisplayOptions + ");\n");
|
"full_spark.draw(fullSparklineView, " + sparklineDisplayOptions + ");\n");
|
||||||
|
@ -494,7 +499,7 @@ public class VisualizationCodeGenerator {
|
||||||
|
|
||||||
String csvDownloadURLHref = "";
|
String csvDownloadURLHref = "";
|
||||||
|
|
||||||
if (yearToUniqueCoauthorsCount.size() > 0) {
|
if (yearToUniqueCoauthors.size() > 0) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (getCSVDownloadURL() != null) {
|
if (getCSVDownloadURL() != null) {
|
||||||
|
@ -531,7 +536,7 @@ public class VisualizationCodeGenerator {
|
||||||
private String getCSVDownloadURL()
|
private String getCSVDownloadURL()
|
||||||
throws UnsupportedEncodingException {
|
throws UnsupportedEncodingException {
|
||||||
|
|
||||||
if (yearToUniqueCoauthorsCount.size() > 0) {
|
if (yearToUniqueCoauthors.size() > 0) {
|
||||||
|
|
||||||
String secondaryContextPath = "";
|
String secondaryContextPath = "";
|
||||||
if (!contextPath.contains("/admin/visQuery")) {
|
if (!contextPath.contains("/admin/visQuery")) {
|
||||||
|
@ -572,7 +577,7 @@ public class VisualizationCodeGenerator {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String fullTimelineLink;
|
String fullTimelineLink;
|
||||||
if (yearToUniqueCoauthorsCount.size() > 0) {
|
if (yearToUniqueCoauthors.size() > 0) {
|
||||||
|
|
||||||
String secondaryContextPath = "";
|
String secondaryContextPath = "";
|
||||||
if (!contextPath.contains("/admin/visQuery")) {
|
if (!contextPath.contains("/admin/visQuery")) {
|
||||||
|
@ -635,10 +640,10 @@ public class VisualizationCodeGenerator {
|
||||||
"</thead>" +
|
"</thead>" +
|
||||||
"<tbody>");
|
"<tbody>");
|
||||||
|
|
||||||
for (Entry<String, Integer> currentEntry : yearToUniqueCoauthorsCount.entrySet()) {
|
for (Entry<String, Set<Node>> currentEntry : yearToUniqueCoauthors.entrySet()) {
|
||||||
dataTable.append("<tr>" +
|
dataTable.append("<tr>" +
|
||||||
"<td>" + currentEntry.getKey() + "</td>" +
|
"<td>" + currentEntry.getKey() + "</td>" +
|
||||||
"<td>" + currentEntry.getValue() + "</td>" +
|
"<td>" + currentEntry.getValue().size() + "</td>" +
|
||||||
"</tr>");
|
"</tr>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class VisualizationRequestHandler {
|
||||||
Map<String, Integer> yearToPublicationCount = publicationQueryManager
|
Map<String, Integer> yearToPublicationCount = publicationQueryManager
|
||||||
.getYearToPublicationCount(authorDocuments);
|
.getYearToPublicationCount(authorDocuments);
|
||||||
|
|
||||||
Map<String, Integer> yearToUniqueCoauthorCount = getUniqueCoauthorsCountPerYear(coAuthorshipVO);
|
// Map<String, Integer> yearToUniqueCoauthorCount = getUniqueCoauthorsCountPerYear(coAuthorshipVO);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -156,7 +156,7 @@ public class VisualizationRequestHandler {
|
||||||
egoURIParam,
|
egoURIParam,
|
||||||
VisualizationCodeGenerator.FULL_SPARKLINE_MODE_URL_HANDLE,
|
VisualizationCodeGenerator.FULL_SPARKLINE_MODE_URL_HANDLE,
|
||||||
uniqueCoauthorsSparklineVisContainerID,
|
uniqueCoauthorsSparklineVisContainerID,
|
||||||
yearToUniqueCoauthorCount,
|
getUniqueCoAuthorsPerYear(coAuthorshipVO),
|
||||||
uniqueCoauthorsSparklineVO,
|
uniqueCoauthorsSparklineVO,
|
||||||
log);
|
log);
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ public class VisualizationRequestHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
private Map<String, Integer> getUniqueCoauthorsCountPerYear(
|
private Map<String, Integer> getUniqueCoauthorsCountPerYear(
|
||||||
edu.cornell.mannlib.vitro.webapp.visualization.coauthorship.VisVOContainer coAuthorshipVO) {
|
edu.cornell.mannlib.vitro.webapp.visualization.coauthorship.VisVOContainer coAuthorshipVO) {
|
||||||
Map<String, Integer> yearToUniqueCoauthorCount = new TreeMap<String, Integer>();
|
Map<String, Integer> yearToUniqueCoauthorCount = new TreeMap<String, Integer>();
|
||||||
|
@ -210,6 +210,7 @@ public class VisualizationRequestHandler {
|
||||||
}
|
}
|
||||||
return yearToUniqueCoauthorCount;
|
return yearToUniqueCoauthorCount;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
private Map<String, Set<Node>> getUniqueCoAuthorsPerYear(edu.cornell.mannlib.vitro.webapp.visualization.coauthorship.VisVOContainer authorNodesAndEdges) {
|
private Map<String, Set<Node>> getUniqueCoAuthorsPerYear(edu.cornell.mannlib.vitro.webapp.visualization.coauthorship.VisVOContainer authorNodesAndEdges) {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue