Пример #1
0
 private void fillComment(ContextBuilder context, Comment comment) {
   context.put("id", comment.getId());
   context.put("text", wiki2html(comment.getText()));
   context.put("author", comment.getAuthorLabel());
   context.put(
       "date",
       comment
           .getDateAndTime()
           .toString(DateAndTime.FORMAT_WEEKDAY_LONGMONTH_DAY_YEAR_HOUR_MINUTE));
 }
Пример #2
0
 private void onCommentChanged(GwtConversation conversation, Comment comment, Map properties) {
   conversation.getProject().updateHomepage(comment.getParent(), false);
   if (comment.isPublished() && properties.containsKey("published")) {
     subscriptionService.notifySubscribers(
         comment.getParent(),
         "New comment posted by " + comment.getAuthorLabel(),
         conversation.getProject(),
         null);
   }
 }
Пример #3
0
 private Set<Comment> getLatest(Set<Comment> comments) {
   if (comments.size() < 2) return comments;
   Comment latest = null;
   for (Comment comment : comments) {
     if (latest == null || comment.getDateAndTime().isAfter(latest.getDateAndTime()))
       latest = comment;
   }
   assert latest != null;
   return Utl.toSet(latest);
 }
Пример #4
0
 @Override
 public void onRequestForum(GwtConversation conversation, boolean all) {
   Project project = conversation.getProject();
   Set<AEntity> parents = new HashSet<AEntity>();
   for (Subject subject : project.getSubjects()) {
     if (subject.getComments().isEmpty()) parents.add(subject);
   }
   for (Comment comment : project.getLatestComments()) {
     AEntity parent = comment.getParent();
     if (!all
         && !conversation.isAvailableOnClient(parent)
         && comment.getDateAndTime().getPeriodToNow().abs().toDays() > 7) continue;
     conversation.sendToClient(comment);
     parents.add(parent);
   }
   conversation.sendToClient(parents);
 }
Пример #5
0
  @Override
  public void onCreateEntity(GwtConversation conversation, String type, Map properties) {
    String id = (String) properties.get("id");
    if (id == null) throw new NullPointerException("id == null");

    ADao dao = getDaoService().getDaoByName(type);
    AEntity entity = dao.newEntityInstance(id);
    entity.updateProperties(properties);
    User currentUser = conversation.getSession().getUser();
    Project currentProject = conversation.getProject();

    if (entity instanceof Numbered) {
      ((Numbered) entity).updateNumber();
    }

    if (entity instanceof Project) {
      Project project = (Project) entity;
      project.addParticipant(currentUser);
      project.addAdmin(currentUser);
      project.addProductOwner(currentUser);
      project.addScrumMaster(currentUser);
      project.addTeamMember(currentUser);
    }

    if (entity instanceof Comment) {
      Comment comment = (Comment) entity;
      comment.setDateAndTime(DateAndTime.now());
      postProjectEvent(
          conversation,
          comment.getAuthor().getName() + " commented on " + comment.getParent(),
          comment.getParent());
      currentProject.updateHomepage(comment.getParent(), true);
    }

    if (entity instanceof ChatMessage) {
      ChatMessage chatMessage = (ChatMessage) entity;
      chatMessage.setDateAndTime(DateAndTime.now());
    }

    if (entity instanceof Impediment) {
      Impediment impediment = (Impediment) entity;
      impediment.setDate(Date.today());
    }

    if (entity instanceof Issue) {
      Issue issue = (Issue) entity;
      issue.setDate(DateAndTime.now());
      issue.setCreator(currentUser);
    }

    if (entity instanceof Task) {
      Task task = (Task) entity;
      Requirement requirement = task.getRequirement();
      requirement.setRejectDate(null);
      requirement.setClosed(false);
      sendToClients(conversation, requirement);
    }

    if (entity instanceof BlogEntry) {
      BlogEntry blogEntry = (BlogEntry) entity;
      blogEntry.setDateAndTime(DateAndTime.now());
      blogEntry.addAuthor(currentUser);
    }

    if (entity instanceof Change) {
      Change change = (Change) entity;
      change.setDateAndTime(DateAndTime.now());
      change.setUser(currentUser);
    }

    if (!(entity instanceof Transient)) dao.saveEntity(entity);

    sendToClients(conversation, entity);

    if (entity instanceof Requirement) {
      Requirement requirement = (Requirement) entity;
      Requirement epic = requirement.getEpic();
      String value = null;
      if (epic != null) {
        value = epic.getReferenceAndLabel();
        Change change =
            changeDao.postChange(epic, currentUser, "@split", null, requirement.getReference());
        conversation.sendToClient(change);
      }
      Change change = changeDao.postChange(requirement, currentUser, "@created", null, value);
      conversation.sendToClient(change);
    }

    if (entity instanceof Task
        || entity instanceof Wikipage
        || entity instanceof Risk
        || entity instanceof Impediment
        || entity instanceof Issue
        || entity instanceof BlogEntry) {
      Change change = changeDao.postChange(entity, currentUser, "@created", null, null);
      conversation.sendToClient(change);
    }

    if (currentUser != null && currentProject != null) {
      ProjectUserConfig config = currentProject.getUserConfig(currentUser);
      config.touch();
      sendToClients(conversation, config);
    }
  }