@Override
 public void addSubjectJDynamiTeValues(JDynamiTe jDynamiTe, Transaction transaction) {
   super.addSubjectJDynamiTeValues(jDynamiTe, transaction);
   CompanyDetails companyDetails =
       CommonConfiguration.getCommonConfiguration().getDefaultCompanyDetails();
   jDynamiTe.setVariable("COMPANY_NAME", companyDetails.getCompanyName());
   jDynamiTe.setVariable("ORDER_NUMBER", transaction.getId().toString());
 }
  public void sendEmail() {
    logger.debug("Entered send email method");
    if (CommonUtil.validateEmailAddressFormat(emailAddress)) {
      Subscriber subscriber = Subscriber.getOrCreateSubscriber(emailAddress);
      if (subscriber.isNew()) {
        String[] senderNameParts = getSenderName().split(" ");
        for (int i = 0, n = senderNameParts.length; i < n; i++) {
          if (i == 0) {
            subscriber.setFirstName(senderNameParts[i]);
          } else if (i == 1) {
            subscriber.setSurname(senderNameParts[i]);
          } else {
            subscriber.setSurname(subscriber.getSurname() + " " + senderNameParts[i]);
          }
        }
      }
      getContactFormSubmission().setSubscriber((Subscriber) subscriber.getSaveableBean());
      getContactFormSubmission().saveDetails();
      AplosEmail aplosEmail =
          new AplosEmail(
              CmsEmailTemplateEnum.CONTACT, getContactFormSubmission(), getContactFormSubmission());
      if (getContactFormSubmission().getAttachment() != null) {
        aplosEmail.addSaveableAttachment(getContactFormSubmission().getAttachment());
      }
      aplosEmail.setToAddress(
          CommonConfiguration.getCommonConfiguration()
              .getDefaultCompanyDetails()
              .getEmailAddress());
      if (isSendingDuplicateEmail()) {
        aplosEmail.addCcAddress(getContactFormSubmission().getEmailAddress());
      }
      if (aplosEmail.sendAplosEmailToQueue() != null) {
        setMessageSent(true);
        JSFUtil.addMessage("Thank you, your message has been sent.", FacesMessage.SEVERITY_INFO);

        aplosEmail =
            new AplosEmail(
                CmsEmailTemplateEnum.CONTACT,
                getContactFormSubmission(),
                getContactFormSubmission());
      } else {
        JSFUtil.addMessage("Sorry, your e-mail has not been sent.", FacesMessage.SEVERITY_WARN);
      }
    } else {
      JSFUtil.addMessage(
          "Sorry, your e-mail has not been sent. Please check your email address is correct.",
          FacesMessage.SEVERITY_WARN);
    }
  }
  @Override
  public void createDefaultWebsiteObjects(AplosContextListener aplosContextListener) {
    super.createDefaultWebsiteObjects(aplosContextListener);
    SystemUser adminUser = CommonConfiguration.getCommonConfiguration().getDefaultAdminUser();

    CssResource cssResource = new CssResource();
    cssResource.setParentWebsite(this);
    cssResource.setName("Main");
    cssResource.saveDetails(this, adminUser);
    setEditorCss(cssResource);
    saveDetails();

    CmsDatabaseLoader.createMenus(this, adminUser);
    TopLevelTemplate mainTemplate = getOrCreateMainTemplate(adminUser);
    TopLevelTemplate holdingTemplate = CmsDatabaseLoader.createHoldingTemplate(this, adminUser);
    CmsDatabaseLoader.createDefaultUserCmsModules(this, adminUser);
    CmsDatabaseLoader.createDefaultPages(this, mainTemplate, holdingTemplate, adminUser);
  }
 @Override
 public void addContentJDynamiTeValues(JDynamiTe jDynamiTe, Transaction transaction) {
   super.addContentJDynamiTeValues(jDynamiTe, transaction);
   jDynamiTe.setVariable(
       "CUSTOMER_FULLNAME", transaction.getEcommerceShoppingCart().getCustomer().getDisplayName());
   CompanyDetails companyDetails =
       CommonConfiguration.getCommonConfiguration().getDefaultCompanyDetails();
   jDynamiTe.setVariable("COMPANY_NAME", companyDetails.getAddress().getContactFirstName());
   if (companyDetails.getLogoDetails() != null) {
     jDynamiTe.setVariable("COMPANY_LOGO", companyDetails.getLogoDetails().getFilename());
   }
   jDynamiTe.setVariable("COMPANY_WEBSITE", companyDetails.getWeb());
   jDynamiTe.setVariable("ORDER_NUMBER", transaction.getId().toString());
   jDynamiTe.setVariable("DISPATCH_DATETIME", new Date().toString());
   String shippingMethodName = "";
   if (transaction.getEcommerceShoppingCart().getAvailableShippingService() != null) {
     shippingMethodName =
         transaction
             .getEcommerceShoppingCart()
             .getAvailableShippingService()
             .getCachedServiceName();
   }
   jDynamiTe.setVariable("SHIPPING_METHOD_NAME", shippingMethodName);
   jDynamiTe.setVariable(
       "SHIPPING_ADDRESS_STRING", transaction.getShippingAddress().getAddressString());
   jDynamiTe.setVariable("ORDER_STATUS", transaction.getTransactionStatus().getLabel());
   List<ShoppingCartItem> shoppingCartItems = transaction.getEcommerceShoppingCart().getItems();
   for (int i = 0, n = shoppingCartItems.size(); i < n; i++) {
     EcommerceShoppingCartItem shoppingItem = (EcommerceShoppingCartItem) shoppingCartItems.get(i);
     jDynamiTe.setVariable(
         "PRODUCT_CODE_REPEATED", CommonUtil.getStringOrEmpty(shoppingItem.getItemCode()));
     jDynamiTe.setVariable("PRODUCT_SIZE_REPEATED", shoppingItem.getProductSize());
     jDynamiTe.setVariable("PRODUCT_BRAND_AND_NAME_REPEATED", shoppingItem.getItemName());
     jDynamiTe.setVariable(
         "PRODUCT_QUANTITY_REPEATED", FormatUtil.formatTwoDigit(shoppingItem.getQuantity()));
     jDynamiTe.parseDynElem("productList");
   }
   jDynamiTe.setVariable(
       "COMPLETE_OR_CONTINUE",
       "This dispatch completes your order. We hope you will be very happy with your purchases.");
   jDynamiTe.setVariable("PART_OR_Y", "Y");
 }