Пример #1
0
  private String postComment(
      String projectId, String entityId, String text, String name, String email) {
    if (projectId == null) throw new RuntimeException("projectId == null");
    if (Str.isBlank(text)) throw new RuntimeException("Comment is empty.");
    Project project = projectDao.getById(projectId);
    AEntity entity = daoService.getById(entityId);
    Comment comment =
        commentDao.postComment(entity, "<nowiki>" + text + "</nowiki>", name, email, true);

    String message = "New comment posted";
    if (!Str.isBlank(name)) message += " by " + name;
    subscriptionService.notifySubscribers(entity, message, project, email);

    project.updateHomepage(entity, true);
    String reference = ((ReferenceSupport) entity).getReference();
    String label = ((LabelSupport) entity).getLabel();
    ProjectEvent event =
        projectEventDao.postEvent(
            project, comment.getAuthorName() + " commented on " + reference + " " + label, entity);
    if (Str.isEmail(email)) subscriptionService.subscribe(email, entity);
    transactionService.commit();

    webApplication.sendToConversationsByProject(project, event);

    return "<h2>Comment posted</h2><p>Thank you for your comment! It will be visible in a few minutes.</p><p>Back to <strong>"
        + KunagiUtl.createExternalRelativeHtmlAnchor(entity)
        + "</strong>.</p>";
  }
Пример #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
 @Override
 public void onConvertIssueToStory(GwtConversation conversation, String issueId) {
   Issue issue = issueDao.getById(issueId);
   Requirement story = requirementDao.postRequirement(issue);
   issue.appendToStatement("Created Story " + story.getReference() + " in Product Backlog.");
   issue.setCloseDate(Date.today());
   sendToClients(conversation, story);
   sendToClients(conversation, issue);
   User currentUser = conversation.getSession().getUser();
   postProjectEvent(
       conversation,
       currentUser.getName()
           + " created "
           + story.getReference()
           + " from "
           + issue.getReferenceAndLabel(),
       issue);
   changeDao.postChange(issue, currentUser, "storyId", null, story.getId());
   changeDao.postChange(story, currentUser, "issueId", null, issue.getId());
   subscriptionService.copySubscribers(issue, story);
   subscriptionService.notifySubscribers(
       story, "Story created from " + issue, conversation.getProject(), null);
 }
Пример #4
0
  private String submitIssue(
      String projectId,
      String label,
      String text,
      String additionalInfo,
      String externalTrackerId,
      String name,
      String email,
      boolean wiki,
      boolean publish,
      String remoteHost) {
    if (projectId == null) throw new RuntimeException("projectId == null");
    if (Str.isBlank(label))
      throw new RuntimeException(
          "Subject is empty, but required. Please write a short title for your issue.");
    if (Str.isBlank(text))
      throw new RuntimeException(
          "Text is empty, but required. Please wirte a short description of your issue.");
    Project project = projectDao.getById(projectId);
    String textAsWiki = wiki ? text : "<nowiki>" + text + "</nowiki>";
    Issue issue =
        issueDao.postIssue(
            project, label, textAsWiki, additionalInfo, externalTrackerId, name, email, publish);
    if (publish) {
      project.updateHomepage(issue);
    }
    String issuer = issue.getIssuer();
    if (Str.isBlank(issuer)) issuer = "anonymous";
    ProjectEvent event =
        projectEventDao.postEvent(
            project, issuer + " submitted " + issue.getReferenceAndLabel(), issue);
    if (Str.isEmail(email)) subscriptionService.subscribe(email, issue);
    transactionService.commit();

    webApplication.sendToConversationsByProject(project, issue);
    webApplication.sendToConversationsByProject(project, event);

    String issueLink =
        publish
            ? KunagiUtl.createExternalRelativeHtmlAnchor(issue)
            : "<code>" + issue.getReference() + "</code>";
    return "<h2>Feedback submitted</h2><p>Thank you for your feedback!</p><p>Your issue is now known as "
        + issueLink
        + " and will be reviewed by our Product Owner.</p>";
  }
Пример #5
0
  private void onRequirementChanged(
      GwtConversation conversation,
      Requirement requirement,
      Map properties,
      Sprint previousRequirementSprint) {
    Project currentProject = conversation.getProject();
    Sprint sprint = requirement.getSprint();
    boolean inCurrentSprint = sprint != null && currentProject.isCurrentSprint(sprint);
    User currentUser = conversation.getSession().getUser();

    if (properties.containsKey("description")
        || properties.containsKey("testDescription")
        || properties.containsKey("qualitysIds")) {
      requirement.setDirty(true);
      conversation.sendToClient(requirement);
    }

    if (properties.containsKey("rejectDate") && requirement.isRejectDateSet()) {
      postProjectEvent(
          conversation,
          currentUser.getName() + " rejected " + requirement.getReferenceAndLabel(),
          requirement);
    }

    if (properties.containsKey("accepted") && requirement.isRejectDateSet()) {
      postProjectEvent(
          conversation,
          currentUser.getName() + " accepted " + requirement.getReferenceAndLabel(),
          requirement);
    }

    if (sprint != previousRequirementSprint) {
      if (properties.containsKey("sprintId")) {
        if (inCurrentSprint) {
          postProjectEvent(
              conversation,
              currentUser.getName()
                  + " pulled "
                  + requirement.getReferenceAndLabel()
                  + " to current sprint",
              requirement);
          subscriptionService.notifySubscribers(
              requirement, "Story pulled to current Sprint", conversation.getProject(), null);
        } else {
          postProjectEvent(
              conversation,
              currentUser.getName()
                  + " kicked "
                  + requirement.getReferenceAndLabel()
                  + " from current sprint",
              requirement);
          subscriptionService.notifySubscribers(
              requirement, "Story kicked from current Sprint", conversation.getProject(), null);
        }
      }
    }

    if (properties.containsKey("estimatedWork")) {
      requirement.initializeEstimationVotes();
      requirement.setDirty(false);
      requirement.setWorkEstimationVotingShowoff(false);
      requirement.setWorkEstimationVotingActive(false);
      conversation.sendToClient(requirement);
    }

    requirement.getProject().getCurrentSprintSnapshot().update();
  }
Пример #6
0
  private void onIssueChanged(GwtConversation conversation, Issue issue, Map properties) {
    User currentUser = conversation.getSession().getUser();

    if (properties.containsKey("closeDate")) {
      if (issue.isClosed()) {
        issue.setCloseDate(Date.today());
        postProjectEvent(
            conversation, currentUser.getName() + " closed " + issue.getReferenceAndLabel(), issue);
        subscriptionService.notifySubscribers(
            issue, "Issue closed", conversation.getProject(), null);
      } else {
        postProjectEvent(
            conversation,
            currentUser.getName() + " reopened " + issue.getReferenceAndLabel(),
            issue);
        subscriptionService.notifySubscribers(
            issue, "Issue reopened", conversation.getProject(), null);
      }
    }

    if (properties.containsKey("ownerId") && issue.isOwnerSet()) {
      if (!issue.isFixed()) {
        postProjectEvent(
            conversation,
            currentUser.getName() + " claimed " + issue.getReferenceAndLabel(),
            issue);
      }

      Release nextRelease = issue.getProject().getNextRelease();
      if (nextRelease != null && issue.isFixReleasesEmpty()) {
        issue.setFixReleases(Collections.singleton(nextRelease));
      }
    }

    if (properties.containsKey("fixDate")) {
      if (issue.isFixed()) {
        postProjectEvent(
            conversation, currentUser.getName() + " fixed " + issue.getReferenceAndLabel(), issue);
      } else {
        postProjectEvent(
            conversation,
            currentUser.getName() + " rejected fix for " + issue.getReferenceAndLabel(),
            issue);
      }
    }

    if (properties.containsKey("urgent")) {
      if (issue.isBug()) {
        Release currentRelease = issue.getProject().getCurrentRelease();
        if (issue.isAffectedReleasesEmpty() && currentRelease != null) {
          issue.setAffectedReleases(Collections.singleton(currentRelease));
        }
      }
    }

    if (properties.containsKey("acceptDate")) {
      if (issue.isIdea() || issue.isBug()) {
        postProjectEvent(
            conversation,
            currentUser.getName() + " accepted " + issue.getReferenceAndLabel(),
            issue);
        subscriptionService.notifySubscribers(
            issue, "Issue accepted", conversation.getProject(), null);
      }
    }

    issue.getProject().updateHomepage(issue, false);
  }