Example #1
0
  @Override
  public void onChangeProperties(GwtConversation conversation, String entityId, Map properties) {
    AEntity entity = getDaoService().getEntityById(entityId);
    User currentUser = conversation.getSession().getUser();
    if (!Auth.isEditable(entity, currentUser)) throw new PermissionDeniedException();

    Sprint previousRequirementSprint =
        entity instanceof Requirement ? ((Requirement) entity).getSprint() : null;

    if (entity instanceof Requirement) {
      postChangeIfChanged(conversation, entity, properties, currentUser, "label");
      postChangeIfChanged(conversation, entity, properties, currentUser, "description");
      postChangeIfChanged(conversation, entity, properties, currentUser, "testDescription");
      postChangeIfChanged(conversation, entity, properties, currentUser, "sprintId");
      postChangeIfChanged(conversation, entity, properties, currentUser, "closed");
      postChangeIfChanged(conversation, entity, properties, currentUser, "issueId");
    }
    Project project = conversation.getProject();
    if (entity instanceof Task) {
      // update sprint day snapshot before change
      if (project.isCurrentSprintSet())
        project.getCurrentSprint().getDaySnapshot(Date.today()).updateWithCurrentSprint();
      postChangeIfChanged(conversation, entity, properties, currentUser, "label");
      postChangeIfChanged(conversation, entity, properties, currentUser, "description");
    }
    if (entity instanceof Wikipage) {
      postChangeIfChanged(conversation, entity, properties, currentUser, "text");
    }
    if (entity instanceof Risk) {
      postChangeIfChanged(conversation, entity, properties, currentUser, "description");
      postChangeIfChanged(conversation, entity, properties, currentUser, "probability");
      postChangeIfChanged(conversation, entity, properties, currentUser, "impact");
      postChangeIfChanged(conversation, entity, properties, currentUser, "probabilityMitigation");
      postChangeIfChanged(conversation, entity, properties, currentUser, "impactMitigation");
    }
    if (entity instanceof Impediment) {
      postChangeIfChanged(conversation, entity, properties, currentUser, "description");
      postChangeIfChanged(conversation, entity, properties, currentUser, "solution");
      postChangeIfChanged(conversation, entity, properties, currentUser, "closed");
    }
    if (entity instanceof Issue) {
      postChangeIfChanged(conversation, entity, properties, currentUser, "description");
      postChangeIfChanged(conversation, entity, properties, currentUser, "statement");
      postChangeIfChanged(conversation, entity, properties, currentUser, "closeDate");
      postChangeIfChanged(conversation, entity, properties, currentUser, "storyId");
    }
    if (entity instanceof BlogEntry) {
      postChangeIfChanged(conversation, entity, properties, currentUser, "text");
    }

    entity.updateProperties(properties);

    if (entity instanceof Task) onTaskChanged(conversation, (Task) entity, properties);
    if (entity instanceof Requirement)
      onRequirementChanged(
          conversation, (Requirement) entity, properties, previousRequirementSprint);
    if (entity instanceof Impediment)
      onImpedimentChanged(conversation, (Impediment) entity, properties);
    if (entity instanceof Issue) onIssueChanged(conversation, (Issue) entity, properties);
    if (entity instanceof BlogEntry)
      onBlogEntryChanged(conversation, (BlogEntry) entity, properties);
    if (entity instanceof Comment) onCommentChanged(conversation, (Comment) entity, properties);
    if (entity instanceof SystemConfig)
      onSystemConfigChanged(conversation, (SystemConfig) entity, properties);
    if (entity instanceof Wikipage) onWikipageChanged(conversation, (Wikipage) entity, properties);

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

    conversation.clearRemoteEntitiesByType(Change.class);
    sendToClients(conversation, entity);
  }