Пример #1
0
  @Override
  public void delete(Long answerNr) throws ProcessingException {
    if (!ACCESS.check(new DeleteAnswerPermission())) {
      throw new VetoException(TEXTS.get("AuthorizationFailed"));
    }

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

    SQL.delete(
        "delete from answers_choices where answer_id = :AnswerNr",
        new NVPair("AnswerNr", answerNr));
    SQL.delete("delete from answers where answer_id = :AnswerNr", new NVPair("AnswerNr", answerNr));
  }
 /** This method is called on server side to load lookup rows. */
 @ConfigOperation
 @Order(10)
 protected List<ILookupRow<T>> execLoadLookupRows(
     String originalSql, String preprocessedSql, ILookupCall<T> call) throws ProcessingException {
   Object[][] data = SQL.selectLimited(preprocessedSql, call.getMaxRowCount(), call);
   if (getConfiguredSortColumn() >= 0) {
     sortData(data, getConfiguredSortColumn());
   }
   try {
     Class<?> genericsParameterClass = Object.class;
     try {
       genericsParameterClass =
           TypeCastUtility.getGenericsParameterClass(getClass(), ILookupService.class);
     } catch (IllegalArgumentException e) {
       LOG.warn(
           "Unable to calculate type parameters for lookup service '"
               + getClass().getName()
               + "'. No key type validation will be performed.");
     }
     return createLookupRowArray(data, call, genericsParameterClass);
   } catch (IllegalArgumentException e) {
     throw new ProcessingException(
         "Unable to load lookup rows for lookup service '" + getClass().getName() + "'.", e);
   }
 }
Пример #3
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);
   }
 }
Пример #4
0
 /**
  * @param formData
  * @throws ProcessingException
  */
 private void loadQuestion(AnswerFormData formData) throws ProcessingException {
   SQL.selectInto(
       " select question_text, multiple_choices "
           + " from  questions "
           + " where question_id = :QuestionNr "
           + " into  :QuestionText, :MultipleChoices",
       formData);
 }
Пример #5
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;
  }
Пример #6
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;
  }
Пример #7
0
 /** This method is called on server side to load lookup rows. */
 @ConfigOperation
 @Order(10)
 protected LookupRow[] execLoadLookupRows(
     String originalSql, String preprocessedSql, LookupCall call) throws ProcessingException {
   Object[][] data = SQL.selectLimited(preprocessedSql, call.getMaxRowCount(), call);
   if (getConfiguredSortColumn() >= 0) {
     sortData(data, getConfiguredSortColumn());
   }
   return createLookupRowArray(data, call);
 }
Пример #8
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;
  }