コード例 #1
0
  /**
   * Method which handles the logic of updating an item's sekSum/value. It first parses the id and
   * amount to integers and fetches the list-item object via the ID. It then updates the list item's
   * seksum witch the amount by calling the updateListItem() method in listDAO class.
   *
   * @param id
   * @param amount
   * @throws Exception
   */
  public void updateListItemValue(String id, String amount) throws Exception {
    try {
      int parsedID = Integer.parseInt(id);
      int parsedAmount = Integer.parseInt(amount);
      TopList toplist = listDAO.getListItemByID(parsedID);
      if (toplist != null) {
        listDAO.updateListItem(toplist, parsedAmount);
      } else throw new Exception();

    } catch (NumberFormatException e) {
      e.printStackTrace();
    } catch (Exception e) {
      throw e;
    }
  }
コード例 #2
0
  /**
   * Method which calls the listDAO class, who returns all the list-items from the database.
   *
   * @return list of all items.
   * @throws Exception
   */
  public List<TopList> getTopListFromDB() throws Exception {
    List<TopList> topList = listDAO.getListItems();

    return topList;
  }
コード例 #3
0
 /**
  * Method which calls the addListItemToDB method in listDAO, which adds the list-item.
  *
  * @param product
  * @param producturl
  * @param userId
  * @throws Exception
  */
 public void addListItem(String product, String producturl, int userId) throws Exception {
   listDAO.addListItemToDB(new TopList(product, producturl, userId));
 }
コード例 #4
0
  /**
   * * Get logged in users topList
   *
   * @author Joel
   * @param userId
   * @return user specific topList
   */
  public List<TopList> getUserTopListFromDB(int userId) throws Exception {
    List<TopList> topList = listDAO.getUserListItems(userId);

    return topList;
  }