Package com.jada.jpa.entity

Examples of com.jada.jpa.entity.Customer


  String custPassword;
  String custSource;
  String custSourceRef;
  public static Customer load(String siteId, Long custId) throws SecurityException, Exception {
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    Customer customer = (Customer) em.find(Customer.class, custId);
    if (!customer.getSiteId().equals(siteId)) {
      throw new SecurityException();
    }
    return customer;
  }
View Full Code Here


            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
      String commentId = request.getParameter("commentId");
      String alertType = request.getParameter("alertType");
      ContentBean contentBean = getContentBean(request);
    Customer customer = getCustomer(request);
    if (customer == null) {
        Language language = contentBean.getContentSessionBean().getSiteProfile().getSiteProfileClass().getLanguage();
        JSONEscapeObject jsonResult = new JSONEscapeObject();
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_SIGNIN);
      jsonResult.put("message", Languages.getLangTranValue(language.getLangId(), "content.text.comment.signin"));
      String jsonString = jsonResult.toHtmlString();
      streamWebService(response, jsonString);
      return null;
    }
   
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    Comment comment = (Comment) em.find(Comment.class, Format.getLong(commentId));

      if (alertType.equals(Constants.ALERT_TYPE_MODERATOR)) {
        comment.setModeration(Constants.VALUE_YES);
        em.persist(comment);
      }
      else {
        Iterator<?> iterator = comment.getAgreeCustomers().iterator();
        while (iterator.hasNext()) {
          Customer c = (Customer) iterator.next();
          if (c.getCustId().equals(customer.getCustId())) {
            iterator.remove();
            break;
          }
        }
        iterator = comment.getDisagreeCustomers().iterator();
        while (iterator.hasNext()) {
          Customer c = (Customer) iterator.next();
          if (c.getCustId().equals(customer.getCustId())) {
            iterator.remove();
            break;
          }
        }
        if (alertType.equals(Constants.ALERT_TYPE_AGREE)) {
View Full Code Here

            ActionForm actionForm,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
      JSONEscapeObject jsonResult = new JSONEscapeObject();
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
      Customer customer = getCustomer(request);
      if (customer == null) {
        jsonResult.put("signinStatus", false);
      }
      else {
        jsonResult.put("signinStatus", true);
View Full Code Here

    Query query = em.createQuery(sql);
    query.setParameter("siteId", contentBean.getContentSessionKey().getSiteId());
    query.setParameter("custEmail", custEmail);
      Language language = contentBean.getContentSessionBean().getSiteProfile().getSiteProfileClass().getLanguage();
     
    Customer customer = null;
    try {
      customer = (Customer) query.getSingleResult();
    }
    catch (javax.persistence.NoResultException e) {}
    if (customer == null) {
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED);
      jsonResult.put("custPasswordError", Languages.getLangTranValue(language.getLangId(), "content.error.login.invalid"));
      this.streamWebService(response, jsonResult.toHtmlString());
      return null;
    }
    if (!AESEncoder.getInstance().decode(customer.getCustPassword()).equals(custPassword)) {
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED);
      jsonResult.put("custPasswordError", Languages.getLangTranValue(language.getLangId(), "content.error.login.invalid"));
      this.streamWebService(response, jsonResult.toHtmlString());
      return null;
    }
      setCustId(request, customer.getCustId());
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    this.streamWebService(response, jsonResult.toHtmlString());
      return null;
    }
View Full Code Here

            query.setParameter("siteDomainId", defaultSiteDomainId);
        }
        else {
          query.setParameter("siteDomainId", contentBean.getSiteDomain().getSiteDomainId());
        }
    Customer customer = null;
    try {
      customer = (Customer) query.getSingleResult();
    }
    catch (javax.persistence.NoResultException e) {}
      if (customer != null) {
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED);
      jsonResult.put("custPublicNameError", Languages.getLangTranValue(language.getLangId(), "content.error.publicName.duplicate"));
      this.streamWebService(response, jsonResult.toHtmlString());
      return null;
      }
     
      sql = "from CustomerClass customerClass where siteId = :siteId and customerClass.systemRecord = 'Y'";
      query = em.createQuery(sql);
      query.setParameter("siteId", contentBean.getSiteDomain().getSite().getSiteId());
      CustomerClass customerClass = (CustomerClass) query.getSingleResult();
     
      sql = "from   Customer customer " +
        "where  customer.siteDomain.siteDomainId = :siteDomainId " +
        "and    custEmail = :custEmail ";
    query = em.createQuery(sql);
    query.setParameter("custEmail", custEmail);
    if (singleCheckout == Constants.VALUE_YES) {
      query.setParameter("siteDomainId", defaultSiteDomainId);
    }
    else {
      query.setParameter("siteDomainId", contentBean.getSiteDomain().getSiteDomainId());
    }
    try {
      customer = (Customer) query.getSingleResult();
    }
    catch (javax.persistence.NoResultException e) {}
    if (customer != null) {
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED);
      jsonResult.put("custEmailError", Languages.getLangTranValue(language.getLangId(), "content.error.email.duplicate"));
      this.streamWebService(response, jsonResult.toHtmlString());
      return null;
    }
   
     
      customer = new Customer();
      customer.setCustPublicName(custPublicName);
      customer.setCustEmail(custEmail);;
      customer.setCustPassword(AESEncoder.getInstance().encode(custPassword));
      customer.setCustSource(Constants.CUSTOMER_SOURCE_REGISTER);
      customer.setCustSourceRef("");
      customer.setActive(Constants.VALUE_YES);
      customer.setRecUpdateBy(Constants.USERNAME_SYSTEM);
      customer.setRecUpdateDatetime(new Date());
      customer.setRecCreateBy(Constants.USERNAME_SYSTEM);
      customer.setRecCreateDatetime(new Date());
      customer.setCustomerClass(customerClass);
      customer.setSite(contentBean.getContentSessionBean().getSiteDomain().getSite());
    if (singleCheckout == Constants.VALUE_YES) {
      SiteDomain siteDomain = (SiteDomain) em.find(SiteDomain.class, defaultSiteDomainId);
      customer.setSiteDomain(siteDomain);
      query.setParameter("siteDomainId", defaultSiteDomainId);
    }
    else {
      customer.setSiteDomain(contentBean.getSiteDomain());
    }
     
        CustomerAddress customerAddress = new CustomerAddress();
        customer.setCustAddress(customerAddress);
        customer.getCustAddresses().add(customerAddress);
        customerAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_OWN);
        customerAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_CUST);
        customerAddress.setRecUpdateBy(Constants.USERNAME_SYSTEM);
        customerAddress.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        customerAddress.setRecCreateBy(Constants.USERNAME_SYSTEM);
        customerAddress.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        em.persist(customerAddress);
       
      em.persist(customer);
     
      setCustId(request, customer.getCustId());
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    this.streamWebService(response, jsonResult.toHtmlString());
      return null;
    }
View Full Code Here

            ActionForm actionForm,
            HttpServletRequest request,
            HttpServletResponse response)
        throws Throwable {
    String contentNaturalKey = (String) request.getParameter("contentNaturalKey");
    Customer customer = getCustomer(request);
    if (customer == null) {
      return null;
    }
   
    ContentSessionBean contentSessionBean = getContentBean(request).getContentSessionBean();
    Site site = contentSessionBean.getSiteDomain().getSite();
    String commentTitle = request.getParameter("commentTitle");
    commentTitle = Utility.escapeStrictHTML(commentTitle);
    String commentLine = request.getParameter("comment");
    commentLine = Utility.escapeStrictHTML(commentLine);
    if (!Format.isNullOrEmpty(commentTitle) ||  !Format.isNullOrEmpty(commentLine)) {   
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      Content content = ContentDAO.loadNatural(site.getSiteId(), Utility.encode(contentNaturalKey));
      Comment comment = new Comment();
      comment.setCommentTitle(commentTitle);
      comment.setComment(commentLine);
      comment.setActive(Constants.VALUE_YES);
      String custName = customer.getCustEmail();
      if (custName.length() > 20) {
        custName = custName.substring(0, 19);
      }
      comment.setRecCreateBy(custName);
      comment.setRecCreateDatetime(new Date(System.currentTimeMillis()));
View Full Code Here

      Site site = contentBean.getSiteDomain().getSite();
    ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
      EntityManager em = null;
    em = JpaConnection.getInstance().getCurrentEntityManager();
   
    Customer customer = getCustomer(request);
    if (customer.getCustPassword() == null) {
        ShoppingCartActionForm form = (ShoppingCartActionForm) actionForm;
      ActionMessages errors = validate(form, site.getSiteId());
      if (errors.size() != 0) {
        saveMessages(request, errors);
        form.setCustPassword(null);
        form.setCustVerifyPassword(null);
        this.initAddressInfo(form, site, shoppingCart, request, errors);
        this.initSearchInfo(form, site.getSiteId(), errors);
        this.initCartInfo(form, site, shoppingCart, request, errors);
            createEmptySecureTemplateInfo(request);
        return actionMapping.findForward("error");
      }
      Customer c = (Customer) em.find(Customer.class, customer.getCustId());
      c.setCustPassword(AESEncoder.getInstance().encode(form.getCustPassword()));
      c.setCustPublicName(form.getCustPublicName());
       }
   
      PayPalEngine paymentEngine = (PayPalEngine) shoppingCart.getPaymentEngine();
      String orderNum = null;
      createEmptySecureTemplateInfo(request);
View Full Code Here

   
    String emailAddress = payer.getPayer().trim();
   
        EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();

        Customer customer = null;
        CustomerAddress customerAddress = null;
        CustomerAddress billingAddress = null;
        CustomerAddress shippingAddress = null;

        String sql = "from Customer customer where custEmail = :custEmail";
        Query query = em.createQuery(sql);
        query.setParameter("custEmail", emailAddress);
        List<?> list = query.getResultList();
        if (list.size() > 0) {
          customer = (Customer) list.iterator().next();
          if (!customer.getActive().equals(Constants.VALUE_YES)) {
            throw new PaymentCustomerException("Customer suspended");
          }
        }
       
        if (customer == null) {
          customer = new Customer();
        CustomerClass customerClass = (CustomerClass) em.find(CustomerClass.class, payPalExpressCheckOut.getPaymentPaypalCustClassId());
        customer.setCustomerClass(customerClass);
          customer.setActive(Constants.VALUE_YES);
            customer.setRecCreateBy(Constants.USERNAME_CUSTOMER);
            customer.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        }
        else {
          customerAddress = customer.getCustAddress();
          for (CustomerAddress address : customer.getCustAddresses()) {
            if (address.getCustAddressType().equals(Constants.CUSTOMER_ADDRESS_BILLING)) {
              billingAddress = address;
              continue;
            }
            if (address.getCustAddressType().equals(Constants.CUSTOMER_ADDRESS_SHIPPING)) {
              shippingAddress = address;
              continue;
            }
          }
        }
       
        if (customerAddress == null) {
          customerAddress = new CustomerAddress();
          customerAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_OWN);
          customerAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_CUST);
          customerAddress.setRecCreateBy(Constants.USERNAME_CUSTOMER);
          customerAddress.setRecCreateDatetime(new Date(System.currentTimeMillis()));
            customer.getCustAddresses().add(customerAddress);
            customer.setCustAddress(customerAddress);
        }
        if (billingAddress == null) {
            billingAddress = new CustomerAddress();
            billingAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_CUST);
            billingAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_BILLING);
            billingAddress.setRecCreateBy(Constants.USERNAME_CUSTOMER);
            billingAddress.setRecCreateDatetime(new Date(System.currentTimeMillis()));
            customer.getCustAddresses().add(billingAddress);
        }
        if (shippingAddress == null) {
            shippingAddress = new CustomerAddress();
            shippingAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_SHIPPING);
            shippingAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_CUST);
            shippingAddress.setRecCreateBy(Constants.USERNAME_CUSTOMER);
            shippingAddress.setRecCreateDatetime(new Date(System.currentTimeMillis()));
            customer.getCustAddresses().add(shippingAddress);
        }
       
        billingAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_CUST);
        billingAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_BILLING);
        billingAddress.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
        billingAddress.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        shoppingCart.setBillingAddress(billingAddress);
        if (billingAddress.getCustAddressId() == null) {
          em.persist(billingAddress);
        }
        shippingAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_CUST);
        shippingAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_SHIPPING);
        shippingAddress.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
        shippingAddress.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        shoppingCart.setShippingAddress(shippingAddress);
        if (shippingAddress.getCustAddressId() == null) {
          em.persist(shippingAddress);
        }
       
        String stateName = Format.getString(payer.getAddress().getStateOrProvince());
        State state = Utility.getStateByNameOrCode(site.getSiteId(), stateName);
        String countryCode = Format.getString(payer.getAddress().getCountry().toString());
        Country country = Utility.getCountryByCode(site.getSiteId(), countryCode);

        customer.setSite(site);
        customer.setCustPublicName("");
        customer.setCustEmail(emailAddress);
        customer.setCustSource(Constants.CUSTOMER_SOURCE_PAYPAL);
        customer.setCustSourceRef(Format.getString(payer.getPayerID()));
        customer.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
        customer.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
//        customer.setCustPublicName(customer.getCustEmail());
        char singleCheckout = contentBean.getSiteDomain().getSite().getSingleCheckout();
        if (singleCheckout == Constants.VALUE_YES) {
          customer.setSiteDomain(contentBean.getSiteDomain().getSite().getSiteDomainDefault());
        }
        else {
          customer.setSiteDomain(contentBean.getSiteDomain());
        }
       
        customerAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_OWN);
        customerAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_CUST);
        customerAddress.setCustPrefix(Format.getString(payer.getPayerName().getSalutation()));
        customerAddress.setCustFirstName(Format.getString(payer.getPayerName().getFirstName()));
        customerAddress.setCustMiddleName(Format.getString(payer.getPayerName().getMiddleName()));
        customerAddress.setCustLastName(Format.getString(payer.getPayerName().getLastName()));
        customerAddress.setCustSuffix(Format.getString(payer.getPayerName().getSuffix()));
        customerAddress.setCustAddressLine1(payer.getAddress().getStreet1());
        customerAddress.setCustAddressLine2(payer.getAddress().getStreet2());
        customerAddress.setCustCityName(payer.getAddress().getCityName());
        customerAddress.setCustStateCode(state.getStateCode());
        customerAddress.setCustStateName(state.getStateName());
        customerAddress.setCustCountryName(country.getCountryName());
        customerAddress.setCustCountryCode(country.getCountryCode());
        customerAddress.setCustZipCode("");
        customerAddress.setCustPhoneNum(Format.getString(payer.getContactPhone()));
        customerAddress.setCustFaxNum("");
        // TODO what if state and country and null
        customerAddress.setState(state);
        customerAddress.setCountry(country);
        customerAddress.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
        customerAddress.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        em.persist(customerAddress);
       
        em.persist(customer);
        shoppingCart.initCustomer(customer, contentBean);
       
        // Automatically sign-in after Pay Pal confirm
        ContentAction.setCustId(request, customer.getCustId());
       
        payerId = Format.getString(payer.getPayerID());
        return;
  }
View Full Code Here

          messages.add("forgot", new ActionMessage("content.text.myaccount.forgot.invalid"));
      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
        }
        Customer customer = (Customer) list.get(0);
       
         MessageResources resources = this.getResources(request);
        Mailer mailer = new Mailer(site);
        SiteDomain siteDomain = contentBean.getContentSessionBean().getSiteDomain();
        SiteDomainLanguage siteDomainLanguage = null;
        for (SiteDomainLanguage language : siteDomain.getSiteDomainLanguages()) {
          if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
            siteDomainLanguage = language;
            break;
         
        }
        SiteDomainParamBean siteDomainParamBean = SiteDomainDAO.getSiteDomainParamBean(siteDomain.getSiteDomainLanguage(), siteDomainLanguage);
        String mailFrom = siteDomainParamBean.getMailFromPwdReset();
        String subject = siteDomainParamBean.getSubjectPwdReset();
        String body = resources.getMessage("message.mail.pwdReset.body", AESEncoder.getInstance().decode(customer.getCustPassword()));
        if (mailFrom == null) {
          mailFrom = "";
        }
        if (subject == null) {
          subject = "";
View Full Code Here

            HttpServletRequest request,
            HttpServletResponse response)
        throws Throwable {
      MyAccountShipInfoActionForm form = (MyAccountShipInfoActionForm) actionForm;
      ActionForward actionForward = actionMapping.findForward("success");
      Customer customer = getCustomer(request);
    String siteId = getContentBean(request).getContentSessionKey().getSiteId();

      customer = CustomerDAO.load(siteId, customer.getCustId());
      CustomerAddress billingAddress = getBillingAddress(customer);
      if (billingAddress != null) {
        form.setBillingCustPrefix(billingAddress.getCustPrefix());
        form.setBillingCustFirstName(billingAddress.getCustFirstName());
        form.setBillingCustMiddleName(billingAddress.getCustMiddleName());
View Full Code Here

TOP

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

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.