KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibatis > jpetstore > service > CatalogService


1 package com.ibatis.jpetstore.service;
2
3 import com.ibatis.common.util.PaginatedList;
4 import com.ibatis.dao.client.DaoManager;
5 import com.ibatis.jpetstore.domain.Category;
6 import com.ibatis.jpetstore.domain.Item;
7 import com.ibatis.jpetstore.domain.Product;
8 import com.ibatis.jpetstore.persistence.DaoConfig;
9 import com.ibatis.jpetstore.persistence.iface.CategoryDao;
10 import com.ibatis.jpetstore.persistence.iface.ItemDao;
11 import com.ibatis.jpetstore.persistence.iface.ProductDao;
12
13 import java.util.List JavaDoc;
14
15 public class CatalogService {
16
17   /* Constants */
18
19   private static final CatalogService instance = new CatalogService();
20
21   /* Private Fields */
22
23   private DaoManager daoManager = DaoConfig.getDaomanager();
24
25   private CategoryDao categoryDao;
26   private ItemDao itemDao;
27   private ProductDao productDao;
28
29   /* Constructors */
30
31   private CatalogService() {
32     categoryDao = (CategoryDao) daoManager.getDao(CategoryDao.class);
33     productDao = (ProductDao) daoManager.getDao(ProductDao.class);
34     itemDao = (ItemDao) daoManager.getDao(ItemDao.class);
35   }
36
37   /* Public Methods */
38
39   public static CatalogService getInstance() {
40     return instance;
41   }
42
43   /* CATEGORY */
44
45   public List getCategoryList() {
46     return categoryDao.getCategoryList();
47   }
48
49   public Category getCategory(String JavaDoc categoryId) {
50     return categoryDao.getCategory(categoryId);
51   }
52
53   /* PRODUCT */
54
55   public Product getProduct(String JavaDoc productId) {
56     return productDao.getProduct(productId);
57   }
58
59   public PaginatedList getProductListByCategory(String JavaDoc categoryId) {
60     return productDao.getProductListByCategory(categoryId);
61   }
62
63   public PaginatedList searchProductList(String JavaDoc keywords) {
64     return productDao.searchProductList(keywords);
65   }
66
67   /* ITEM */
68
69   public PaginatedList getItemListByProduct(String JavaDoc productId) {
70     return itemDao.getItemListByProduct(productId);
71   }
72
73   public Item getItem(String JavaDoc itemId) {
74     return itemDao.getItem(itemId);
75   }
76
77   public boolean isItemInStock(String JavaDoc itemId) {
78     return itemDao.isItemInStock(itemId);
79   }
80
81 }
Popular Tags