01: package com.technoetic.xplanner.actions;
02:
03: import com.technoetic.xplanner.db.AggregateTimesheetQuery;
04: import com.technoetic.xplanner.forms.AggregateTimesheetForm;
05: import net.sf.hibernate.Session;
06: import org.apache.log4j.Logger;
07: import org.apache.struts.action.ActionForm;
08: import org.apache.struts.action.ActionForward;
09: import org.apache.struts.action.ActionMapping;
10:
11: import javax.servlet.ServletException;
12: import javax.servlet.http.HttpServletRequest;
13: import javax.servlet.http.HttpServletResponse;
14: import java.text.SimpleDateFormat;
15:
16: public class ViewAggregateTimesheetAction extends AbstractAction {
17: private static final Logger log = Logger
18: .getLogger("ViewAggregateTimesheetAction");
19:
20: protected ActionForward doExecute(ActionMapping actionMapping,
21: ActionForm actionForm, HttpServletRequest request,
22: HttpServletResponse reply) throws Exception {
23: AggregateTimesheetForm form = (AggregateTimesheetForm) actionForm;
24: try {
25: Session session = getSession(request);
26: try {
27:
28: form
29: .setAllPeople(session
30: .find("from people in class com.technoetic.xplanner.domain.Person "
31: + "where people.hidden = false order by name"));
32: AggregateTimesheetQuery query = new AggregateTimesheetQuery(
33: getSession(request));
34: query.setPersonIds(form.getSelectedPeople());
35: query.setStartDate(form.getStartDate());
36: query.setEndDate(form.getEndDate());
37: form.setTimesheet(query.getTimesheet());
38: if (form.getDateFormat() == null) {
39: String format = getResources(request).getMessage(
40: "format.date");
41: form.setDateFormat(new SimpleDateFormat(format));
42: }
43: return actionMapping
44: .findForward("view/aggregateTimesheet");
45: } catch (Exception ex) {
46: session.connection().rollback();
47: log.error("error", ex);
48: throw new ServletException(ex);
49: }
50: } catch (ServletException ex) {
51: throw ex;
52: } catch (Exception ex) {
53: log.error("error", ex);
54: throw new ServletException(ex);
55: }
56: }
57: }
|