diff --git a/productMods/js/visualization/entitycomparison/gui-event-manager.js b/productMods/js/visualization/entitycomparison/gui-event-manager.js index 7b8659be..938b41e1 100644 --- a/productMods/js/visualization/entitycomparison/gui-event-manager.js +++ b/productMods/js/visualization/entitycomparison/gui-event-manager.js @@ -138,9 +138,8 @@ $(document).ready(function() { labelToEntityRecord[val.label] = val; }); - getEntityVisMode(jsonData); prepareTableForDataTablePagination(jsonData); - setEntityLevel(); + setEntityLevel(getEntityVisMode(jsonData)); $(".disabled-checkbox-event-receiver").live("click", function () { diff --git a/productMods/js/visualization/entitycomparison/util.js b/productMods/js/visualization/entitycomparison/util.js index 578e9a1d..3d40f4c7 100644 --- a/productMods/js/visualization/entitycomparison/util.js +++ b/productMods/js/visualization/entitycomparison/util.js @@ -1085,26 +1085,41 @@ function removeStopWords(val){ return typeStringWithoutStopWords.substring(1, typeStringWithoutStopWords.length); } -function setEntityLevel(){ - $('#entitylevelheading').text(' - ' + toCamelCase(entityLevel) + ' Level').css('font-style', 'italic'); +function setEntityLevel(entityLevel){ + //$('#entitylevelheading').text(' - ' + toCamelCase(entityLevel) + ' Level').css('font-style', 'italic'); $('#entityleveltext').text(' ' + entityLevel.toLowerCase()).css('font-style', 'italic'); - $('#entityHeader').text(toCamelCase(entityLevel)).css('font-weight', 'bold'); + $('#entityHeader').text(entityLevel).css('font-weight', 'bold'); $('#headerText').css("color", "#2485ae"); } function getEntityVisMode(jsonData){ + var entityLevels = new Array(); + $.each(jsonData, function(index, val) { if (val.visMode == "PERSON"){ - entityLevel = "People"; + entityLevels.push("People"); } else { - entityLevel = "Organizations"; + entityLevels.push("Organizations"); } - return; }); - /* To provide graceful degradation set entity level to a default error message.*/ - entitylevel = "ENTITY LEVEL UNDEFINED ERROR"; + var uniqueEntityLevels = $.unique(entityLevels); + + /* + * This case is when organizations & people are mixed because both are directly attached + * to the parent organization. + * */ + if (uniqueEntityLevels.length > 1) { + entityLevel = "Organizations & People"; + } else if (uniqueEntityLevels.length === 1) { + entityLevel = uniqueEntityLevels[0]; + } else { + /* To provide graceful degradation set entity level to a default error message.*/ + entitylevel = "ENTITY LEVEL UNDEFINED ERROR"; + } + + return entityLevel; } function toCamelCase(string){ diff --git a/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonBody.ftl b/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonBody.ftl index e7b95d1a..122483a1 100644 --- a/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonBody.ftl +++ b/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonBody.ftl @@ -76,7 +76,7 @@

You have selected 0 of a maximum - 10 schools to compare. + 10 schools. Clear diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountQueryRunner.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountQueryRunner.java index 502fb4ae..53359e3d 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountQueryRunner.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountQueryRunner.java @@ -146,15 +146,18 @@ public class EntityPublicationCountQueryRunner implements QueryRunner { if (subEntityLabelNode != null) { subEntity.setIndividualLabel(subEntityLabelNode.toString()); } - // entity.addSubEntity(subEntity); + + entity.addSubEntity(subEntity); + subEntity.addPublications(biboDocument); } RDFNode personURLNode = solution.get(QueryFieldLabels.PERSON_URL); - if(personURLNode != null){ - SubEntity person ; - if(personURLToVO.containsKey(personURLNode.toString())) { + if (personURLNode != null) { + SubEntity person; + + if (personURLToVO.containsKey(personURLNode.toString())) { person = personURLToVO.get(personURLNode.toString()); } else { person = new SubEntity(personURLNode.toString()); @@ -166,7 +169,19 @@ public class EntityPublicationCountQueryRunner implements QueryRunner { person.setIndividualLabel(personLabelNode.toString()); } -// entity.addSubEntity(person); + /* + * This makes sure that either, + * 1. the parent organization is a department-like organization with no organizations + * beneath it, or + * 2. the parent organizations has both sub-organizations and people directly + * attached to that organizations e.g. president of a university. + * */ + if (subEntityURLNode == null) { + + entity.addSubEntity(person); + + } + person.addPublications(biboDocument); } @@ -174,16 +189,19 @@ public class EntityPublicationCountQueryRunner implements QueryRunner { entity.addPublications(biboDocument); } - if(subentityURLToVO.size() != 0){ - for(SubEntity subEntity : subentityURLToVO.values()){ - entity.addSubEntity(subEntity); - } - } else if(subentityURLToVO.size() == 0 && personURLToVO.size() != 0){ - for(SubEntity person : personURLToVO.values()){ - entity.addSubEntity(person); - } - } else if (subentityURLToVO.size() == 0 && personURLToVO.size() == 0){ + /* + if (subentityURLToVO.size() != 0) { + + entity.addSubEntitities(subentityURLToVO.values()); + + } else if (subentityURLToVO.size() == 0 && personURLToVO.size() != 0) { + + entity.addSubEntitities(personURLToVO.values()); + + } else*/ if (subentityURLToVO.size() == 0 && personURLToVO.size() == 0) { + entity = new Entity(this.entityURI, "no-label"); + } //TODO: return non-null value diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntitySubOrganizationTypesQueryRunner.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntitySubOrganizationTypesQueryRunner.java index d7a7f3db..c22f0fe6 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntitySubOrganizationTypesQueryRunner.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntitySubOrganizationTypesQueryRunner.java @@ -97,7 +97,7 @@ public class EntitySubOrganizationTypesQueryRunner implements QueryRunner> createJavaValueObjects(ResultSet resultSet) { - Map> subOrganizationLabelToTypes = new HashMap>(); - Map> personLabelToTypes = new HashMap>(); + /*Map> subOrganizationLabelToTypes = new HashMap>(); + Map> personLabelToTypes = new HashMap>();*/ + Map> subEntityLabelToTypes = new HashMap>(); while(resultSet.hasNext()){ @@ -115,34 +116,50 @@ public class EntitySubOrganizationTypesQueryRunner implements QueryRunner()); - subOrganizationLabelToTypes.get(subOrganizationLabel.toString()).add(subOrganizationType.toString()); + } else { + RDFNode subOrganizationType = solution + .get(QueryFieldLabels.SUBORGANIZATION_TYPE_LABEL); + if (subOrganizationType != null) { + subEntityLabelToTypes.put( + subOrganizationLabel.toString(), + new HashSet()); + subEntityLabelToTypes.get( + subOrganizationLabel.toString()).add( + subOrganizationType.toString()); } } } RDFNode personLabel = solution.get(QueryFieldLabels.PERSON_LABEL); - - if(personLabel != null){ - if(personLabelToTypes.containsKey(personLabel.toString())){ - RDFNode personType = solution.get(QueryFieldLabels.PERSON_TYPE_LABEL); - if(personType != null && ! personType.toString().startsWith("http")){ - personLabelToTypes.get(personLabel.toString()).add(personType.toString()); + + if (personLabel != null) { + if (subEntityLabelToTypes.containsKey(personLabel.toString())) { + RDFNode personType = solution + .get(QueryFieldLabels.PERSON_TYPE_LABEL); + if (personType != null + && !personType.toString().startsWith("http")) { + subEntityLabelToTypes.get(personLabel.toString()).add( + personType.toString()); } - }else{ - RDFNode personType = solution.get(QueryFieldLabels.PERSON_TYPE_LABEL); - if(personType != null && ! personType.toString().startsWith("http")){ - personLabelToTypes.put(personLabel.toString(), new HashSet()); - personLabelToTypes.get(personLabel.toString()).add(personType.toString()); + } else { + RDFNode personType = solution + .get(QueryFieldLabels.PERSON_TYPE_LABEL); + if (personType != null + && !personType.toString().startsWith("http")) { + subEntityLabelToTypes.put(personLabel.toString(), + new HashSet()); + subEntityLabelToTypes.get(personLabel.toString()).add( + personType.toString()); } } } @@ -151,10 +168,10 @@ public class EntitySubOrganizationTypesQueryRunner implements QueryRunner " + subOrganizationLabelToTypes.size()); // System.out.println("\n\nPeople Label Types Size --> " + personLabelToTypes.size()); - log.info("Sub Organization Label Types Size : " + subOrganizationLabelToTypes.size()); - log.info("People Label Types Size : " + personLabelToTypes.size()); + log.info("Sub Organization Label Types Size : " + subEntityLabelToTypes.size()); - return (subOrganizationLabelToTypes.size() != 0 )? subOrganizationLabelToTypes : personLabelToTypes ; + return subEntityLabelToTypes; + //return (subOrganizationLabelToTypes.size() != 0 )? subOrganizationLabelToTypes : personLabelToTypes ; } public Map> getQueryResult() throws MalformedQueryParametersException { diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/valueobjects/Entity.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/valueobjects/Entity.java index d442b79f..db6729a6 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/valueobjects/Entity.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/valueobjects/Entity.java @@ -1,6 +1,7 @@ /* $This file is distributed under the terms of the license in /doc/license.txt$ */ package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects; +import java.util.Collection; import java.util.HashSet; import java.util.Set; import java.util.LinkedHashSet; @@ -48,6 +49,11 @@ public class Entity extends Individual{ this.children.add(subEntity); } + + public void addSubEntitities(Collection subEntities) { + this.children.addAll(subEntities); + + } public void addGrants(Grant grant) { this.grants.add(grant);