コード例 #1
0
 /**
  * Update Question Name.
  *
  * @param questionId
  * @param questionName
  */
 public void updateQuestionName(final Long questionId, final String questionName) {
   final Question question = getQuestionDao().retrieveQuestionById(questionId);
   if (question != null) {
     question.setQuestion(questionName);
     getQuestionDao().saveOrUpdate(question);
   }
 }
コード例 #2
0
 /**
  * Update Question.
  *
  * @param unitQuestionPoll
  * @throws EnMeExpcetion Exception
  */
 public void updateQuestion(final QuestionBean unitQuestionPoll) throws EnMeExpcetion {
   final Question question = getQuestionDao().retrieveQuestionById(unitQuestionPoll.getId());
   if (question == null) {
     throw new EnMeExpcetion("question not found");
   } else {
     question.setQuestion(unitQuestionPoll.getQuestionName());
     getQuestionDao().saveOrUpdate(question);
   }
 }
コード例 #3
0
 /**
  * Create {@link QuestionAnswer} from an String array
  *
  * @param answers
  * @param question
  */
 public void createQuestionAnswers(final String[] answers, final Question question) {
   for (int row = 0; row < answers.length; row++) {
     final String answersText = answers[row];
     Assert.assertNotNull(answersText);
     if (!answersText.isEmpty()) {
       log.debug("creatong answer=>" + question.getQidKey());
       log.debug("creatong answer=>" + answersText.trim());
       createAnswers(question, answersText.trim());
     }
   }
 }
コード例 #4
0
  /**
   * Load all questions.
   *
   * @return List of {@link QuestionBean}
   * @throws EnMeExpcetion exception
   */
  public List<QuestionBean> loadAllQuestions() throws EnMeExpcetion {
    final List<QuestionBean> listQuestionBean = new LinkedList<QuestionBean>();
    try {
      final List<Question> questionsList = getQuestionDao().loadAllQuestions();
      if (questionsList.size() > 0) {

        for (Question questions : questionsList) {
          final QuestionBean q = new QuestionBean();
          q.setId(Long.valueOf(questions.getQid().toString()));
          q.setQuestionName(questions.getQuestion());
          listQuestionBean.add(q);
        }
      }
    } catch (HibernateException e) {
      throw new EnMeExpcetion(e);
    } catch (Exception e) {
      throw new EnMeExpcetion(e);
    }
    return listQuestionBean;
  }
コード例 #5
0
 /**
  * Create Question.
  *
  * @param questionBean {@link QuestionBean}.
  * @param account {@link UserAccount}
  * @param questionPattern {@link QuestionPattern}
  * @throws EnMeExpcetion exception
  */
 public Question createQuestion(
     final QuestionBean questionBean,
     final UserAccount account,
     final QuestionPattern questionPattern)
     throws EnMeExpcetion {
   final Question question = new Question();
   try {
     question.setQuestion(questionBean.getQuestionName());
     question.setSlugQuestion(RestFullUtil.slugify(questionBean.getQuestionName()));
     question.setAccountQuestion(account.getAccount());
     question.setQidKey(MD5Utils.md5(RandomStringUtils.randomAlphanumeric(500)));
     question.setSharedQuestion(false);
     getQuestionDao().saveOrUpdate(question);
     //                for (final QuestionAnswerBean answerBean : questionBean.getListAnswers()) {
     //                    this.createQuestionAnswer(answerBean, question);
     //                }
   } catch (Exception e) {
     log.error(e);
     throw new EnMeExpcetion(e);
   }
   return question;
 }
コード例 #6
0
ファイル: TestQuestionDao.java プロジェクト: gcobr/encuestame
 /** Test create question. */
 @Test
 public void testCreateQuestion() {
   final Question question = createQuestion("Why encuestame is better than polldady?", this.user);
   final Question retrieveQuestion = getQuestionDaoImp().retrieveQuestionById(question.getQid());
   assertEquals("Questions should be equals", question.getQid(), retrieveQuestion.getQid());
 }