private void onTaskChanged(GwtConversation conversation, Task task, Map properties) {
   // update sprint day snapshot after change
   conversation
       .getProject()
       .getCurrentSprint()
       .getDaySnapshot(Date.today())
       .updateWithCurrentSprint();
   Requirement requirement = task.getRequirement();
   if (requirement.isInCurrentSprint()) {
     User currentUser = conversation.getSession().getUser();
     if (task.isClosed() && properties.containsKey("remainingWork")) {
       String event = currentUser.getName() + " closed " + task.getReferenceAndLabel();
       if (requirement.isTasksClosed()) {
         event += ", all tasks closed in " + requirement.getReferenceAndLabel();
       }
       postProjectEvent(conversation, event, task);
     } else if (task.isOwnerSet() && properties.containsKey("ownerId")) {
       postProjectEvent(
           conversation, currentUser.getName() + " claimed " + task.getReferenceAndLabel(), task);
     }
     if (!task.isOwnerSet() && properties.containsKey("ownerId")) {
       postProjectEvent(
           conversation,
           currentUser.getName() + " unclaimed " + task.getReferenceAndLabel(),
           task);
     }
     if (!task.isClosed() && requirement.isRejectDateSet()) {
       requirement.setRejectDate(null);
       sendToClients(conversation, requirement);
     }
   }
 }
 @Override
 public void onPublishRelease(GwtConversation conversation, String releaseId) {
   Project project = conversation.getProject();
   Release release = (Release) getDaoService().getEntityById(releaseId);
   if (!release.isProject(project)) throw new PermissionDeniedException();
   release.release(project, conversation.getSession().getUser(), webApplication);
 }
 @Override
 public void onRequestReleaseIssues(GwtConversation conversation, String releaseId) {
   assertProjectSelected(conversation);
   Project project = conversation.getProject();
   Release release = releaseDao.getById(releaseId);
   if (!release.isProject(project)) throw new PermissionDeniedException();
   conversation.sendToClient(release.getIssues());
 }
 @Override
 public void onSearch(GwtConversation conversation, String text) {
   Project project = conversation.getProject();
   if (project == null) return;
   List<AEntity> foundEntities = project.search(text);
   log.debug("Found entities for search", "\"" + text + "\"", "->", foundEntities);
   conversation.sendToClient(foundEntities);
 }
 @Override
 public void onRequestRequirementEstimationVotes(
     GwtConversation conversation, String requirementId) {
   assertProjectSelected(conversation);
   Project project = conversation.getProject();
   Requirement requirement = requirementDao.getById(requirementId);
   if (!requirement.isProject(project)) throw new PermissionDeniedException();
   conversation.sendToClient(requirement.getEstimationVotes());
 }
 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);
   }
 }
 @Override
 public void onCloseProject(GwtConversation conversation) {
   Project project = conversation.getProject();
   if (project != null && conversation.getSession().getGwtConversations().size() < 2) {
     ProjectUserConfig config = project.getUserConfig(conversation.getSession().getUser());
     config.reset();
     sendToClients(conversation, config);
   }
   conversation.clearRemoteEntities();
   conversation.setProject(null);
 }
  private void postProjectEvent(GwtConversation conversation, String message, AEntity subject) {
    assertProjectSelected(conversation);
    Project project = conversation.getProject();
    webApplication.postProjectEvent(project, message, subject);

    try {
      sendProjectEventEmails(
          message, subject, project, conversation.getSession().getUser().getEmail());
    } catch (Throwable ex) {
      log.error("Sending project event notification emails failed.", ex);
    }
  }
 @Override
 public void onRequestHistory(GwtConversation conversation) {
   assertProjectSelected(conversation);
   Project project = conversation.getProject();
   Set<SprintReport> reports = project.getSprintReports();
   Set<AEntity> entities = new HashSet<AEntity>();
   entities.addAll(reports);
   for (SprintReport report : reports) {
     entities.addAll(getAssociatedEntities(report));
   }
   conversation.sendToClient(entities);
 }
Exemple #10
0
  @Override
  public void onRequestEntityByReference(GwtConversation conversation, String reference) {
    assertProjectSelected(conversation);
    Project project = conversation.getProject();

    AEntity entity = project.getEntityByReference(reference);
    if (entity == null) {
      log.info("Requested entity not found:", reference);
    } else {
      conversation.sendToClient(entity);
      conversation.sendToClient(getAssociatedEntities(entity));
    }
  }
Exemple #11
0
 @Override
 public DataTransferObject startConversation(int conversationNumber) {
   log.debug("startConversation");
   WebSession session = (WebSession) getSession();
   GwtConversation conversation = session.getGwtConversation(-1);
   ilarkesto.di.Context context = ilarkesto.di.Context.get();
   context.setName("gwt-srv:startSession");
   context.bindCurrentThread();
   try {
     onStartConversation(conversation);
     onServiceMethodExecuted(context);
   } catch (Throwable t) {
     handleServiceMethodException(conversation.getNumber(), "startSession", t);
   }
   return (scrum.client.DataTransferObject) conversation.popNextData();
 }
Exemple #12
0
  @Override
  public void onRequestEntity(GwtConversation conversation, String entityId) {
    assertProjectSelected(conversation);

    try {
      AEntity entity = getDaoService().getById(entityId);
      if (!Auth.isVisible(entity, conversation.getSession().getUser()))
        throw new PermissionDeniedException();
      // TODO check if entity is from project
      conversation.sendToClient(entity);
      conversation.sendToClient(getAssociatedEntities(entity));
    } catch (EntityDoesNotExistException ex) {
      log.info("Requested entity not found:", entityId);
      // nop
    }
  }
Exemple #13
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);
 }
Exemple #14
0
 private void postChangeIfChanged(
     GwtConversation conversation, AEntity entity, Map properties, User user, String property) {
   if (properties.containsKey(property)) {
     Object oldValue = Reflect.getProperty(entity, property);
     Object newValue = properties.get(property);
     Change change = changeDao.postChange(entity, user, property, oldValue, newValue);
     conversation.sendToClient(change);
   }
 }
Exemple #15
0
  @Override
  public void onPullStoryToSprint(GwtConversation conversation, String storyId) {
    assertProjectSelected(conversation);
    Requirement story = requirementDao.getById(storyId);
    Project project = conversation.getProject();
    Sprint sprint = project.getCurrentSprint();
    User currentUser = conversation.getSession().getUser();

    sprint.pullRequirement(story, currentUser);

    postProjectEvent(
        conversation,
        currentUser.getName() + " pulled " + story.getReferenceAndLabel() + " to current sprint",
        story);

    sendToClients(conversation, sprint);
    sendToClients(conversation, story);
    sendToClients(conversation, story.getTasksInSprint());
  }
Exemple #16
0
 private void onTaskDeleted(GwtConversation conversation, Task task) {
   // update sprint day snapshot after delete
   conversation
       .getProject()
       .getCurrentSprint()
       .getDaySnapshot(Date.today())
       .updateWithCurrentSprint();
   Requirement requirement = task.getRequirement();
   if (requirement.isInCurrentSprint()) {
     if (task.isOwnerSet()) {
       postProjectEvent(
           conversation,
           conversation.getSession().getUser().getName()
               + " deleted "
               + task.getReferenceAndLabel(),
           task);
     }
   }
 }
Exemple #17
0
  @Override
  public void onChangePassword(
      GwtConversation conversation, String oldPassword, String newPassword) {
    User user = conversation.getSession().getUser();
    if (!user.matchesPassword(oldPassword)) throw new WrongPasswordException();

    user.setPassword(newPassword);

    log.info("password changed by", user);
  }
Exemple #18
0
 @Override
 public void onResetPassword(GwtConversation conversation, String userId) {
   if (!conversation.getSession().getUser().isAdmin()) throw new PermissionDeniedException();
   User user = userDao.getById(userId);
   if (webApplication.getSystemConfig().isSmtpServerSet() && user.isEmailSet()) {
     user.triggerPasswordReset();
   } else {
     user.setPassword(webApplication.getSystemConfig().getDefaultUserPassword());
   }
 }
Exemple #19
0
 @Override
 public void onActivateRequirementEstimationVoting(
     GwtConversation conversation, String requirementId) {
   Requirement requirement = requirementDao.getById(requirementId);
   if (requirement == null || !requirement.isProject(conversation.getProject()))
     throw new PermissionDeniedException();
   requirement.initializeEstimationVotes();
   requirement.setWorkEstimationVotingActive(true);
   requirement.setWorkEstimationVotingShowoff(false);
   sendToClients(conversation, requirement);
   sendToClients(conversation, requirement.getEstimationVotes());
 }
Exemple #20
0
 @Override
 public void onSwitchToNextSprint(GwtConversation conversation) {
   assertProjectSelected(conversation);
   Project project = conversation.getProject();
   Sprint oldSprint = project.getCurrentSprint();
   for (Requirement requirement : oldSprint.getRequirements()) {
     if (!requirement.isClosed()) {
       requirement.setDirty(true);
       sendToClients(conversation, requirement);
     }
   }
   Sprint newSprint = project.switchToNextSprint();
   postProjectEvent(
       conversation, conversation.getSession().getUser() + " switched to next sprint ", newSprint);
   sendToClients(conversation, project.getSprints());
   sendToClients(conversation, project.getSprintReports());
   sendToClients(conversation, project.getRequirements());
   sendToClients(conversation, project.getTasks()); // TODO optimize: no history tasks
   sendToClients(conversation, oldSprint.getReleases());
   sendToClients(conversation, project);
 }
Exemple #21
0
  @Override
  public void onDeleteEntity(GwtConversation conversation, String entityId) {
    AEntity entity = getDaoService().getEntityById(entityId);
    User user = conversation.getSession().getUser();
    if (!Auth.isDeletable(entity, user)) throw new PermissionDeniedException();

    if (entity instanceof File) {
      File file = (File) entity;
      file.deleteFile();
    }

    if (entity instanceof Task) {
      // update sprint day snapshot before delete
      conversation
          .getProject()
          .getCurrentSprint()
          .getDaySnapshot(Date.today())
          .updateWithCurrentSprint();
    }

    ADao dao = getDaoService().getDao(entity);
    dao.deleteEntity(entity);

    if (entity instanceof Task) onTaskDeleted(conversation, (Task) entity);

    Project project = conversation.getProject();
    if (project != null) {
      for (GwtConversation c : webApplication.getConversationsByProject(project, conversation)) {
        c.getNextData().addDeletedEntity(entityId);
      }
    }

    if (user != null && project != null) {
      ProjectUserConfig config = project.getUserConfig(user);
      config.touch();
      sendToClients(conversation, config);
    }
  }
Exemple #22
0
 @Override
 public void onSendIssueReplyEmail(
     GwtConversation conversation,
     String issueId,
     String from,
     String to,
     String subject,
     String text) {
   assertProjectSelected(conversation);
   Issue issue = issueDao.getById(issueId);
   if (Str.isEmail(from)) {
     emailSender.sendEmail(conversation.getProject(), to, subject, text);
   } else {
     emailSender.sendEmail(from, to, subject, text);
   }
   User user = conversation.getSession().getUser();
   postProjectEvent(
       conversation,
       user.getName() + " emailed a response to " + issue.getReferenceAndLabel(),
       issue);
   Change change = changeDao.postChange(issue, user, "@reply", null, text);
   conversation.sendToClient(change);
 }
Exemple #23
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);
 }
Exemple #24
0
 private void onStartConversation(GwtConversation conversation) {
   User user = conversation.getSession().getUser();
   if (user == null) throw new PermissionDeniedException("Login required.");
   conversation.clearRemoteEntities();
   conversation.getNextData().applicationInfo = webApplication.getApplicationInfo();
   conversation.sendToClient(webApplication.getSystemConfig());
   conversation.getNextData().setUserId(user.getId());
   conversation.sendUserScopeDataToClient(user);
 }
Exemple #25
0
  private void onBlogEntryChanged(
      GwtConversation conversation, BlogEntry blogEntry, Map properties) {
    User currentUser = conversation.getSession().getUser();

    if (properties.containsKey("text")) {
      blogEntry.addAuthor(currentUser);
    }

    if (properties.containsKey("published")) {
      if (blogEntry.isPublished()) {
        postProjectEvent(
            conversation,
            currentUser.getName() + " published " + blogEntry.getReferenceAndLabel(),
            blogEntry);
      }
      blogEntry.getProject().updateHomepage();
    }
  }
Exemple #26
0
 private void onImpedimentChanged(
     GwtConversation conversation, Impediment impediment, Map properties) {
   User currentUser = conversation.getSession().getUser();
   if (properties.containsKey("closed")) {
     if (impediment.isClosed()) {
       impediment.setDate(Date.today());
       postProjectEvent(
           conversation,
           currentUser.getName() + " closed " + impediment.getReferenceAndLabel(),
           impediment);
     } else {
       postProjectEvent(
           conversation,
           currentUser.getName() + " reopened " + impediment.getReferenceAndLabel(),
           impediment);
     }
   }
 }
Exemple #27
0
  @Override
  public void onKickStoryFromSprint(GwtConversation conversation, String storyId) {
    assertProjectSelected(conversation);
    Requirement story = requirementDao.getById(storyId);
    Sprint sprint = story.getSprint();
    User currentUser = conversation.getSession().getUser();

    sprint.kickRequirement(story, currentUser);

    postProjectEvent(
        conversation,
        currentUser.getName() + " kicked " + story.getReferenceAndLabel() + " from current sprint",
        story);

    sendToClients(conversation, story.getTasksInSprint());
    sendToClients(conversation, story);
    sendToClients(conversation, sprint);
    sendToClients(conversation, sprint.getProject());
  }
Exemple #28
0
 @Override
 public void onTouchLastActivity(GwtConversation conversation) {
   Project project = conversation.getProject();
   if (project == null) return;
   project.getUserConfig(conversation.getSession().getUser()).touch();
 }
Exemple #29
0
 @Override
 public void onUpdateProjectHomepage(GwtConversation conversation) {
   assertProjectSelected(conversation);
   Project project = conversation.getProject();
   project.updateHomepage();
 }
Exemple #30
0
 @Override
 public void onRequestChanges(GwtConversation conversation, String parentId) {
   conversation.sendToClient(changeDao.getChangesByParentId(parentId));
 }