/**
   * Process the specified HTTP request, and create the corresponding HTTP response (or forward to
   * another web component that will create it). Return an <code>ActionForward</code> instance
   * describing where and how control should be forwarded, or <code>null</code> if the response has
   * already been completed.
   *
   * @param mapping The ActionMapping used to select this instance
   * @param form The optional ActionForm bean for this request (if any)
   * @param request The HTTP request we are processing
   * @param response The HTTP response we are creating
   * @exception Exception if business logic throws an exception
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    // Extract attributes we will need
    MessageResources messages = getResources(request);

    // save errors
    ActionMessages errors = new ActionMessages();

    // START check for login (security)
    if (!SecurityService.getInstance().checkForLogin(request.getSession(false))) {
      return (mapping.findForward("welcome"));
    }
    // END check for login (security)

    // START get id of current quote from either request, attribute, or cookie
    // id of quote from request
    String quoteId = null;
    quoteId = request.getParameter("quoteViewId");

    // check attribute in request
    if (quoteId == null) {
      quoteId = (String) request.getAttribute("quoteViewId");
    }

    // id of quote from cookie
    if (quoteId == null) {
      quoteId = StandardCode.getInstance().getCookie("quoteViewId", request.getCookies());
    }

    Integer id = Integer.valueOf(quoteId);

    // END get id of current quote from either request, attribute, or cookie

    // get quote to and then its sources
    Quote1 q = QuoteService.getInstance().getSingleQuote(id);

    // this quotes sources
    Set sources = q.getSourceDocs();

    DynaValidatorForm qvgatd1 = (DynaValidatorForm) form;

    qvgatd1.set("sources", (SourceDoc[]) sources.toArray(new SourceDoc[0]));

    // place quote into attribute for dispaly
    request.setAttribute("quote", q);

    // Forward control to the specified success URI
    return (mapping.findForward("Success"));
  }
  /**
   * Process the specified HTTP request, and create the corresponding HTTP response (or forward to
   * another web component that will create it). Return an <code>ActionForward</code> instance
   * describing where and how control should be forwarded, or <code>null</code> if the response has
   * already been completed.
   *
   * @param mapping The ActionMapping used to select this instance
   * @param form The optional ActionForm bean for this request (if any)
   * @param request The HTTP request we are processing
   * @param response The HTTP response we are creating
   * @exception Exception if business logic throws an exception
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    // Extract attributes we will need
    MessageResources messages = getResources(request);

    // save errors
    ActionMessages errors = new ActionMessages();

    // START check for login (security)
    if (!SecurityService.getInstance().checkForLogin(request.getSession(false))) {
      return (mapping.findForward("welcome"));
    }
    // END check for login (security)

    // PRIVS check that hrAdmin user is viewing this page
    if (!StandardCode.getInstance()
        .checkPrivStringArray(
            (String[]) request.getSession(false).getAttribute("userPrivs"), "hrAdmin")) {
      return (mapping.findForward("accessDenied"));
    } // END PRIVS check that hrAdmin user is viewing this page

    // get the employee to edit from the request
    String hrAdminUserId = request.getParameter("hrAdminUserId");
    User u = UserService.getInstance().getSingleUser(Integer.valueOf(hrAdminUserId));

    // get new performance review values
    DynaValidatorForm ha = (DynaValidatorForm) form;
    String dueDate = (String) ha.get("dueDate");
    String actualDate = (String) ha.get("actualDate");
    String signedDate = (String) ha.get("signedDate");
    PerformanceReview performanceReviewNew = (PerformanceReview) ha.get("performanceReviewNew");

    if (dueDate.length() > 0) // if entered
    performanceReviewNew.setDueDate(DateService.getInstance().convertDate(dueDate).getTime());
    if (actualDate.length() > 0) // if entered
    performanceReviewNew.setActualDate(DateService.getInstance().convertDate(actualDate).getTime());
    if (signedDate.length() > 0) // if entered
    performanceReviewNew.setSignedDate(DateService.getInstance().convertDate(signedDate).getTime());

    // add new performanceReview to the db
    UserService.getInstance().addPerformanceReview(performanceReviewNew, u);

    // Forward control to the specified success URI
    return (mapping.findForward("Success"));
  }
  /**
   * Process the specified HTTP request, and create the corresponding HTTP response (or forward to
   * another web component that will create it). Return an <code>ActionForward</code> instance
   * describing where and how control should be forwarded, or <code>null</code> if the response has
   * already been completed.
   *
   * @param mapping The ActionMapping used to select this instance
   * @param form The optional ActionForm bean for this request (if any)
   * @param request The HTTP request we are processing
   * @param response The HTTP response we are creating
   * @exception Exception if business logic throws an exception
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    // Extract attributes we will need
    MessageResources messages = getResources(request);

    // save errors
    ActionMessages errors = new ActionMessages();

    // START check for login (security)
    if (!SecurityService.getInstance().checkForLogin(request.getSession(false))) {
      return (mapping.findForward("welcome"));
    }
    // END check for login (security)

    // values for adding the related contact
    DynaValidatorForm qae2 = (DynaValidatorForm) form;

    // from wizard add clientContact
    String contactId = (String) request.getAttribute("clientContactViewId");
    if (contactId == null) {
      contactId = (String) (qae2.get("contact"));
    }

    // need the project and contact to build the link between contact and project
    String projectId = StandardCode.getInstance().getCookie("projectAddId", request.getCookies());
    Project p = ProjectService.getInstance().getSingleProject(Integer.valueOf(projectId));

    ClientContact cc =
        ClientService.getInstance().getSingleClientContact(Integer.valueOf(contactId));

    // insert into db, building link between contact and project
    ProjectService.getInstance().linkProjectClientContact(p, cc);

    // Forward control to the specified success URI
    return (mapping.findForward("Success"));
  }