Esempio 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);
   }
 }
Esempio n. 2
0
  @Override
  public AnswerFormData create(AnswerFormData formData) throws ProcessingException {
    if (!ACCESS.check(new CreateAnswerPermission())) {
      throw new VetoException(TEXTS.get("AuthorizationFailed"));
    }

    SQL.insert(
        " insert into answers (name, question_id) " + " values (:YourName, :QuestionNr) ",
        formData);

    SQL.selectInto(" values IDENTITY_VAL_LOCAL() " + " into  :AnswerNr", formData);

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

    storeAnswerChoice(formData);
    return formData;
  }