01: package com.ibatis.jpetstore.service;
02:
03: import java.util.List;
04:
05: import com.ibatis.common.util.PaginatedList;
06: import com.ibatis.dao.client.DaoManager;
07: import com.ibatis.jpetstore.domain.Category;
08: import com.ibatis.jpetstore.domain.Item;
09: import com.ibatis.jpetstore.domain.Product;
10: import com.ibatis.jpetstore.persistence.DaoConfig;
11: import com.ibatis.jpetstore.persistence.iface.CategoryDao;
12: import com.ibatis.jpetstore.persistence.iface.ItemDao;
13: import com.ibatis.jpetstore.persistence.iface.ProductDao;
14:
15: public class CatalogServiceImpl implements CatalogService {
16:
17: /* Private Fields */
18:
19: private DaoManager daoManager = DaoConfig.getDaomanager();
20:
21: private CategoryDao categoryDao;
22:
23: private ItemDao itemDao;
24:
25: private ProductDao productDao;
26:
27: /* Constructors */
28:
29: public CatalogServiceImpl() {
30: categoryDao = (CategoryDao) daoManager
31: .getDao(CategoryDao.class);
32: productDao = (ProductDao) daoManager.getDao(ProductDao.class);
33: itemDao = (ItemDao) daoManager.getDao(ItemDao.class);
34: }
35:
36: /* CATEGORY */
37:
38: public List getCategoryList() {
39: return categoryDao.getCategoryList();
40: }
41:
42: public Category getCategory(String categoryId) {
43: return categoryDao.getCategory(categoryId);
44: }
45:
46: /* PRODUCT */
47:
48: public Product getProduct(String productId) {
49: return productDao.getProduct(productId);
50: }
51:
52: public PaginatedList getProductListByCategory(String categoryId) {
53: return productDao.getProductListByCategory(categoryId);
54: }
55:
56: public PaginatedList searchProductList(String keywords) {
57: return productDao.searchProductList(keywords);
58: }
59:
60: /* ITEM */
61:
62: public PaginatedList getItemListByProduct(String productId) {
63: return itemDao.getItemListByProduct(productId);
64: }
65:
66: public Item getItem(String itemId) {
67: return itemDao.getItem(itemId);
68: }
69:
70: public boolean isItemInStock(String itemId) {
71: return itemDao.isItemInStock(itemId);
72: }
73:
74: }
|