1 package org.javabb.action; 2 3 import java.util.ArrayList ; 4 import java.util.List ; 5 6 import org.javabb.action.infra.BaseAction; 7 import org.javabb.transaction.CategoryTransaction; 8 import org.javabb.transaction.UserTransaction; 9 import org.javabb.vh.Stats; 10 import org.javabb.vo.Category; 11 12 27 28 34 public class CategoryAction extends BaseAction { 35 36 private CategoryTransaction _categoryTransaction; 37 private UserTransaction _userTransaction; 38 39 private Stats stats = new Stats(); 40 private Category category = new Category(); 41 private List lstCategory = new ArrayList (); 42 43 44 47 public void setCategoryTransaction(CategoryTransaction categoryTransaction) { 48 this._categoryTransaction = categoryTransaction; 49 } 50 51 54 public void setUserTransaction(UserTransaction userTransaction) { 55 _userTransaction = userTransaction; 56 } 57 58 62 66 public String listCategory() throws Exception { 67 stats = _categoryTransaction.lastRegisteredUser(); 68 stats.setTotalPostCount(new Integer ((int) _categoryTransaction.countAllPosts())); 69 stats.setTotalRegisteredUsers(new Integer ((int) _categoryTransaction.countAllUsers())); 70 lstCategory = _categoryTransaction.listCategory(); 71 _userTransaction.updateVisitTimestamp(); 72 return SUCCESS; 73 } 74 75 80 public String loadCategory() throws Exception { 81 stats = _categoryTransaction.lastRegisteredUser(); 82 stats.setTotalPostCount(new Integer ((int) _categoryTransaction.countAllPosts())); 83 stats.setTotalRegisteredUsers(new Integer ((int) _categoryTransaction.countAllUsers())); 84 category = _categoryTransaction.obtainCategory(category); 85 lstCategory = _categoryTransaction.listCategory(); 86 _userTransaction.updateVisitTimestamp(); 87 return SUCCESS; 88 } 89 90 public String updateCategory(){ 91 _categoryTransaction.updateCategory(category.getIdCategory(), category); 92 return SUCCESS; 93 } 94 95 public String insertCategory(){ 96 _categoryTransaction.insertCategory(category); 97 return SUCCESS; 98 } 99 100 public String showEditCategory(){ 101 category = _categoryTransaction.loadCategory(category.getIdCategory()); 102 return SUCCESS; 103 } 104 105 106 110 public String listAllCategory() throws Exception { 111 lstCategory = _categoryTransaction.findAll(); 112 return SUCCESS; 113 } 114 115 public String deleteCategory() throws Exception { 116 _categoryTransaction.deleteCategory(category); 117 return SUCCESS; 118 } 119 120 124 127 public Category getCategory() { 128 return category; 129 } 130 131 134 public List getLstCategory() { 135 return lstCategory; 136 } 137 138 141 public Stats getStats() { 142 return stats; 143 } 144 } | Popular Tags |