testing
This commit is contained in:
parent
1de7ae90e5
commit
0ecf2b6ee9
186 changed files with 14574 additions and 0 deletions
104
src/java/org/thdl/lex/commands/FindCommand.java
Normal file
104
src/java/org/thdl/lex/commands/FindCommand.java
Normal file
|
@ -0,0 +1,104 @@
|
|||
package org.thdl.lex.commands;
|
||||
|
||||
import org.thdl.lex.*;
|
||||
import org.thdl.lex.component.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* Description of the Class
|
||||
*
|
||||
*@author travis
|
||||
*@created October 1, 2003
|
||||
*/
|
||||
public class FindCommand extends LexCommand implements Command
|
||||
{
|
||||
//helper methods
|
||||
/**
|
||||
* Description of the Method
|
||||
*
|
||||
*@param req Description of Parameter
|
||||
*@param component Description of Parameter
|
||||
*@return Description of the Returned Value
|
||||
*@exception CommandException Description of Exception
|
||||
*@since
|
||||
*/
|
||||
public String execute( HttpServletRequest req, ILexComponent component ) throws CommandException
|
||||
{
|
||||
try
|
||||
{
|
||||
String msg = null;
|
||||
String forward = (String) getForwards().get( req.getParameter( LexConstants.LABEL_REQ_PARAM ) );
|
||||
|
||||
component.populate( req.getParameterMap() );
|
||||
setNext( forward );
|
||||
|
||||
if ( component instanceof ITerm )
|
||||
{
|
||||
ITerm term = (ITerm) component;
|
||||
|
||||
LexQuery query = getSessionMgr().getQuery( req.getSession( true ) );
|
||||
|
||||
query.setQueryComponent( term );
|
||||
LexComponentRepository.findTermsByTerm( query );
|
||||
Iterator iterator = query.getResults().keySet().iterator();
|
||||
if ( iterator.hasNext() )
|
||||
{
|
||||
setNext( "displayEntry.jsp" );
|
||||
getSessionMgr().setQuery( req.getSession( true ), query );
|
||||
msg = "There are " + query.getResults().size() + " terms matching " + term.getTerm();
|
||||
}
|
||||
else
|
||||
{
|
||||
setNext( "menu.jsp" );
|
||||
msg = "There were no terms matching " + term.getTerm();
|
||||
}
|
||||
}
|
||||
req.setAttribute( LexConstants.MESSAGE_REQ_ATTR, msg );
|
||||
return getNext();
|
||||
}
|
||||
catch ( LexComponentException e )
|
||||
{
|
||||
throw new CommandException( e );
|
||||
}
|
||||
catch ( LexRepositoryException e )
|
||||
{
|
||||
throw new CommandException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Description of the Method
|
||||
*
|
||||
*@return Description of the Returned Value
|
||||
*@since
|
||||
*/
|
||||
public HashMap initForwards()
|
||||
{
|
||||
HashMap map = new HashMap();
|
||||
map.put( LexConstants.TERMLABEL_VALUE, "displayEntry.jsp" );
|
||||
// map.put( LexConstants.DEFINITIONLABEL_VALUE, "displayEntry.jsp" );
|
||||
// map.put( LexConstants.PASSAGELABEL_VALUE, "displayEntry.jsp" );
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
//constructors
|
||||
/**
|
||||
* Constructor for the FindCommand object
|
||||
*
|
||||
*@since
|
||||
*/
|
||||
public FindCommand()
|
||||
{
|
||||
super();
|
||||
setForwards( initForwards() );
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue