private void notifyCategories(Map categoryEventsByCategoryId) {
    for (Iterator iterator = categoryEventsByCategoryId.entrySet().iterator();
        iterator.hasNext(); ) {
      Map.Entry entry = (Map.Entry) iterator.next();
      String categoryId = (String) entry.getKey();
      CategoryEvent categoryEvent = (CategoryEvent) entry.getValue();
      Category category = (Category) categoriesById.get(categoryId);

      if (category != null) {
        category.fireCategoryChanged(categoryEvent);
      }
    }
  }
  private CategoryEvent updateCategory(Category category) {
    Set categoryActivityBindings = (Set) categoryActivityBindingsByCategoryId.get(category.getId());
    boolean categoryActivityBindingsChanged =
        category.setCategoryActivityBindings(
            categoryActivityBindings != null ? categoryActivityBindings : Collections.EMPTY_SET);
    CategoryDefinition categoryDefinition =
        (CategoryDefinition) categoryDefinitionsById.get(category.getId());
    boolean definedChanged = category.setDefined(categoryDefinition != null);
    boolean nameChanged =
        category.setName(categoryDefinition != null ? categoryDefinition.getName() : null);
    boolean descriptionChanged =
        category.setDescription(
            categoryDefinition != null ? categoryDefinition.getDescription() : null);

    if (categoryActivityBindingsChanged || definedChanged || nameChanged || descriptionChanged) {
      return new CategoryEvent(
          category,
          categoryActivityBindingsChanged,
          definedChanged,
          descriptionChanged,
          nameChanged);
    }

    return null;
  }