Search in sources :

Example 11 with ConversionRuntimeException

use of com.salesmanager.shop.store.api.exception.ConversionRuntimeException in project shopizer by shopizer-ecommerce.

the class CustomerFacadeImpl method updateAuthCustomer.

private PersistableCustomer updateAuthCustomer(PersistableCustomer customer, MerchantStore store) {
    if (customer.getId() == null || customer.getId() == 0) {
        throw new ServiceRuntimeException("Can't update a customer with null id");
    }
    Customer cust = customerService.getById(customer.getId());
    try {
        customerPopulator.populate(customer, cust, store, store.getDefaultLanguage());
    } catch (ConversionException e) {
        throw new ConversionRuntimeException(e);
    }
    saveCustomer(cust);
    customer.setId(cust.getId());
    return customer;
}
Also used : ConversionException(com.salesmanager.core.business.exception.ConversionException) ReadableCustomer(com.salesmanager.shop.model.customer.ReadableCustomer) Customer(com.salesmanager.core.model.customer.Customer) PersistableCustomer(com.salesmanager.shop.model.customer.PersistableCustomer) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException)

Example 12 with ConversionRuntimeException

use of com.salesmanager.shop.store.api.exception.ConversionRuntimeException in project shopizer by shopizer-ecommerce.

the class SearchFacadeImpl method convertCategoryToReadableCategory.

private ReadableCategory convertCategoryToReadableCategory(MerchantStore merchantStore, Language language, Map<String, Long> productCategoryCount, Category category) {
    ReadableCategoryPopulator populator = new ReadableCategoryPopulator();
    try {
        ReadableCategory categoryProxy = populator.populate(category, new ReadableCategory(), merchantStore, language);
        Long total = productCategoryCount.get(categoryProxy.getCode());
        if (total != null) {
            categoryProxy.setProductCount(total.intValue());
        }
        return categoryProxy;
    } catch (ConversionException e) {
        throw new ConversionRuntimeException(e);
    }
}
Also used : ConversionException(com.salesmanager.core.business.exception.ConversionException) ReadableCategory(com.salesmanager.shop.model.catalog.category.ReadableCategory) ReadableCategoryPopulator(com.salesmanager.shop.populator.catalog.ReadableCategoryPopulator) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException)

Example 13 with ConversionRuntimeException

use of com.salesmanager.shop.store.api.exception.ConversionRuntimeException in project shopizer by shopizer-ecommerce.

the class StoreFacadeImpl method convertPersistableMerchantStoreToMerchantStore.

private MerchantStore convertPersistableMerchantStoreToMerchantStore(PersistableMerchantStore store, Language language) {
    MerchantStore mStore = new MerchantStore();
    // set default values
    mStore.setWeightunitcode(MeasureUnit.KG.name());
    mStore.setSeizeunitcode(MeasureUnit.IN.name());
    try {
        mStore = persistableMerchantStorePopulator.populate(store, mStore, language);
    } catch (ConversionException e) {
        throw new ConversionRuntimeException(e);
    }
    return mStore;
}
Also used : ConversionException(com.salesmanager.core.business.exception.ConversionException) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ReadableMerchantStore(com.salesmanager.shop.model.store.ReadableMerchantStore) PersistableMerchantStore(com.salesmanager.shop.model.store.PersistableMerchantStore) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException)

Example 14 with ConversionRuntimeException

use of com.salesmanager.shop.store.api.exception.ConversionRuntimeException in project shopizer by shopizer-ecommerce.

the class StoreFacadeImpl method mergePersistableMerchantStoreToMerchantStore.

private MerchantStore mergePersistableMerchantStoreToMerchantStore(PersistableMerchantStore store, String code, Language language) {
    MerchantStore mStore = getMerchantStoreByCode(code);
    store.setId(mStore.getId());
    try {
        mStore = persistableMerchantStorePopulator.populate(store, mStore, language);
    } catch (ConversionException e) {
        throw new ConversionRuntimeException(e);
    }
    return mStore;
}
Also used : ConversionException(com.salesmanager.core.business.exception.ConversionException) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ReadableMerchantStore(com.salesmanager.shop.model.store.ReadableMerchantStore) PersistableMerchantStore(com.salesmanager.shop.model.store.PersistableMerchantStore) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException)

Example 15 with ConversionRuntimeException

use of com.salesmanager.shop.store.api.exception.ConversionRuntimeException in project shopizer by shopizer-ecommerce.

the class CustomerFacadeImpl method convertPersistableCustomerReviewToCustomerReview.

private CustomerReview convertPersistableCustomerReviewToCustomerReview(PersistableCustomerReview review, MerchantStore store, Language language) {
    PersistableCustomerReviewPopulator populator = new PersistableCustomerReviewPopulator();
    populator.setCustomerService(customerService);
    populator.setLanguageService(languageService);
    try {
        return populator.populate(review, new CustomerReview(), store, language);
    } catch (ConversionException e) {
        throw new ConversionRuntimeException(e);
    }
}
Also used : ConversionException(com.salesmanager.core.business.exception.ConversionException) PersistableCustomerReviewPopulator(com.salesmanager.shop.populator.customer.PersistableCustomerReviewPopulator) ReadableCustomerReview(com.salesmanager.shop.model.customer.ReadableCustomerReview) CustomerReview(com.salesmanager.core.model.customer.review.CustomerReview) PersistableCustomerReview(com.salesmanager.shop.model.customer.PersistableCustomerReview) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException)

Aggregations

ConversionRuntimeException (com.salesmanager.shop.store.api.exception.ConversionRuntimeException)29 ConversionException (com.salesmanager.core.business.exception.ConversionException)17 ArrayList (java.util.ArrayList)9 ServiceException (com.salesmanager.core.business.exception.ServiceException)8 Product (com.salesmanager.core.model.catalog.product.Product)7 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)7 Language (com.salesmanager.core.model.reference.language.Language)7 Category (com.salesmanager.core.model.catalog.category.Category)6 ProductDescription (com.salesmanager.core.model.catalog.product.description.ProductDescription)6 ProductAvailability (com.salesmanager.core.model.catalog.product.availability.ProductAvailability)5 ProductImage (com.salesmanager.core.model.catalog.product.image.ProductImage)5 ReadableCategory (com.salesmanager.shop.model.catalog.category.ReadableCategory)5 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 CollectionUtils (org.apache.commons.collections4.CollectionUtils)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 ProductOptionValue (com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue)4 FinalPrice (com.salesmanager.core.model.catalog.product.price.FinalPrice)4 Mapper (com.salesmanager.shop.mapper.Mapper)4 ProductSpecification (com.salesmanager.shop.model.catalog.product.ProductSpecification)4