Ejemplo n.º 1
0
  public void deleteQuestion(SocialUser loginUser, Long questionId) {
    Assert.notNull(loginUser, "loginUser should be not null!");
    Assert.notNull(questionId, "questionId should be not null!");

    Question question = questionRepository.findOne(questionId);
    question.delete(loginUser);
  }
Ejemplo n.º 2
0
  public Question updateQuestion(SocialUser loginUser, QuestionDto questionDto) {
    Assert.notNull(loginUser, "loginUser should be not null!");
    Assert.notNull(questionDto, "question should be not null!");

    Question question = questionRepository.findOne(questionDto.getQuestionId());

    Set<Tag> tags = tagService.processTags(questionDto.getPlainTags());
    question.update(loginUser, questionDto.getTitle(), questionDto.getContents(), tags);
    return question;
  }
Ejemplo n.º 3
0
 public void createAnswer(SocialUser loginUser, Long questionId, Answer answer) {
   Question question = questionRepository.findOne(questionId);
   answer.writedBy(loginUser);
   answer.answerTo(question);
   Answer savedAnswer = answerRepository.saveAndFlush(answer);
   notificationService.notifyToFacebook(
       loginUser, question, question.findNotificationUser(loginUser));
   if (answer.isConnected()) {
     log.info("firing sendAnswerMessageToFacebook!");
     facebookService.sendToAnswerMessage(loginUser, savedAnswer.getAnswerId());
   }
 }
Ejemplo n.º 4
0
  public void deleteAnswer(SocialUser loginUser, Long questionId, Long answerId) {
    Assert.notNull(loginUser, "loginUser should be not null!");
    Assert.notNull(questionId, "questionId should be not null!");
    Assert.notNull(answerId, "answerId should be not null!");

    Answer answer = answerRepository.findOne(answerId);
    if (!answer.isWritedBy(loginUser)) {
      throw new AccessDeniedException(loginUser + " is not owner!");
    }
    answerRepository.delete(answer);
    Question question = questionRepository.findOne(questionId);
    question.deAnswered();
  }
Ejemplo n.º 5
0
  public Question createQuestion(SocialUser loginUser, QuestionDto questionDto) {
    Assert.notNull(loginUser, "loginUser should be not null!");
    Assert.notNull(questionDto, "question should be not null!");

    Set<Tag> tags = tagService.processTags(questionDto.getPlainTags());

    Question newQuestion =
        new Question(loginUser, questionDto.getTitle(), questionDto.getContents(), tags);
    Question savedQuestion = questionRepository.saveAndFlush(newQuestion);

    if (questionDto.isConnected()) {
      log.info("firing sendMessageToFacebook!");
      facebookService.sendToQuestionMessage(loginUser, savedQuestion.getQuestionId());
    }
    return savedQuestion;
  }
Ejemplo n.º 6
0
 public Question findByQuestionId(Long id) {
   return questionRepository.findOne(id);
 }
Ejemplo n.º 7
0
 public Page<Question> findsQuestion(Pageable pageable) {
   return questionRepository.findAll(QnaSpecifications.equalsIsDelete(false), pageable);
 }
Ejemplo n.º 8
0
 public Page<Question> findsByTag(String name, Pageable pageable) {
   return questionRepository.findsByTag(name, pageable);
 }
Ejemplo n.º 9
0
 public Question showQuestion(Long id) {
   questionRepository.updateShowCount(id);
   return questionRepository.findOne(id);
 }