Exemplo n.º 1
0
  private void deleteAction(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    Survey survey = (Survey) request.getAttribute(RequestUtils.SURVEY);

    List<Question> questions = (List<Question>) request.getAttribute(RequestUtils.QUESTIONS);
    List<Language> languages = (List<Language>) request.getAttribute(RequestUtils.LANGUAGES);
    List<AnswerSet> answerSets = (List<AnswerSet>) request.getAttribute(RequestUtils.ANSWER_SETS);

    if (!questions.isEmpty()) {
      EditUtils.addEditUsingKey(request, "surveyCantBeDeletedWithQuestionsMessage");
    }

    if (!languages.isEmpty()) {
      EditUtils.addEditUsingKey(request, "surveyCantBeDeletedWithLanguagesMessage");
    }

    if (!answerSets.isEmpty()) {
      EditUtils.addEditUsingKey(request, "surveyCantBeDeletedWithAnswerSetsMessage");
    }

    if (!EditUtils.hasEdits(request)) {
      survey.setLastUpdateUserId(request.getUserPrincipal().getName());
      SurveyDelete.execute(survey);
    }

    if (!EditUtils.hasEdits(request)) {
      RequestUtils.forwardTo(request, response, ControllerConstants.SURVEYS_REDIRECT);
    } else {
      RequestUtils.forwardTo(request, response, ControllerConstants.SURVEY_UPDATE);
    }
  }
Exemplo n.º 2
0
  private void updateAction(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    Survey survey = (Survey) request.getAttribute(RequestUtils.SURVEY);

    survey.setLastUpdateUserId(request.getUserPrincipal().getName());
    survey = SurveyUpdate.execute(survey);

    // If no edits, forward to question.
    if (!EditUtils.hasEdits(request)) {
      request.setAttribute("surveyId", survey.getKey().getId());
      RequestUtils.forwardTo(request, response, ControllerConstants.SURVEY_REDIRECT);
    } else {
      RequestUtils.forwardTo(request, response, ControllerConstants.SURVEY_UPDATE);
    }
  }