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

PropertyReturnsDescription
draftboolean

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.

ParameterDescription
namethe path-safe, unique name for the auction
titlethe display title for the auction
auctionTypethe key identifying the bidding strategy to use, for example a highest-bid auction
startDatethe date and time bidding opens, or null to leave unset
endDatethe date and time bidding closes, or null to leave unset
websitethe website the auction belongs to
pointsBucketthe name of an existing reward to use as the auction's points bucket, or null for none
isActivetrue 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.

ParameterDescription
auctionthe auction the bids belong to
bidIdsthe 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.

ParameterDescription
auctionthe auction to save

findAuctionSetByName(String auctionSetName)

Returns: AuctionSet

Looks up an auction set belonging to the current organisation by its name.

ParameterDescription
auctionSetNamethe 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.

ParameterDescription
websitethe website to search within
setthe 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.

ParameterDescription
websitethe website to search within
setthe 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.

ParameterDescription
websitethe website to search within
setthe auction set to filter by
profilethe 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.

ParameterDescription
websitethe 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.

ParameterDescription
websitethe website to search within
profilethe 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.

ParameterDescription
auctionthe auction to check access to
profilethe 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.

ParameterDescription
auctionthe auction whose images are searched
preferredOrientationthe 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.

ParameterDescription
auctionthe auction whose images are searched

getBestSquareImageHref(Auction auction)

Returns: String

The href of the best image for the given auction with a square orientation.

ParameterDescription
auctionthe auction whose images are searched

getBestVerticalImageHref(Auction auction)

Returns: String

The href of the best image for the given auction with a vertical orientation.

ParameterDescription
auctionthe auction whose images are searched

getBestHorizontalImageHref(Auction auction)

Returns: String

The href of the best image for the given auction with a horizontal orientation.

ParameterDescription
auctionthe 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.

ParameterDescription
auctionthe 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.

ParameterDescription
auctionthe 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.

ParameterDescription
auctionthe 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.

ParameterDescription
auctionthe 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.

ParameterDescription
auctionthe 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.

ParameterDescription
auctionthe 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.

ParameterDescription
auctionthe 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.

ParameterDescription
namethe path-safe, unique name for the auction
titlethe title of the auction
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.