1 37 38 39 40 41 package golfShop.business.inventory; 42 43 import java.util.Vector ; 44 import com.lutris.appserver.server.user.*; 45 import golfShop.data.item.ItemDO; 46 import golfShop.data.item.CategoryDO; 47 import golfShop.spec.inventory.Inventory; 48 51 57 public class InventoryImpl implements Inventory{ 58 private boolean isCategoryObj; private long objectid; private String desc; private String ref; 64 67 public InventoryImpl(){} 68 69 public InventoryImpl(boolean IsCategoryObj, long ObjectId, String Desc, 70 String Ref) { 71 isCategoryObj = IsCategoryObj; 72 objectid = ObjectId; 73 desc = Desc; 74 ref = Ref; 75 } 76 77 80 private static String getCatDesc(CategoryDO c) { 81 String desc = c.getName(); 82 if (desc.equals("Main Menu")) { 83 desc = "Store Directory"; 84 } else if (desc.equals("MensApparel")) { 85 desc = "Men's Apparel"; 86 } else if (desc.equals("WomensApparel")) { 87 desc = "Women's Apparel"; 88 } 89 return desc; 90 } 91 92 95 public Vector getItems(long thisid) { 96 Vector retlist = new Vector (); 97 98 CategoryDO thecategory = CategoryDO.getCategory(thisid); 100 101 long[] catlist = thecategory.getSubCategories(); 103 for ( int count = 0; count < catlist.length ; count++) 104 { 105 CategoryDO c = CategoryDO.getCategory((int)catlist[count]); 106 107 InventoryImpl newinv = new InventoryImpl(true, 108 c.getObjectId(), 109 getCatDesc(c), 110 c.getName()); 111 retlist.addElement(newinv); 112 } 113 114 long[] itemlist = thecategory.getItems(); 116 for ( int count = 0; count < itemlist.length ; count++) 117 { 118 ItemDO theitem = ItemDO.getItemByObjectId(itemlist[count]); 120 121 InventoryImpl newinv = new InventoryImpl(false, 122 theitem.getObjectId(), 123 theitem.getName(), 124 theitem.getDescription()); 125 retlist.addElement(newinv); 126 } 127 128 return retlist; 129 } 130 public Inventory getParent(long childid) 131 { 132 CategoryDO cc = CategoryDO.getCategory(childid); 133 long pid = cc.getParentId(); 134 CategoryDO pc = CategoryDO.getCategory(pid); 135 if (pc.getObjectId() == cc.getObjectId()) 137 return null; 138 139 InventoryImpl pinv = new InventoryImpl(true, 140 pc.getObjectId(), 141 getCatDesc(pc), 142 pc.getName()); 143 return pinv; 144 } 145 146 148 public Inventory getInventoryById(long thisid) { 149 CategoryDO c = CategoryDO.getCategory(thisid); 151 InventoryImpl newinv = new InventoryImpl(true, 152 c.getObjectId(), 153 getCatDesc(c), 154 c.getName()); 155 return newinv; 156 } 157 158 public boolean isCategory() { 159 return isCategoryObj; 160 } 161 162 public long getObjectId() { 163 return objectid; 164 } 165 public String getDesc() { 166 return desc; 167 } 168 public String getRef() { 169 return ref; 170 } 171 } 172 | Popular Tags |