Package com.tmm.enterprise.microblog.domain

Examples of com.tmm.enterprise.microblog.domain.Question


    Account acc = accountService.loadAccountByUserName(currentUserName);
    Person currentUser = acc.getUserProfile();
    // assigning to
    if (currentUser != null) {
      Contactable contact = contactService.loadContactable(assignedToId);
      Question q = new Question();
      q.setTitle(title);
      q.setDetails(description);
      q.setRaisedBy(currentUser);
      q.setAssignedTo(contact);

      if (tags != null && !"".equals(tags)) {
        String[] listTags = tags.split(",");
        for (String t : listTags) {
          QuestionTag tag = questionTagDao.loadOrCreateTagByName(t.trim());
          q.addTag(tag);
        }
      }

      questionDao.persist(q);
    }
View Full Code Here


  public void createAnswer(long questionId, String answer, String currentUserName) {
    Account acc = accountService.loadAccountByUserName(currentUserName);
    Person currentUser = acc.getUserProfile();
    // assigning to
    if (currentUser != null) {
      Question q = loadQuestion(questionId);
      Answer a = new Answer();
      a.setAssignedTo(currentUser);
      a.setRaisedBy(currentUser);
      a.setDetails(answer);
      a.setQuestion(q);
      q.addAnswer(a);
      answerService.createAnswer(a);
    }
  }
View Full Code Here

    // FIXME - just put in to get web running.. will need more thought on
    // the rendering approach

    JsonObject n = new JsonObject();
    Question q = (Question) renderTarget.getActivity();
    n.addProperty("read", renderTarget.isRead());
    String msg = q.getTitle() == null ? (q.getDetails().length() > 100 ? q.getDetails().substring(0, 100) : q.getDetails()) : (q.getTitle()
        .length() > 100 ? q.getTitle().substring(0, 100) : q.getTitle());
    boolean isOwner = q.getRaisedBy() != null && q.getRaisedBy().getNotifications().contains(renderTarget);
    String from;
    if (isOwner) {
      from = "you asked this question";
    } else {
      from = "asked by " + (q.getRaisedBy() == null ? "Unknown Sender" : q.getRaisedBy().getName());
    }
    n.addProperty("body", msg);
    n.addProperty("from", from);
    n.addProperty("activityId", q.getId());
    n.addProperty("activityType", "Question");

    return n;
  }
View Full Code Here

    JsonObject n = new JsonObject();
    Answer a = (Answer) renderTarget.getActivity();
    n.addProperty("read", renderTarget.isRead());
    String msg;

    Question q = a.getQuestion();
    if (q != null) {
      msg = "Answer added for: "
          + (q.getTitle() == null ? (q.getDetails().length() > 100 ? q.getDetails().substring(0, 100) : q.getDetails()) : (q.getTitle()
              .length() > 100 ? q.getTitle().substring(0, 100) : q.getTitle()));
    } else {
      msg = a.getTitle() == null ? (a.getDetails().length() > 100 ? a.getDetails().substring(0, 100) : a.getDetails())
          : (a.getTitle().length() > 100 ? a.getTitle().substring(0, 100) : a.getTitle());
    }
View Full Code Here

  public ModelAndView detail(@PathVariable("questionId") long questionId, HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    Person currentUser = accountService.getPerson(request);
    notificationService.markAsRead(currentUser, questionId);

    Question q = questionService.loadQuestion(questionId);
    JsonObject question = jsonService.convertToJson(q);
    JsonArray answers = new JsonArray();
    for (Answer a : q.getAnswers()) {
      JsonObject jo = jsonService.convertToJson(a);
      answers.add(jo);
      notificationService.markAsRead(currentUser, a.getId());
    }

    JsonArray tags = new JsonArray();
    for (QuestionTag tag : q.getTags()) {
      tags.add(jsonService.convertToJson(tag));
    }

    List<Activity> similarQuestions = searchService.searchQuestionsByTitle(q.getTitle());
    JsonArray similar = new JsonArray();
    for (Activity ques : similarQuestions) {
      if (!ques.equals(q)) {
        JsonObject obj = new JsonObject();
        obj.addProperty("title", ques.getTitle());
        obj.addProperty("id", ques.getId());
        similar.add(obj);
      }
    }

    Map<String, Object> model = Maps.newHashMap();
    model.put("question", question);
    model.put("answers", answers);
    model.put("similar", similar);
    model.put("tags", tags);
    model.put("numAnswers", q.getAnswers().size());
    jsonService.addUserInfoToModel(accountService.getAccount(request), model);
    List<Contactable> contacts = contactService.loadAllContactables();
    jsonService.addContactsToModel(contacts, model);
    return new ModelAndView("questionDetail", model);
  }
View Full Code Here

TOP

Related Classes of com.tmm.enterprise.microblog.domain.Question

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.