01: package com.technoetic.xplanner.actions;
02:
03: import com.technoetic.xplanner.db.PersonTimesheetQuery;
04: import com.technoetic.xplanner.forms.PersonTimesheetForm;
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 ViewTimesheetAction extends AbstractAction {
17: private static final Logger log = Logger
18: .getLogger("ViewTimesheetAction");
19:
20: protected ActionForward doExecute(ActionMapping actionMapping,
21: ActionForm actionForm, HttpServletRequest request,
22: HttpServletResponse reply) throws Exception {
23: PersonTimesheetForm form = (PersonTimesheetForm) actionForm;
24: try {
25: Session session = getSession(request);
26: try {
27: PersonTimesheetQuery query = new PersonTimesheetQuery(
28: getSession(request));
29: query.setPersonId(form.getPersonId());
30: query.setStartDate(form.getStartDate());
31: query.setEndDate(form.getEndDate());
32: form.setTimesheet(query.getTimesheet());
33: if (form.getDateFormat() == null) {
34: String format = getResources(request).getMessage(
35: "format.date");
36: form.setDateFormat(new SimpleDateFormat(format));
37: }
38:
39: return actionMapping.findForward("view/timesheet");
40: } catch (Exception ex) {
41: session.connection().rollback();
42: log.error("error", ex);
43: throw new ServletException(ex);
44: }
45: } catch (ServletException ex) {
46: throw ex;
47: } catch (Exception ex) {
48: log.error("error", ex);
49: throw new ServletException(ex);
50: }
51: }
52: }
|