diff --git a/config/web.xml b/config/web.xml index 7cff8ef..299e180 100644 --- a/config/web.xml +++ b/config/web.xml @@ -64,20 +64,22 @@ action org.thdl.lex.LexActionServlet - - - - public - org.thdl.lex.LexActionServlet + + globalDataRefreshDelay + + 6 + + + recentItems + + 6 + login org.thdl.lex.LoginServlet - + loginPage /login.jsp @@ -97,25 +99,15 @@ - - test - org.thdl.lex.HibernateTestServlet - - - - test - /test - - action /action - public + action /public diff --git a/src/java/org/thdl/lex/LexActionServlet.java b/src/java/org/thdl/lex/LexActionServlet.java index 9b209e9..90c6349 100644 --- a/src/java/org/thdl/lex/LexActionServlet.java +++ b/src/java/org/thdl/lex/LexActionServlet.java @@ -92,6 +92,13 @@ public class LexActionServlet extends HttpServlet super.init( config ); initCommands(); config.getServletContext().setAttribute( "flatData", new LexFlatDataRepository() ); + String delay = config.getInitParameter( "globalDataRefreshDelay" ); + long refreshDelay = Long.parseLong( delay ) * 1000 * 60; + String recent = config.getInitParameter( "recentItems" ); + int recentItems = Integer.parseInt( recent ); + Global global = new Global( recentItems, refreshDelay ); + config.getServletContext().setAttribute( "global", global ); + LexLogger.debugComponent( global ); } diff --git a/src/java/org/thdl/lex/LexComponentRepository.java b/src/java/org/thdl/lex/LexComponentRepository.java index d8ec104..f8c9be8 100644 --- a/src/java/org/thdl/lex/LexComponentRepository.java +++ b/src/java/org/thdl/lex/LexComponentRepository.java @@ -328,6 +328,30 @@ public class LexComponentRepository } + /** + * Gets the recentTerms attribute of the LexComponentRepository class + * + * @param limit Description of the Parameter + * @return The recentTerms value + * @exception LexRepositoryException Description of the Exception + */ + public static List getRecentTerms( int limit ) throws LexRepositoryException + { + Query query = null; + List results = null; + String queryString = " FROM org.thdl.lex.component.ITerm ORDER BY modifiedOn DESC LIMIT " + limit; + try + { + query = getSession().createQuery( queryString ); + results = query.list(); + } + catch ( HibernateException he ) + { + throw new LexRepositoryException( he ); + } + return results; + } + /** * Description of the Method diff --git a/src/java/org/thdl/lex/commands/InsertCommand.java b/src/java/org/thdl/lex/commands/InsertCommand.java index 6736de6..18776d7 100644 --- a/src/java/org/thdl/lex/commands/InsertCommand.java +++ b/src/java/org/thdl/lex/commands/InsertCommand.java @@ -60,6 +60,7 @@ public class InsertCommand extends LexCommand implements Command String msg = null; String next = getNext(); DisplayHelper displayHelper = getSessionManager().getDisplayHelper( req.getSession( true ) ); + Global global = (Global) req.getServletContext().getAttribute( "global" ); try { HttpSession ses = req.getSession( false ); @@ -124,7 +125,7 @@ public class InsertCommand extends LexCommand implements Command LexLogger.debugComponent( term ); LexComponentRepository.saveOrUpdate( term ); - + global.setRequiresRefresh( true ); msg = "Successful Update"; getSessionManager().setDisplayMode( req.getSession( true ), "edit" ); } diff --git a/src/java/org/thdl/lex/commands/UpdateCommand.java b/src/java/org/thdl/lex/commands/UpdateCommand.java index 2f468e2..2b29b4e 100644 --- a/src/java/org/thdl/lex/commands/UpdateCommand.java +++ b/src/java/org/thdl/lex/commands/UpdateCommand.java @@ -60,6 +60,7 @@ public class UpdateCommand extends LexCommand implements Command String msg = null; String next = getNext(); DisplayHelper displayHelper = getSessionManager().getDisplayHelper( req.getSession( true ) ); + Global global = (Global) req.getServletContext().getAttribute( "global" ); try { HttpSession ses = req.getSession( false ); @@ -104,7 +105,7 @@ public class UpdateCommand extends LexCommand implements Command LexLogger.debugComponent( term ); LexComponentRepository.update( term ); - + global.setRequiresRefresh( true ); msg = "Successful Update"; getSessionManager().setDisplayMode( req.getSession( true ), "edit" ); } diff --git a/src/jsp/jsp/menu.jsp b/src/jsp/jsp/menu.jsp index 88c8270..7c8dba1 100644 --- a/src/jsp/jsp/menu.jsp +++ b/src/jsp/jsp/menu.jsp @@ -79,7 +79,19 @@ Message:

- + +

Recently Updated Terms

+ +

+

+ Created by + on +
+ Modified by + on +

+
+