/** * How many times has this page been favourited * * @return the count of favourites of this page */ public Long getFavouriteCount() { return portalPage.getFavouriteCount(); }
/** * How many times has this page been favourited altered by whether it will disabled or enabled * * @return the count of favourites of this page altered by whether it will disabled or enabled */ public long getAlternateFavouriteCount() { return (isFavourite) ? (portalPage.getFavouriteCount().intValue() - 1) : (portalPage.getFavouriteCount().intValue() + 1); }
public boolean evaluate(final Object o) { final PortalPage portalPage = (PortalPage) o; // Has someone apart from the owner favourited this portal page? return (favouriteIds.contains(portalPage.getId())) ? portalPage.getFavouriteCount() > 1 : portalPage.getFavouriteCount() > 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 ApplicationUser dashboardOwner = dashboard.getOwner(); final boolean isFavourite = favouriteService.isFavourite(dashboardOwner, dashboard); final int count = isFavourite ? dashboard.getFavouriteCount().intValue() - 1 : dashboard.getFavouriteCount().intValue(); otherFavouriteCount = (long) count; } return otherFavouriteCount.intValue(); }
/** * 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(getLoggedInUser(), page); final int count = isFavourite ? page.getFavouriteCount().intValue() - 1 : page.getFavouriteCount().intValue(); otherFavouriteCount = new Long(count); } return otherFavouriteCount.intValue(); }
/** * Note: result is cached to avoid double calculation (once for checking emptyness, once for iterating). * * @return a Map containing the current user's {@link com.atlassian.jira.portal.PortalPage}s which have been favourited * by other users, and the number of other users who have that PortalPage favourited. */ public Map /*<PortalPage, Long>*/ getPortalPagesFavouritedByOthersWithUserCount() { if (portalPagesFavouritedByOthersWithUserCount == null) { Collection<PortalPage> requests = portalPageService.getPortalPagesFavouritedByOthers(getLoggedInUser()); portalPagesFavouritedByOthersWithUserCount = new LinkedHashMap<PortalPage, Long>(requests.size()); for (final PortalPage portalPage : requests) { long numberFavourites = portalPage.getFavouriteCount().longValue(); if (favouritesService.isFavourite(getLoggedInUser(), portalPage)) { numberFavourites--; } if (numberFavourites > 0) { portalPagesFavouritedByOthersWithUserCount.put(portalPage, Long.valueOf(numberFavourites)); } } } return portalPagesFavouritedByOthersWithUserCount; } }
public Builder portalPage(PortalPage page) { id = page.getId(); name = page.getName(); description = page.getDescription(); isSystemDashboard = page.isSystemDefaultPortalPage(); favouriteCount = page.getFavouriteCount(); permissions = page.getPermissions(); layout = page.getLayout(); owner = page.getOwner(); version = page.getVersion(); return this; }