Minor changes to allow zero values to appear on Temporal Graphs (matches old behaviour)

This commit is contained in:
grahamtriggs 2015-10-30 23:07:58 +00:00
parent 3605888ad3
commit 2235abed00
3 changed files with 37 additions and 19 deletions

View file

@ -2,6 +2,7 @@
package edu.cornell.mannlib.vitro.webapp.visualization.temporalgraph;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
@ -157,13 +158,13 @@ public class TemporalGrantVisualizationRequestHandler implements
Set<String> orgGrants = new HashSet<String>();
Set<String> orgGrantsPeople = new HashSet<String>();
Map<String, Set<String>> subOrgPublicationsMap = new HashMap<String, Set<String>>();
Map<String, Set<String>> subOrgGrantsMap = new HashMap<String, Set<String>>();
OrgUtils.getObjectMappingsForOrgAnSubOrgs(
subjectEntityURI,
orgGrants,
orgGrantsPeople,
subOrgPublicationsMap,
subOrgGrantsMap,
subOrgMap,
organisationToPeopleMap,
personToGrantMap
@ -183,15 +184,19 @@ public class TemporalGrantVisualizationRequestHandler implements
Set subEntitiesJson = new HashSet();
// For each suborganisation
for (String subOrg : subOrgPublicationsMap.keySet()) {
for (String subOrg : subOrgGrantsMap.keySet()) {
JsonObject entityJson = new JsonObject(orgLabelMap.get(subOrg));
List<List<Integer>> yearPubCounts = CounterUtils.getObjectCountByYear(subOrgPublicationsMap.get(subOrg), grantToYearMap);
if (subOrgGrantsMap.containsKey(subOrg)) {
List<List<Integer>> yearPubCounts = CounterUtils.getObjectCountByYear(subOrgGrantsMap.get(subOrg), grantToYearMap);
entityJson.setYearToActivityCount(yearPubCounts);
} else {
entityJson.setYearToActivityCount(new ArrayList<List<Integer>>());
}
String type = orgMostSpecificLabelMap.get(subOrg);
entityJson.setYearToActivityCount(yearPubCounts);
entityJson.setOrganizationTypes(Arrays.asList(type == null ? "Organization" : type));
entityJson.setEntityURI(subOrg);
entityJson.setVisMode("ORGANIZATION");
@ -202,12 +207,16 @@ public class TemporalGrantVisualizationRequestHandler implements
for (String person : orgGrantsPeople) {
JsonObject entityJson = new JsonObject(personLabelMap.get(person));
if (personToGrantMap.containsKey(person)) {
List<List<Integer>> yearPubCounts = CounterUtils.getObjectCountByYear(personToGrantMap.get(person), grantToYearMap);
entityJson.setYearToActivityCount(yearPubCounts);
} else {
entityJson.setYearToActivityCount(new ArrayList<List<Integer>>());
}
String type = personMostSpecificLabelMap.get(person);
entityJson.setYearToActivityCount(yearPubCounts);
entityJson.setOrganizationTypes(Arrays.asList(type == null ? "Person" : type));
entityJson.setEntityURI(person);
entityJson.setVisMode("PERSON");
@ -234,11 +243,11 @@ public class TemporalGrantVisualizationRequestHandler implements
csvFileContent.append("Entity Name, Grant Count, Entity Type\n");
for (String subOrg : subOrgPublicationsMap.keySet()) {
for (String subOrg : subOrgGrantsMap.keySet()) {
csvFileContent.append(StringEscapeUtils.escapeCsv(orgLabelMap.get(subOrg)));
csvFileContent.append(", ");
csvFileContent.append(subOrgPublicationsMap.get(subOrg).size());
csvFileContent.append(subOrgGrantsMap.get(subOrg).size());
csvFileContent.append(", ");
csvFileContent.append("Organization");

View file

@ -2,6 +2,7 @@
package edu.cornell.mannlib.vitro.webapp.visualization.temporalgraph;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
@ -126,12 +127,16 @@ public class TemporalPublicationVisualizationRequestHandler implements
for (String subOrg : subOrgPublicationsMap.keySet()) {
JsonObject entityJson = new JsonObject(orgLabelMap.get(subOrg));
if (subOrgPublicationsMap.containsKey(subOrg)) {
List<List<Integer>> yearPubCounts = CounterUtils.getObjectCountByYear(subOrgPublicationsMap.get(subOrg), publicationToYearMap);
entityJson.setYearToActivityCount(yearPubCounts);
} else {
entityJson.setYearToActivityCount(new ArrayList<List<Integer>>());
}
String type = orgMostSpecificLabelMap.get(subOrg);
entityJson.setYearToActivityCount(yearPubCounts);
entityJson.setOrganizationTypes(Arrays.asList(type == null ? "Organization" : type));
entityJson.setEntityURI(subOrg);
entityJson.setVisMode("ORGANIZATION");
@ -142,12 +147,16 @@ public class TemporalPublicationVisualizationRequestHandler implements
for (String person : orgPublicationsPeople) {
JsonObject entityJson = new JsonObject(personLabelMap.get(person));
if (personToPublicationMap.containsKey(person)) {
List<List<Integer>> yearPubCounts = CounterUtils.getObjectCountByYear(personToPublicationMap.get(person), publicationToYearMap);
entityJson.setYearToActivityCount(yearPubCounts);
} else {
entityJson.setYearToActivityCount(new ArrayList<List<Integer>>());
}
String type = personMostSpecificLabelMap.get(person);
entityJson.setYearToActivityCount(yearPubCounts);
entityJson.setOrganizationTypes(Arrays.asList(type == null ? "Person" : type));
entityJson.setEntityURI(person);
entityJson.setVisMode("PERSON");

View file

@ -65,8 +65,8 @@ public class OrgUtils {
Set<String> people = organisationToPeopleMap.get(orgUri);
if (people != null) {
for (String person : people) {
if (personToObjectMap.containsKey(person)) {
if (orgObjectsIncludesPeople.add(person)) {
if (personToObjectMap.containsKey(person)) {
orgObjects.addAll(personToObjectMap.get(person));
}
}