1 package com.dotmarketing.portlets.product.struts; 2 3 import java.util.List ; 4 5 import javax.portlet.ActionRequest; 6 import javax.servlet.http.HttpServletRequest ; 7 8 import org.apache.struts.Globals; 9 import org.apache.struts.action.ActionErrors; 10 import org.apache.struts.action.ActionMapping; 11 import org.apache.struts.action.ActionMessage; 12 import org.apache.struts.validator.ValidatorForm; 13 14 import com.dotmarketing.util.UtilMethods; 15 import com.liferay.portal.util.Constants; 16 import com.dotmarketing.portlets.product.model.ProductPrice; 17 18 public class ProductFormatForm extends ValidatorForm { 19 20 private static final long serialVersionUID = 1L; 21 22 private long inode; private long productInode; private String formatName; private String itemNum; private String format; private int inventoryQuantity; private int reorderTrigger; private float weight; private int width; private int height; private int depth; 35 private long priceInode; private long productFormatInode; private int minQty; private int maxQty; private float retailPrice; private float partnerPrice; 43 private List <ProductPrice> prices; 44 45 public ProductFormatForm() { 46 } 47 48 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { 49 if(request.getParameter("cmd")!=null && request.getParameter("cmd").equals(Constants.ADD)) { 50 return super.validate(mapping, request); 51 } 52 return null; 53 } 54 55 public int getDepth() { 56 return depth; 57 } 58 59 public void setDepth(int depth) { 60 this.depth = depth; 61 } 62 63 public String getFormat() { 64 return format; 65 } 66 67 public void setFormat(String format) { 68 this.format = format; 69 } 70 71 public String getFormatName() { 72 return formatName; 73 } 74 75 public void setFormatName(String formatName) { 76 this.formatName = formatName; 77 } 78 79 public int getHeight() { 80 return height; 81 } 82 83 public void setHeight(int height) { 84 this.height = height; 85 } 86 87 public long getInode() { 88 return inode; 89 } 90 91 public void setInode(long inode) { 92 this.inode = inode; 93 } 94 95 public int getInventoryQuantity() { 96 return inventoryQuantity; 97 } 98 99 public void setInventoryQuantity(int inventoryQuantity) { 100 this.inventoryQuantity = inventoryQuantity; 101 } 102 103 public String getItemNum() { 104 return itemNum; 105 } 106 107 public void setItemNum(String itemNum) { 108 this.itemNum = itemNum; 109 } 110 111 public long getProductInode() { 112 return productInode; 113 } 114 115 public void setProductInode(long productInode) { 116 this.productInode = productInode; 117 } 118 119 public int getReorderTrigger() { 120 return reorderTrigger; 121 } 122 123 public void setReorderTrigger(int reorderTrigger) { 124 this.reorderTrigger = reorderTrigger; 125 } 126 127 public float getWeight() { 128 return weight; 129 } 130 131 public void setWeight(float weight) { 132 this.weight = weight; 133 } 134 135 public int getWidth() { 136 return width; 137 } 138 139 public void setWidth(int width) { 140 this.width = width; 141 } 142 143 public List <ProductPrice> getPrices() { 144 return prices; 145 } 146 147 public void setPrices(List <ProductPrice> prices) { 148 this.prices = prices; 149 } 150 151 public ActionErrors validate(ActionMapping mapping,ActionRequest req) 152 { 153 ActionErrors ae = new ActionErrors(); 154 if(!UtilMethods.isSet(formatName)) 155 { 156 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Format Name")); 157 } 158 if(!UtilMethods.isSet(itemNum)) 159 { 160 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Item # or ISBN (Books)")); 161 } 162 if(inventoryQuantity == 0) 163 { 164 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Inventory Quantity")); 165 } 166 if(reorderTrigger == 0) 167 { 168 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Reorder Trigger")); 169 } 170 return ae; 171 } 172 173 public long getPriceInode() { 175 return priceInode; 176 } 177 178 public void setPriceInode(long priceInode) { 179 this.priceInode = priceInode; 180 } 181 182 public int getMaxQty() { 183 return maxQty; 184 } 185 186 public void setMaxQty(int maxQty) { 187 this.maxQty = maxQty; 188 } 189 190 public int getMinQty() { 191 return minQty; 192 } 193 194 public void setMinQty(int minQty) { 195 this.minQty = minQty; 196 } 197 198 public float getPartnerPrice() { 199 return partnerPrice; 200 } 201 202 public void setPartnerPrice(float partnerPrice) { 203 this.partnerPrice = partnerPrice; 204 } 205 206 public long getProductFormatInode() { 207 return productFormatInode; 208 } 209 210 public void setProductFormatInode(long productFormatInode) { 211 this.productFormatInode = productFormatInode; 212 } 213 214 public float getRetailPrice() { 215 return retailPrice; 216 } 217 218 public void setRetailPrice(float retailPrice) { 219 this.retailPrice = retailPrice; 220 } 221 222 public ActionErrors validatePrice(ActionMapping mapping,ActionRequest req) 223 { 224 ActionErrors ae = new ActionErrors(); 225 if(minQty < 0) 226 { 227 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.format","Min Qty")); 228 } 229 if(maxQty < 0 || maxQty < minQty) 230 { 231 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.format","Max Qty")); 232 } 233 if(retailPrice < 0) 234 { 235 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.format","Retail Price")); 236 } 237 if(partnerPrice < 0) 238 { 239 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.format","Partner Price")); 240 } 241 return ae; 242 } 243 } 244 | Popular Tags |