コード例 #1
0
  protected ActionForward performAction(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    String forward = FWD_SUCCESS;

    DynaActionForm dynaForm = (DynaActionForm) form;
    // get selected qaEvents
    String[] selectedIDs = (String[]) dynaForm.get("selectedIDs");

    // get sysUserId from login module
    UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA);
    String sysUserId = String.valueOf(usd.getSystemUserId());

    List qaEvents = new ArrayList();

    for (int i = 0; i < selectedIDs.length; i++) {
      QaEvent qaEvent = new QaEvent();
      qaEvent.setId(selectedIDs[i]);
      qaEvent.setSysUserId(sysUserId);
      qaEvents.add(qaEvent);
    }
    ActionMessages errors = null;
    try {

      QaEventDAO qaEventDAO = new QaEventDAOImpl();
      qaEventDAO.deleteData(qaEvents);
      // System.out.println("Just deleted QaEvent");
      // initialize the form
      dynaForm.initialize(mapping);

    } catch (LIMSRuntimeException lre) {
      // bugzilla 2154
      LogEvent.logError("QaEventDeleteAction", "performAction()", lre.toString());
      request.setAttribute(IActionConstants.REQUEST_FAILED, true);

      errors = new ActionMessages();
      ActionError error = null;
      if (lre.getException() instanceof org.hibernate.StaleObjectStateException) {
        error = new ActionError("errors.OptimisticLockException", null, null);
      } else {
        error = new ActionError("errors.DeleteException", null, null);
      }
      errors.add(ActionMessages.GLOBAL_MESSAGE, error);
      saveErrors(request, errors);
      request.setAttribute(Globals.ERROR_KEY, errors);
      forward = FWD_FAIL;
    }
    if (forward.equals(FWD_FAIL)) return mapping.findForward(forward);

    if ("true".equalsIgnoreCase(request.getParameter("close"))) {
      forward = FWD_CLOSE;
    }

    request.setAttribute("menuDefinition", "QaEventMenuDefinition");
    return mapping.findForward(forward);
  }
コード例 #2
0
  @SuppressWarnings("unchecked")
  private static List<IdValuePair> createSortedQAEvents() {
    List<IdValuePair> qaEvents = new ArrayList<IdValuePair>();
    QaEventDAO qaEventDAO = new QaEventDAOImpl();
    List<QaEvent> qaEventList = qaEventDAO.getAllQaEvents();

    boolean sortList =
        ConfigurationProperties.getInstance()
            .isPropertyValueEqual(Property.QA_SORT_EVENT_LIST, "true");
    if (sortList) {
      Collections.sort(
          qaEventList,
          new Comparator<QaEvent>() {
            @Override
            public int compare(QaEvent o1, QaEvent o2) {
              return o1.getLocalizedName().compareTo(o2.getLocalizedName());
            }
          });
    }

    QaEvent otherQaEvent = null;
    // Put the "Other" type of event at the bottom of the list.
    for (QaEvent event : qaEventList) {
      if (sortList && "Other".equals(event.getQaEventName())) {
        otherQaEvent = event;
      } else {
        qaEvents.add(new IdValuePair(event.getId(), event.getLocalizedName()));
      }
    }

    if (otherQaEvent != null) {
      qaEvents.add(new IdValuePair(otherQaEvent.getId(), otherQaEvent.getLocalizedName()));
    }

    return qaEvents;
  }