1 package org.apache.ojb.odmg.shared; 2 3 import org.apache.ojb.odmg.shared.ProductGroup; 4 import org.apache.commons.lang.builder.ToStringBuilder; 5 import org.apache.commons.lang.builder.EqualsBuilder; 6 7 8 12 public class Article implements org.apache.ojb.odmg.TransactionAware 13 { 14 15 public String toString() 16 { 17 return new ToStringBuilder(this) 18 .append("articleId", articleId) 19 .append("articleName", articleName) 20 .append("productGroup", (productGroup != null ? productGroup.getName() : null)) 21 .append("productGroupId", productGroupId) 22 .append("isSelloutArticle", isSelloutArticle) 23 .append("minimumStock", minimumStock) 24 .append("orderedUnits", orderedUnits) 25 .append("price", price) 26 .append("orderedUnits", orderedUnits) 27 .append("stock", stock) 28 .append("supplierId", supplierId) 29 .append("unit", unit) 30 .toString(); 31 } 32 33 34 private int articleId; 35 36 private String articleName; 37 38 private boolean isSelloutArticle; 39 40 private int minimumStock; 41 42 private int orderedUnits; 43 44 private double price; 45 46 private ProductGroup productGroup; 47 48 private int productGroupId; 49 50 private int stock; 51 52 private int supplierId; 53 54 private String unit; 55 56 public Article(int pArticleId, String pArticleName, 57 int pSupplierId, int pProcuctGroupId, 58 String pUnit, double pPrice, int pStock, 59 int pOrderedUnits, int pMinimumStock, 60 boolean pIsSelloutArticle) 61 { 62 articleId = pArticleId; 63 articleName = pArticleName; 64 supplierId = pSupplierId; 65 productGroupId = pProcuctGroupId; 66 unit = pUnit; 67 price = pPrice; 68 stock = pStock; 69 orderedUnits = pOrderedUnits; 70 minimumStock = pMinimumStock; 71 isSelloutArticle = pIsSelloutArticle; 72 73 } 74 75 public Article() 76 { 77 } 78 79 public static Article createInstance() 80 { 81 return new Article(); 82 } 83 84 85 88 public void addToStock(int diff) 89 { 90 stock += diff; 91 } 92 93 97 public int getArticleId() 98 { 99 return articleId; 100 } 101 102 106 public String getArticleName() 107 { 108 return articleName; 109 } 110 111 112 public ProductGroup getProductGroup() 113 { 114 return productGroup; 115 } 116 117 121 public int getStock() 122 { 123 return stock; 124 } 125 126 127 public double getStockValue() 128 { 129 return price * stock; 130 } 131 132 136 public void setArticleId(int articleId) 137 { 138 this.articleId = articleId; 139 } 140 141 145 public void setArticleName(String articleName) 146 { 147 this.articleName = articleName; 148 } 149 150 154 public void setStock(int stock) 155 { 156 this.stock = stock; 157 } 158 159 166 public void afterAbort() 167 { 168 } 170 171 175 public void afterCommit() 176 { 177 } 179 180 183 public void beforeAbort() 184 { 185 } 187 188 194 public void beforeCommit() throws org.odmg.TransactionAbortedException 195 { 196 } 198 199 200 public boolean equals(Object obj) 201 { 202 if (obj instanceof Article) 203 { 204 Article other = ((Article) obj); 205 return new EqualsBuilder() 206 .append(articleId, other.articleId) 207 .append(articleName, other.articleName) 208 .append(productGroupId, other.productGroupId) 209 .append(isSelloutArticle, other.isSelloutArticle) 210 .append(minimumStock, other.minimumStock) 211 .append(orderedUnits, other.orderedUnits) 212 .append(price, other.price) 213 .append(orderedUnits, other.orderedUnits) 214 .append(stock, other.stock) 215 .append(supplierId, other.supplierId) 216 .append(unit, other.unit) 217 .isEquals(); 218 } 219 else 220 return false; 221 } 222 223 224 227 public int hashCode() 228 { 229 return articleId; 231 } 232 233 237 public boolean getIsSelloutArticle() 238 { 239 return isSelloutArticle; 240 } 241 242 246 public void setIsSelloutArticle(boolean isSelloutArticle) 247 { 248 this.isSelloutArticle = isSelloutArticle; 249 } 250 251 255 public int getMinimumStock() 256 { 257 return minimumStock; 258 } 259 260 264 public void setMinimumStock(int minimumStock) 265 { 266 this.minimumStock = minimumStock; 267 } 268 269 273 public int getOrderedUnits() 274 { 275 return orderedUnits; 276 } 277 278 282 public void setOrderedUnits(int orderedUnits) 283 { 284 this.orderedUnits = orderedUnits; 285 } 286 287 291 public double getPrice() 292 { 293 return price; 294 } 295 296 300 public void setPrice(double price) 301 { 302 this.price = price; 303 } 304 305 309 public void setProductGroup(ProductGroup productGroup) 310 { 311 this.productGroup = productGroup; 312 } 313 314 318 public int getProductGroupId() 319 { 320 return productGroupId; 321 } 322 323 327 public void setProductGroupId(int productGroupId) 328 { 329 this.productGroupId = productGroupId; 330 } 331 332 336 public int getSupplierId() 337 { 338 return supplierId; 339 } 340 341 345 public void setSupplierId(int supplierId) 346 { 347 this.supplierId = supplierId; 348 } 349 350 354 public String getUnit() 355 { 356 return unit; 357 } 358 359 363 public void setUnit(String unit) 364 { 365 this.unit = unit; 366 } 367 368 } 369 | Popular Tags |