Exemple #1
0
 public Item save(Item item) {
   validateItem(item);
   try {
     if (item.getId() != null) {
       itemDAO.update(item);
     } else {
       itemDAO.insert(item);
     }
   } catch (Exception e) {
     throw new ApplicationRuntimeException(bundle.getString("ADM_ITEM_SAVE_NOK", e));
   }
   return item;
 }
Exemple #2
0
 public void delete(Item item) {
   try {
     item = itemDAO.load(item.getId());
     if (item == null) {
       throw new ApplicationRuntimeException(bundle.getString("OBJECT_NOT_FOUND"));
     }
     List<Auction> listAuctions = auctionDAO.listAllAuctionsByItem(item);
     if (listAuctions != null)
       if (listAuctions.size() > 0)
         throw new ApplicationRuntimeException(
             bundle.getString("ADM_ITEM_DELETE_NOK_THERE_ARE_AUCTIONS"));
     itemDAO.delete(item.getId());
   } catch (Exception e) {
     e.printStackTrace();
     throw new ApplicationRuntimeException(bundle.getString("ADM_ITEM_DELETED_NOK" + e));
   }
 }
Exemple #3
0
 public List<Item> filterByCategory(Item item) {
   if (item.getCategory() != null) {
     try {
       List<Item> list = itemDAO.listByCategory(item.getCategory());
       return list;
     } catch (Exception e) {
       throw new ApplicationRuntimeException(bundle.getString("ADM_ITEM_LIST_LOAD_NOK", e));
     }
   }
   return new ArrayList<Item>();
 }