From 5f71827f934a44f63ecb8981b27b98190c2e481c Mon Sep 17 00:00:00 2001 From: hudajkhan Date: Mon, 4 Nov 2013 11:52:36 -0500 Subject: [PATCH 1/5] search part of page needs to be broken out to include search box in jsp pages --- themes/wilma/templates/page.ftl | 15 +-------------- themes/wilma/templates/search.ftl | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 themes/wilma/templates/search.ftl diff --git a/themes/wilma/templates/page.ftl b/themes/wilma/templates/page.ftl index 61a2b3c4..b826291c 100644 --- a/themes/wilma/templates/page.ftl +++ b/themes/wilma/templates/page.ftl @@ -10,20 +10,7 @@ <#include "identity.ftl"> - - - + <#include "search.ftl" > <#include "menu.ftl"> <#-- VIVO OpenSocial Extension by UCSF --> diff --git a/themes/wilma/templates/search.ftl b/themes/wilma/templates/search.ftl new file mode 100644 index 00000000..a3825eea --- /dev/null +++ b/themes/wilma/templates/search.ftl @@ -0,0 +1,17 @@ +<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> + +<#--Breaking this out so this can be utilized by other pages such as the jsp advanced tools pages--> + + + \ No newline at end of file From 35ec65eebe70466486e2ffaf1178eafcf4f19377 Mon Sep 17 00:00:00 2001 From: j2blake Date: Mon, 4 Nov 2013 12:48:13 -0500 Subject: [PATCH 2/5] VIVO-415 OpenSocial template was in Wilma - should be in VIVO. --- .../freemarker/body/individual}/individual-openSocial.ftl | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {themes/wilma/templates => productMods/templates/freemarker/body/individual}/individual-openSocial.ftl (100%) diff --git a/themes/wilma/templates/individual-openSocial.ftl b/productMods/templates/freemarker/body/individual/individual-openSocial.ftl similarity index 100% rename from themes/wilma/templates/individual-openSocial.ftl rename to productMods/templates/freemarker/body/individual/individual-openSocial.ftl From 9f854b6490b05fa36fdf34040a1e482c3fd4dbaa Mon Sep 17 00:00:00 2001 From: j2blake Date: Mon, 4 Nov 2013 12:50:19 -0500 Subject: [PATCH 3/5] VIVO-482 replace core:URLLink with card:URL --- rdf/display/everytime/vivoSearchProhibited.n3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdf/display/everytime/vivoSearchProhibited.n3 b/rdf/display/everytime/vivoSearchProhibited.n3 index 17985305..8e7b7063 100644 --- a/rdf/display/everytime/vivoSearchProhibited.n3 +++ b/rdf/display/everytime/vivoSearchProhibited.n3 @@ -27,7 +27,7 @@ vitroDisplay:excludeClass core:DateTimeValuePrecision ; vitroDisplay:excludeClass core:DateTimeInterval ; vitroDisplay:excludeClass core:AcademicDegree ; - vitroDisplay:excludeClass core:URLLink ; + vitroDisplay:excludeClass vcard:URL ; vitroDisplay:excludeClass vcard:Communication ; vitroDisplay:excludeClass vcard:Code ; vitroDisplay:excludeClass vcard:Explanatory ; From 50d788adb44774b86b9fc91250c85d6ee9eabcda Mon Sep 17 00:00:00 2001 From: j2blake Date: Mon, 4 Nov 2013 12:55:02 -0500 Subject: [PATCH 4/5] Refine the script that scans for obsolete URIs --- .../obsoleteUris/directory_walker.rb | 6 +- .../obsoleteUris/{doit2 => doit} | 4 +- .../ISF-transition/obsoleteUris/doit_old | 2 + .../obsoleteUris/vivo_known_exceptions.txt | 56 ++++++++++++++----- ...ns_2.txt => vivo_known_exceptions_old.txt} | 33 +++++------ 5 files changed, 64 insertions(+), 37 deletions(-) rename utilities/ISF-transition/obsoleteUris/{doit2 => doit} (64%) create mode 100755 utilities/ISF-transition/obsoleteUris/doit_old rename utilities/ISF-transition/obsoleteUris/{vivo_known_exceptions_2.txt => vivo_known_exceptions_old.txt} (91%) diff --git a/utilities/ISF-transition/obsoleteUris/directory_walker.rb b/utilities/ISF-transition/obsoleteUris/directory_walker.rb index 5ccaa89c..3a499bdb 100644 --- a/utilities/ISF-transition/obsoleteUris/directory_walker.rb +++ b/utilities/ISF-transition/obsoleteUris/directory_walker.rb @@ -10,6 +10,8 @@ class DirectoryWalker if FileTest.directory?(path) if File.basename(path).start_with?(".") Find.prune # Don't look any further into this directory. + elsif @known_exceptions.skip?(path) + Find.prune else next end @@ -33,13 +35,13 @@ class DirectoryWalker def scan_line(path, line_number, line) @obsolete_uris.uris.each do |uri| - next if @known_exceptions.skip?(path, line_number, uri) +# next if @known_exceptions.skip?(path, line_number, uri) @report.add_event(Event.new(path, line_number, line, uri)) if line =~ Regexp.new("\\b#{Regexp.quote(uri)}\\b") end if @complete @obsolete_uris.localnames.each do |localname| term = ":#{localname}" - next if @known_exceptions.skip?(path, line_number, term) +# next if @known_exceptions.skip?(path, line_number, term) @report.add_event(Event.new(path, line_number, line, term)) if line =~ Regexp.new("#{Regexp.quote(term)}\\b") end end diff --git a/utilities/ISF-transition/obsoleteUris/doit2 b/utilities/ISF-transition/obsoleteUris/doit similarity index 64% rename from utilities/ISF-transition/obsoleteUris/doit2 rename to utilities/ISF-transition/obsoleteUris/doit index 2f8a8b33..157ddc6d 100755 --- a/utilities/ISF-transition/obsoleteUris/doit2 +++ b/utilities/ISF-transition/obsoleteUris/doit @@ -1,7 +1,7 @@ ruby obsoleteUriChecker.rb /Users/jeb228/git/VIVO \ ../../../productMods/WEB-INF/ontologies/update/diff.tab.txt \ - vivo_known_exceptions_2.txt complete > scan_VIVO_maint_branch + vivo_known_exceptions.txt complete > scan_VIVO_maint_branch ruby obsoleteUriChecker.rb /Users/jeb228/git/Vitro \ ../../../productMods/WEB-INF/ontologies/update/diff.tab.txt \ - vivo_known_exceptions_2.txt complete > scan_Vitro_maint_branch + vivo_known_exceptions.txt complete > scan_Vitro_maint_branch diff --git a/utilities/ISF-transition/obsoleteUris/doit_old b/utilities/ISF-transition/obsoleteUris/doit_old new file mode 100755 index 00000000..5be4adc8 --- /dev/null +++ b/utilities/ISF-transition/obsoleteUris/doit_old @@ -0,0 +1,2 @@ +ruby obsoleteUriChecker.rb /Users/jeb228/Documents/Releases/VIVO\ 1.6/vivo-rel-1.6-rc1 ../../../productMods/WEB-INF/ontologies/update/diff.tab.txt vivo_known_exceptions.txt complete + diff --git a/utilities/ISF-transition/obsoleteUris/vivo_known_exceptions.txt b/utilities/ISF-transition/obsoleteUris/vivo_known_exceptions.txt index 3409da4c..ae8dfa94 100644 --- a/utilities/ISF-transition/obsoleteUris/vivo_known_exceptions.txt +++ b/utilities/ISF-transition/obsoleteUris/vivo_known_exceptions.txt @@ -1,17 +1,23 @@ -.GIF -.as -.class -.fla -.gif -.gz -.ico -.jar -.jpg -.psd -.png -.swf -.war -.zip + +bin +utilities/ISF-transition/obsoleteUris + +*.GIF +*.as +*.class +*.fla +*.gif +*.gz +*.ico +*.jar +*.jpg +*.psd +*.png +*.swf +*.war +*.zip + +**/.* # # first_pass: no excluded files. everything was duplicated in the .bin directory, and @@ -39,3 +45,25 @@ productMods/WEB-INF/ontologies/update/oldVersion/vivo-bibo-1.5.owl productMods/WEB-INF/ontologies/update/oldVersion/scires-1.5.owl productMods/WEB-INF/ontologies/update/oldVersion/vivo-dcterms-1.5.owl productMods/WEB-INF/ontologies/update/oldVersion/vivo-dcelements-1.5.owl + +# +# Exclude old performance tests +# +utilities/LoadTesting/distros/release1.4/deploy.properties.template + +# +# Exclude the migration code itself +# +productMods/WEB-INF/ontologies/update/**/* + +# +# This is commented out. +# +src/edu/cornell/mannlib/vitro/webapp/visualization/utilities/UtilitiesRequestHandler.java + +# +# The URI is obsolete, but it has been replaced by another URI with the same localname. +# http://purl.org/dc/terms/publisher http://vivoweb.org/ontology/core#publisher +# How to catch this? +# + diff --git a/utilities/ISF-transition/obsoleteUris/vivo_known_exceptions_2.txt b/utilities/ISF-transition/obsoleteUris/vivo_known_exceptions_old.txt similarity index 91% rename from utilities/ISF-transition/obsoleteUris/vivo_known_exceptions_2.txt rename to utilities/ISF-transition/obsoleteUris/vivo_known_exceptions_old.txt index 8d1d4e7e..3409da4c 100644 --- a/utilities/ISF-transition/obsoleteUris/vivo_known_exceptions_2.txt +++ b/utilities/ISF-transition/obsoleteUris/vivo_known_exceptions_old.txt @@ -1,22 +1,17 @@ -.* -bin - -*.GIF -*.as -*.class -*.fla -*.gif -*.gz -*.ico -*.jar -*.jpg -*.psd -*.png -*.swf -*.war -*.zip - -**/.* +.GIF +.as +.class +.fla +.gif +.gz +.ico +.jar +.jpg +.psd +.png +.swf +.war +.zip # # first_pass: no excluded files. everything was duplicated in the .bin directory, and From 6fd299301cd23eaf98e819f5e7284a38ec98c91e Mon Sep 17 00:00:00 2001 From: tworrall Date: Mon, 4 Nov 2013 14:45:43 -0500 Subject: [PATCH 5/5] VIVO-485 convert datagetter to ajax call --- productMods/js/homePageMaps.js | 26 +++++- .../freemarker/lib/lib-home-page.ftl | 14 --- rdf/display/everytime/homePageDataGetters.n3 | 23 +---- .../ajax/GeoFocusResearcherCount.java | 83 +++++++++++++++++ .../ajax/HomePageAjaxController.java | 88 ++++++++++--------- themes/wilma/templates/page-home.ftl | 1 - 6 files changed, 152 insertions(+), 83 deletions(-) create mode 100644 src/edu/cornell/mannlib/vitro/webapp/controller/ajax/GeoFocusResearcherCount.java diff --git a/productMods/js/homePageMaps.js b/productMods/js/homePageMaps.js index 06283d1e..c41b6fbc 100644 --- a/productMods/js/homePageMaps.js +++ b/productMods/js/homePageMaps.js @@ -6,11 +6,12 @@ $(document).ready(function(){ var countryMapBuilt = false; var localMapBuilt = false; var researchAreas = { "type": "FeatureCollection", "features": []}; + var geoResearcherCount = "0"; $.extend(this, urlsBase); $.extend(this, i18nStrings); - $.extend(this, geoResearcherCount); + getGeoFocusResearcherCount(); getGeoJsonForMaps(); $('a#globalLink').click(function() { @@ -367,9 +368,26 @@ $(document).ready(function(){ }); } + function getGeoFocusResearcherCount() { + $.ajax({ + url: urlsBase + "/homePageAjax", + dataType: "json", + data: { + action: "getGeoFocusResearcherCount", + }, + complete: function(xhr, status) { + + var results = $.parseJSON(xhr.responseText); + // there will only ever be one key/value pair + if ( results != null ) { + geoResearcherCount = results.count; + } + } + }); + } + function getResearcherCount(area) { - var researcherCount = this.geoResearcherCount; var areaCount = 0; var text = ""; if ( area == "global" ) { @@ -391,7 +409,7 @@ $(document).ready(function(){ if ( areaCount == 1 && text == " states.") { text = " " + i18nStrings.stateString; } - if ( researcherCount == 1 ) { + if ( geoResearcherCount == 1 ) { researcherText = " " + i18nStrings.researcherString + " " + i18nStrings.inString; } else { @@ -399,7 +417,7 @@ $(document).ready(function(){ } $('div#researcherTotal').html("" - + researcherCount + + geoResearcherCount + " " + researcherText + " " + areaCount + "" + text); } diff --git a/productMods/templates/freemarker/lib/lib-home-page.ftl b/productMods/templates/freemarker/lib/lib-home-page.ftl index f105863c..7235a394 100644 --- a/productMods/templates/freemarker/lib/lib-home-page.ftl +++ b/productMods/templates/freemarker/lib/lib-home-page.ftl @@ -204,17 +204,3 @@ var urlsBase = "${urls.base}"; --> - -<#-- retrieves a count, the number of researchers with a geographic focus, --> -<#-- and saves it as a js variable to be used by the homePageMaps.js file --> -<#macro getGeoResearcherCount> - - diff --git a/rdf/display/everytime/homePageDataGetters.n3 b/rdf/display/everytime/homePageDataGetters.n3 index 48bbcd1c..02184a68 100644 --- a/rdf/display/everytime/homePageDataGetters.n3 +++ b/rdf/display/everytime/homePageDataGetters.n3 @@ -17,35 +17,14 @@ display:academicDeptsDataGetter display:saveToVar "academicDeptDG" ; display:query """ PREFIX rdfs: - PREFIX rdf: PREFIX vivo: SELECT DISTINCT ?theURI (str(?label) as ?name) WHERE { - ?theURI rdf:type vivo:AcademicDepartment . + ?theURI a vivo:AcademicDepartment . ?theURI rdfs:label ?label } """ . - display:hasDataGetter display:researcherCountDataGetter . - -display:researcherCountDataGetter - a ; - display:saveToVar "researcherCountDG" ; - display:query """ - PREFIX geo: - PREFIX rdfs: - PREFIX rdf: - PREFIX core: - PREFIX foaf: - PREFIX vivoc: - - SELECT DISTINCT (COUNT(DISTINCT ?person) AS ?count) - WHERE { - ?person rdf:type foaf:Person . - ?person core:geographicFocus ?focus - } - - """ . diff --git a/src/edu/cornell/mannlib/vitro/webapp/controller/ajax/GeoFocusResearcherCount.java b/src/edu/cornell/mannlib/vitro/webapp/controller/ajax/GeoFocusResearcherCount.java new file mode 100644 index 00000000..fa177450 --- /dev/null +++ b/src/edu/cornell/mannlib/vitro/webapp/controller/ajax/GeoFocusResearcherCount.java @@ -0,0 +1,83 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ +package edu.cornell.mannlib.vitro.webapp.controller.ajax; + +import java.io.IOException; +import java.lang.Integer; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONException; + +import com.hp.hpl.jena.query.QuerySolution; +import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.rdf.model.RDFNode; + +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; +import edu.cornell.mannlib.vitro.webapp.controller.ajax.VitroAjaxController; +import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; +import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils; + +public class GeoFocusResearcherCount extends AbstractAjaxResponder { + + private static final Log log = LogFactory.getLog(GeoFocusResearcherCount.class.getName()); + private List> geoFocusCount; + private static String GEO_FOCUS_COUNT_QUERY = "" + + "PREFIX core: \n" + + "PREFIX foaf: \n" + + "SELECT DISTINCT (COUNT(DISTINCT ?person) AS ?count) \n" + + "WHERE { \n" + + " ?person a foaf:Person . \n" + + " ?person core:geographicFocus ?focus \n" + + "}" ; + + public GeoFocusResearcherCount(HttpServlet parent, VitroRequest vreq, + HttpServletResponse resp) { + super(parent, vreq, resp); + } + + @Override + public String prepareResponse() throws IOException, JSONException { + try { + geoFocusCount = getGeoFocusCount(vreq); + + String response = "{ "; + + for (Map map: geoFocusCount) { + String theCount = map.get("count"); + response += "\"count\": \"" + theCount + "\""; + } + response += " }"; + log.debug(response); + return response; + } catch (Exception e) { + log.error("Failed geographic focus count", e); + return EMPTY_RESPONSE; + } + } + + private List> getGeoFocusCount(VitroRequest vreq) { + + String queryStr = GEO_FOCUS_COUNT_QUERY; + log.debug("queryStr = " + queryStr); + List> count = new ArrayList>(); + try { + ResultSet results = QueryUtils.getQueryResults(queryStr, vreq); + while (results.hasNext()) { + QuerySolution soln = results.nextSolution(); + count.add(QueryUtils.querySolutionToStringValueMap(soln)); + } + } catch (Exception e) { + log.error(e, e); + } + + return count; + } +} diff --git a/src/edu/cornell/mannlib/vitro/webapp/controller/ajax/HomePageAjaxController.java b/src/edu/cornell/mannlib/vitro/webapp/controller/ajax/HomePageAjaxController.java index e5f2c437..3674d7cf 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/controller/ajax/HomePageAjaxController.java +++ b/src/edu/cornell/mannlib/vitro/webapp/controller/ajax/HomePageAjaxController.java @@ -1,42 +1,46 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.controller.ajax; - -import java.io.IOException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; -import edu.cornell.mannlib.vitro.webapp.controller.ajax.VitroAjaxController; - -/** - * Handle the AJAX functions that are specific to the "new" home page sections, at - * this point just the mapping of geographic locations. - */ -public class HomePageAjaxController extends VitroAjaxController { - private static final Log log = LogFactory - .getLog(HomePageAjaxController.class); - - private static final String PARAMETER_ACTION = "action"; - - @Override - protected void doRequest(VitroRequest vreq, HttpServletResponse resp) - throws ServletException, IOException { - try { - String function = vreq.getParameter(PARAMETER_ACTION); - if ("getGeoFocusLocations".equals(function)) { - new GeoFocusMapLocations(this, vreq, resp).processRequest(); - } else { - resp.getWriter().write("[]"); - } - } catch (Exception e) { - log.error(e, e); - resp.getWriter().write("[]"); - } - } - -} +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.controller.ajax; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; +import edu.cornell.mannlib.vitro.webapp.controller.ajax.VitroAjaxController; + +/** + * Handle the AJAX functions that are specific to the "new" home page sections, at + * this point just the mapping of geographic locations. + */ +public class HomePageAjaxController extends VitroAjaxController { + private static final Log log = LogFactory + .getLog(HomePageAjaxController.class); + + private static final String PARAMETER_ACTION = "action"; + + @Override + protected void doRequest(VitroRequest vreq, HttpServletResponse resp) + throws ServletException, IOException { + try { + String function = vreq.getParameter(PARAMETER_ACTION); + if ("getGeoFocusLocations".equals(function)) { + new GeoFocusMapLocations(this, vreq, resp).processRequest(); + } + else if ("getGeoFocusResearcherCount".equals(function)) { + new GeoFocusResearcherCount(this, vreq, resp).processRequest(); + } + else { + resp.getWriter().write("[]"); + } + } catch (Exception e) { + log.error(e, e); + resp.getWriter().write("[]"); + } + } + +} diff --git a/themes/wilma/templates/page-home.ftl b/themes/wilma/templates/page-home.ftl index 8547e0b8..d28a80b5 100644 --- a/themes/wilma/templates/page-home.ftl +++ b/themes/wilma/templates/page-home.ftl @@ -110,6 +110,5 @@ $('input.search-homepage').attr("value","${i18n().limit_search} \u2192"); } - <@lh.getGeoResearcherCount/> \ No newline at end of file