Example #1
0
  public ActionForward editEscalation(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    ActionErrors errors = new ActionErrors();
    ActionForward forward = new ActionForward(); // return value
    boolean editSuccess = false;
    String flag = null;

    try {
      HttpSession session = request.getSession(false);
      UserDetailsDTO userDetails = (UserDetailsDTO) session.getAttribute("USER_INFO");

      EscalationForm escalationForm = (EscalationForm) form;
      String requestNo = escalationForm.getWorkflow_escalation_id();
      System.out.println("EDIT ACTION------------" + requestNo);

      if (escalationForm != null) {
        String userName = userDetails.getUserLoginId();
        escalationForm.setModified_by(userName);

        EscalationDTO escalationDTO = new EscalationDTO();
        EscalationDao escalationDaoImpl = new EscalationDaoImpl();
        BeanUtils.copyProperties(escalationDTO, escalationForm);

        editSuccess = escalationDaoImpl.editEscalation(escalationDTO, requestNo);

        if (editSuccess == true) {
          flag = "editsuccessful";
          request.setAttribute("editSuccess", flag);
          request.setAttribute("escalationID", requestNo);
          request.setAttribute("escalationType", escalationDTO.getEscalation_type());
        }
      }
    } catch (Exception exp) {
      errors.add("editCategory", new ActionError(""));
      saveErrors(request, errors);
      return mapping.findForward("InitEditEscalation");
    }
    if (!errors.isEmpty()) {
      saveErrors(request, errors);
      // Forward control to the appropriate 'failure' URI (change name as desired)
      forward = mapping.findForward("EditEscalation");
    } else {
      // Forward control to the appropriate 'success' URI (change name as desired)
      errors.add("editCategory", new ActionError("message.success"));
      saveErrors(request, errors);
      forward = mapping.findForward("EditEscalationSuccess");
      request.setAttribute("errorFlag", "1");
    }
    // Finish with
    return (forward);
  }
Example #2
0
  public ActionForward createEscalation(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    ActionErrors errors = new ActionErrors();
    ActionForward forward = new ActionForward();

    try {
      HttpSession session = request.getSession(false);
      UserDetailsDTO userDetails = (UserDetailsDTO) session.getAttribute("USER_INFO");

      EscalationForm escalationForm = (EscalationForm) form;
      EscalationDTO escalationDTO = new EscalationDTO();
      EscalationDao escalationDaoImpl = new EscalationDaoImpl();

      if (escalationForm != null) {
        logger.info("Form is not null");
        logger.debug("Form is not null");

        String userName = userDetails.getUserLoginId();
        escalationForm.setCreated_by(userName);
        escalationForm.setModified_by(userName);
        List escalation_level_list = escalationForm.getEscalation_level_list();

        BeanUtils.copyProperties(escalationDTO, escalationForm);

        int flag = escalationDaoImpl.createEscalation(escalationDTO);

        if (flag == 1) {
          //					errors.add(null, new ActionError("create.escalation.success"));
          //					saveErrors(request, errors);
          request.setAttribute(
              "RESET",
              "TRUE"); // used to identify from the initCreate Action that the action is called
          // after successfull creation.
          errors.add(null, new ActionError("create.escalation.success"));
          saveErrors(request, errors);
        } else if (flag == 2) {
          //					errors.add(null, new ActionError("create.escalation.existing"));
          //					saveErrors(request, errors);
          request.setAttribute(
              "RESET",
              "TRUE"); // used to identify from the initCreate Action that the action is called
          // after successfull creation.
          errors.add(null, new ActionError("create.escalation.existing"));
          saveErrors(request, errors);
        }
      }

    } catch (BusinessException exp) {
      exp.printStackTrace();
      errors.add("createEscalation", new ActionError(exp.getBusinessCode()));
      saveErrors(request, errors);
      return mapping.findForward("InitCreateEscalation");
    } catch (ApplicationException exp) {
      exp.printStackTrace();
      errors.add("createEscalation", new ActionError(exp.getBusinessCode()));
      saveErrors(request, errors);
      return mapping.findForward("InitCreateEscalation");
    } catch (Exception exp) {
      exp.printStackTrace();
      errors.add("createEscalation", new ActionError(""));
      saveErrors(request, errors);
      return mapping.findForward("InitCreateEscalation");
    }

    forward = mapping.findForward("CreateEscalationSuccess");
    return (forward);
  }