@Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    // Pre-process the request (from the super class)
    preprocess(mapping, request, response, true, true);

    int horseId =
        StringUtils.str2int(request.getParameter(ATTR_HORSE_ID), Constants.INVALID_INT_ID);
    request.setAttribute(ATTR_HORSE_ID, horseId);
    request.setAttribute(PARAM_ASSIGNID, request.getParameter(PARAM_ASSIGNID));
    request.setAttribute(ATTR_ACTION, getActionPath(request));
    int preVersionId = StringUtils.str2int(request.getParameter(PARAM_CONTENT_VERSION_ID));
    if (preVersionId <= 0) {
      ContentVersion cntVer = surveyService.getLastestContentVersionByHorseId(horseId);
      if (cntVer != null) {
        preVersionId = cntVer.getId();
      }
    }
    request.setAttribute(PARAM_CONTENT_VERSION_ID, preVersionId);

    return mapping.findForward(FWD_SUCCESS);
  }
Esempio n. 2
0
  /**
   * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws ServletException if a servlet-specific error occurs
   * @throws IOException if an I/O error occurs
   */
  @Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    prehandle(mapping, request);
    int horseId = StringUtils.str2int(request.getParameter(PARAM_HORSE_ID), -1);
    int questionId = StringUtils.str2int(request.getParameter(PARAM_QUESTION_ID), -1);
    log.info(
        "Get scorecard answer - [horseId="
            + horseId
            + ", questionId="
            + questionId
            + ", version="
            + version
            + "]");

    ScorecardInfo scorecard = getScorecardInfo(horseId);

    if (scorecard != null) {
      JSONObject jsonObj = ScorecardAnswerJsonUtils.toJson(scorecard, questionId);
      response.setContentType("text/html;charset=UTF-8");
      PrintWriter out = response.getWriter();
      try {
        out.write(jsonObj.toJSONString());
      } finally {
        out.close();
      }
    }
    return null;
  }
Esempio n. 3
0
  /**
   * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws ServletException if a servlet-specific error occurs
   * @throws IOException if an I/O error occurs
   */
  @Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    prehandle(mapping, request);
    int horseId = StringUtils.str2int(request.getParameter(PARAM_HORSE_ID), -1);
    String baseDir = request.getParameter(PARAM_BASE_DIR);
    String cacheDir = request.getParameter(PARAM_CACHE_DIR);
    Boolean genericLabel = StringUtils.str2int(request.getParameter("genericLabel"), 0) == 1;

    log.info(
        "Get data summary - [horseId="
            + horseId
            + ", version="
            + version
            + " baseDir="
            + baseDir
            + ", cacheDir="
            + cacheDir
            + "] - "
            + genericLabel);

    JSONObject jsonObj = DataSummaryJsonUtils.toJson(horseId, baseDir, cacheDir, genericLabel);
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
      out.write(jsonObj.toJSONString());
    } finally {
      out.close();
    }
    return null;
  }
Esempio n. 4
0
 private void fillFilters(HttpServletRequest request, ActionData actionData) {
   fillFilter(actionData.getTargetFilter(), request.getParameter("targetFilter").split(","));
   fillFilter(actionData.getProductFilter(), request.getParameter("productFilter").split(","));
   fillFilter(actionData.getRoleFilter(), request.getParameter("roleFilter").split(","));
   fillFilter(actionData.getTeamFilter(), request.getParameter("teamFilter").split(","));
   actionData.setHasCaseFilter(StringUtils.str2int(request.getParameter("hasCaseFilter")));
   actionData.setStatusFilter(StringUtils.str2int(request.getParameter("statusFilter")));
 }