}
coupon.setCouponPriority(Integer.valueOf(form.getCouponPriority()));
coupon.setPublished(form.isPublished() ? Constants.PUBLISHED_YES : Constants.PUBLISHED_NO);
coupon.setRecUpdateBy(adminBean.getUser().getUserId());
coupon.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
CouponLanguage couponLanguage = coupon.getCouponLanguage();
if (couponLanguage == null) {
couponLanguage = new CouponLanguage();
couponLanguage.setCoupon(coupon);
coupon.getCouponLanguages().add(couponLanguage);
SiteProfileClass siteProfileClass = (SiteProfileClass) em.find(SiteProfileClass.class, form.getSiteProfileClassDefaultId());
couponLanguage.setSiteProfileClass(siteProfileClass);
couponLanguage.setRecCreateBy(adminBean.getUser().getUserId());
couponLanguage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
coupon.setCouponLanguage(couponLanguage);
}
CouponCurrency couponCurrency = coupon.getCouponCurrency();
if (couponCurrency == null) {
couponCurrency = new CouponCurrency();
couponCurrency.setCoupon(coupon);
coupon.getCouponCurrencies().add(couponCurrency);
SiteCurrencyClass siteCurrencyClass = (SiteCurrencyClass) em.find(SiteCurrencyClass.class, form.getSiteCurrencyClassDefaultId());
couponCurrency.setSiteCurrencyClass(siteCurrencyClass);
couponCurrency.setRecCreateBy(adminBean.getUser().getUserId());
couponCurrency.setRecCreateDatetime(new Date(System.currentTimeMillis()));
coupon.setCouponCurrency(couponCurrency);
}
couponLanguage.setCouponName(form.getCouponName());
couponLanguage.setRecUpdateBy(adminBean.getUser().getUserId());
couponLanguage.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
em.persist(couponLanguage);
couponCurrency.setCouponDiscountAmount(null);
couponCurrency.setCouponOrderAmount(null);
if (form.getCouponType().equals(Constants.COUPONTYPE_DISCOUNT_AMOUNT)) {