Package com.jada.admin

Examples of com.jada.admin.AdminBean


   
    public ActionForward sendShippingQuote(ActionMapping actionMapping,
            ActionForm actionForm,
            HttpServletRequest request,
            HttpServletResponse response) throws Throwable {
    AdminBean adminBean = getAdminBean(request);
    User user = adminBean.getUser();

      OrderMaintActionForm form = (OrderMaintActionForm) actionForm;
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      OrderHeader orderHeader = (OrderHeader) em.find(OrderHeader.class, Format.getLong(form.getOrderHeaderId()));
     
View Full Code Here


            ActionForm actionForm,
            HttpServletRequest request,
            HttpServletResponse response) throws Throwable {
      OrderMaintActionForm form = (OrderMaintActionForm) actionForm;
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    AdminBean adminBean = getAdminBean(request);
    User user = adminBean.getUser();
      OrderHeader orderHeader = (OrderHeader) em.find(OrderHeader.class, Format.getLong(form.getOrderHeaderId()));
      OrderTrackingDisplayForm trackingForms[] = form.getOrderTrackings();
      for (int i = 0 ; i < trackingForms.length; i++) {
        OrderTracking orderTracking = (OrderTracking) em.find(OrderTracking.class, Format.getLong(trackingForms[i].getOrderTrackingId()));
        String value = String.valueOf(Constants.VALUE_NO);
View Full Code Here

            ActionForm actionForm,
            HttpServletRequest request,
            HttpServletResponse response)
    throws Throwable {
 
      AdminBean adminBean = getAdminBean(request);
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    ShippingMethodMaintActionForm form = (ShippingMethodMaintActionForm) actionForm;
    if (form == null) {
      form = new ShippingMethodMaintActionForm();
    }
    initSiteProfiles(form, getAdminBean(request).getSite());
   
    Site site = getAdminBean(request).getSite();
    initSiteProfiles(form, site);
    ShippingMethod shippingMethod = (ShippingMethod) em.find(ShippingMethod.class, Format.getLong(form.getShippingMethodId()));
   
        GoogleTranslate translator = new GoogleTranslate(form.getFromLocale(), form.getToLocale());
    form.setShippingMethodNameLangFlag(true);
    form.setShippingMethodNameLang(translator.translate(shippingMethod.getShippingMethodLanguage().getShippingMethodName()));
   
    initJsonSmRegions(form, shippingMethod, site.getSiteId(), adminBean.getUser());
   
    FormUtils.setFormDisplayMode(request, form, FormUtils.EDIT_MODE);
    ActionForward actionForward = actionMapping.findForward("success");
    return actionForward;
  }
View Full Code Here

    public ActionForward language(ActionMapping actionMapping,
            ActionForm actionForm,
            HttpServletRequest request,
            HttpServletResponse response)
    throws Throwable {
      AdminBean adminBean = getAdminBean(request);
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    ShippingMethodMaintActionForm form = (ShippingMethodMaintActionForm) actionForm;
    if (form == null) {
      form = new ShippingMethodMaintActionForm();
    }
    initSiteProfiles(form, getAdminBean(request).getSite());
   
    Site site = getAdminBean(request).getSite();
    initSiteProfiles(form, site);
    ShippingMethod shippingMethod = (ShippingMethod) em.find(ShippingMethod.class, Format.getLong(form.getShippingMethodId()));
   
    if (!form.isSiteProfileClassDefault()) {
      form.setShippingMethodNameLangFlag(false);
      form.setShippingMethodNameLang(shippingMethod.getShippingMethodLanguage().getShippingMethodName());
        boolean found = false;
        ShippingMethodLanguage shippingMethodLanguage = null;
        Long siteProfileClassId = form.getSiteProfileClassId();
        Iterator<?> iterator = shippingMethod.getShippingMethodLanguages().iterator();
        while (iterator.hasNext()) {
          shippingMethodLanguage = (ShippingMethodLanguage) iterator.next();
          if (shippingMethodLanguage.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
            found = true;
            break;
          }
        }
        if (found) {
          if (shippingMethodLanguage.getShippingMethodName() != null) {
            form.setShippingMethodNameLangFlag(true);
            form.setShippingMethodNameLang(shippingMethodLanguage.getShippingMethodName());
          }
        }
    }
    initJsonSmRegions(form, shippingMethod, site.getSiteId(), adminBean.getUser());
   
    FormUtils.setFormDisplayMode(request, form, FormUtils.EDIT_MODE);
    ActionForward actionForward = actionMapping.findForward("success");
    return actionForward;
  }
View Full Code Here

                              ActionForm actionForm,
                              HttpServletRequest request,
                              HttpServletResponse response)
        throws Throwable {

        AdminBean adminBean = getAdminBean(request);
        Site site = adminBean.getSite();
        ShippingMethodMaintActionForm form = (ShippingMethodMaintActionForm) actionForm;
        if (form == null) {
            form = new ShippingMethodMaintActionForm();
        }
    initSiteProfiles(form, site);
    String shippingMethodId = request.getParameter("shippingMethodId");
        ShippingMethod shippingMethod = new ShippingMethod();
        shippingMethod = ShippingMethodDAO.load(site.getSiteId(), Format.getLong(shippingMethodId));
        form.setMode("U");
    form.setShippingMethodId(Format.getLong(shippingMethod.getShippingMethodId()));
    form.setShippingMethodName(shippingMethod.getShippingMethodLanguage().getShippingMethodName());
    form.setPublished(shippingMethod.getPublished() == Constants.PUBLISHED_YES);
   
    if (!form.isSiteProfileClassDefault()) {
      form.setShippingMethodNameLang(shippingMethod.getShippingMethodLanguage().getShippingMethodName());
        boolean found = false;
        ShippingMethodLanguage shippingMethodLanguage = null;
        Long siteProfileClassId = form.getSiteProfileClassId();
        Iterator<?> iterator = shippingMethod.getShippingMethodLanguages().iterator();
        while (iterator.hasNext()) {
          shippingMethodLanguage = (ShippingMethodLanguage) iterator.next();
          if (shippingMethodLanguage.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
            found = true;
            break;
          }
        }
        if (found) {
          if (shippingMethodLanguage.getShippingMethodName() != null) {
            form.setShippingMethodNameLangFlag(true);
            form.setShippingMethodNameLang(shippingMethodLanguage.getShippingMethodName());
          }
        }
    }

    initJsonSmRegions(form, shippingMethod, site.getSiteId(), adminBean.getUser());

        FormUtils.setFormDisplayMode(request, form, FormUtils.EDIT_MODE);
        ActionForward actionForward = actionMapping.findForward("success");
        return actionForward;
    }
View Full Code Here

                HttpServletRequest request,
                HttpServletResponse response)
    throws Throwable {

      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      AdminBean adminBean = getAdminBean(request);
      Site site = adminBean.getSite();
    boolean insertMode = false;
    ShippingMethodMaintActionForm form = (ShippingMethodMaintActionForm) actionForm;
    initSiteProfiles(form, site);
    ActionMessages errors = validate(form);
    if (errors.size() != 0) {
      saveMessages(request, errors);
      return mapping.findForward("error");
    }
    if (form.getMode().equals("C")) {
      insertMode = true;
    }
   
    ShippingMethod shippingMethod = new ShippingMethod();
    ShippingMethodLanguage shippingMethodLanguage = new ShippingMethodLanguage();
    if (!insertMode) {
      shippingMethod = ShippingMethodDAO.load(site.getSiteId(), Format.getLong(form.getShippingMethodId()));
      shippingMethodLanguage = shippingMethod.getShippingMethodLanguage();
    }
    if (insertMode) {
          String sql = "select max(seqNum) " +
                   "from   ShippingMethod " +
                   "where  siteId = :siteId ";
          int seqNum = 0;
      Query query = em.createQuery(sql);
      query.setParameter("siteId", site.getSiteId());
      Integer i = (Integer) query.getResultList().iterator().next();
      if (i != null) {
        seqNum = i.intValue() + 1;
      }
      shippingMethod.setSeqNum(seqNum);
      shippingMethod.setSite(site);
      shippingMethod.setRecCreateBy(adminBean.getUser().getUserId());
      shippingMethod.setRecCreateDatetime(new Date(System.currentTimeMillis()));
     
      shippingMethodLanguage.setRecCreateBy(adminBean.getUser().getUserId());
      shippingMethodLanguage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
      shippingMethodLanguage.setShippingMethod(shippingMethod);
      SiteProfileClass siteProfileClass = SiteProfileClassDAO.load(form.getSiteProfileClassId());
      shippingMethodLanguage.setSiteProfileClass(siteProfileClass);
      shippingMethod.getShippingMethodLanguages().add(shippingMethodLanguage);
    }

    for (ShippingMethodRegion shippingMethodRegion : shippingMethod.getShippingMethodRegions()) {
      shippingMethodRegion.setPublished(Constants.PUBLISHED_NO);
      String shippingRegionId = shippingMethodRegion.getShippingRegion().getShippingRegionId().toString();
      if (form.getShippingRegionIds() != null) {
        for (int i = 0; i < form.getShippingRegionIds().length; i++) {
          if (shippingRegionId.equals(form.getShippingRegionIds()[i])) {
            shippingMethodRegion.setPublished(Constants.PUBLISHED_YES);
            break;
          }
        }
      }
      shippingMethodRegion.setRecUpdateBy(adminBean.getUser().getUserId());
      shippingMethodRegion.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      em.persist(shippingMethodRegion);
    }

    if (form.isSiteProfileClassDefault()) {
      saveDefault(shippingMethod, shippingMethodLanguage, form, adminBean);
      shippingMethod.setShippingMethodLanguage(shippingMethodLanguage);
      if (insertMode) {
        em.persist(shippingMethodLanguage);
        em.persist(shippingMethod);
      }
    }
    else {
      saveLanguage(shippingMethod, form, adminBean);     
    }
    initJsonSmRegions(form, shippingMethod, site.getSiteId(), adminBean.getUser());

    form.setMode("U");
    form.setShippingMethodId(shippingMethod.getShippingMethodId().toString());
        FormUtils.setFormDisplayMode(request, form, FormUtils.EDIT_MODE);
    return mapping.findForward("success");
View Full Code Here

            return forward;
      }
      throw e;
        }
       
        AdminBean adminBean = getAdminBean(request);
        if (adminBean.getSite() == null) {
          Iterator<?> iterator = null;
          if (user.getUserType().equals(Constants.USERTYPE_SUPER) || user.getUserType().equals(Constants.USERTYPE_ADMIN)) {
             String sql = "from Site where siteId not like '\\_%' order by siteId";
             Query query = em.createQuery(sql);
             iterator = query.getResultList().iterator();
          }
          else {
            iterator = user.getSites().iterator();
          }
          Site site = (Site) iterator.next();
          adminBean.setSiteId(site.getSiteId());
          user.setUserLastVisitSiteId(site.getSiteId());
          // em.update(user);
        }

        ActionForward forward = new ActionForward();
View Full Code Here

   
    public ActionForward getJsonRate(ActionMapping actionMapping,
            ActionForm actionForm,
            HttpServletRequest request,
            HttpServletResponse response) throws Throwable {
      AdminBean adminBean = getAdminBean(request);
      ShippingMethodMaintActionForm form = (ShippingMethodMaintActionForm) actionForm;
      this.initSiteProfiles(form, adminBean.getSite());

    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      Long shippingRegionId = Format.getLong(form.getShippingRegionId());
      Long shippingMethodId = Format.getLong(form.getShippingMethodId());
      Long shippingTypeId = Format.getLong(form.getShippingTypeId());
View Full Code Here

    public ActionForward updateJsonRate(ActionMapping actionMapping,
            ActionForm actionForm,
            HttpServletRequest request,
            HttpServletResponse response) throws Throwable {
      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) {
View Full Code Here

    public ActionForward create(ActionMapping actionMapping,
            ActionForm actionForm,
            HttpServletRequest request,
            HttpServletResponse response) throws Throwable {
      InvoiceMaintActionForm form = (InvoiceMaintActionForm) actionForm;
      AdminBean adminBean = getAdminBean(request);
      User user = adminBean.getUser();
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    OrderHeader orderHeader = (OrderHeader) em.find(OrderHeader.class, Format.getLong(form.getOrderHeaderId()));
   
    InvoiceEngine invoiceEngine = new InvoiceEngine(orderHeader, user);
    invoiceEngine.invoiceAll();
View Full Code Here

TOP

Related Classes of com.jada.admin.AdminBean

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.