コード例 #1
0
  /**
   * Get the number of people who have added the dashboard as a favourite. Used to warn against
   * deleting.
   *
   * @return the number of users (not including owner) that has favourited the dashboard.
   */
  public int getOtherFavouriteCount() {
    if (otherFavouriteCount == null) {
      final PortalPage page = getPortalPage();

      // We want to know how many times it has been favourited by OTHER people
      final boolean isFavourite = favouritesService.isFavourite(getRemoteUser(), page);
      final int count =
          isFavourite
              ? page.getFavouriteCount().intValue() - 1
              : page.getFavouriteCount().intValue();
      otherFavouriteCount = new Long(count);
    }
    return otherFavouriteCount.intValue();
  }
コード例 #2
0
  public int getOtherFavouriteCount() {
    if (otherFavouriteCount == null) {
      final PortalPage dashboard = getDashboard();

      // We want to know how many times it has been favourited by OTHER people
      User dashboardOwner = UserUtils.getUser(dashboard.getOwnerUserName());
      final boolean isFavourite = favouriteService.isFavourite(dashboardOwner, dashboard);
      final int count =
          isFavourite
              ? dashboard.getFavouriteCount().intValue() - 1
              : dashboard.getFavouriteCount().intValue();
      otherFavouriteCount = (long) count;
    }
    return otherFavouriteCount.intValue();
  }