use of com.salesmanager.core.model.system.optin.Optin in project shopizer by shopizer-ecommerce.
the class InitializationDatabaseImpl method createMerchant.
private void createMerchant() throws ServiceException {
LOGGER.info(String.format("%s : Creating merchant ", name));
Date date = new Date(System.currentTimeMillis());
Language en = languageService.getByCode("en");
Country ca = countryService.getByCode("CA");
Currency currency = currencyService.getByCode("CAD");
Zone qc = zoneService.getByCode("QC");
List<Language> supportedLanguages = new ArrayList<Language>();
supportedLanguages.add(en);
// create a merchant
MerchantStore store = new MerchantStore();
store.setCountry(ca);
store.setCurrency(currency);
store.setDefaultLanguage(en);
store.setInBusinessSince(date);
store.setZone(qc);
store.setStorename("Default store");
store.setStorephone("888-888-8888");
store.setCode(MerchantStore.DEFAULT_STORE);
store.setStorecity("My city");
store.setStoreaddress("1234 Street address");
store.setStorepostalcode("H2H-2H2");
store.setStoreEmailAddress("john@test.com");
store.setDomainName("localhost:8080");
store.setStoreTemplate("december");
store.setRetailer(true);
store.setLanguages(supportedLanguages);
merchantService.create(store);
TaxClass taxclass = new TaxClass(TaxClass.DEFAULT_TAX_CLASS);
taxclass.setMerchantStore(store);
taxClassService.create(taxclass);
// create default manufacturer
Manufacturer defaultManufacturer = new Manufacturer();
defaultManufacturer.setCode("DEFAULT");
defaultManufacturer.setMerchantStore(store);
ManufacturerDescription manufacturerDescription = new ManufacturerDescription();
manufacturerDescription.setLanguage(en);
manufacturerDescription.setName("DEFAULT");
manufacturerDescription.setManufacturer(defaultManufacturer);
manufacturerDescription.setDescription("DEFAULT");
defaultManufacturer.getDescriptions().add(manufacturerDescription);
manufacturerService.create(defaultManufacturer);
Optin newsletter = new Optin();
newsletter.setCode(OptinType.NEWSLETTER.name());
newsletter.setMerchant(store);
newsletter.setOptinType(OptinType.NEWSLETTER);
optinService.create(newsletter);
}
use of com.salesmanager.core.model.system.optin.Optin in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method optinCustomer.
@Override
public void optinCustomer(PersistableCustomerOptin optin, MerchantStore store) {
// check if customer optin exists
Optin optinDef = getOptinByCode(store);
CustomerOptin customerOptin = getCustomerOptinByEmailAddress(optin.getEmail(), store, OptinType.NEWSLETTER);
if (customerOptin != null) {
// exists update
customerOptin.setEmail(optin.getEmail());
customerOptin.setFirstName(optin.getFirstName());
customerOptin.setLastName(optin.getLastName());
} else {
customerOptin = new com.salesmanager.core.model.system.optin.CustomerOptin();
customerOptin.setEmail(optin.getEmail());
customerOptin.setFirstName(optin.getFirstName());
customerOptin.setLastName(optin.getLastName());
customerOptin.setOptinDate(new Date());
customerOptin.setOptin(optinDef);
customerOptin.setMerchantStore(store);
}
saveCustomerOption(customerOptin);
}
use of com.salesmanager.core.model.system.optin.Optin in project shopizer by shopizer-ecommerce.
the class OptinFacadeImpl method create.
@Override
public ReadableOptin create(PersistableOptin persistableOptin, MerchantStore merchantStore, Language language) {
Optin optinEntity = persistableOptinConverter.convert(persistableOptin, merchantStore, language);
Optin savedOptinEntity = createOptin(optinEntity);
return readableOptinConverter.convert(savedOptinEntity, merchantStore, language);
}
use of com.salesmanager.core.model.system.optin.Optin in project shopizer by shopizer-ecommerce.
the class PersistableOptinMapper method convert.
@Override
public Optin convert(PersistableOptin source, MerchantStore store, Language language) {
Optin optinEntity = new Optin();
optinEntity.setCode(source.getCode());
optinEntity.setDescription(source.getDescription());
optinEntity.setOptinType(OptinType.valueOf(source.getOptinType()));
optinEntity.setMerchant(store);
return optinEntity;
}
Aggregations