示例#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);
   }
 }
示例#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;
  }
示例#3
0
  @Override
  public AnswerFormData prepareCreate(AnswerFormData formData) throws ProcessingException {
    if (!ACCESS.check(new CreateAnswerPermission())) {
      throw new VetoException(TEXTS.get("AuthorizationFailed"));
    }

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

    loadQuestion(formData);

    return formData;
  }
示例#4
0
  @Override
  public AnswerFormData store(AnswerFormData formData) throws ProcessingException {
    if (!ACCESS.check(new UpdateAnswerPermission())) {
      throw new VetoException(TEXTS.get("AuthorizationFailed"));
    }

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

    SQL.update("update answers set name = :YourName where answer_id = :AnswerNr", formData);

    SQL.delete("delete from answers_choices where answer_id = :AnswerNr", formData);

    storeAnswerChoice(formData);

    return formData;
  }
示例#5
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;
  }