Package com.jada.jpa.entity

Examples of com.jada.jpa.entity.SiteProfileClass


    boolean isNew = false;
    Site site = SiteDAO.load(siteId);
    if (site == null) {
      throw new ItemSaveException(resources.getMessage("IE.ERROR.E109", "site", "siteId", siteId));
    }
    SiteProfileClass siteProfileClassDefault = site.getSiteProfileClassDefault();
    SiteCurrencyClass siteCurrencyClassDefault = site.getSiteCurrencyClassDefault();
   
   
   
    com.jada.jpa.entity.Item item = null;
    if (itemId != null) {
      item = ItemDAO.load(siteId, itemId);
      if (item == null) {
        throw new ItemSaveException(resources.getMessage("IE.ERROR.E109", "item", "itemId", itemId));
      }
     
    }
    else if (itemSkuCd != null) {
      item = ItemDAO.loadBySku(siteId, itemSkuCd);
    }
    if (item == null) {
      isNew = true;
      item = new com.jada.jpa.entity.Item();
      item.setItemUpcCd(itemSkuCd);
      item.setItemQty(0);
      item.setItemTypeCd(Constants.ITEM_TYPE_REGULAR);
      item.setItemBookedQty(0);
      item.setItemExpireOn(Format.HIGHDATE);
      item.setItemPublishOn(new Date());
      item.setItemHitCounter(0);
      item.setItemRating(Float.valueOf(0));
      item.setItemRatingCount(0);
      item.setSeqNum(0);
      item.setRecCreateBy(Constants.USERNAME_IMPORT);
      item.setRecCreateDatetime(new Date());
      item.setSite(site);
    }

    if (isNew) {
      if (isSimple) {
        boolean found = false;
        for (ItemLanguage itemLanguage : this.getItemLanguages()) {
          if (itemLanguage.getSiteProfileClassId() != null) {
            if (itemLanguage.getSiteProfileClassId().equals(siteProfileClassDefault.getSiteProfileClassId())) {
              found = true;
              break;
            }
          }
          else {
            if (itemLanguage.getSiteProfileClassName().equals(siteProfileClassDefault.getSiteProfileClassName())) {
              found = true;
              break;
            }
          }
        }
        if (!found) {
          throw new ItemSaveException(resources.getMessage("IE.ERROR.E111", siteProfileClassDefault.getSiteProfileClassName()));
        }
        found = false;
        for (ItemPriceCurrency itemPriceCurrency : this.getItemPriceCurrencies()) {
          if (itemPriceCurrency.getSiteCurrencyClassId() != null) {
            if (itemPriceCurrency.getSiteCurrencyClassId().equals(siteCurrencyClassDefault.getSiteCurrencyClassId())) {
              found = true;
              break;
            }
          }
          else {
            if (itemPriceCurrency.getSiteCurrencyClassName().equals(siteCurrencyClassDefault.getSiteCurrencyClassName())) {
              found = true;
              break;
            }
          }
        }
        if (!found) {
          throw new ItemSaveException(resources.getMessage("IE.ERROR.E112", siteCurrencyClassDefault.getSiteCurrencyClassName()));
        }
      }
    }
   
    item.setItemNum(itemNum);
    item.setItemSkuCd(itemSkuCd);
    item.setItemNaturalKey(Utility.encode(itemSkuCd));
    item.setItemSellable(itemSellable);
    item.setItemCost(itemCost);
    if (itemUpcCd != null) {
      item.setItemUpcCd(itemUpcCd);
    }
    if (itemTypeCd != null) {
      item.setItemTypeCd(itemTypeCd);
    }
    if (itemPublishOn != null) {
      item.setItemPublishOn(itemPublishOn);
    }
    if (itemExpireOn != null) {
      item.setItemExpireOn(itemExpireOn);
    }
    if (itemHitCounter != null) {
      item.setItemHitCounter(itemHitCounter);
    }
    if (itemRating != null) {
      item.setItemRating(itemRating);
    }
    if (itemRatingCount != null) {
      item.setItemRatingCount(itemRatingCount);
    }
    if (itemQty != null) {
      item.setItemQty(itemQty);
    }
    if (itemBookedQty != null) {
      item.setItemBookedQty(itemBookedQty);
    }
    item.setPublished(published);
    item.setRecUpdateBy(Constants.USERNAME_IMPORT);
    item.setRecUpdateDatetime(new Date());
   
    for (ItemLanguage itemLanguageImport : this.getItemLanguages()) {
      com.jada.jpa.entity.ItemLanguage itemLanguage = null;
      boolean found = false;
      for (com.jada.jpa.entity.ItemLanguage language : item.getItemLanguages()) {
        if (itemLanguageImport.getSiteProfileClassId() != null) {
          if (language.getSiteProfileClass().getSiteProfileClassId().equals(itemLanguageImport.getSiteProfileClassId())) {
            itemLanguage = language;
            found = true;
            break;
          }
        }
        else {
          if (language.getSiteProfileClass().getSiteProfileClassName().equals(itemLanguageImport.getSiteProfileClassName())) {
            itemLanguage = language;
            found = true;
            break;
          }
        }
      }
      if (!found) {
        itemLanguage = new com.jada.jpa.entity.ItemLanguage();
        itemLanguage.setItemImageOverride(String.valueOf(Constants.VALUE_NO));
        itemLanguage.setRecCreateBy(Constants.USERNAME_IMPORT);
        itemLanguage.setRecCreateDatetime(new Date());
        SiteProfileClass siteProfileClass = getSiteProfileClass(siteId, itemLanguageImport.getSiteProfileClassId(), itemLanguageImport.getSiteProfileClassName());
        if (siteProfileClass == null) {
          throw new ItemSaveException(resources.getMessage("IE.ERROR.E109",
                                   "siteProfileClass",
                                   "siteProfileClassId and siteProfileClassName",
                                   itemLanguageImport.getSiteProfileClassId().toString() + " and " + itemLanguageImport.getSiteProfileClassName()));
View Full Code Here


    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);
    }
View Full Code Here

    }
    if (!found) {
      couponLanguage = new CouponLanguage();
      couponLanguage.setRecCreateBy(user.getUserId());
      couponLanguage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        SiteProfileClass siteProfileClass = (SiteProfileClass) em.find(SiteProfileClass.class, siteProfileClassId);
        couponLanguage.setSiteProfileClass(siteProfileClass);
        couponLanguage.setCoupon(coupon);
        coupon.getCouponLanguages().add(couponLanguage);
    }
    if (form.isCouponNameLangFlag()) {
View Full Code Here

    protected void initSiteProfiles(AdminMaintActionForm form, Site site) throws Exception {
        EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
 
        Vector<LabelValueBean> vector = new Vector<LabelValueBean>();
      Long siteProfileClassDefaultId = null;
        SiteProfileClass siteProfileClassDefault = site.getSiteProfileClassDefault();
        if (siteProfileClassDefault != null) {
          siteProfileClassDefaultId = siteProfileClassDefault.getSiteProfileClassId();
          form.setSiteProfileClassDefaultId(siteProfileClassDefaultId);
          vector.add(new LabelValueBean(siteProfileClassDefault.getSiteProfileClassName(),
              siteProfileClassDefault.getSiteProfileClassId().toString()));
        }
       
      String sql = "from   SiteProfileClass siteProfileClass " +
             "where  siteProfileClass.site.siteId = :siteId " +
             "order  by siteProfileClassName ";
      Query query = em.createQuery(sql);
      query.setParameter("siteId", site.getSiteId());
        Iterator<?> iterator = query.getResultList().iterator();
        while (iterator.hasNext()) {
          SiteProfileClass siteProfileClass = (SiteProfileClass) iterator.next();
          if (siteProfileClassDefault != null) {
            if (siteProfileClass.getSiteProfileClassId().equals(siteProfileClassDefaultId)) {
              continue;
            }
          }
          vector.add(new LabelValueBean(siteProfileClass.getSiteProfileClassName(),
                          siteProfileClass.getSiteProfileClassId().toString()));
        }
        LabelValueBean siteProfileClassBeans[] = new LabelValueBean[vector.size()];
        vector.copyInto(siteProfileClassBeans);
        form.setSiteProfileClassBeans(siteProfileClassBeans);
       
        if (form.getSiteProfileClassId() != null) {
          boolean found = false;
          for (LabelValueBean bean : siteProfileClassBeans) {
            if (bean.getValue().equals(form.getSiteProfileClassId().toString())) {
              found = true;
              break;
            }
          }
          if (!found) {
            form.setSiteProfileClassId(null);
          }
        }
       
        if (form.getSiteProfileClassId() == null) {
          if (siteProfileClassDefault != null) {
            form.setSiteProfileClassId(siteProfileClassDefaultId);
          }
          form.setSiteProfileClassDefault(true);
        }
        else {
          if (siteProfileClassDefault == null || form.getSiteProfileClassId().equals(siteProfileClassDefaultId)) {
            form.setSiteProfileClassDefault(true);
          }
          else {
              form.setSiteProfileClassDefault(false);
          }
          form.setTranslationEnable(false);
          String fromLocale = "";
          String toLocale = "";
          fromLocale = siteProfileClassDefault.getLanguage().getGoogleTranslateLocale();
          SiteProfileClass siteProfileClass = (SiteProfileClass) em.find(SiteProfileClass.class, form.getSiteProfileClassId());
          toLocale = siteProfileClass.getLanguage().getGoogleTranslateLocale();
          if (!Format.isNullOrEmpty(fromLocale) && !Format.isNullOrEmpty(toLocale) && !fromLocale.equals(toLocale)) {
            form.setTranslationEnable(true);
            form.setFromLocale(fromLocale);
            form.setToLocale(toLocale);
          }
View Full Code Here

      }
      if (!found) {
        menuLanguage = new MenuLanguage();
        menuLanguage.setRecCreateBy(user.getUserId());
        menuLanguage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        SiteProfileClass siteProfileClass = (SiteProfileClass) em.find(SiteProfileClass.class, siteProfileClassId);
        menuLanguage.setSiteProfileClass(siteProfileClass);
        menuLanguage.setMenu(menu);
      }
      if (form.isMenuNameLangFlag()) {
        menuLanguage.setMenuName(form.getMenuNameLang());
View Full Code Here

    sql = "from SiteProfileClass siteProfileClass where siteProfileClass.site.siteId = :siteId";
    query = em.createQuery(sql);
    query.setParameter("siteId", site.getSiteId());
    iterator = query.getResultList().iterator();
    while (iterator.hasNext()) {
      SiteProfileClass siteProfileClass = (SiteProfileClass) iterator.next();
        em.remove(siteProfileClass);
    }

    sql = "from SiteCurrencyClass siteCurrencyClass where siteCurrencyClass.site.siteId = :siteId";
    query = em.createQuery(sql);
View Full Code Here

    TaxLanguage taxLanguage = tax.getTaxLanguage();
    if (taxLanguage == null) {
      taxLanguage = new TaxLanguage();
      taxLanguage.setTax(tax);
      tax.getTaxLanguages().add(taxLanguage);
        SiteProfileClass siteProfileClass = (SiteProfileClass) em.find(SiteProfileClass.class, form.getSiteProfileClassDefaultId());
        taxLanguage.setSiteProfileClass(siteProfileClass);
        taxLanguage.setRecCreateBy(adminBean.getUser().getUserId());
        taxLanguage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        tax.setTaxLanguage(taxLanguage);
    }
View Full Code Here

      }
      if (!found) {
        taxLanguage = new TaxLanguage();
        taxLanguage.setRecCreateBy(user.getUserId());
        taxLanguage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        SiteProfileClass siteProfileClass = (SiteProfileClass) em.find(SiteProfileClass.class, siteProfileClassId);
        taxLanguage.setSiteProfileClass(siteProfileClass);
        taxLanguage.setTax(tax);
      }
      if (form.isTaxCodeLangFlag()) {
        taxLanguage.setTaxCode(form.getTaxCodeLang());
View Full Code Here

      }
      if (!found) {
        homePageLanguage = new HomePageLanguage();
        homePageLanguage.setRecCreateBy(user.getUserId());
        homePageLanguage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        SiteProfileClass siteProfileClass = (SiteProfileClass) em.find(SiteProfileClass.class, siteProfileClassId);
        homePageLanguage.setSiteProfileClass(siteProfileClass);
        homePageLanguage.setHomePage(homePage);
      }
      if (form.isPageTitleLangFlag()) {
        homePageLanguage.setHomePageTitle(form.getPageTitleLang());
View Full Code Here

        EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();

        String sql = "from SiteProfileClass siteProfileClass where siteProfileClass.site.siteId = :siteId";
      Query query = em.createQuery(sql);
      query.setParameter("siteId", site.getSiteId());
      SiteProfileClass siteProfileClasses[] = new SiteProfileClass[query.getResultList().size()];
      query.getResultList().toArray(siteProfileClasses);
     
      sql = "from SiteCurrencyClass siteCurrencyClass where siteCurrencyClass.site.siteId = :siteId";
      query = em.createQuery(sql);
      query.setParameter("siteId", site.getSiteId());
View Full Code Here

TOP

Related Classes of com.jada.jpa.entity.SiteProfileClass

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.