private long createCoupon( String title, String startDate, String endDate, int amount, CouponType type, String massage, double price) { System.out.println("creating coupon : " + title); Coupon coupon = new Coupon(); try { coupon.setStartDate(Utils.string2Date(startDate)); coupon.setEndDate(Utils.string2Date(endDate)); coupon.setTitle(title); coupon.setAmount(amount); coupon.setPrice(price); coupon.setType(type); coupon.setMassage(massage); String image = title + ".img"; coupon.setImage(image); compFacade.createCoupon(coupon); return coupon.getId(); } catch (Exception e) { logger.error("create coupons " + title + " failed : " + e.toString()); return 0; } }
private void expireCoupon(long couponId) { System.out.println("expiering coupon with id : " + couponId); try { Coupon coupon = compFacade.getCoupon(couponId); coupon.setEndDate(new Date()); // the DailyCouponExpirationTask will delete this coupon compFacade.updateCoupon(coupon); } catch (Exception e) { logger.error("expireCoupon failed : " + e.toString()); } }