New Global object for statistics like recently updated terms, term count, etc.
This commit is contained in:
parent
f8ed816ff3
commit
d7be0f33cd
6 changed files with 60 additions and 23 deletions
|
@ -64,20 +64,22 @@
|
|||
<servlet>
|
||||
<servlet-name>action</servlet-name>
|
||||
<servlet-class>org.thdl.lex.LexActionServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>public</servlet-name>
|
||||
<servlet-class>org.thdl.lex.LexActionServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>globalDataRefreshDelay</param-name>
|
||||
<!--delay in minutes-->
|
||||
<param-value>6</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>recentItems</param-name>
|
||||
<!--number of recently modified terms to store in the global object-->
|
||||
<param-value>6</param-value>
|
||||
</init-param>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>login</servlet-name>
|
||||
<servlet-class>org.thdl.lex.LoginServlet</servlet-class>
|
||||
<!-- <init-param>
|
||||
<param-name>userDataManager</param-name>
|
||||
<param-value>org.thdl.lex.LexUserDataManager</param-value>
|
||||
</init-param> -->
|
||||
|
||||
<init-param>
|
||||
<param-name>loginPage</param-name>
|
||||
<param-value>/login.jsp</param-value>
|
||||
|
@ -97,25 +99,15 @@
|
|||
</init-param>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>test</servlet-name>
|
||||
<servlet-class>org.thdl.lex.HibernateTestServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<!--SERVLET MAPPPINGS-->
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>test</servlet-name>
|
||||
<url-pattern>/test</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>action</servlet-name>
|
||||
<url-pattern>/action</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>public</servlet-name>
|
||||
<servlet-name>action</servlet-name>
|
||||
<url-pattern>/public</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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" );
|
||||
}
|
||||
|
|
|
@ -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" );
|
||||
}
|
||||
|
|
|
@ -80,6 +80,18 @@
|
|||
</p>
|
||||
</c:if>
|
||||
|
||||
<h2>Recently Updated Terms</h2>
|
||||
<c:forEach var="term" items="${applicationScope.global.recentUpdates }">
|
||||
<h3><c:out value="${ term.term }"/></h3>
|
||||
<p>
|
||||
<span class="label">Created by </span><c:out value="${ applicationScope.flatData.users[ term.meta.createdBy ] }" escapeXml="false"/>
|
||||
<span class="label">on </span><c:out value="${ term.meta.createdOn }" default="unknown" escapeXml="false"/>
|
||||
<br/>
|
||||
<span class="label">Modified by </span><c:out value="${ applicationScope.flatData.users[ term.meta.modifiedBy ] }" default="unknown" escapeXml="false"/>
|
||||
<span class="label">on </span><c:out value="${ term.meta.modifiedOn }" default="unknown" escapeXml="false"/>
|
||||
</p>
|
||||
</c:forEach>
|
||||
|
||||
</div><!--END COLUMN CENTER-->
|
||||
|
||||
<jsp:include page="footer.jsf" flush="false" />
|
||||
|
|
Loading…
Reference in a new issue