Exemplo n.º 1
0
 /**
  * @param formData
  * @throws ProcessingException
  */
 private void storeAnswerChoice(AnswerFormData formData) throws ProcessingException {
   if (BooleanUtility.nvl(formData.getMultipleChoices())) {
     if (formData.getChoices().isValueSet() && formData.getChoices().getValue() != null) {
       for (Long choiceId : formData.getChoices().getValue()) {
         SQL.insert(
             " insert into answers_choices (answer_id, choice_id) "
                 + " values (:AnswerNr, :ChoiceId) ",
             formData,
             new NVPair("ChoiceId", choiceId));
       }
     }
   } else {
     SQL.insert(
         " insert into answers_choices (answer_id, choice_id) " + " values (:AnswerNr, :Choice) ",
         formData);
   }
 }
Exemplo n.º 2
0
  @Override
  public AnswerFormData load(AnswerFormData formData) throws ProcessingException {
    if (!ACCESS.check(new ReadAnswerPermission())) {
      throw new VetoException(TEXTS.get("AuthorizationFailed"));
    }

    if (formData.getAnswerNr() == null) {
      throw new ProcessingException("AnswerNr can no be null");
    }

    SQL.selectInto(
        " select question_id, name "
            + " from answers "
            + " where answer_id = :AnswerNr "
            + " into  :QuestionNr, :YourName",
        formData);

    if (formData.getQuestionNr().getValue() == null) {
      throw new ProcessingException("QuestionNr can no be null");
    }

    loadQuestion(formData);
    if (BooleanUtility.nvl(formData.getMultipleChoices())) {
      SQL.selectInto(
          " select choice_id "
              + " from  answers_choices "
              + " where answer_id = :AnswerNr "
              + " into  :Choices",
          formData);
    } else {
      SQL.selectInto(
          " select choice_id "
              + " from  answers_choices "
              + " where answer_id = :AnswerNr "
              + " into  :Choice",
          formData);
    }

    return formData;
  }