Interface InventoryItemDao

All Known Implementing Classes:
MongoInventoryItemDao

public interface InventoryItemDao
Created by davidjbrooks on 11/11/18.
  • Field Details

  • Method Details

    • getInventoryItem

      InventoryItem getInventoryItem(String inventoryItemId)
      Gets the specific inventory item with the id, or throws a NotFoundException if the inventory item can't be found.
      Returns:
      the InventoryItem that was requested, never null
    • getInventoryItems

      Pagination<InventoryItem> getInventoryItems(int offset, int count)
      Gets inventory items specifying the offset and the count.
      Parameters:
      offset - the offset
      count - the count
      Returns:
      a Pagination of InventoryItem objects.
    • getUserPublicInventoryItems

      Pagination<InventoryItem> getUserPublicInventoryItems(int offset, int count, User user)
      Gets inventory items for specified user, which are flagged publicVisible
      Parameters:
      offset - the offset
      count - the count
      Returns:
      a Pagination of InventoryItem objects.
    • getInventoryItems

      Pagination<InventoryItem> getInventoryItems(int offset, int count, User user, String search)
      Gets inventory items specifying the offset and the count, specifying a search filter.
      Parameters:
      offset - the offset
      count - the count
      user - the User that owns the items
      search - a query to filter the results
      Returns:
      a Pagination of InventoryItem objects.
    • getInventoryItemByItemNameOrId

      InventoryItem getInventoryItemByItemNameOrId(User user, String itemNameOrId, int priority)
      Gets the primary (single) inventory item for with the item name or id, or throws a NotFoundException if the item or inventory item can't be found.
      Parameters:
      user - the User that owns the item
      itemNameOrId - an item name or ID to limit the results
      priority -
      Returns:
      the InventoryItem that was requested, never null
    • updateInventoryItem

      InventoryItem updateInventoryItem(String inventoryItemId, int quantity)
      Updates the specific inventory item with the id, or throws a NotFoundException if the inventory item can't be found. The InventoryItem.getId() is used to key the inventory item being updated.
      Parameters:
      inventoryItemId -
      quantity -
      Returns:
      the InventoryItem as it was written into the database
      Throws:
      InvalidDataException - if the state of the passed in InventoryItem is invalid
    • createInventoryItem

      InventoryItem createInventoryItem(InventoryItem inventoryItem)
      Creates an inventory item. The value of InventoryItem.getId() will be ignored.
      Returns:
      the InventoryItem as it was written into the database
      Throws:
      InvalidDataException - if the state of the passed in InventoryItem is invalid
      DuplicateException - if the passed in Item has a name that already exists
    • setQuantityForItem

      InventoryItem setQuantityForItem(User user, String itemNameOrId, int priority, int quantity)
      Adjusts the quantity of the supplied item and user.
      Parameters:
      user - the User for which to adjust the item.
      itemNameOrId - the Item.getName() or Item.getId()
      priority - the priority of the item slot
      quantity - the amount to adjust the quantity by
      Returns:
      the updated InventoryItem
    • adjustQuantityForItem

      InventoryItem adjustQuantityForItem(String inventoryItemId, int quantityDelta)
      Adjusts the quantity of the supplied item and user.
      Parameters:
      inventoryItemId - the Item.getName() or Item.getId()
      quantityDelta - the amount to adjust the quantity by
      Returns:
      the updated InventoryItem
    • adjustQuantityForItem

      InventoryItem adjustQuantityForItem(User user, String itemNameOrId, int priority, int quantityDelta)
      Convenience method which allows for invoking adjustQuantityForItem(String, int) without needing to create the item first.
      Parameters:
      user - the user object to adjust
      itemNameOrId - the item name or identifier
      priority - the priority slot
      quantityDelta - the quantity delta
      Returns:
      the updated InventoryItem
    • deleteInventoryItem

      void deleteInventoryItem(String inventoryItemId)
      Deletes an inventory item.
      Parameters:
      inventoryItemId - the InventoryItem's id.