Interface RewardIssuanceDao

All Known Implementing Classes:
MongoRewardIssuanceDao

public interface RewardIssuanceDao
Manipulates the instances of RewardIssuance, including the operations to ensure tha the rewards are properly inserted into the database and credited to a user's inventory in an atomic way.
  • Method Details

    • getRewardIssuance

      RewardIssuance getRewardIssuance(String id)
      Fetches the instance of RewardIssuance.
      Parameters:
      id - the id of the RewardIssuance as specified by RewardIssuance.getId().
      Returns:
      the reward issuance
    • getRewardIssuance

      RewardIssuance getRewardIssuance(User user, String context)
      Fetches the reward issuance for the given user and context.
      Parameters:
      user -
      context -
      Returns:
      the reward issuance
    • getRewardIssuances

      default Pagination<RewardIssuance> getRewardIssuances(User user, int offset, int count)
      Gets all reward issuances for a given user.
      Parameters:
      user - the user
      offset - the offset
      count - the count
      Returns:
      a Pagination of RewardIssuance
    • getRewardIssuances

      Pagination<RewardIssuance> getRewardIssuances(User user, int offset, int count, List<RewardIssuance.State> states, List<String> tags)
      Gets all reward issuances for the given user, optionally specifying the allowable RewardIssuance.States and/or .
      Parameters:
      offset - the offset
      count - the count
      states - if non-empty, will include the requested states in the query. Otherwise states will be ignored in the query.
      tags - if non-empty, will include the requested set of tags in the query. Otherwise tags will be ignored in the query.
      Returns:
      a Pagination of RewardIssuance
    • getOrCreateRewardIssuance

      RewardIssuance getOrCreateRewardIssuance(RewardIssuance rewardIssuance)
      Gets or creates an instance of RewardIssuance. If created, the issuance will be set to a state of RewardIssuance.State.ISSUED.
      Parameters:
      rewardIssuance - the instance of RewardIssuance to create
      Returns:
      the RewardIssuance instance
    • updateExpirationTimestamp

      RewardIssuance updateExpirationTimestamp(RewardIssuance rewardIssuance, long expirationTimestamp)
      Updates the given issuance to a new expiration timestamp. If a negative value is provided, the value will be unset in the db.
      Parameters:
      rewardIssuance - the issuance to update
      expirationTimestamp - the expiration, in ms
      Returns:
    • redeem

      InventoryItem redeem(RewardIssuance rewardIssuance)
      Redeems the RewardIssuance. Once redeemed, the reward will be placed into the associated user's inventory. This method will select an InventoryItem with a priority of value zero to accept the RewardIssuance.

      Additionally this method must guarantee that applying the same RewardIssuance multiple times will only credit the user once.

      Parameters:
      rewardIssuance - the reward to redeem
      Returns:
      the InventoryItem to which this RewardIssuance was applied.
    • delete

      void delete(String id)
      Deltes a RewardIssuance with the supplied id.
      Parameters:
      id - the id