Creates, updates and queries auctions and auction bids for the current organisation. Registered in JavaScript as auctionManager, so app and theme scripts create auctions, filter them for a viewer, and read an auction's bidding state through this manager rather than working with the Auction entity directly.
Group: Managers
Properties
| Property | Returns | Description |
|---|---|---|
| draft | boolean |
Methods
createAuction(String name, String title, String auctionType, Date startDate, Date endDate, Website website, String pointsBucket, Boolean isActive) · deleteBids(Auction auction, List<Long> bidIds) · updateAuction(Auction auction) · findAuctionSetByName(String auctionSetName) · findAuctionsBySet(Website website, AuctionSet set) · findAuctionsBySetForUser(Website website, AuctionSet set) · findAuctionsBySetForUser(Website website, AuctionSet set, Profile profile) · findAuctionsForUser(Website website) · findAuctionsForUser(Website website, Profile profile) · canUserAccess(Auction auction, Profile profile) · getBestImageHref(Auction auction, String preferredOrientation) · getBestDefaultImageHref(Auction auction) · getBestSquareImageHref(Auction auction) · getBestVerticalImageHref(Auction auction) · getBestHorizontalImageHref(Auction auction) · getBiddingState(Auction auction) · getUserBidCount(Auction auction) · getAuctionBidCount(Auction auction) · isAuctionClosed(Auction auction) · getAuctionState(Auction auction) · getWSUri(Auction auction) · getWonBy(Auction auction) · newAuctionBuilder(String name, String title)
createAuction(String name, String title, String auctionType, Date startDate, Date endDate, Website website, String pointsBucket, Boolean isActive)
Returns: Auction
Creates and persists a new auction for the current organisation. If the given points bucket names an existing reward with a points type, that reward is attached as the auction's reward.
| Parameter | Description |
|---|---|
name | the path-safe, unique name for the auction |
title | the display title for the auction |
auctionType | the key identifying the bidding strategy to use, for example a highest-bid auction |
startDate | the date and time bidding opens, or null to leave unset |
endDate | the date and time bidding closes, or null to leave unset |
website | the website the auction belongs to |
pointsBucket | the name of an existing reward to use as the auction's points bucket, or null for none |
isActive | true to create the auction as active, false or null to create it as a draft |
deleteBids(Auction auction, List<Long> bidIds)
Returns: int
Deletes the bids with the given ids from the given auction and recalculates the auction's leading bid afterwards, since the deleted bids may have included the previous leading bid.
| Parameter | Description |
|---|---|
auction | the auction the bids belong to |
bidIds | the ids of the bids to delete; ids that do not match a bid on the auction are ignored |
updateAuction(Auction auction)
Returns: void
Saves changes made to an auction back to the database.
| Parameter | Description |
|---|---|
auction | the auction to save |
findAuctionSetByName(String auctionSetName)
Returns: AuctionSet
Looks up an auction set belonging to the current organisation by its name.
| Parameter | Description |
|---|---|
auctionSetName | the name of the auction set to find; a blank name always returns null |
findAuctionsBySet(Website website, AuctionSet set)
Returns: CommonList<Auction>
Finds all auctions for the current organisation that belong to the given website and auction set, with no filtering by viewer access.
| Parameter | Description |
|---|---|
website | the website to search within |
set | the auction set to filter by |
findAuctionsBySetForUser(Website website, AuctionSet set)
Returns: CommonList<Auction>
Finds the auctions in the given website and auction set that the current user is allowed to access.
| Parameter | Description |
|---|---|
website | the website to search within |
set | the auction set to filter by |
findAuctionsBySetForUser(Website website, AuctionSet set, Profile profile)
Returns: CommonList<Auction>
Finds the auctions in the given website and auction set that the given profile is allowed to access, based on group and organisation membership and the auction's active status.
| Parameter | Description |
|---|---|
website | the website to search within |
set | the auction set to filter by |
profile | the profile whose access is checked |
findAuctionsForUser(Website website)
Returns: CommonList<Auction>
Finds all auctions in the given website that the current user is allowed to access.
| Parameter | Description |
|---|---|
website | the website to search within |
findAuctionsForUser(Website website, Profile profile)
Returns: CommonList<Auction>
Finds all auctions in the given website that the given profile is allowed to access, based on group and organisation membership and the auction's active status.
| Parameter | Description |
|---|---|
website | the website to search within |
profile | the profile whose access is checked |
canUserAccess(Auction auction, Profile profile)
Returns: boolean
Whether the given profile is allowed to access the given auction: the auction must not be deleted, the profile's group and organisation membership must satisfy the auction's group and organisation restrictions, and the auction must be active unless it is being viewed as a draft.
| Parameter | Description |
|---|---|
auction | the auction to check access to |
profile | the profile whose access is checked |
getBestImageHref(Auction auction, String preferredOrientation)
Returns: String
The href of the best matching image for the given auction and orientation: an image with that exact orientation if one exists, falling back to an image with no orientation set, and finally to the first available image.
| Parameter | Description |
|---|---|
auction | the auction whose images are searched |
preferredOrientation | the preferred orientation, or null to prefer images with no orientation set |
getBestDefaultImageHref(Auction auction)
Returns: String
The href of the best image for the given auction with no preferred orientation.
| Parameter | Description |
|---|---|
auction | the auction whose images are searched |
getBestSquareImageHref(Auction auction)
Returns: String
The href of the best image for the given auction with a square orientation.
| Parameter | Description |
|---|---|
auction | the auction whose images are searched |
getBestVerticalImageHref(Auction auction)
Returns: String
The href of the best image for the given auction with a vertical orientation.
| Parameter | Description |
|---|---|
auction | the auction whose images are searched |
getBestHorizontalImageHref(Auction auction)
Returns: String
The href of the best image for the given auction with a horizontal orientation.
| Parameter | Description |
|---|---|
auction | the auction whose images are searched |
getBiddingState(Auction auction)
Returns: String
The current user's bid status on the given auction: won or lost once it has closed, otherwise leading, outbid or no-bid depending on whether the user holds the leading bid.
| Parameter | Description |
|---|---|
auction | the auction to check the current user's bidding state against |
getUserBidCount(Auction auction)
Returns: long
The number of bids the current user has placed on the given auction.
| Parameter | Description |
|---|---|
auction | the auction to count the current user's bids on |
getAuctionBidCount(Auction auction)
Returns: long
The total number of bids placed on the given auction by any user.
| Parameter | Description |
|---|---|
auction | the auction to count bids for |
isAuctionClosed(Auction auction)
Returns: boolean
Whether the given auction has been processed for closing, meaning bidding has finished and a winning bid, if any, has been determined.
| Parameter | Description |
|---|---|
auction | the auction to check |
getAuctionState(Auction auction)
Returns: String
The current lifecycle state of the given auction: draft while its status is draft, and while active either closed, active (before its start date) or open (accepting bids) depending on its start date and whether it has been processed for closing.
| Parameter | Description |
|---|---|
auction | the auction to check |
getWSUri(Auction auction)
Returns: String
A base-64 encoded identifier combining the given auction's name and organisation id, used to address the auction over the websocket channel used for live bid updates.
| Parameter | Description |
|---|---|
auction | the auction to build the identifier for |
getWonBy(Auction auction)
Returns: Profile
The profile of the user who placed the winning bid on the given auction, or null if it has no winning bid yet.
| Parameter | Description |
|---|---|
auction | the auction to check |
newAuctionBuilder(String name, String title)
Returns: AuctionBuilder
Starts a fluent builder for creating a new auction, pre-populated with the given name and title. Configure the builder with its setter methods and call build to create and persist the auction.
| Parameter | Description |
|---|---|
name | the path-safe, unique name for the auction |
title | the title of the auction |