use of cn.edu.zju.acm.onlinejudge.form.LogSearchForm in project zoj by licheng.
the class ShowActionDashboardAction method execute.
/**
* ShowRolesAction.
*
* @param mapping action mapping
* @param form action form
* @param request http servlet request
* @param response http servlet response
*
* @return action forward instance
*
* @throws Exception any errors happened
*/
public ActionForward execute(ActionMapping mapping, ActionForm form, ContextAdapter context) throws Exception {
ActionForward forward = checkAdmin(mapping, context);
if (forward != null) {
return forward;
}
LogSearchForm searchForm = (LogSearchForm) form;
if (searchForm.getTimeStart() == null) {
searchForm.setTimeStart(Utility.toTimestamp(new Date(System.currentTimeMillis() - 24 * 3600 * 1000)));
}
ActionMessages errors = searchForm.check();
if (errors.size() > 0) {
context.setAttribute("logs", new ArrayList<AccessLog>());
return handleFailure(mapping, context, errors);
}
LogCriteria criteria = searchForm.toLogCriteria();
if (criteria.getTimeStart() == null) {
criteria.setTimeStart(new Date(System.currentTimeMillis() - 24 * 3600 * 1000));
}
List<ActionLog> logs = PerformanceManager.getInstance().getActionDashboard(criteria, searchForm.getOrderBy());
context.setAttribute("parameters", searchForm.toParameterMap());
context.setAttribute("logs", logs);
return handleSuccess(mapping, context, "success");
}
use of cn.edu.zju.acm.onlinejudge.form.LogSearchForm in project zoj by licheng.
the class ShowDashboardAction method execute.
/**
* ShowRolesAction.
*
* @param mapping
* action mapping
* @param form
* action form
* @param request
* http servlet request
* @param response
* http servlet response
*
* @return action forward instance
*
* @throws Exception
* any errors happened
*/
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, ContextAdapter context) throws Exception {
ActionForward forward = this.checkAdmin(mapping, context);
if (forward != null) {
return forward;
}
LogSearchForm searchForm = (LogSearchForm) form;
if (searchForm.getTimeStart() == null) {
searchForm.setTimeStart(Utility.toTimestamp(new Date(System.currentTimeMillis() - 24 * 3600 * 1000)));
}
ActionMessages errors = searchForm.check();
if (errors.size() > 0) {
context.setAttribute("logs", new ArrayList<AccessLog>());
return this.handleFailure(mapping, context, errors);
}
int page = Utility.parseInt(context.getRequest().getParameter("page"));
if (page < 0) {
page = 1;
}
int logsPerPage = 20;
LogCriteria criteria = searchForm.toLogCriteria();
List<AccessLog> logs = PerformanceManager.getInstance().searchLogs(criteria, (page - 1) * 20, logsPerPage, searchForm.getOrderBy());
context.setAttribute("parameters", searchForm.toParameterMap());
context.setAttribute("page", page);
context.setAttribute("logsPerPage", logsPerPage);
context.setAttribute("logs", logs);
return this.handleSuccess(mapping, context, "success");
}
Aggregations