Package com.jada.jpa.entity

Examples of com.jada.jpa.entity.TaxRegion


        Site site = getAdminBean(request).getSite();
        if (form == null) {
            form = new TaxRegionMaintActionForm();
        }
    String taxRegionId = request.getParameter("taxRegionId");
        TaxRegion taxRegion = TaxRegionDAO.load(site.getSiteId(), Format.getLong(taxRegionId));
        form.setMode("U");
    form.setTaxRegionId(Format.getLong(taxRegion.getTaxRegionId()));
    form.setTaxRegionDesc(taxRegion.getTaxRegionDesc());
    if (taxRegion.getPublished() == Constants.VALUE_YES) {
      form.setPublished(true);
    }
    ProductClass productClass = taxRegion.getShippingProductClass();
    if (productClass != null) {
      form.setShippingProductClassId(productClass.getProductClassId().toString());
    }
   
        createAdditionalInfo(form, site, taxRegion);
View Full Code Here


    throws Throwable {
   
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
        Site site = getAdminBean(request).getSite();
    TaxRegionMaintActionForm form = (TaxRegionMaintActionForm) actionForm;
    TaxRegion taxRegion = TaxRegionDAO.load(site.getSiteId(), Format.getLong(form.getTaxRegionId()));
    em.remove(taxRegion);
    ActionForward actionForward = actionMapping.findForward("removeSuccess");
    return actionForward;
  }
View Full Code Here

    AdminBean adminBean = getAdminBean(request);
    Site site = adminBean.getSite();
    String siteId = site.getSiteId();

    TaxRegion taxRegion = new TaxRegion();
    if (!insertMode) {
      taxRegion = TaxRegionDAO.load(siteId, Format.getLong(form.getTaxRegionId()));
    }

    ActionMessages errors = validate(form);
    if (errors.size() != 0) {
      saveMessages(request, errors);
          if (insertMode) {
              FormUtils.setFormDisplayMode(request, form, FormUtils.CREATE_MODE);
          }
          else {
              FormUtils.setFormDisplayMode(request, form, FormUtils.EDIT_MODE);
          }
      return mapping.findForward("error");
    }

    if (insertMode) {
      taxRegion.setRecCreateBy(adminBean.getUser().getUserId());
      taxRegion.setRecCreateDatetime(new Date(System.currentTimeMillis()));
    }
    taxRegion.setSite(site);
    taxRegion.setTaxRegionDesc(form.getTaxRegionDesc());
    if (!Format.isNullOrEmpty(form.getShippingProductClassId())) {
      ProductClass productClass = (ProductClass) em.find(ProductClass.class, Format.getLong(form.getShippingProductClassId()));
      taxRegion.setShippingProductClass(productClass);
    }
    else {
      taxRegion.setShippingProductClass(null);
    }
    taxRegion.setPublished(Constants.VALUE_NO);
    if (form.isPublished()) {
      taxRegion.setPublished(Constants.VALUE_YES);
    }
    taxRegion.setRecUpdateBy(adminBean.getUser().getUserId());
    taxRegion.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
    if (insertMode) {
      em.persist(taxRegion);
    }
    else {
      // em.update(taxRegion);
    }
        form.setTaxRegionId(Format.getLong(taxRegion.getTaxRegionId()));
    form.setMode("U");
        createAdditionalInfo(form, site, taxRegion);
        FormUtils.setFormDisplayMode(request, form, FormUtils.EDIT_MODE);
    return mapping.findForward("success");
  }
View Full Code Here

        HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    TaxRegionMaintActionForm form = (TaxRegionMaintActionForm) actionForm;
        Long taxRegionId = Format.getLong(form.getTaxRegionId());
        TaxRegion taxRegion = (TaxRegion) em.find(TaxRegion.class, taxRegionId);
    JSONEscapeObject jsonResult = new JSONEscapeObject();
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    String result = getJSONCountriesAndStatesList(taxRegion);
    streamWebService(response, result);
    return null;
View Full Code Here

        HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    TaxRegionMaintActionForm form = (TaxRegionMaintActionForm) actionForm;
        Long taxRegionId = Format.getLong(form.getTaxRegionId());
        TaxRegion taxRegion = (TaxRegion) em.find(TaxRegion.class, taxRegionId);
    JSONEscapeObject jsonResult = new JSONEscapeObject();
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    String result = getJSONZipCodeList(taxRegion);
    streamWebService(response, result);
    return null;
View Full Code Here

        AdminBean adminBean = getAdminBean(request);
      JSONEscapeObject jsonResult = new JSONEscapeObject();
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
      Long taxRegionId = Format.getLong(form.getTaxRegionId());
        Long productClassId = Format.getLong(form.getProductClassId());
        TaxRegion taxRegion = (TaxRegion) em.find(TaxRegion.class, taxRegionId);
        ProductClass productClass = (ProductClass) em.find(ProductClass.class, productClassId);
       
        Iterator<?> iterator = taxRegion.getProductClasses().iterator();
        while (iterator.hasNext()) {
          TaxRegionProduct p = (TaxRegionProduct) iterator.next();
          if (p.getProductClass().getProductClassId().equals(productClass.getProductClassId())) {
              jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED);
              jsonResult.put("message", "Product class already exist");
              streamWebService(response, jsonResult.toHtmlString());
            return null;
          }
        }
       
        TaxRegionProduct trProduct = new TaxRegionProduct();
        trProduct.setTaxRegion(taxRegion);
        trProduct.setProductClass(productClass);
        trProduct.setRecUpdateBy(adminBean.getUser().getUserId());
    trProduct.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
    trProduct.setRecCreateBy(adminBean.getUser().getUserId());
    trProduct.setRecCreateDatetime(new Date(System.currentTimeMillis()));
    taxRegion.getProductClasses().add(trProduct);
   
    em.persist(trProduct);
   
    String result = getJSONProduct(request, trProduct);
    streamWebService(response, result);
View Full Code Here

        TaxRegionMaintActionForm form = (TaxRegionMaintActionForm) actionForm;
       JSONEscapeObject jsonResult = new JSONEscapeObject();
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
     
        Long taxRegionId = Format.getLong(form.getTaxRegionId());
        TaxRegion taxRegion = (TaxRegion) em.find(TaxRegion.class, taxRegionId);

      String countryIds[] = form.getCountryIds();
      if (countryIds != null) {
        for (int i = 0; i < countryIds.length; i++) {
          Long countryId = Format.getLong(countryIds[i]);
              Country country = (Country) em.find(Country.class, countryId);
              Iterator<?> countries = taxRegion.getCountries().iterator();
              boolean found = false;
              while (countries.hasNext()) {
                Country c = (Country) countries.next();
                if (c.getCountryId().equals(countryId)) {
                  found = true;
                  break;
                }
              }
              if (!found) {
                taxRegion.getCountries().add(country);
              }
        }
      }
     
      String stateIds[] = form.getStateIds();
      if (stateIds != null) {
        for (int i = 0; i < stateIds.length; i++) {
          Long stateId = Format.getLong(stateIds[i]);
              State state = (State) em.find(State.class, stateId);
              Iterator<?> states = taxRegion.getStates().iterator();
              boolean found = false;
              while (states.hasNext()) {
                State s = (State) states.next();
                if (s.getStateId().equals(stateId)) {
                  found = true;
                  break;
                }
              }
              if (!found) {
                taxRegion.getStates().add(state);
              }
        }
      }
    em.persist(taxRegion);
   
View Full Code Here

        TaxRegionMaintActionForm form = (TaxRegionMaintActionForm) actionForm;
       JSONEscapeObject jsonResult = new JSONEscapeObject();
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
     
        Long taxRegionId = Format.getLong(form.getTaxRegionId());
        TaxRegion taxRegion = (TaxRegion) em.find(TaxRegion.class, taxRegionId);
       
        boolean modified = false;
      String countryIds[] = form.getCountryIds();
      if (countryIds != null) {
        for (int i = 0; i < countryIds.length; i++) {
          Long countryId = Format.getLong(countryIds[i]);
              Iterator<?> countries = taxRegion.getCountries().iterator();
              while (countries.hasNext()) {
                Country c = (Country) countries.next();
                if (c.getCountryId().equals(countryId)) {
                  countries.remove();
                  modified = true;
                  break;
                }
              }
        }
      }
     
      String stateIds[] = form.getStateIds();
      if (stateIds != null) {
        for (int i = 0; i < stateIds.length; i++) {
          Long stateId = Format.getLong(stateIds[i]);
              Iterator<?> states = taxRegion.getStates().iterator();
              while (states.hasNext()) {
                State s = (State) states.next();
                if (s.getStateId().equals(stateId)) {
                  states.remove();
                  modified = true;
View Full Code Here

        AdminBean adminBean = getAdminBean(request);
      JSONEscapeObject jsonResult = new JSONEscapeObject();
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
     
        Long taxRegionId = Format.getLong(form.getTaxRegionId());
        TaxRegion taxRegion = (TaxRegion) em.find(TaxRegion.class, taxRegionId);
       
        TaxRegionZip taxRegionZip = new TaxRegionZip();
        taxRegionZip.setZipCodeStart(form.getZipCodeStart());
        taxRegionZip.setZipCodeEnd(form.getZipCodeEnd());
        taxRegionZip.setRecUpdateBy(adminBean.getUser().getUserId());
View Full Code Here

        AdminBean adminBean = getAdminBean(request);
      JSONEscapeObject jsonResult = new JSONEscapeObject();
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
     
        Long taxRegionId = Format.getLong(form.getTaxRegionId());
        TaxRegion taxRegion = (TaxRegion) em.find(TaxRegion.class, taxRegionId);
        Long taxRegionZipId = Format.getLong(form.getTaxRegionZipId());
        TaxRegionZip taxRegionZip = (TaxRegionZip) em.find(TaxRegionZip.class, taxRegionZipId);
      
        taxRegionZip.setZipCodeStart(form.getZipCodeStart());
        taxRegionZip.setZipCodeEnd(form.getZipCodeEnd());
View Full Code Here

TOP

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

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.