diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/TabEntitiesController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/TabEntitiesController.java index bd1b439d2..9e230fad4 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/TabEntitiesController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/TabEntitiesController.java @@ -1,9 +1,9 @@ /* $This file is distributed under the terms of the license in /doc/license.txt$ */ -package edu.cornell.mannlib.vitro.webapp.controller; - + +package edu.cornell.mannlib.vitro.webapp.controller; + import java.io.IOException; -import java.net.URLEncoder; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -39,86 +39,86 @@ import edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneIndexFactory; import edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneIndexer; import edu.cornell.mannlib.vitro.webapp.utils.FlagMathUtils; import edu.cornell.mannlib.vitro.webapp.web.TabWebUtil; - -/** - * Produces the entity lists for tabs. - * - * @author bdc34 - * - */ -public class TabEntitiesController extends VitroHttpServlet { - private static final long serialVersionUID = -5340982482787800013L; - - private static final Log log = LogFactory.getLog(TabEntitiesController.class.getName()); - public static int TAB_DEPTH_CUTOFF = 3; + +/** + * Produces the entity lists for tabs. + * + * @author bdc34 + * + */ +public class TabEntitiesController extends VitroHttpServlet { + private static final long serialVersionUID = -5340982482787800013L; + + private static final Log log = LogFactory.getLog(TabEntitiesController.class.getName()); + public static int TAB_DEPTH_CUTOFF = 3; public static int MAX_PAGES = 40; //must be even public static int DEFAULT_NUMBER_INDIVIDUALS_ON_TAB = 8; private static int MAX_RESULTS=40000; private static int NON_PAGED_LIMIT=1000; private static Random random = new Random(); - - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doGet(request, response); - } - - /*********************************************** - Display a set of entities for a tab, these entities - may be manually linked, auto-linked, a mix of these two, - or a gallery. - - request.attributes - a Tab object for the tabId must be in the attributes. - It should have the key - - request.parameters - "tabId" id of the tab to do entities for - - "tabDepth" String that is the depth of the tab in the display for - which we are doing entities. - leadingTab = 1, child of leadingTab = 2, etc. - - "alpha" if set to a letter entities will be filtered - to have only that initial. - + + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + doGet(request, response); + } + + /*********************************************** + Display a set of entities for a tab, these entities + may be manually linked, auto-linked, a mix of these two, + or a gallery. + + request.attributes + a Tab object for the tabId must be in the attributes. + It should have the key + + request.parameters + "tabId" id of the tab to do entities for + + "tabDepth" String that is the depth of the tab in the display for + which we are doing entities. + leadingTab = 1, child of leadingTab = 2, etc. + + "alpha" if set to a letter entities will be filtered + to have only that initial. + bdc34 2006-01-12 created - bdc34 2010-09-17 modified to use lucene for some tasks. - */ -public void doGet( HttpServletRequest req, HttpServletResponse response ) - throws IOException, ServletException { + bdc34 2010-09-17 modified to use lucene for some tasks. + */ +public void doGet( HttpServletRequest req, HttpServletResponse response ) + throws IOException, ServletException { super.doGet(req,response); - - try{ - VitroRequest request = new VitroRequest(req); + + try{ + VitroRequest request = new VitroRequest(req); TabDao tabDao = request.getWebappDaoFactory().getTabDao(); - - int depth = getTabDepth(request); - if( depth >= TAB_DEPTH_CUTOFF){ - String tabId = request.getParameter("tabId"); - log.debug("\ttab "+tabId+" is at, "+ depth+" below "+ TAB_DEPTH_CUTOFF); - return; - } - - String tabId = request.getParameter("tabId"); - if( tabId == null ){ - String e="TabEntitiesController expects that request parameter 'tabId' be set"; - throw new ServletException(e); - } - - Tab tab = TabWebUtil.findStashedTab(tabId,request); - if( tab == null ){ - String e="TabEntitiesController expects that tab"+tabId+" will be in the request attribute. " - +"It should have been placed there by a call to TabWebUtil.stashTabsInRequest in tabPrimary.jsp"; - throw new ServletException(e); + + int depth = getTabDepth(request); + if( depth >= TAB_DEPTH_CUTOFF){ + String tabId = request.getParameter("tabId"); + log.debug("\ttab "+tabId+" is at, "+ depth+" below "+ TAB_DEPTH_CUTOFF); + return; + } + + String tabId = request.getParameter("tabId"); + if( tabId == null ){ + String e="TabEntitiesController expects that request parameter 'tabId' be set"; + throw new ServletException(e); + } + + Tab tab = TabWebUtil.findStashedTab(tabId,request); + if( tab == null ){ + String e="TabEntitiesController expects that tab"+tabId+" will be in the request attribute. " + +"It should have been placed there by a call to TabWebUtil.stashTabsInRequest in tabPrimary.jsp"; + throw new ServletException(e); } req.setAttribute("tabId", tab.getTabId()); request.setAttribute("controllerParam","primary=" + tab.getTabId()); - - String alpha = request.getParameter("alpha"); - boolean doAlphaFilter = false; - if(( alpha != null && alpha.length() == 1) ){ + + String alpha = request.getParameter("alpha"); + boolean doAlphaFilter = false; + if(( alpha != null && alpha.length() == 1) ){ doAlphaFilter = true; - request.setAttribute("alpha", alpha.toUpperCase()); + request.setAttribute("alpha", alpha.toUpperCase()); } boolean doPagedFilter = request.getParameter("page") != null; @@ -180,13 +180,14 @@ public void doGet( HttpServletRequest req, HttpServletResponse response ) log.debug("TabEntitiesController: doing none for tabtypeid: " + tab.getTabtypeId() +" and link mode: " + tab.getEntityLinkMethod()); } - - } catch (Throwable e) { - req.setAttribute("javax.servlet.jsp.jspException",e); - RequestDispatcher rd = req.getRequestDispatcher("/error.jsp"); - rd.include(req, response); - } - } + + + } catch (Throwable e) { + req.setAttribute("javax.servlet.jsp.jspException",e); + RequestDispatcher rd = req.getRequestDispatcher("/error.jsp"); + rd.include(req, response); + } + } /** * This build a lucene query for the tab, runs the query, gets individuals for that query, @@ -337,22 +338,22 @@ public void doGet( HttpServletRequest req, HttpServletResponse response ) return query; } - private void doAlphaFiltered(String alpha, Tab tab, - VitroRequest request, HttpServletResponse response, TabDao tabDao, int size) + private void doAlphaFiltered(String alpha, Tab tab, + VitroRequest request, HttpServletResponse response, TabDao tabDao, int size) throws ServletException, IOException { log.debug("in doAlphaFitlered"); - - request.setAttribute("entities", tab.getRelatedEntities()); - request.setAttribute("alpha", alpha); - request.setAttribute("count", Integer.toString(size) ); + + request.setAttribute("entities", tab.getRelatedEntities()); + request.setAttribute("alpha", alpha); + request.setAttribute("count", Integer.toString(size) ); request.setAttribute("tabParam",tab.getTabDepthName()+"="+tab.getTabId()); - request.setAttribute("letters",Controllers.getLetters()); - //request.setAttribute("letters",tab.grabEntityFactory().getLettersOfEnts()); - request.setAttribute("servlet",Controllers.TAB); - String jsp = Controllers.ENTITY_LIST_FOR_TABS_JSP; - RequestDispatcher rd = - request.getRequestDispatcher(jsp); - rd.include(request, response); + request.setAttribute("letters",Controllers.getLetters()); + //request.setAttribute("letters",tab.grabEntityFactory().getLettersOfEnts()); + request.setAttribute("servlet",Controllers.TAB); + String jsp = Controllers.ENTITY_LIST_FOR_TABS_JSP; + RequestDispatcher rd = + request.getRequestDispatcher(jsp); + rd.include(request, response); } private void doAutoLinked(Tab tab, VitroRequest request, HttpServletResponse response, TabDao tabDao, int size) @@ -369,8 +370,7 @@ public void doGet( HttpServletRequest req, HttpServletResponse response ) request.getRequestDispatcher(jsp); rd.include(request, response); } - - + private int getPage(VitroRequest request) { String p = request.getParameter("page") ; if( p == null ) @@ -380,7 +380,7 @@ public void doGet( HttpServletRequest req, HttpServletResponse response ) }catch(Exception e){ return 1; } - } + } /** * Mixed and auto linked tabs get their individuals via @@ -494,20 +494,20 @@ public void doGet( HttpServletRequest req, HttpServletResponse response ) } } - private int getSizeForGalleryTab(Tab tab){ + private int getSizeForGalleryTab(Tab tab){ int rows = tab.getGalleryRows() != 0 ? tab.getGalleryRows() : 8; int col = tab.getGalleryCols() != 0 ? tab.getGalleryCols() : 8; return rows * col; - } - - private int getSizeForNonGalleryTab(Tab tab, boolean showPaged ){ - if( showPaged ) - if( tab.getGalleryCols() == 0 || tab.getGalleryRows() == 0 ) - return 8; - else - return getSizeForGalleryTab(tab); - else - return NON_PAGED_LIMIT; + } + + private int getSizeForNonGalleryTab(Tab tab, boolean showPaged ){ + if( showPaged ) + if( tab.getGalleryCols() == 0 || tab.getGalleryRows() == 0 ) + return 8; + else + return getSizeForGalleryTab(tab); + else + return NON_PAGED_LIMIT; } private int getTabDepth(VitroRequest request){ @@ -587,5 +587,5 @@ public void doGet( HttpServletRequest req, HttpServletResponse response ) public boolean getSelected(){ return selected; } - } -} + } +} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/lucene/LuceneIndexFactory.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/lucene/LuceneIndexFactory.java index 2c92cbc9f..2e12a96b4 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/lucene/LuceneIndexFactory.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/lucene/LuceneIndexFactory.java @@ -55,9 +55,12 @@ public class LuceneIndexFactory { /** * This method can be used to force the LuceneIndexFactory to return a new IndexSearcher. + * This will force a re-opening of the search index. + * * This could be useful if the index was rebult in a different directory on the file system. */ public synchronized void forceNewIndexSearcher(){ + log.debug("forcing the re-opening of the search index"); searcher = null; } diff --git a/webapp/web/templates/entity/entityListForTabs.jsp b/webapp/web/templates/entity/entityListForTabs.jsp index 2726b6930..bd383feee 100644 --- a/webapp/web/templates/entity/entityListForTabs.jsp +++ b/webapp/web/templates/entity/entityListForTabs.jsp @@ -89,6 +89,40 @@ +<<<<<<< HEAD:webapp/web/templates/entity/entityListForTabs.jsp +======= + + +<%-- Show pages to select from --%> +<% +if( request.getAttribute("alpha") != null && ! "all".equalsIgnoreCase((String)request.getAttribute("alpha"))) { + request.setAttribute("pageAlpha",request.getAttribute("alpha")); +}else{ + request.setAttribute("pageAlpha",request.getAttribute("all")); +} +%> + + +
+ Pages: + + + ${requestScope.tabId} + ${page.index} + + ${requestScope.pageAlpha} + + + + ${page.text} + + + ${page.text} + + +
+
+>>>>>>> c91e65e... Fixing page index on lucene based tabs. NIHVIVO-1143:webapp/web/templates/entity/entityListForTabs.jsp