Package com.jada.jpa.entity

Examples of com.jada.jpa.entity.Site


            HttpServletRequest request,
            HttpServletResponse response)
        throws Throwable {
     
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      Site site = getAdminBean(request).getSite();
        CountryListingActionForm form = (CountryListingActionForm) actionForm;

        try {
          if (form.getCountries() != null) {
            CountryDisplayForm countries[] = form.getCountries();
            for (int i = 0; i < countries.length; i++) {
              if (countries[i].getRemove() == null) {
                continue;
              }
              if (!countries[i].getRemove().equals("Y")) {
                continue;
              }
                Country country = new Country();
                country = CountryDAO.load(site.getSiteId(), Format.getLong(countries[i].getCountryId()));
                em.remove(country);
            }
            em.getTransaction().commit();
          }
        }
View Full Code Here


    public void extract(AdminListingActionForm actionForm, HttpServletRequest request) throws Throwable {
      ItemListingActionForm form = (ItemListingActionForm) actionForm;
     
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
        AdminBean adminBean = getAdminBean(request);
        Site site = adminBean.getSite();

        ActionMessages errors = validate(form);
    if (errors.size() != 0) {
      saveMessages(request, errors);
      return;
    }

        Query query = null;
        String selectedCategories[] = form.getSrSelectedCategories();

        String sql = "select   distinct item " +
               "from     Item item ";
        if (selectedCategories != null) {
          sql += "left   join item.categories category ";
        }
        sql += "where   item.siteId = :siteId ";
        if (form.getSrItemNum() != null && form.getSrItemNum().length() > 0) {
          sql += "and item.itemNum = :itemNum ";
        }
        if (form.getSrItemSkuCd().length() > 0) {
          sql += "and item.itemSkuCd = :itemSkuCd ";
        }
        if (form.getSrItemUpcCd().length() > 0) {
          sql += "and item.itemUpcCd = :itemUpcCd ";
        }
        if (form.getSrItemShortDesc().length() > 0) {
          sql += "and item.itemLanguage.itemShortDesc like :itemShortDesc ";
        }
        if (!form.getSrPublished().equals("*")) {
          sql += "and item.published = :published ";
        }
        sql += "and item.itemTypeCd in (";
        if (form.isSrItemTypeRegular()) {
          sql += "'01',";
        }
        if (form.isSrItemTypeTemplate()) {
          sql += "'02',";
        }
        if (form.isSrItemTypeSku()) {
          sql += "'03',";
        }
        if (form.isSrItemTypeStaticBundle()) {
          sql += "'04',";
        }
        if (form.isSrItemTypeRecommandBundle()) {
          sql += "'05',";
        }
        sql += "'') ";
        sql += "and item.itemPublishOn between :itemPublishOnStart and :itemPublishOnEnd ";
        sql += "and item.itemExpireOn between :itemExpireOnStart and :itemExpireOnEnd ";
        if (!form.getSrUpdateBy().equals("All")) {
          sql += "and item.recUpdateBy = :recUpdateBy ";
        }
        if (!form.getSrCreateBy().equals("All")) {
          sql += "and item.recCreateBy = :recCreateBy ";
        }
       
        if (selectedCategories != null) {
          sql += "and category.catId in (";
          int index = 0;
          for (int i = 0; i < selectedCategories.length; i++) {
            Long catIds[] = Utility.getCatIdTreeList(site.getSiteId(), Format.getLong(selectedCategories[i]));
            for (int j = 0; j < catIds.length; j++) {
              if (index > 0) {
                sql += ",";
              }
              sql += ":selectedCategory" + index++;
            }
           }
             sql += ") ";
        }

        query = em.createQuery(sql);
        Date date = null;
        query.setParameter("siteId", site.getSiteId());
        if (form.getSrItemSkuCd().length() > 0) {
          query.setParameter("itemSkuCd", form.getSrItemSkuCd());
        }
        if (form.getSrItemNum().length() > 0) {
          query.setParameter("itemNum", form.getSrItemNum());
        }
        if (form.getSrItemUpcCd().length() > 0) {
          query.setParameter("itemUpcCd", form.getSrItemUpcCd());
        }
        if (form.getSrItemShortDesc().length() > 0) {
          query.setParameter("itemShortDesc", "%" + form.getSrItemShortDesc() + "%");
        }
        if (!form.getSrPublished().equals("*")) {
          query.setParameter("published", form.getSrPublished());
        }
        if (form.getSrItemPublishOnStart().length() > 0) {
          date = Format.getDate(form.getSrItemPublishOnStart());
          query.setParameter("itemPublishOnStart", date);
        }
        else {
          query.setParameter("itemPublishOnStart", Format.LOWDATE);
        }
        if (form.getSrItemPublishOnEnd().length() > 0) {
          date = Format.getDate(form.getSrItemPublishOnEnd());
          query.setParameter("itemPublishOnEnd", date);
        }
        else {
          query.setParameter("itemPublishOnEnd", Format.HIGHDATE);
        }
        if (form.getSrItemExpireOnStart().length() > 0) {
          date = Format.getDate(form.getSrItemExpireOnStart());
          query.setParameter("itemExpireOnStart", date);
        }
        else {
          query.setParameter("itemExpireOnStart", Format.LOWDATE);
        }
        if (form.getSrItemExpireOnEnd().length() > 0) {
          date = Format.getDate(form.getSrItemExpireOnEnd());
          query.setParameter("itemExpireOnEnd", date);
        }
        else {
          query.setParameter("itemExpireOnEnd", Format.HIGHDATE);
        }
        if (!form.getSrUpdateBy().equals("All")) {
          query.setParameter("recUpdateBy", form.getSrUpdateBy());
        }
        if (!form.getSrCreateBy().equals("All")) {
          query.setParameter("recCreateBy", form.getSrCreateBy());
        }
        if (selectedCategories != null) {
          int index = 0;
          for (int i = 0; i < selectedCategories.length; i++) {
            Long catIds[] = Utility.getCatIdTreeList(site.getSiteId(), Format.getLong(selectedCategories[i]));
            for (int j = 0; j < catIds.length; j++) {
              query.setParameter("selectedCategory" + index++, catIds[j].longValue());
            }
          }
        }
View Full Code Here

            HttpServletRequest request,
            HttpServletResponse response)
        throws Throwable {
     
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      Site site = getAdminBean(request).getSite();
        ItemListingActionForm form = (ItemListingActionForm) actionForm;
        String itemIds[] = form.getItemIds();
       
        try {
          if (form.getItems() != null) {
            ItemDisplayForm items[] = form.getItems();
            for (int i = 0; i < items.length; i++) {
              if (items[i].getRemove() == null) {
                continue;
              }
              if (!items[i].getRemove().equals("Y")) {
                continue;
              }
                Item item = ItemDAO.load(site.getSiteId(), Format.getLong(items[i].getItemId()));
                ItemDAO.remove(site.getSiteId(), item);
                em.remove(item);
            }
            em.getTransaction().commit();
          }
        }
    catch (Exception e) {
      if (Utility.isConstraintViolation(e)) {
        ActionMessages errors = new ActionMessages();
        errors.add("error", new ActionMessage("error.remove.items.constraint"));
        saveMessages(request, errors);
            ActionForward forward = actionMapping.findForward("removeError") ;
            return forward;
      }
      throw e;
       }
       
        if (itemIds != null) {
          for (int i = 0; i < itemIds.length; i++) {
              Item item = new Item();
              item = ItemDAO.load(site.getSiteId(), Format.getLong(itemIds[i]));
              em.remove(item);
          }
        }

        ActionForward forward = actionMapping.findForward("removed") ;
View Full Code Here

    public ActionForward edit(ActionMapping actionMapping,
                              ActionForm actionForm,
                              HttpServletRequest request,
                              HttpServletResponse response)
        throws Throwable {
      Site site = getAdminBean(request).getSite();
        CountryMaintActionForm form = (CountryMaintActionForm) actionForm;
        if (form == null) {
            form = new CountryMaintActionForm();
        }
    String countryId = request.getParameter("countryId");
        Country country = new Country();
        country = CountryDAO.load(site.getSiteId(), Format.getLong(countryId));
        form.setMode("U");
    form.setCountryId(Format.getLong(country.getCountryId()));
    form.setCountryCode(country.getCountryCode());
    form.setCountryName(country.getCountryName());
   
View Full Code Here

            HttpServletRequest request,
            HttpServletResponse response)
    throws Throwable {
   
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    Site site = getAdminBean(request).getSite();
    CountryMaintActionForm form = (CountryMaintActionForm) actionForm;
    Country country = CountryDAO.load(site.getSiteId(), Format.getLong(form.getCountryId()));
    try {
      em.remove(country);
      em.getTransaction().commit();
    }
    catch (Exception e) {
View Full Code Here

    if (form.getMode().equals("C")) {
      insertMode = true;
    }
 
    AdminBean adminBean = getAdminBean(request);
    Site site = adminBean.getSite();
 
    Country country = new Country();
    if (!insertMode) {
      country = CountryDAO.load(site.getSiteId(), Format.getLong(form.getCountryId()));
    }
 
    ActionMessages errors = validate(form);
    if (errors.size() != 0) {
      saveMessages(request, errors);
      return mapping.findForward("error");
    }
 
    String sql = "from    Country country " +
              "where   country.site.siteId = :siteId " +
              "and     countryCode = :countryCode ";
    if (!Format.isNullOrEmpty(form.getCountryId())) {
      sql += "and    countryId != :countryId";
    }
    Query query = em.createQuery(sql);
    query.setParameter("siteId", site.getSiteId());
    query.setParameter("countryCode", form.getCountryCode());
    if (!Format.isNullOrEmpty(form.getCountryId())) {
      query.setParameter("countryId", Long.valueOf(form.getCountryId()));
    }
    if (query.getResultList().iterator().hasNext()) {
View Full Code Here

        HttpServletRequest request,
        HttpServletResponse response)
    throws Throwable {
   
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      Site site = getAdminBean(request).getSite();
    CountryMaintActionForm form = (CountryMaintActionForm) actionForm;
    Country country = CountryDAO.load(site.getSiteId(), Format.getLong(form.getCountryId()));
   
    StateDisplayForm states[] = form.getStates();
    for (int i = 0; i < states.length; i++) {
      StateDisplayForm stateForm = states[i];
      if (stateForm.getRemove() == null) {
        continue;
      }
      if (stateForm.getRemove().equals(String.valueOf(Constants.VALUE_YES))) {
        State state = StateDAO.load(site.getSiteId(), Format.getLong(stateForm.getStateId()));
        country.getStates().remove(state);
        em.remove(state);
      }
    }
   
View Full Code Here

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

    String stateId = (String) request.getParameter("stateId");
    String countryId = (String) request.getParameter("countryId");
        String stateCode = (String) request.getParameter("stateCode");
        String stateName = (String) request.getParameter("stateName");
      MessageResources resources = this.getResources(request);
      JSONEscapeObject jsonResult = new JSONEscapeObject();
     
      Vector<JSONEscapeObject> vector = new Vector<JSONEscapeObject>();

      boolean error = false;
      if (Format.isNullOrEmpty(stateCode)) {
        JSONEscapeObject object = new JSONEscapeObject();
           object.put("message", resources.getMessage("error.stateCode.required"))
           vector.add(object);
           error = true;
      }
      if (Format.isNullOrEmpty(stateName)) {
        JSONEscapeObject object = new JSONEscapeObject();
           object.put("message", resources.getMessage("error.stateName.required"))
           vector.add(object);
           error = true;
      }
    if (!Format.isNullOrEmpty(stateId)) {
          String sql = "from  State state " +
                 "left  outer join state.country country " +
                 "where  country.site.siteId = :siteId " +
                 "and   state.stateCode = :stateCode " +
                 "and  state.stateId != :stateId ";
          Query query = em.createQuery(sql);
          query.setParameter("siteId", site.getSiteId());
          query.setParameter("stateCode", stateCode);
          query.setParameter("stateId", Format.getLong(stateId));
          Iterator<?> iterator = query.getResultList().iterator();
          if (iterator.hasNext()) {
            error = true;
          JSONEscapeObject object = new JSONEscapeObject();
             object.put("message", resources.getMessage("error.stateCode.duplicate"))
             vector.add(object);
          }
    }
    jsonResult.put("messages", vector);
    if (!error) {
      boolean exist = false;
      State state = null;
      if (!Format.isNullOrEmpty(stateId)) {
        state = StateDAO.load( site.getSiteId(), Format.getLong(stateId));
        exist = true;
      }
      else {
        state = new State();
        state.setRecCreateBy(adminBean.getUser().getUserId());
        state.setRecCreateDatetime(new Date(System.currentTimeMillis()));
      }
      state.setStateCode(stateCode);
      state.setStateName(stateName);
     
      Country country = CountryDAO.load( site.getSiteId(), Format.getLong(countryId));
      state.setCountry(country);
      state.setRecUpdateBy(adminBean.getUser().getUserId());
      state.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      if (!exist) {
        em.persist(state);
View Full Code Here

                              HttpServletResponse response)
        throws Throwable {

        SyndicationMaintActionForm form = (SyndicationMaintActionForm) actionForm;
        AdminBean adminBean = getAdminBean(request);
        Site site = adminBean.getSite();
   
        initListInfo(form, site.getSiteId());

        ActionForward actionForward = actionMapping.findForward("success");
        return actionForward;
    }
View Full Code Here

        throws Throwable {

      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      SyndicationMaintActionForm form = (SyndicationMaintActionForm) actionForm;
        AdminBean adminBean = getAdminBean(request);
        Site site = adminBean.getSite();

        SyndicationDisplayForm displayForms[] = form.getSyns();
        for (int i = 0; i < displayForms.length; i++) {
          SyndicationDisplayForm displayForm = displayForms[i];
          if (displayForm.getSynId().length() > 0) {
          Syndication syndication = SyndicationDAO.load(site.getSiteId(), Format.getLong(displayForm.getSynId()));
            if (displayForm.getSynUrl().trim().length() == 0) {
              displayForm.setSynId("");
              em.remove(syndication);
            }
            else {
              syndication.setSeqNum(i);
              syndication.setSynUrl(displayForm.getSynUrl().trim());
              syndication.setActive(displayForm.isActive() ? Constants.ACTIVE_YES : Constants.ACTIVE_NO);
              syndication.setRecUpdateBy(adminBean.getUser().getUserId());
              syndication.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
              // em.update(syndication);
            }
          }
          else {
            if (displayForm.getSynUrl().trim().length() > 0) {
              Syndication syndication = new Syndication();
              syndication.setSite(site);
              syndication.setSeqNum(i);
                 syndication.setSynUrl(displayForm.getSynUrl().trim());
              syndication.setActive(displayForm.isActive() ? Constants.ACTIVE_YES : Constants.ACTIVE_NO);
              syndication.setRecUpdateBy(adminBean.getUser().getUserId());
              syndication.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
              syndication.setRecCreateBy(adminBean.getUser().getUserId());
              syndication.setRecCreateDatetime(new Date(System.currentTimeMillis()));
              em.persist(syndication);
            }
          }
        }
        if (SyndReader.hasInstance(site.getSiteId())) {
          SyndReader.getInstance(site.getSiteId()).reset();
        }
        initListInfo(form, site.getSiteId());

        ActionForward actionForward = actionMapping.findForward("success");
        return actionForward;
    }
View Full Code Here

TOP

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

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.