Package com.jada.util

Examples of com.jada.util.JSONEscapeObject


    initSiteProfiles(form, site);
   
    Item item = ItemDAO.load(site.getSiteId(), Format.getLong(form.getItemId()));
    Item itemCrossSell = ItemDAO.load(site.getSiteId(), Format.getLong(form.getItemCrossSellId()));
   
      JSONEscapeObject jsonResult = new JSONEscapeObject();
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
       EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    Iterator<?> iterator = item.getItemsCrossSell().iterator();
    while (iterator.hasNext()) {
      Item i = (Item) iterator.next();
      if (i.getItemId().equals(itemCrossSell.getItemId())) {
        MessageResources resources = this.getResources(request);
        jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED);
        jsonResult.put("message", resources.getMessage("error.item.exist"));
        streamWebService(response, jsonResult.toHtmlString());
        return null;
      }
    }
    item.getItemsCrossSell().add(itemCrossSell);
    item.setRecUpdateBy(adminBean.getUser().getUserId());
    item.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
    em.persist(item);

    jsonResult.put("recUpdateBy", item.getRecUpdateBy());
    jsonResult.put("recUpdateDatetime", Format.getFullDatetime(item.getRecUpdateDatetime()));
    streamWebService(response, jsonResult.toHtmlString());
    return null;
 
View Full Code Here


        }
        if (itemShortDesc != null && itemShortDesc.length() > 0) {
          query.setParameter("itemShortDesc", "%" + itemShortDesc + "%");
        }
        Iterator<?> iterator = query.getResultList().iterator();
      JSONEscapeObject jsonResult = new JSONEscapeObject();
      jsonResult.put("itemNum", itemNum);
      jsonResult.put("itemUpcCd", itemUpcCd);
      jsonResult.put("itemShortDesc", itemShortDesc);
      int counter = 0;
      Vector<JSONEscapeObject> vector = new Vector<JSONEscapeObject>();
        while (iterator.hasNext()) {
          Item item = (Item) iterator.next();
          JSONEscapeObject jsonItem = new JSONEscapeObject();
          jsonItem.put("itemId", item.getItemId());
          jsonItem.put("itemNum", item.getItemNum());
          jsonItem.put("itemUpcCd", item.getItemUpcCd());
          jsonItem.put("itemShortDesc", item.getItemLanguage().getItemShortDesc());
          vector.add(jsonItem);
          counter++;
          if (counter == Constants.ADMIN_SEARCH_MAXCOUNT) {
              MessageResources resources = this.getResources(request);
            jsonResult.put("message", resources.getMessage("error.lookup.tooManyRecord"));
View Full Code Here

            HttpServletResponse response) throws Exception {
     
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
        Site site = getAdminBean(request).getSite();

      JSONEscapeObject jsonResult = new JSONEscapeObject();
      Vector<JSONEscapeObject> countries = new Vector<JSONEscapeObject>();
        Query query = em.createQuery("from Country country where siteId = :siteId order by countryName");
    query.setParameter("siteId", site.getSiteId());
    Iterator<?> iterator = query.getResultList().iterator();
    while (iterator.hasNext()) {
      Country country = (Country) iterator.next();
      JSONEscapeObject jsonCountry = new JSONEscapeObject();
      jsonCountry.put("countryId", country.getCountryId());
      jsonCountry.put("countryCode", country.getCountryCode());
      jsonCountry.put("countryName", country.getCountryName());
      Iterator<?> iterator1 = country.getStates().iterator();
      Vector<JSONEscapeObject> states = new Vector<JSONEscapeObject>();
      while (iterator1.hasNext()) {
        State state = (State) iterator1.next();
        JSONEscapeObject jsonState = new JSONEscapeObject();
        jsonState.put("stateId", state.getStateId());
        jsonState.put("stateCode", state.getStateCode());
        jsonState.put("stateName", state.getStateName());
        states.add(jsonState);
      }
      jsonCountry.put("states", states);
      countries.add(jsonCountry);
    }
View Full Code Here

            ActionForm actionForm,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
     
        AdminBean adminBean = getAdminBean(request);
        JSONEscapeObject jsonCategory = Utility.makeJSONCategoryTree(adminBean.getSite().getSiteId(), null, true);
        String jsonString = jsonCategory.toHtmlString();
        this.streamWebService(response, jsonString);
        return null;
    }
View Full Code Here

               "order    by customAttribute.customAttribName ";
        Query query = em.createQuery(sql);
        query.setParameter("siteId", adminBean.getSite().getSiteId());
        query.setParameter("siteProfileClassId", adminBean.getSite().getSiteProfileClassDefault().getSiteProfileClassId());
        Iterator<?> iterator = query.getResultList().iterator();
      JSONEscapeObject jsonResult = new JSONEscapeObject();
      Vector<JSONEscapeObject> vector = new Vector<JSONEscapeObject>();
        while (iterator.hasNext()) {
          CustomAttribute customAttribute = (CustomAttribute) iterator.next();
          if (type != null && type.equals(LOOKUP_TYPE_FOR_CUSTOMATTRIBUTEGROUP)) {
/*
            if (customAttribute.getSystemRecord() == Constants.VALUE_YES) {
              continue;
            }
*/
          }
          if (type != null && type.equals(LOOKUP_TYPE_FOR_CUSTOMATTRIBUTECOMPARE)) {
/*
            if (customAttribute.getSystemRecord() == Constants.VALUE_YES) {
              continue;
            }
*/
            if (customAttribute.getCustomAttribTypeCode() != Constants.CUSTOM_ATTRIBUTE_TYPE_USER_SELECT_DROPDOWN) {
              continue;
            }
          }
          JSONEscapeObject jsonItem = new JSONEscapeObject();
          jsonItem.put("customAttribId", customAttribute.getCustomAttribId());
          jsonItem.put("customAttribName", customAttribute.getCustomAttribName());
          vector.add(jsonItem);
        }
        jsonResult.put("customAttributes", vector);
        String jsonString = jsonResult.toHtmlString();
        this.streamWebService(response, jsonString);
View Full Code Here

    Vector<ShippingRegion> srVector = new Vector<ShippingRegion>();
    while (iterator.hasNext()) {
      ShippingRegion shippingRegion = (ShippingRegion) iterator.next();
      srVector.add(shippingRegion);
     
      JSONEscapeObject JSONEscapeObject = new JSONEscapeObject();
      JSONEscapeObject.put("shippingRegionId", shippingRegion.getShippingRegionId().toString());
      JSONEscapeObject.put("shippingRegionName", shippingRegion.getShippingRegionName());
      jsonShippingRegions.add(JSONEscapeObject);
    }
    sql = "from ShippingRegion shippingRegion where shippingRegion.site.siteId = :siteId and shippingRegionName != :shippingRegionName order by shippingRegionName";
    query = em.createQuery(sql);
    query.setParameter("siteId", siteId);
    query.setParameter("shippingRegionName", Constants.SHIPPINGREGION_OTHERS);
    iterator = query.getResultList().iterator();
    srVector = new Vector<ShippingRegion>();
    while (iterator.hasNext()) {
      ShippingRegion shippingRegion = (ShippingRegion) iterator.next();
      srVector.add(shippingRegion);

      JSONEscapeObject JSONEscapeObject = new JSONEscapeObject();
      JSONEscapeObject.put("shippingRegionId", shippingRegion.getShippingRegionId().toString());
      JSONEscapeObject.put("shippingRegionName", shippingRegion.getShippingRegionName());
     
      boolean published = false;
      for (ShippingMethodRegion shippingMethodRegion : shippingMethod.getShippingMethodRegions()) {
        if (shippingMethodRegion.getShippingRegion().getShippingRegionId().equals(shippingRegion.getShippingRegionId())) {
          if (shippingMethodRegion.getPublished() == Constants.VALUE_YES) {
            published = true;
            break;
          }
        }
      }
      JSONEscapeObject.put("published", published);

      jsonShippingRegions.add(JSONEscapeObject);
    }
    ShippingRegion shippingRegions[] = new ShippingRegion[srVector.size()];
    srVector.toArray(shippingRegions);
   
    Vector<JSONEscapeObject> jsonShippingTypes = new Vector<JSONEscapeObject>();
    for (int i = 0; i < shippingTypes.length; i++) {
      JSONEscapeObject JSONEscapeObject = new JSONEscapeObject();
      JSONEscapeObject.put("shippingTypeId", shippingTypes[i].getShippingTypeId());
      JSONEscapeObject.put("shippingTypeName", shippingTypes[i].getShippingTypeName());
      for (int j = 0; j < shippingRegions.length; j++) {
        ShippingRate shippingRate = findRate(shippingMethod, shippingRegions[j], shippingTypes[i], user);
        JSONEscapeObject jsonShippingRate = new JSONEscapeObject();
        jsonShippingRate.put("shippingMethodId", shippingMethod.getShippingMethodId().toString());
        jsonShippingRate.put("shippingRegionId", shippingRegions[j].getShippingRegionId().toString());
        jsonShippingRate.put("shippingTypeId", shippingTypes[i].getShippingTypeId().toString());
        if (shippingRate != null) {
          JSONEscapeObject.put("exist", true);
          if (shippingRate.getShippingRateCurrency() == null || shippingRate.getShippingRateCurrency().getShippingRateFee() == null) {
            jsonShippingRate.put("shippingRateFee", "");
          }
          else {
            jsonShippingRate.put("shippingRateFee", Format.getFloat(shippingRate.getShippingRateCurrency().getShippingRateFee()));
          }
          if (shippingRate.getShippingRatePercentage() == null) {
            jsonShippingRate.put("shippingRatePercentage", "");
          }
          else {
            jsonShippingRate.put("shippingRatePercentage", Format.getFloat(shippingRate.getShippingRatePercentage()));
          }
          if (shippingRate.getShippingRateCurrency() == null || shippingRate.getShippingRateCurrency().getShippingAdditionalRateFee() == null) {
            jsonShippingRate.put("shippingAdditionalRateFee", "");
          }
          else {
            jsonShippingRate.put("shippingAdditionalRateFee", Format.getFloat(shippingRate.getShippingRateCurrency().getShippingAdditionalRateFee()));
          }
          if (shippingRate.getShippingAdditionalRatePercentage() == null) {
            jsonShippingRate.put("shippingAdditionalRatePercentage", "");
          }
          else {
            jsonShippingRate.put("shippingAdditionalRatePercentage", Format.getFloat(shippingRate.getShippingAdditionalRatePercentage()));
          }
          JSONEscapeObject.put(shippingRegions[j].getShippingRegionId().toString(), jsonShippingRate);
        }
        else {
          JSONEscapeObject.put("exist", false);
          jsonShippingRate.put("shippingRateFee", "");
          jsonShippingRate.put("shippingRatePercentage", "");
          jsonShippingRate.put("shippingAdditionalRateFee", "");
          jsonShippingRate.put("shippingAdditionalRatePercentage", "");
          JSONEscapeObject.put(shippingRegions[j].getShippingRegionId().toString(), jsonShippingRate);
        }
        if (!form.isSiteCurrencyClassDefault()) {
          if (shippingRate != null) {
            ShippingRateCurrency shippingRateCurrency = new ShippingRateCurrency();
            for (ShippingRateCurrency srCurrency : shippingRate.getShippingRateCurrencies()) {
              if (srCurrency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(form.getSiteCurrencyClassId())) {
                shippingRateCurrency = srCurrency;
                break;
              }
            }
            if (shippingRateCurrency.getShippingRateFee() != null) {
              jsonShippingRate.put("shippingRateFeeCurr", Format.getFloat(shippingRateCurrency.getShippingRateFee()));
              jsonShippingRate.put("shippingRateFeeCurrFlag", true);
            }
            else {
              jsonShippingRate.put("shippingRateFeeCurr", "");
              jsonShippingRate.put("shippingRateFeeCurrFlag", false);
            }
            if (shippingRateCurrency.getShippingAdditionalRateFee() != null) {
              jsonShippingRate.put("shippingAdditionalRateFeeCurr", Format.getFloat(shippingRateCurrency.getShippingAdditionalRateFee()));
              jsonShippingRate.put("shippingAdditionalRateFeeCurrFlag", true);
            }
            else {
              jsonShippingRate.put("shippingAdditionalRateFeeCurr", "");
              jsonShippingRate.put("shippingAdditionalRateFeeCurrFlag", false);
            }
          }
          else {
            jsonShippingRate.put("shippingRateFeeCurr", "");
            jsonShippingRate.put("shippingRateFeeCurrFlag", false);
            jsonShippingRate.put("shippingAdditionalRateFeeCurr", "");
            jsonShippingRate.put("shippingAdditionalRateFeeCurrFlag", false);
          }
        }
      }
      jsonShippingTypes.add(JSONEscapeObject);
    }
    JSONEscapeObject JSONEscapeObject = new JSONEscapeObject();
    JSONEscapeObject.put("shippingRegions", jsonShippingRegions);
    JSONEscapeObject.put("shippingTypes", jsonShippingTypes);
    form.setJsonShippingTypes(JSONEscapeObject.toHtmlString());
  }
View Full Code Here

            HttpServletResponse response)
    throws Throwable {
   
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    SiteMaintActionForm form = (SiteMaintActionForm) actionForm;
      JSONEscapeObject jsonResult = new JSONEscapeObject();
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);

    try {
      String siteDomainIds[] = form.getSiteDomainIds();
      for (int i = 0; i < siteDomainIds.length; i++) {
        Long siteDomainId = Format.getLong(siteDomainIds[i]);
        SiteDomainDAO.remove(siteDomainId);
      }
      em.getTransaction().commit();
    }
    catch (Exception e) {
      if (Utility.isConstraintViolation(e)) {
        MessageResources resources = this.getResources(request);
        jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED);
        jsonResult.put("message", resources.getMessage("error.remove.site.constraint"));
      }
      throw e;
    }
   
    streamWebService(response, jsonResult.toHtmlString());
    return null;
  }
View Full Code Here

        HttpServletResponse response)
      throws Throwable {
    AdminBean adminBean = getAdminBean(request);
    SiteMaintActionForm form = (SiteMaintActionForm) actionForm;
        Site site = SiteDAO.load(form.getSiteId());
      JSONEscapeObject jsonResult = new JSONEscapeObject();
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
      Vector<JSONEscapeObject> siteDomains = new Vector<JSONEscapeObject>();
      SiteDomain siteDomainDefault = site.getSiteDomainDefault();
    JSONEscapeObject object = new JSONEscapeObject();
    Long siteDomainDefaultId = siteDomainDefault.getSiteDomainId();
    object.put("siteDomainId", siteDomainDefault.getSiteDomainId());
    object.put("siteName", siteDomainDefault.getSiteDomainLanguage().getSiteName());
    object.put("siteDomainPrefix", siteDomainDefault.getSiteDomainPrefix());
    object.put("sitePublicPortNum", siteDomainDefault.getSitePublicPortNum());
    object.put("siteDomainPrefix", siteDomainDefault.getSiteDomainPrefix());
    object.put("siteDomainUrl", Utility.formatDomainURL(siteDomainDefault, adminBean.getContextPath()));
    object.put("master", true);
    object.put("active", siteDomainDefault.getActive());
    siteDomains.add(object);

      java.util.Iterator<SiteDomain> iterator = site.getSiteDomains().iterator();
      while (iterator.hasNext()) {
        SiteDomain siteDomain = (SiteDomain) iterator.next();
        if (siteDomain.getSiteDomainId().equals(siteDomainDefaultId)) {
          continue;
        }
        object = new JSONEscapeObject();
        object.put("siteDomainId", siteDomain.getSiteDomainId());
        object.put("siteName", siteDomain.getSiteDomainLanguage().getSiteName());
        object.put("siteDomainPrefix", siteDomain.getSiteDomainPrefix());
        object.put("sitePublicPortNum", siteDomain.getSitePublicPortNum());
        object.put("siteDomainPrefix", siteDomain.getSiteDomainPrefix());
        object.put("siteDomainUrl", Utility.formatDomainURL(siteDomain, adminBean.getContextPath()));
        object.put("master", false);
        object.put("active", siteDomain.getActive());
        siteDomains.add(object);
      }
      jsonResult.put("siteDomains", siteDomains);
      String result = jsonResult.toHtmlString();
    streamWebService(response, result);
View Full Code Here

            "order    by customerClass.custClassName ";  
    Query query = em.createQuery(sql);
    query.setParameter("siteId", site.getSiteId());
    Iterator<?> iterator = query.getResultList().iterator();
    Vector<JSONEscapeObject> custClasses = new Vector<JSONEscapeObject>();
    JSONEscapeObject object = new JSONEscapeObject();
    object.put("custClassId", "");
    object.put("custClassName", "All");
    custClasses.add(object);
    while (iterator.hasNext()) {
      CustomerClass customerClass = (CustomerClass) iterator.next();
      object = new JSONEscapeObject();
      object.put("custClassId", customerClass.getCustClassId());
      object.put("custClassName", customerClass.getCustClassName());
      custClasses.add(object);
    }
    return custClasses;
  }
View Full Code Here

    }
    return custClasses;
  }
 
  private String getJSONItemTierPrice(ItemTierPrice itemTierPrice, ItemMaintActionForm form) throws Exception {
      JSONEscapeObject jsonResult = new JSONEscapeObject();
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    jsonResult.put("itemTierPriceId", itemTierPrice.getItemTierPriceId());
    jsonResult.put("customerClasses", getJSONCustomerClassesSegment(itemTierPrice.getItem().getSite()));
    if (itemTierPrice.getCustomerClass() != null) {
      jsonResult.put("custClassId", itemTierPrice.getCustomerClass().getCustClassId());
    }
    else {
      jsonResult.put("custClassId", "");
    }
    jsonResult.put("itemTierQty", itemTierPrice.getItemTierQty());
    jsonResult.put("itemTierPrice", Format.getFloat(itemTierPrice.getItemTierPriceCurrency().getItemPrice()));
    if (itemTierPrice.getItemTierPricePublishOn() != null) {
      jsonResult.put("itemTierPricePublishOn", Format.getDate(itemTierPrice.getItemTierPricePublishOn()));
    }
    else {
      jsonResult.put("itemTierPricePublishOn", "");
    }
    if (itemTierPrice.getItemTierPriceExpireOn() != null) {
      jsonResult.put("itemTierPriceExpireOn", Format.getDate(itemTierPrice.getItemTierPriceExpireOn()));
    }
    else {
      jsonResult.put("itemTierPriceExpireOn", "");
    }
    if (!form.isSiteCurrencyClassDefault()) {
      Long siteCurrencyClassId = form.getSiteCurrencyClassId();
      ItemTierPriceCurrency itemTierPriceCurrency = null;
      for (ItemTierPriceCurrency priceCurrency : itemTierPrice.getItemTierPriceCurrencies()) {
        if (priceCurrency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClassId)) {
          itemTierPriceCurrency = priceCurrency;
          break;
        }
      }
      if (itemTierPriceCurrency != null) {
        if (itemTierPriceCurrency.getItemPrice() == null) {
          jsonResult.put("itemTierPriceCurrFlag", false);
        }
        else {
          jsonResult.put("itemTierPriceCurrFlag", true);
          jsonResult.put("itemTierPriceCurr", itemTierPriceCurrency.getItemPrice());
        }
      }
    }
    return jsonResult.toHtmlString();
  }
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.