From f1e947571605863d381443be5130f424f8a0e568 Mon Sep 17 00:00:00 2001 From: cdtank Date: Wed, 9 Feb 2011 22:29:34 +0000 Subject: [PATCH] 1. Made changes to fix the bug NIHVIVO-2087. Incorrent count values were being displayed in cases of collaborators sparklines. --- .../coAuthorshipSparklineContent.ftl | 6 +++++- .../copi/coInvestigationSparklineContent.ftl | 8 +++++++- .../CoAuthorshipVisCodeGenerator.java | 12 ++++++++++++ .../CoPIVisCodeGenerator.java | 17 +++++++++++++++-- .../freemarker/valueobjects/SparklineData.java | 13 ++++++++++++- 5 files changed, 51 insertions(+), 5 deletions(-) diff --git a/productMods/templates/freemarker/visualization/coauthorship/coAuthorshipSparklineContent.ftl b/productMods/templates/freemarker/visualization/coauthorship/coAuthorshipSparklineContent.ftl index 868e05f6..3b10e956 100644 --- a/productMods/templates/freemarker/visualization/coauthorship/coAuthorshipSparklineContent.ftl +++ b/productMods/templates/freemarker/visualization/coauthorship/coAuthorshipSparklineContent.ftl @@ -125,7 +125,11 @@ } - var totalPublicationCount = knownYearPublicationCounts + unknownYearPublicationCounts; + if (${sparklineVO.totalCollaborationshipCount?c}) { + var totalPublicationCount = ${sparklineVO.totalCollaborationshipCount?c}; + } else { + var totalPublicationCount = knownYearPublicationCounts + unknownYearPublicationCounts; + } <#if sparklineVO.shortVisMode> diff --git a/productMods/templates/freemarker/visualization/copi/coInvestigationSparklineContent.ftl b/productMods/templates/freemarker/visualization/copi/coInvestigationSparklineContent.ftl index dfdb7d17..a9bee296 100644 --- a/productMods/templates/freemarker/visualization/copi/coInvestigationSparklineContent.ftl +++ b/productMods/templates/freemarker/visualization/copi/coInvestigationSparklineContent.ftl @@ -124,8 +124,14 @@ } } + + if (${sparklineVO.totalCollaborationshipCount?c}) { + var totalGrantCount = ${sparklineVO.totalCollaborationshipCount?c}; + } else { + var totalGrantCount = knownYearGrantCounts + unknownYearGrantCounts; + } - var totalGrantCount = knownYearGrantCounts + unknownYearGrantCounts; + <#if sparklineVO.shortVisMode> diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/coauthorship/CoAuthorshipVisCodeGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/coauthorship/CoAuthorshipVisCodeGenerator.java index 559ba6c2..cb77db70 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/coauthorship/CoAuthorshipVisCodeGenerator.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/coauthorship/CoAuthorshipVisCodeGenerator.java @@ -159,6 +159,14 @@ public class CoAuthorshipVisCodeGenerator { sparklineData.setRenderedSparks(renderedFullSparks); sparklineData.setYearToEntityCountDataTable(yearToUniqueCoauthorsCountDataTable); + + /* + * This is required only for the sparklines which convey collaborationships like coinvestigatorships + * and coauthorship. There are edge cases where a collaborator can be present for in a collaboration + * with known & unknown year. We do not want to repeat the count for this collaborator when we present + * it in the front-end. + * */ + Set totalUniqueCoInvestigators = new HashSet(allCoAuthorsWithKnownAuthorshipYears); /* * Total publications will also consider publications that have no year associated with @@ -168,10 +176,14 @@ public class CoAuthorshipVisCodeGenerator { if (yearToUniqueCoauthors.get(VOConstants.DEFAULT_PUBLICATION_YEAR) != null) { unknownYearCoauthors = yearToUniqueCoauthors .get(VOConstants.DEFAULT_PUBLICATION_YEAR).size(); + + totalUniqueCoInvestigators.addAll(yearToUniqueCoauthors.get(VOConstants.DEFAULT_GRANT_YEAR)); } sparklineData.setUnknownYearPublications(unknownYearCoauthors); + sparklineData.setTotalCollaborationshipCount(totalUniqueCoInvestigators.size()); + if (providedVisContainerID != null) { visContainerID = providedVisContainerID; } else { diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/coprincipalinvestigator/CoPIVisCodeGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/coprincipalinvestigator/CoPIVisCodeGenerator.java index 17a26247..90a3b809 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/coprincipalinvestigator/CoPIVisCodeGenerator.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/coprincipalinvestigator/CoPIVisCodeGenerator.java @@ -159,17 +159,25 @@ public class CoPIVisCodeGenerator { renderedFullSparks += currentUniqueCoPIs; uniqueCoPICounter++; } - + /* * For the purpose of this visualization I have come up with a term * "Sparks" which essentially means data points. Sparks that will be * rendered in full mode will always be the one's which have any year * associated with it. Hence. */ - sparklineData.setRenderedSparks(renderedFullSparks); + sparklineData.setRenderedSparks(allCoPIsWithKnownGrantShipYears.size()); sparklineData.setYearToEntityCountDataTable(yearToUniqueInvestigatorsCountDataTable); + /* + * This is required only for the sparklines which convey collaborationships like coinvestigatorships + * and coauthorship. There are edge cases where a collaborator can be present for in a collaboration + * with known & unknown year. We do not want to repeat the count for this collaborator when we present + * it in the front-end. + * */ + Set totalUniqueCoInvestigators = new HashSet(allCoPIsWithKnownGrantShipYears); + /* * Total grants will also consider grants that have no year * associated with them. Hence. @@ -178,8 +186,13 @@ public class CoPIVisCodeGenerator { if (yearToUniqueCoPIs.get(VOConstants.DEFAULT_GRANT_YEAR) != null) { unknownYearGrants = yearToUniqueCoPIs.get( VOConstants.DEFAULT_GRANT_YEAR).size(); + + totalUniqueCoInvestigators.addAll(yearToUniqueCoPIs.get(VOConstants.DEFAULT_GRANT_YEAR)); + } + sparklineData.setTotalCollaborationshipCount(totalUniqueCoInvestigators.size()); + sparklineData.setUnknownYearGrants(unknownYearGrants); if (providedVisContainerID != null) { diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/valueobjects/SparklineData.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/valueobjects/SparklineData.java index 905a42bd..89830407 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/valueobjects/SparklineData.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/valueobjects/SparklineData.java @@ -17,6 +17,8 @@ public class SparklineData { private Integer unknownYearPublications; private Integer unknownYearGrants; + private Integer totalCollaborationshipCount; + private Map yearToActivityCount; private String downloadDataLink = ""; @@ -29,7 +31,16 @@ public class SparklineData { private List yearToEntityCountDataTable; private int numOfYearsToBeRendered; - + + public void setTotalCollaborationshipCount( + Integer totalCollaborationshipCount) { + this.totalCollaborationshipCount = totalCollaborationshipCount; + } + + public Integer getTotalCollaborationshipCount() { + return totalCollaborationshipCount; + } + public Integer getEarliestRenderedGrantYear() { return earliestRenderedGrantYear; }