Package com.jada.util

Examples of com.jada.util.JSONEscapeObject


    ItemMaintActionForm form = (ItemMaintActionForm) actionForm;
    AdminBean adminBean = getAdminBean(request);
    Site site = adminBean.getSite();
    initSiteProfiles(form, site);
   
      JSONEscapeObject jsonResult = new JSONEscapeObject();
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    jsonResult.put("customerClasses", getJSONCustomerClassesSegment(site));
    String jsonString = jsonResult.toHtmlString();
    streamWebService(response, jsonString);
    return null;
 
View Full Code Here


      }
    }
    item.setRecUpdateBy(adminBean.getUser().getUserId());
    item.setRecUpdateDatetime(new Date(System.currentTimeMillis()));

      JSONEscapeObject jsonResult = new JSONEscapeObject();
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    jsonResult.put("recUpdateBy", item.getRecUpdateBy());
    jsonResult.put("recUpdateDatetime", Format.getFullDatetime(item.getRecUpdateDatetime()));
    String jsonString = jsonResult.toHtmlString();
    streamWebService(response, jsonString);
    em.getTransaction().commit();
      return null;
  }
View Full Code Here

    AdminBean adminBean = getAdminBean(request);
    Site site = adminBean.getSite();
    initSiteProfiles(form, site);
   
    MessageResources resources = this.getResources(request);
    JSONEscapeObject jsonResult = new JSONEscapeObject();
    if (form.isSiteCurrencyClassDefault()) {
      if (Format.isNullOrEmpty(form.getItemTierQty())) {
        jsonResult.put("itemTierQty", resources.getMessage("error.string.required"));
      }
      else {
        if (!Format.isInt(form.getItemTierQty())) {
          jsonResult.put("itemTierQty", resources.getMessage("error.int.invalid"));
        }
      }
      if (Format.isNullOrEmpty(form.getItemTierPricePublishOn())) {
        jsonResult.put("itemTierPricePublishOn", resources.getMessage("error.string.required"));
      }
      else {
        if (!Format.isDate(form.getItemTierPricePublishOn())) {
          jsonResult.put("itemTierPricePublishOn", resources.getMessage("error.date.invalid"));
        }
      }
      if (Format.isNullOrEmpty(form.getItemTierPriceExpireOn())) {
        jsonResult.put("itemTierPriceExpireOn", resources.getMessage("error.string.required"));
      }
      else {
        if (!Format.isDate(form.getItemTierPriceExpireOn())) {
          jsonResult.put("itemTierPriceExpireOn", resources.getMessage("error.date.invalid"));
        }
      }
      if (jsonResult.length() > 0) {
        jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED);
        streamWebService(response, jsonResult.toHtmlString());
        return null;
      }
    }
    if (Format.isNullOrEmpty(form.getItemTierPrice())) {
      jsonResult.put("itemTierPrice", resources.getMessage("error.string.required"));
    }
    else {
      if (!Format.isInt(form.getItemTierPrice())) {
        jsonResult.put("itemTierPrice", resources.getMessage("error.float.invalid"));
      }
    }

       String itemTierPriceId = form.getItemTierPriceId();
    Item item = ItemDAO.load(site.getSiteId(), Format.getLong(form.getItemId()));
    ItemTierPrice itemTierPrice = null;
    ItemTierPriceCurrency itemTierPriceCurrency = null;
    boolean exist = true;
    if (!Format.isNullOrEmpty(itemTierPriceId)) {
      itemTierPrice = ItemTierPriceDAO.load(site.getSiteId(), Format.getLong(itemTierPriceId));
      itemTierPriceCurrency = itemTierPrice.getItemTierPriceCurrency();
    }
    else {
      itemTierPrice = new ItemTierPrice();
      itemTierPrice.setRecCreateBy(adminBean.getUser().getUserId());
      itemTierPrice.setRecCreateDatetime(new Date(System.currentTimeMillis()));
      itemTierPrice.setItem(item);
     
      itemTierPriceCurrency = new ItemTierPriceCurrency();
      exist = false;
      itemTierPriceCurrency.setRecCreateBy(adminBean.getUser().getUserId());
      itemTierPriceCurrency.setRecCreateDatetime(new Date(System.currentTimeMillis()));
      itemTierPrice.setItemTierPriceCurrency(itemTierPriceCurrency);
      itemTierPrice.getItemTierPriceCurrencies().add(itemTierPriceCurrency);
      SiteCurrencyClass siteCurrencyClass = SiteCurrencyClassDAO.load(form.getSiteCurrencyClassDefaultId());
      itemTierPriceCurrency.setSiteCurrencyClass(siteCurrencyClass);
    }
    if (form.isSiteCurrencyClassDefault()) {
      itemTierPriceCurrency.setItemPrice(Format.getFloat(form.getItemTierPrice()));
      itemTierPriceCurrency.setRecUpdateBy(adminBean.getUser().getUserId());
      itemTierPriceCurrency.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      if (!exist) {
        em.persist(itemTierPriceCurrency);
      }

      itemTierPrice.setItemTierQty(Format.getIntObj(form.getItemTierQty()));
      if (!Format.isNullOrEmpty(form.getItemTierPricePublishOn())) {
        itemTierPrice.setItemTierPricePublishOn(Format.getDate(form.getItemTierPricePublishOn()));
      }
      else {
        itemTierPrice.setItemTierPricePublishOn(null);
      }
      if (!Format.isNullOrEmpty(form.getItemTierPriceExpireOn())) {
        itemTierPrice.setItemTierPriceExpireOn(Format.getDate(form.getItemTierPriceExpireOn()));
      }
      else {
        itemTierPrice.setItemTierPriceExpireOn(null);
      }
      itemTierPrice.setRecUpdateBy(adminBean.getUser().getUserId());
      itemTierPrice.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      if (Format.isNullOrEmpty(form.getCustClassId())) {
        itemTierPrice.setCustomerClass(null);
      }
      else {
        CustomerClass customerClass = CustomerClassDAO.load(site.getSiteId(), Format.getLong(form.getCustClassId()));
        itemTierPrice.setCustomerClass(customerClass);
      }
      em.persist(itemTierPrice);
    }
    else {
      itemTierPriceCurrency = null;
      SiteCurrencyClass siteCurrencyClass = SiteCurrencyClassDAO.load(form.getSiteCurrencyClassId());
      for (ItemTierPriceCurrency priceCurrency : itemTierPrice.getItemTierPriceCurrencies()) {
        if (priceCurrency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClass.getSiteCurrencyClassId())) {
          itemTierPriceCurrency = priceCurrency;
          break;
        }
      }
      exist = true;
      if (itemTierPriceCurrency == null) {
        itemTierPriceCurrency = new ItemTierPriceCurrency();
        exist = false;
        itemTierPriceCurrency.setRecCreateBy(adminBean.getUser().getUserId());
        itemTierPriceCurrency.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        itemTierPriceCurrency.setItemTierPrice(itemTierPrice);
        itemTierPriceCurrency.setSiteCurrencyClass(siteCurrencyClass);
      }
      if (form.isItemTierPriceOverride()) {
        itemTierPriceCurrency.setItemPrice(Format.getFloat(form.getItemTierPrice()));
      }
      else {
        itemTierPriceCurrency.setItemPrice(null);
      }
      itemTierPriceCurrency.setRecUpdateBy(adminBean.getUser().getUserId());
      itemTierPriceCurrency.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      if (!exist) {
        em.persist(itemTierPriceCurrency);
      }
    }

    item.setRecUpdateBy(adminBean.getUser().getUserId());
    item.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
    em.persist(item);

    jsonResult = new JSONEscapeObject();
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    jsonResult.put("itemTierPriceId", itemTierPrice.getItemTierPriceId());
    jsonResult.put("recUpdateBy", item.getRecUpdateBy());
    jsonResult.put("recUpdateDatetime", Format.getFullDatetime(item.getRecUpdateDatetime()));
    streamWebService(response, jsonResult.toHtmlString());
    return null;
  }
View Full Code Here

    ItemMaintActionForm form = (ItemMaintActionForm) actionForm;
    AdminBean adminBean = getAdminBean(request);
    Site site = adminBean.getSite();
    initSiteProfiles(form, site);
   
    JSONEscapeObject jsonResult = new JSONEscapeObject();
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    CustomAttributeGroup customAttributeGroup = CustomAttributeGroupDAO.load(site.getSiteId(), Format.getLong(form.getCustomAttribGroupId()));
    Vector<JSONEscapeObject> customAttributeDetails = new Vector<JSONEscapeObject>();
    for (CustomAttributeDetail customAttributeDetail : customAttributeGroup.getCustomAttributeDetails()) {
      JSONEscapeObject result = new JSONEscapeObject();
      result.put("customAttribDetailId", customAttributeDetail.getCustomAttribDetailId());
      result.put("customAttribDesc", customAttributeDetail.getCustomAttribute().getCustomAttributeLanguage().getCustomAttribDesc());
      customAttributeDetails.add(result);
    }
    jsonResult.put("customAttributeDetails", customAttributeDetails);
 
    streamWebService(response, jsonResult.toHtmlString());
View Full Code Here

    item.setItemHitCounter(new Integer(0));
    item.setRecUpdateBy(adminBean.getUser().getUserId());
    item.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
    // em.update(item);
   
      JSONEscapeObject jsonResult = new JSONEscapeObject();
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    jsonResult.put("recUpdateBy", item.getRecUpdateBy());
    jsonResult.put("recUpdateDatetime", Format.getFullDatetime(item.getRecUpdateDatetime()));
    String jsonString = jsonResult.toHtmlString();
    streamWebService(response, jsonString);
    em.getTransaction().commit();
      return null;
  }
View Full Code Here

    ItemMaintActionForm form = (ItemMaintActionForm) actionForm;
    AdminBean adminBean = getAdminBean(request);
   
    Item item = new Item();
    item = ItemDAO.load(adminBean.getSite().getSiteId(), Format.getLong(form.getItemId()));
    JSONEscapeObject jsonResult = new JSONEscapeObject();
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    Iterator<?> iterator = item.getComments().iterator();
    Vector<JSONEscapeObject> comments = new Vector<JSONEscapeObject>();
    while (iterator.hasNext()) {
      Comment comment = (Comment) iterator.next();
      JSONEscapeObject jsonComment = new JSONEscapeObject();
      jsonComment.put("commentId", comment.getCommentId());
      jsonComment.put("commentTitle", comment.getCommentTitle());
      jsonComment.put("comment", comment.getComment());
      jsonComment.put("moderation", comment.getModeration());
      jsonComment.put("commentApproved", comment.getCommentApproved());
      jsonComment.put("custEmail", comment.getCustomer().getCustEmail());
      jsonComment.put("custPublicName", comment.getCustomer().getCustPublicName());
      jsonComment.put("recCreateDatetime", Format.getFullDatetime(comment.getRecCreateDatetime()));
      jsonComment.put("agreeCount", comment.getAgreeCustomers().size());
      jsonComment.put("disagreeCount", comment.getDisagreeCustomers().size());
      comments.add(jsonComment);
    }
    jsonResult.put("comments", comments);
    String jsonString = jsonResult.toHtmlString();
    streamWebService(response, jsonString);
View Full Code Here

        HttpServletResponse response)
    throws Throwable {
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    ItemMaintActionForm form = (ItemMaintActionForm) actionForm;
    AdminBean adminBean = getAdminBean(request);
      JSONEscapeObject jsonResult = new JSONEscapeObject();
    MessageResources resources = this.getResources(request);
   
    Item item = new Item();
    item = ItemDAO.load(adminBean.getSite().getSiteId(), Format.getLong(form.getItemId()), LockModeType.WRITE);
    if (!Format.isInt(form.getItemAdjQty())) {
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED);
      jsonResult.put("message", resources.getMessage("error.int.invalid"));
      String jsonString = jsonResult.toHtmlString();
      streamWebService(response, jsonString);
      em.getTransaction().commit();
        return null;
      }

    int itemQty = Format.getInt(form.getItemAdjQty());
    InventoryEngine engine = new InventoryEngine(item.getItemId());
    engine.adjustQty(itemQty);
    form.setItemAdjQty("");
    item.setRecUpdateBy(adminBean.getUser().getUserId());
    item.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
    // em.update(item);
   
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    jsonResult.put("itemQty", Format.getInt(item.getItemQty()));
    jsonResult.put("recUpdateBy", item.getRecUpdateBy());
    jsonResult.put("recUpdateDatetime", Format.getFullDatetime(item.getRecUpdateDatetime()));
    String jsonString = jsonResult.toHtmlString();
    streamWebService(response, jsonString);
    em.getTransaction().commit();
      return null;
  }
View Full Code Here

    throws Throwable {
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    ItemMaintActionForm form = (ItemMaintActionForm) actionForm;
    AdminBean adminBean = getAdminBean(request);
        initSiteProfiles(form, adminBean.getSite());
      JSONEscapeObject jsonResult = new JSONEscapeObject();
    MessageResources resources = this.getResources(request);
 
    Item item = new Item();
    item = ItemDAO.load(adminBean.getSite().getSiteId(), Format.getLong(form.getItemId()), LockModeType.WRITE);
    if (!Format.isInt(form.getItemAdjBookedQty())) {
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED);
      jsonResult.put("message", resources.getMessage("error.int.invalid"));
      String jsonString = jsonResult.toHtmlString();
      streamWebService(response, jsonString);
      em.getTransaction().commit();
        return null;
      }

    int itemBookedQty = Format.getInt(form.getItemAdjBookedQty());
    InventoryEngine engine = new InventoryEngine(item.getItemId());
    engine.adjustBookedQty(itemBookedQty);
    item.setRecUpdateBy(adminBean.getUser().getUserId());
    item.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
    form.setItemAdjBookedQty("");
    // em.update(item);
   
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    jsonResult.put("itemBookedQty", Format.getInt(item.getItemBookedQty()));
    jsonResult.put("recUpdateBy", item.getRecUpdateBy());
    jsonResult.put("recUpdateDatetime", Format.getFullDatetime(item.getRecUpdateDatetime()));
    String jsonString = jsonResult.toHtmlString();
    streamWebService(response, jsonString);
    em.getTransaction().commit();
      return null;
  }
View Full Code Here

      Long shippingRegionId = Format.getLong(form.getShippingRegionId());
      Long shippingMethodId = Format.getLong(form.getShippingMethodId());
      Long shippingTypeId = Format.getLong(form.getShippingTypeId());
    ShippingMethod shippingMethod = (ShippingMethod) em.find(ShippingMethod.class, Format.getLong(form.getShippingMethodId()));
   
    JSONEscapeObject jsonResult = new JSONEscapeObject();
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    JSONEscapeObject jsonRate = new JSONEscapeObject();
      jsonRate.put("siteCurrencyClassId", form.getSiteCurrencyClassId());
      jsonRate.put("siteCurrencyClassDefault", form.isSiteCurrencyClassDefault());
      jsonRate.put("shippingRegionId", shippingRegionId.toString());
      jsonRate.put("shippingTypeId", shippingTypeId.toString());
      jsonRate.put("shippingMethodId", shippingMethodId.toString());
    ShippingRate shippingRate = new ShippingRate();
    for (ShippingMethodRegion shippingMethodRegion : shippingMethod.getShippingMethodRegions()) {
      if (shippingMethodRegion.getShippingRegion().getShippingRegionId().equals(shippingRegionId)) {
        for (ShippingMethodRegionType shippingMethodRegionType : shippingMethodRegion.getShippingMethodRegionTypes()) {
          if (shippingMethodRegionType.getShippingType().getShippingTypeId().equals(shippingTypeId)) {
            if (shippingMethodRegionType.getShippingRate() != null) {
              shippingRate = shippingMethodRegionType.getShippingRate();
            }
          }
        }
      }
    }
    ShippingRateCurrency shippingRateCurrency = new ShippingRateCurrency();
    if (shippingRate.getShippingRateCurrency() != null) {
      shippingRateCurrency = shippingRate.getShippingRateCurrency();
    }
    if (shippingRateCurrency.getShippingRateFee() != null) {
      jsonRate.put("shippingRateFee", Format.getFloat(shippingRate.getShippingRateCurrency().getShippingRateFee()));
    }
    else {
      jsonRate.put("shippingRateFee", "");
    }
    if (shippingRate.getShippingRatePercentage() != null) {
      jsonRate.put("shippingRatePercentage", Format.getFloat(shippingRate.getShippingRatePercentage()));
    }
    else {
      jsonRate.put("shippingRatePercentage", "");
    }
    if (shippingRateCurrency.getShippingAdditionalRateFee() != null) {
      jsonRate.put("shippingAdditionalRateFee", Format.getFloat(shippingRate.getShippingRateCurrency().getShippingAdditionalRateFee()));
    }
    else {
      jsonRate.put("shippingAdditionalRateFee", "");
    }
    if (shippingRate.getShippingAdditionalRatePercentage() != null) {
      jsonRate.put("shippingAdditionalRatePercentage", Format.getFloat(shippingRate.getShippingAdditionalRatePercentage()));
    }
    else {
      jsonRate.put("shippingAdditionalRatePercentage", "");
    }
   
    if (!form.isSiteCurrencyClassDefault()) {
      shippingRateCurrency = new ShippingRateCurrency();
      for (ShippingRateCurrency srCurrency : shippingRate.getShippingRateCurrencies()) {
        if (srCurrency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(form.getSiteCurrencyClassId())) {
          shippingRateCurrency = srCurrency;
          break;
        }
      }
      if (shippingRateCurrency.getShippingRateFee() != null) {
        jsonRate.put("shippingRateFeeCurr", Format.getFloat(shippingRateCurrency.getShippingRateFee()));
        jsonRate.put("shippingRateFeeCurrFlag", true);
      }
      else {
        jsonRate.put("shippingRateFeeCurr", "");
        jsonRate.put("shippingRateFeeCurrFlag", false);
      }
      if (shippingRateCurrency.getShippingAdditionalRateFee() != null) {
        jsonRate.put("shippingAdditionalRateFeeCurr", Format.getFloat(shippingRateCurrency.getShippingAdditionalRateFee()));
        jsonRate.put("shippingAdditionalRateFeeCurrFlag", true);
      }
      else {
        jsonRate.put("shippingAdditionalRateFeeCurr", "");
        jsonRate.put("shippingAdditionalRateFeeCurrFlag", false);
      }
    }
    jsonResult.put("shippingRate", jsonRate);
   
    this.streamWebService(response, jsonResult.toHtmlString());
View Full Code Here

      AdminBean adminBean = getAdminBean(request);
      ShippingMethodMaintActionForm form = (ShippingMethodMaintActionForm) actionForm;
      this.initSiteProfiles(form, adminBean.getSite());

    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    JSONEscapeObject jsonResult = new JSONEscapeObject();
 
      boolean error = false;
    MessageResources resources = this.getResources(request);
    if (form.isSiteCurrencyClassDefault()) {
      if (!Format.isNullOrEmpty(form.getShippingRateFee())) {
        if (!Format.isFloat(form.getShippingRateFee())) {
          jsonResult.put("shippingRateFeeError", resources.getMessage("error.float.invalid"));
          error = true;
        }
      }
      if (!Format.isNullOrEmpty(form.getShippingRatePercentage())) {
        if (!Format.isFloat(form.getShippingRatePercentage())) {
          jsonResult.put("shippingRatePercentageError", resources.getMessage("error.float.invalid"));
          error = true;
        }
      }
      if (!Format.isNullOrEmpty(form.getShippingAdditionalRateFee())) {
        if (!Format.isFloat(form.getShippingAdditionalRateFee())) {
          jsonResult.put("shippingRateAdditionalFeeError", resources.getMessage("error.float.invalid"));
          error = true;
        }
      }
      if (!Format.isNullOrEmpty(form.getShippingAdditionalRatePercentage())) {
        if (!Format.isFloat(form.getShippingAdditionalRatePercentage())) {
          jsonResult.put("shippingAdditionalRatePercentageError", resources.getMessage("error.float.invalid"));
          error = true;
        }
      }
    }
    else {
      if (!Format.isNullOrEmpty(form.getShippingRateFeeCurr())) {
        if (!Format.isFloat(form.getShippingRateFeeCurr())) {
          jsonResult.put("shippingRateFeeCurrError", resources.getMessage("error.float.invalid"));
          error = true;
        }
      }
      if (!Format.isNullOrEmpty(form.getShippingAdditionalRateFeeCurr())) {
        if (!Format.isFloat(form.getShippingAdditionalRateFeeCurr())) {
          jsonResult.put("shippingRateAdditionalFeeCurrError", resources.getMessage("error.float.invalid"));
          error = true;
        }
      }
    }
    if (error) {
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED);
      this.streamWebService(response, jsonResult.toHtmlString());
      return null;
    }
   
      Long shippingRegionId = Format.getLong(form.getShippingRegionId());
      Long shippingMethodId = Format.getLong(form.getShippingMethodId());
      Long shippingTypeId = Format.getLong(form.getShippingTypeId());
    ShippingMethod shippingMethod = (ShippingMethod) em.find(ShippingMethod.class, shippingMethodId);

    ShippingRate shippingRate = null;
    ShippingRateCurrency shippingRateCurrency = null;
    ShippingMethodRegionType shippingMethodRegionType = null;
    for (ShippingMethodRegion shippingMethodRegion : shippingMethod.getShippingMethodRegions()) {
      if (shippingMethodRegion.getShippingRegion().getShippingRegionId().equals(shippingRegionId)) {
        for (ShippingMethodRegionType smrt : shippingMethodRegion.getShippingMethodRegionTypes()) {
          if (smrt.getShippingType().getShippingTypeId().equals(shippingTypeId)) {
            shippingMethodRegionType = smrt;
            shippingRate = shippingMethodRegionType.getShippingRate();
            break;
          }
        }
      }
    }
    if (shippingRate == null) {
      shippingRate = new ShippingRate();
      shippingRate.setRecUpdateBy(adminBean.getUser().getUserId());
      shippingRate.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      shippingRate.setRecCreateBy(adminBean.getUser().getUserId());
      shippingRate.setRecCreateDatetime(new Date(System.currentTimeMillis()));
      shippingRate.setPublished(Constants.VALUE_YES);
      shippingMethodRegionType.setShippingRate(shippingRate);
    }
    if (form.isSiteCurrencyClassDefault()) {
      shippingRateCurrency = shippingRate.getShippingRateCurrency();
      if (shippingRateCurrency == null) {
        shippingRateCurrency = new ShippingRateCurrency();
        shippingRateCurrency.setShippingRate(shippingRate);
        shippingRateCurrency.setRecCreateBy(adminBean.getUser().getUserId());
        shippingRateCurrency.setRecCreateDatetime(new Date(System.currentTimeMillis()));
          SiteCurrencyClass siteCurrencyClass = SiteCurrencyClassDAO.load(form.getSiteCurrencyClassDefaultId());
          shippingRateCurrency.setSiteCurrencyClass(siteCurrencyClass);
        shippingRate.setShippingRateCurrency(shippingRateCurrency);
        shippingRate.getShippingRateCurrencies().add(shippingRateCurrency);
      }
      if (!Format.isNullOrEmpty(form.getShippingRateFee())) {
        shippingRateCurrency.setShippingRateFee(Format.getFloatObj(form.getShippingRateFee()));
      }
      if (!Format.isNullOrEmpty(form.getShippingRatePercentage())) {
        shippingRate.setShippingRatePercentage(Format.getFloatObj(form.getShippingRatePercentage()));
      }
      if (!Format.isNullOrEmpty(form.getShippingAdditionalRateFee())) {
        shippingRateCurrency.setShippingAdditionalRateFee(Format.getFloatObj(form.getShippingAdditionalRateFee()));
      }
      if (!Format.isNullOrEmpty(form.getShippingAdditionalRatePercentage())) {
        shippingRate.setShippingAdditionalRatePercentage(Format.getFloatObj(form.getShippingAdditionalRatePercentage()));
      }
      shippingRate.setRecUpdateBy(adminBean.getUser().getUserId());
      shippingRate.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
     
      shippingRateCurrency.setRecUpdateBy(adminBean.getUser().getUserId());
      shippingRateCurrency.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      if (shippingRateCurrency.getShippingRateCurrId() == null) {
        em.persist(shippingRateCurrency);
      }
      if (shippingRate.getShippingRateId() == null) {
        em.persist(shippingRate);
      }
 
      if (shippingRate.getShippingRateCurrency().getShippingRateFee() != null) {
        jsonResult.put("shippingRateFee", Format.getFloat(shippingRate.getShippingRateCurrency().getShippingRateFee()));
      }
      else {
        jsonResult.put("shippingRateFee", "");
      }
      if (shippingRate.getShippingRatePercentage() != null) {
        jsonResult.put("shippingRatePercentage", Format.getFloat(shippingRate.getShippingRatePercentage()));
      }
      else {
        jsonResult.put("shippingRatePercentage", "");
      }
      if (shippingRate.getShippingRateCurrency().getShippingAdditionalRateFee() != null) {
        jsonResult.put("shippingAdditionalRateFee", Format.getFloat(shippingRate.getShippingRateCurrency().getShippingAdditionalRateFee()));
      }
      else {
        jsonResult.put("shippingAdditionalRateFee", "");
      }
      if (shippingRate.getShippingAdditionalRatePercentage() != null) {
        jsonResult.put("shippingAdditionalRatePercentage", Format.getFloat(shippingRate.getShippingAdditionalRatePercentage()));
      }
      else {
        jsonResult.put("shippingAdditionalRatePercentage", "");
      }
    }
    else {
      shippingRateCurrency = null;
      for (ShippingRateCurrency srCurrency : shippingRate.getShippingRateCurrencies()) {
        if (srCurrency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(form.getSiteCurrencyClassId())) {
          shippingRateCurrency = srCurrency;
        }
      }
      if (shippingRateCurrency == null) {
        shippingRateCurrency = new ShippingRateCurrency();
        SiteCurrencyClass siteCurrencyClass = SiteCurrencyClassDAO.load(form.getSiteCurrencyClassId());
        shippingRateCurrency.setRecCreateBy(adminBean.getUser().getUserId());
        shippingRateCurrency.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        shippingRateCurrency.setSiteCurrencyClass(siteCurrencyClass);
        shippingRateCurrency.setShippingRate(shippingRate);
        shippingRate.getShippingRateCurrencies().add(shippingRateCurrency);
      }
      shippingRate.setRecUpdateBy(adminBean.getUser().getUserId());
      shippingRate.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
     
      if (form.isShippingRateFeeCurrFlag()) {
        shippingRateCurrency.setShippingRateFee(Format.getFloat(form.getShippingRateFeeCurr()));
      }
      else {
        shippingRateCurrency.setShippingRateFee(null);
      }
      if (form.isShippingAdditionalRateFeeCurrFlag()) {
        shippingRateCurrency.setShippingAdditionalRateFee(Format.getFloat(form.getShippingAdditionalRateFeeCurr()));
      }
      else {
        shippingRateCurrency.setShippingAdditionalRateFee(null);
      }
      shippingRateCurrency.setRecUpdateBy(adminBean.getUser().getUserId());
      shippingRateCurrency.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      if (shippingRate.getShippingRateId() == null) {
        em.persist(shippingRate);
      }
      if (shippingRateCurrency.getShippingRateCurrId() == null) {
        em.persist(shippingRateCurrency);
      }
     
      if (shippingRate.getShippingRateCurrency() != null && shippingRate.getShippingRateCurrency().getShippingRateFee() != null) {
        jsonResult.put("shippingRateFee", Format.getFloat(shippingRate.getShippingRateCurrency().getShippingRateFee()));
      }
      else {
        jsonResult.put("shippingRateFee", "");
      }
      if (shippingRate.getShippingRatePercentage() != null) {
        jsonResult.put("shippingRatePercentage", Format.getFloat(shippingRate.getShippingRatePercentage()));
      }
      else {
        jsonResult.put("shippingRatePercentage", "");
      }
      if (shippingRate.getShippingRateCurrency() != null && shippingRate.getShippingRateCurrency().getShippingAdditionalRateFee() != null) {
        jsonResult.put("shippingAdditionalRateFee", Format.getFloat(shippingRate.getShippingRateCurrency().getShippingAdditionalRateFee()));
      }
      else {
        jsonResult.put("shippingAdditionalRateFee", "");
      }
      if (shippingRate.getShippingAdditionalRatePercentage() != null) {
        jsonResult.put("shippingAdditionalRatePercentage", Format.getFloat(shippingRate.getShippingAdditionalRatePercentage()));
      }
      else {
        jsonResult.put("shippingAdditionalRatePercentage", "");
      }
      if (shippingRateCurrency.getShippingRateFee() != null) {
        jsonResult.put("shippingRateFeeCurr", Format.getFloat(shippingRateCurrency.getShippingRateFee()));
        jsonResult.put("shippingRateFeeCurrFlag", true);
      }
      else {
        jsonResult.put("shippingRateFeeCurr", "");
        jsonResult.put("shippingRateFeeCurrFlag", false);
      }
      if (shippingRateCurrency.getShippingAdditionalRateFee() != null) {
        jsonResult.put("shippingAdditionalRateFeeCurr", Format.getFloat(shippingRateCurrency.getShippingAdditionalRateFee()));
        jsonResult.put("shippingAdditionalRateFeeCurrFlag", true);
      }
      else {
        jsonResult.put("shippingAdditionalRateFeeCurr", "");
        jsonResult.put("shippingAdditionalRateFeeCurrFlag", false);
      }
    }
   
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    this.streamWebService(response, jsonResult.toHtmlString());
    return null;
    }
View Full Code Here

TOP

Related Classes of com.jada.util.JSONEscapeObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.