コード例 #1
0
ファイル: AnswerProcessService.java プロジェクト: jmini/mcqs
  @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;
  }
コード例 #2
0
ファイル: AnswerProcessService.java プロジェクト: jmini/mcqs
  @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;
  }