📄 queryreferencedataaction.java
字号:
/* @LICENSE_COPYRIGHT@ */
package net.sf.irunninglog.servlet.action;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import net.sf.irunninglog.canonical.Route;
import net.sf.irunninglog.canonical.RunType;
import net.sf.irunninglog.canonical.Shoe;
import net.sf.irunninglog.service.IQueryService;
import net.sf.irunninglog.servlet.UserContainer;
/**
* Perform a query to find all reference data for the current Runner. This
* is a wrapper around the various <code>IQueryService</code> methods which
* return reference data based on the current Runner's id. This action uses
* the canonical id of the current form bean to determine which objects to
* return.
*
* @author <a href="mailto:allan_e_lewis@yahoo.com">Allan Lewis</a>
* @version $Revision: 1.3 $ $Date: 2005/06/25 15:18:20 $
* @since iRunningLog 1.0
*/
public final class QueryReferenceDataAction extends DefaultQueryAction {
/** <code>Log</code> instance for this class. */
private static final Log LOG =
LogFactory.getLog(QueryReferenceDataAction.class);
/**
* Execute the query by invoking the appropriate <code>IQueryService</code>
* method. This method will use the value of the mapping's parameter to
* determine which method should be called.
*
* @param mapping The <code>ActionMapping</code> used to select this
* instance.
* @param form The optional <code>ActionForm</code> bean for this request
* @param request The HTTP request being processed
* @param container The <code>UserContainer</code> object for the current
* user
* @return The collection of objects found by the query
* @exception Exception if the application business logic throws
* an exception
*/
protected Collection executeQuery(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
UserContainer container)
throws Exception {
String runnerId = container.getUserName();
String parameter = mapping.getParameter();
IQueryService queryService = container.getQueryService();
Collection results = null;
if (LOG.isDebugEnabled()) {
LOG.debug("executeQuery: About to invoke the query operation");
LOG.debug("executeQuery: runnerId is " + runnerId);
LOG.debug("executeQuery: parameter is " + parameter);
}
if (parameter.indexOf(Route.CANONICAL_ID) != -1) {
results = queryService.findRoutesForRunner(runnerId);
} else if (parameter.indexOf(RunType.CANONICAL_ID) != -1) {
results = queryService.findRunTypesForRunner(runnerId);
} else if (parameter.indexOf(Shoe.CANONICAL_ID) != -1) {
results = queryService.findShoesForRunner(runnerId);
} else {
LOG.error("Unable to query based on parameter " + parameter);
throw new IllegalArgumentException("Unable to query based on"
+ " parameter " + parameter);
}
return results;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -