From 06c7dcfabd152a6e0094f582b67f4cecb5af8cd2 Mon Sep 17 00:00:00 2001 From: tworrall Date: Wed, 8 May 2013 13:03:30 -0400 Subject: [PATCH] removed unneeded order by to improve sparql performace; updated checkLocationHash method so that tab name was not hard-coded --- .../js/individual/propertyGroupControls.js | 20 ++++++++----- .../controller/ajax/GeoFocusMapLocations.java | 30 +++++++++++-------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/productMods/js/individual/propertyGroupControls.js b/productMods/js/individual/propertyGroupControls.js index 890ebbad..27ab7a7d 100644 --- a/productMods/js/individual/propertyGroupControls.js +++ b/productMods/js/individual/propertyGroupControls.js @@ -67,20 +67,24 @@ $(document).ready(function(){ if ( location.hash ) { // remove the trailing white space location.hash = location.hash.replace(/\s+/g, ''); - if ( location.hash.indexOf("map") >= 0 ) { - // if the first tab section is named "Research" we don't have to do anything; - // otherwise, select the Research tab and deselect the first one + if ( location.hash.indexOf("map") >= 0 ) { + // get the name of the group that contains the geographicFocusOf property. + var tabName = $('h3#geographicFocusOf').parent('article').parent('div').attr("id"); + tabName = tabName.replace("Group",""); + tabNameCapped = tabName.charAt(0).toUpperCase() + tabName.slice(1); + // if the name of the first tab section = tabName we don't have to do anything; + // otherwise, select the correct tab and deselect the first one var $firstTab = $('li.clickable').first(); - if ( $firstTab.text() != "Research") { - // select the stored tab - $("li[groupName='research']").removeClass("nonSelectedGroupTab clickable"); - $("li[groupName='research']").addClass("selectedGroupTab clickable"); + if ( $firstTab.text() != tabNameCapped ) { + // select the correct tab + $('li[groupName="' + tabName + '"]').removeClass("nonSelectedGroupTab clickable"); + $('li[groupName="' + tabName + '"]').addClass("selectedGroupTab clickable"); // deselect the first tab $firstTab.removeClass("selectedGroupTab clickable"); $firstTab.addClass("nonSelectedGroupTab clickable"); $('section.property-group:visible').hide(); // show the selected tab section - $('section#research').show(); + $('section#' + tabName).show(); } } else { diff --git a/src/edu/cornell/mannlib/vitro/webapp/controller/ajax/GeoFocusMapLocations.java b/src/edu/cornell/mannlib/vitro/webapp/controller/ajax/GeoFocusMapLocations.java index 889ae168..f2e3574d 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/controller/ajax/GeoFocusMapLocations.java +++ b/src/edu/cornell/mannlib/vitro/webapp/controller/ajax/GeoFocusMapLocations.java @@ -34,23 +34,14 @@ public class GeoFocusMapLocations extends AbstractAjaxResponder { + "PREFIX rdf: \n" + "PREFIX core: \n" + "PREFIX foaf: \n" - + "PREFIX vivoc: \n" + "SELECT DISTINCT ?label ?location (COUNT(?person) AS ?count) \n" - + "WHERE { {" + + "WHERE {" + " ?location rdf:type core:GeographicRegion . \n" + " ?location rdfs:label ?label . " + " ?location core:geographicFocusOf ?person . \n" + " ?person rdf:type foaf:Person \n" - + " FILTER (! regex(str(?location), \"dbpedia\")) \n" - + "} UNION { \n " - + " ?sublocation rdf:type vivoc:DomesticGeographicalRegion . \n" - + " ?sublocation core:geographicFocusOf ?person . \n" - + " ?person rdf:type foaf:Person \n" - + " bind((\"United States of America\"^^) AS ?label) \n" - + " bind( AS ?location) \n" - + "} } \n" - + "GROUP BY ?label ?location \n" - + "ORDER BY ?label ?location \n"; + + "} \n" + + "GROUP BY ?label ?location \n"; public GeoFocusMapLocations(HttpServlet parent, VitroRequest vreq, HttpServletResponse resp) { @@ -76,12 +67,25 @@ public class GeoFocusMapLocations extends AbstractAjaxResponder { } Integer count = Integer.parseInt(map.get("count")); String radius = String.valueOf(calculateRadius(count)); + String name = ""; if ( label != null && !label.equals(previousLabel) ) { + if ( label.contains("Ivoire") ) { + name = "Ivory Coast"; + } + else if ( label.contains("New York State") ) { + name = "New York"; + } + else if ( label.contains("United Kingdom") ) { + name = "United Kingdom"; + } + else { + name = label; + } String tempStr = geometry; //+label tempStr += typeProps //+ label + "\"popupContent\": \"" - + label + + name + "\",\"html\":" + html + ",\"radius\":"