Ejemplo n.º 1
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());
    }
  }
Ejemplo n.º 2
0
  private void updateCoupon(long couponId) {
    System.out.println("updating coupon with id : " + couponId);

    try {
      Coupon coupon = compFacade.getCoupon(couponId);
      coupon.setAmount(100);
      coupon.setPrice(coupon.getPrice() / 2);
      compFacade.updateCoupon(coupon);
    } catch (Exception e) {
      logger.error("updateCoupon failed : " + e.toString());
    }
  }
Ejemplo n.º 3
0
  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;
    }
  }
Ejemplo n.º 4
0
 private void removeCoupon(long couponId) {
   System.out.println("removing coupon with id : " + couponId);
   try {
     compFacade.removeCoupon(couponId);
   } catch (Exception e) {
     logger.error("removeCoupon failed : " + e.toString());
   }
 }
Ejemplo n.º 5
0
 private void printCouponsByType(CouponType type) {
   try {
     Collection<Coupon> coupon = compFacade.getCouponsByType(type);
     System.out.println("coupons of type " + type);
     printCoupons(coupon);
   } catch (Exception e) {
     logger.error("printCouponsByType  failed : " + e.toString());
   }
 }
Ejemplo n.º 6
0
 private void printCouponsByPrice(long price) {
   try {
     Collection<Coupon> coupon = compFacade.getCouponsByPrice(price);
     System.out.println("coupons cheaper then " + price);
     printCoupons(coupon);
   } catch (Exception e) {
     logger.error("printCouponsByPrice  failed : " + e.toString());
   }
 }
Ejemplo n.º 7
0
 private void printCouponByDate(String toDate) {
   try {
     Collection<Coupon> coupon = compFacade.getCouponsByDate(Utils.string2Date(toDate));
     System.out.println("coupons ending before " + toDate);
     printCoupons(coupon);
   } catch (Exception e) {
     logger.error("printCouponByDate  failed : " + e.toString());
   }
 }
Ejemplo n.º 8
0
  private void printCompany() {
    try {
      Company company =
          compFacade.getCompany(); // get the company that is associated with the facade
      System.out.println(company + " num coupons = " + company.getCoupons().size());

      printCoupons(company.getCoupons(), "\t");
    } catch (Exception e) {
      logger.error("printCompany failed : " + e.toString());
    }
  }