Search in sources :

Example 91 with Language

use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.

the class ProductInventoryFacadeImpl method getInventory.

@Override
public ReadableEntityList<ReadableInventory> getInventory(Long productId, MerchantStore store, String child, Language language, int page, int count) {
    Product product = getProductById(productId);
    validateProductHasSameStore(store, product);
    Page<ProductAvailability> availabilities = productAvailabilityService.listByProduct(product, store, child, page, count);
    List<ReadableInventory> inventories = availabilities.stream().map(pa -> readableInventoryMapper.convert(pa, store, language)).collect(Collectors.toList());
    return createReadableList(availabilities, inventories);
}
Also used : ProductService(com.salesmanager.core.business.services.catalog.product.ProductService) ReadableEntityUtil.createReadableList(com.salesmanager.shop.util.ReadableEntityUtil.createReadableList) Autowired(org.springframework.beans.factory.annotation.Autowired) ProductInventoryFacade(com.salesmanager.shop.store.controller.product.facade.ProductInventoryFacade) ServiceException(com.salesmanager.core.business.exception.ServiceException) Language(com.salesmanager.core.model.reference.language.Language) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) Service(org.springframework.stereotype.Service) MerchantStoreService(com.salesmanager.core.business.services.merchant.MerchantStoreService) Product(com.salesmanager.core.model.catalog.product.Product) PersistableInventory(com.salesmanager.shop.model.catalog.product.inventory.PersistableInventory) ReadableInventoryMapper(com.salesmanager.shop.mapper.inventory.ReadableInventoryMapper) ProductAvailabilityService(com.salesmanager.core.business.services.catalog.product.availability.ProductAvailabilityService) Page(org.springframework.data.domain.Page) Profile(org.springframework.context.annotation.Profile) Collectors(java.util.stream.Collectors) ReadableInventory(com.salesmanager.shop.model.catalog.product.inventory.ReadableInventory) Objects(java.util.Objects) List(java.util.List) Validate(org.apache.commons.lang3.Validate) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) Optional(java.util.Optional) ProductAvailability(com.salesmanager.core.model.catalog.product.availability.ProductAvailability) PersistableInventoryMapper(com.salesmanager.shop.mapper.inventory.PersistableInventoryMapper) ReadableEntityList(com.salesmanager.shop.model.entity.ReadableEntityList) ProductAvailability(com.salesmanager.core.model.catalog.product.availability.ProductAvailability) ReadableInventory(com.salesmanager.shop.model.catalog.product.inventory.ReadableInventory) Product(com.salesmanager.core.model.catalog.product.Product)

Example 92 with Language

use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.

the class ProductOptionFacadeImpl method optionValues.

@Override
public ReadableProductOptionValueList optionValues(MerchantStore store, Language language, String name, int page, int count) {
    Validate.notNull(store, "MerchantStore should not be null");
    Page<ProductOptionValue> options = productOptionValueService.getByMerchant(store, null, name, page, count);
    ReadableProductOptionValueList valueList = new ReadableProductOptionValueList();
    valueList.setTotalPages(options.getTotalPages());
    valueList.setRecordsTotal(options.getTotalElements());
    valueList.setNumber(options.getNumber());
    List<ReadableProductOptionValueEntity> values = options.getContent().stream().map(option -> readableOptionValueMapper.convert(option, store, null)).collect(Collectors.toList());
    valueList.setOptionValues(values);
    return valueList;
}
Also used : NotImplementedException(org.apache.commons.lang3.NotImplementedException) ProductService(com.salesmanager.core.business.services.catalog.product.ProductService) ReadableProductAttributeList(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductAttributeList) ReadableProductOptionValueEntity(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionValueEntity) Autowired(org.springframework.beans.factory.annotation.Autowired) ProductOptionValueService(com.salesmanager.core.business.services.catalog.product.attribute.ProductOptionValueService) ServiceException(com.salesmanager.core.business.exception.ServiceException) Language(com.salesmanager.core.model.reference.language.Language) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ReadableProductOptionList(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionList) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) Service(org.springframework.stereotype.Service) ReadableProductAttributeMapper(com.salesmanager.shop.mapper.catalog.ReadableProductAttributeMapper) ProductOption(com.salesmanager.core.model.catalog.product.attribute.ProductOption) FileContentType(com.salesmanager.core.model.content.FileContentType) ProductAttributeService(com.salesmanager.core.business.services.catalog.product.attribute.ProductAttributeService) PersistableProductAttributeMapper(com.salesmanager.shop.mapper.catalog.PersistableProductAttributeMapper) ProductOptionFacade(com.salesmanager.shop.store.controller.product.facade.ProductOptionFacade) ProductAttribute(com.salesmanager.core.model.catalog.product.attribute.ProductAttribute) Validate(org.jsoup.helper.Validate) Product(com.salesmanager.core.model.catalog.product.Product) ReadableProductOptionMapper(com.salesmanager.shop.mapper.catalog.ReadableProductOptionMapper) ProductOptionValue(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue) PersistableProductOptionEntity(com.salesmanager.shop.model.catalog.product.attribute.api.PersistableProductOptionEntity) CodeEntity(com.salesmanager.shop.model.entity.CodeEntity) PersistableProductAttribute(com.salesmanager.shop.model.catalog.product.attribute.PersistableProductAttribute) PersistableProductOptionValue(com.salesmanager.shop.model.catalog.product.attribute.PersistableProductOptionValue) Page(org.springframework.data.domain.Page) InputContentFile(com.salesmanager.core.model.content.InputContentFile) Collectors(java.util.stream.Collectors) ContentService(com.salesmanager.core.business.services.content.ContentService) ReadableProductOptionValueList(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionValueList) List(java.util.List) PersistableProductOptionMapper(com.salesmanager.shop.mapper.catalog.PersistableProductOptionMapper) ReadableProductOptionValueMapper(com.salesmanager.shop.mapper.catalog.ReadableProductOptionValueMapper) ReadableProductAttributeEntity(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductAttributeEntity) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) MultipartFile(org.springframework.web.multipart.MultipartFile) ProductOptionService(com.salesmanager.core.business.services.catalog.product.attribute.ProductOptionService) PersistableProductOptionValueMapper(com.salesmanager.shop.mapper.catalog.PersistableProductOptionValueMapper) ReadableProductOptionEntity(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionEntity) InputStream(java.io.InputStream) ProductOptionValue(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue) PersistableProductOptionValue(com.salesmanager.shop.model.catalog.product.attribute.PersistableProductOptionValue) ReadableProductOptionValueEntity(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionValueEntity) ReadableProductOptionValueList(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionValueList)

Example 93 with Language

use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.

the class ProductOptionFacadeImpl method options.

@Override
public ReadableProductOptionList options(MerchantStore store, Language language, String name, int page, int count) {
    Validate.notNull(store, "MerchantStore should not be null");
    Page<ProductOption> options = productOptionService.getByMerchant(store, null, name, page, count);
    ReadableProductOptionList valueList = new ReadableProductOptionList();
    valueList.setTotalPages(options.getTotalPages());
    valueList.setRecordsTotal(options.getTotalElements());
    valueList.setNumber(options.getNumber());
    List<ReadableProductOptionEntity> values = options.getContent().stream().map(option -> readableMapper.convert(option, store, null)).collect(Collectors.toList());
    valueList.setOptions(values);
    return valueList;
}
Also used : ProductOption(com.salesmanager.core.model.catalog.product.attribute.ProductOption) NotImplementedException(org.apache.commons.lang3.NotImplementedException) ProductService(com.salesmanager.core.business.services.catalog.product.ProductService) ReadableProductAttributeList(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductAttributeList) ReadableProductOptionValueEntity(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionValueEntity) Autowired(org.springframework.beans.factory.annotation.Autowired) ProductOptionValueService(com.salesmanager.core.business.services.catalog.product.attribute.ProductOptionValueService) ServiceException(com.salesmanager.core.business.exception.ServiceException) Language(com.salesmanager.core.model.reference.language.Language) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ReadableProductOptionList(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionList) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) Service(org.springframework.stereotype.Service) ReadableProductAttributeMapper(com.salesmanager.shop.mapper.catalog.ReadableProductAttributeMapper) ProductOption(com.salesmanager.core.model.catalog.product.attribute.ProductOption) FileContentType(com.salesmanager.core.model.content.FileContentType) ProductAttributeService(com.salesmanager.core.business.services.catalog.product.attribute.ProductAttributeService) PersistableProductAttributeMapper(com.salesmanager.shop.mapper.catalog.PersistableProductAttributeMapper) ProductOptionFacade(com.salesmanager.shop.store.controller.product.facade.ProductOptionFacade) ProductAttribute(com.salesmanager.core.model.catalog.product.attribute.ProductAttribute) Validate(org.jsoup.helper.Validate) Product(com.salesmanager.core.model.catalog.product.Product) ReadableProductOptionMapper(com.salesmanager.shop.mapper.catalog.ReadableProductOptionMapper) ProductOptionValue(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue) PersistableProductOptionEntity(com.salesmanager.shop.model.catalog.product.attribute.api.PersistableProductOptionEntity) CodeEntity(com.salesmanager.shop.model.entity.CodeEntity) PersistableProductAttribute(com.salesmanager.shop.model.catalog.product.attribute.PersistableProductAttribute) PersistableProductOptionValue(com.salesmanager.shop.model.catalog.product.attribute.PersistableProductOptionValue) Page(org.springframework.data.domain.Page) InputContentFile(com.salesmanager.core.model.content.InputContentFile) Collectors(java.util.stream.Collectors) ContentService(com.salesmanager.core.business.services.content.ContentService) ReadableProductOptionValueList(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionValueList) List(java.util.List) PersistableProductOptionMapper(com.salesmanager.shop.mapper.catalog.PersistableProductOptionMapper) ReadableProductOptionValueMapper(com.salesmanager.shop.mapper.catalog.ReadableProductOptionValueMapper) ReadableProductAttributeEntity(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductAttributeEntity) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) MultipartFile(org.springframework.web.multipart.MultipartFile) ProductOptionService(com.salesmanager.core.business.services.catalog.product.attribute.ProductOptionService) PersistableProductOptionValueMapper(com.salesmanager.shop.mapper.catalog.PersistableProductOptionValueMapper) ReadableProductOptionEntity(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionEntity) InputStream(java.io.InputStream) ReadableProductOptionList(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionList) ReadableProductOptionEntity(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionEntity)

Example 94 with Language

use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.

the class ProductOptionFacadeImpl method getAttributesList.

@Override
public ReadableProductAttributeList getAttributesList(Long productId, MerchantStore store, Language language, int page, int count) {
    try {
        Product product = this.product(productId, store);
        ReadableProductAttributeList attrList = new ReadableProductAttributeList();
        Page<ProductAttribute> attr = null;
        if (language != null) {
            // all entry
            // attributes = productAttributeService.getByProductId(store, product, language);
            attr = productAttributeService.getByProductId(store, product, language, page, count);
            attrList.setRecordsTotal(attr.getTotalElements());
            attrList.setNumber(attr.getSize());
            attrList.setTotalPages(attr.getTotalPages());
        } else {
            attr = productAttributeService.getByProductId(store, product, page, count);
            attrList.setRecordsTotal(attr.getTotalElements());
            attrList.setNumber(attr.getSize());
            attrList.setTotalPages(attr.getTotalPages());
        }
        List<ReadableProductAttributeEntity> values = attr.getContent().stream().map(attribute -> readableProductAttributeMapper.convert(attribute, store, language)).collect(Collectors.toList());
        attrList.setAttributes(values);
        return attrList;
    } catch (ServiceException e) {
        throw new ServiceRuntimeException("Error while getting attributes", e);
    }
}
Also used : NotImplementedException(org.apache.commons.lang3.NotImplementedException) ProductService(com.salesmanager.core.business.services.catalog.product.ProductService) ReadableProductAttributeList(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductAttributeList) ReadableProductOptionValueEntity(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionValueEntity) Autowired(org.springframework.beans.factory.annotation.Autowired) ProductOptionValueService(com.salesmanager.core.business.services.catalog.product.attribute.ProductOptionValueService) ServiceException(com.salesmanager.core.business.exception.ServiceException) Language(com.salesmanager.core.model.reference.language.Language) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ReadableProductOptionList(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionList) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) Service(org.springframework.stereotype.Service) ReadableProductAttributeMapper(com.salesmanager.shop.mapper.catalog.ReadableProductAttributeMapper) ProductOption(com.salesmanager.core.model.catalog.product.attribute.ProductOption) FileContentType(com.salesmanager.core.model.content.FileContentType) ProductAttributeService(com.salesmanager.core.business.services.catalog.product.attribute.ProductAttributeService) PersistableProductAttributeMapper(com.salesmanager.shop.mapper.catalog.PersistableProductAttributeMapper) ProductOptionFacade(com.salesmanager.shop.store.controller.product.facade.ProductOptionFacade) ProductAttribute(com.salesmanager.core.model.catalog.product.attribute.ProductAttribute) Validate(org.jsoup.helper.Validate) Product(com.salesmanager.core.model.catalog.product.Product) ReadableProductOptionMapper(com.salesmanager.shop.mapper.catalog.ReadableProductOptionMapper) ProductOptionValue(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue) PersistableProductOptionEntity(com.salesmanager.shop.model.catalog.product.attribute.api.PersistableProductOptionEntity) CodeEntity(com.salesmanager.shop.model.entity.CodeEntity) PersistableProductAttribute(com.salesmanager.shop.model.catalog.product.attribute.PersistableProductAttribute) PersistableProductOptionValue(com.salesmanager.shop.model.catalog.product.attribute.PersistableProductOptionValue) Page(org.springframework.data.domain.Page) InputContentFile(com.salesmanager.core.model.content.InputContentFile) Collectors(java.util.stream.Collectors) ContentService(com.salesmanager.core.business.services.content.ContentService) ReadableProductOptionValueList(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionValueList) List(java.util.List) PersistableProductOptionMapper(com.salesmanager.shop.mapper.catalog.PersistableProductOptionMapper) ReadableProductOptionValueMapper(com.salesmanager.shop.mapper.catalog.ReadableProductOptionValueMapper) ReadableProductAttributeEntity(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductAttributeEntity) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) MultipartFile(org.springframework.web.multipart.MultipartFile) ProductOptionService(com.salesmanager.core.business.services.catalog.product.attribute.ProductOptionService) PersistableProductOptionValueMapper(com.salesmanager.shop.mapper.catalog.PersistableProductOptionValueMapper) ReadableProductOptionEntity(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionEntity) InputStream(java.io.InputStream) ServiceException(com.salesmanager.core.business.exception.ServiceException) ReadableProductAttributeList(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductAttributeList) Product(com.salesmanager.core.model.catalog.product.Product) ProductAttribute(com.salesmanager.core.model.catalog.product.attribute.ProductAttribute) PersistableProductAttribute(com.salesmanager.shop.model.catalog.product.attribute.PersistableProductAttribute) ReadableProductAttributeEntity(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductAttributeEntity) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException)

Example 95 with Language

use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.

the class ProductOptionSetFacadeImpl method list.

@Override
public List<ReadableProductOptionSet> list(MerchantStore store, Language language, String type) {
    Validate.notNull(store, "MerchantStore cannot be null");
    Validate.notNull(language, "Language cannot be null");
    Validate.notNull(type, "Product type cannot be null");
    // find product type by id
    ReadableProductType readable = productTypeFacade.get(store, type, language);
    if (readable == null) {
        throw new ResourceNotFoundException("Can't fing product type [" + type + "] fpr merchand [" + store.getCode() + "]");
    }
    List<ProductOptionSet> optionSets = productOptionSetService.getByProductType(readable.getId(), store, language);
    return optionSets.stream().map(opt -> this.convert(opt, store, language)).collect(Collectors.toList());
}
Also used : OperationNotAllowedException(com.salesmanager.shop.store.api.exception.OperationNotAllowedException) ProductOptionSetFacade(com.salesmanager.shop.store.controller.product.facade.ProductOptionSetFacade) ProductOptionSet(com.salesmanager.core.model.catalog.product.attribute.ProductOptionSet) ReadableProductType(com.salesmanager.shop.model.catalog.product.type.ReadableProductType) Autowired(org.springframework.beans.factory.annotation.Autowired) Collectors(java.util.stream.Collectors) ProductOptionSetService(com.salesmanager.core.business.services.catalog.product.attribute.ProductOptionSetService) ServiceException(com.salesmanager.core.business.exception.ServiceException) Language(com.salesmanager.core.model.reference.language.Language) List(java.util.List) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) Validate(org.apache.commons.lang3.Validate) ReadableProductOptionSetMapper(com.salesmanager.shop.mapper.catalog.ReadableProductOptionSetMapper) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) Service(org.springframework.stereotype.Service) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) PersistableProductOptionSet(com.salesmanager.shop.model.catalog.product.attribute.optionset.PersistableProductOptionSet) PersistableProductOptionSetMapper(com.salesmanager.shop.mapper.catalog.PersistableProductOptionSetMapper) ReadableProductOptionSet(com.salesmanager.shop.model.catalog.product.attribute.optionset.ReadableProductOptionSet) ProductTypeFacade(com.salesmanager.shop.store.controller.product.facade.ProductTypeFacade) ProductOptionSet(com.salesmanager.core.model.catalog.product.attribute.ProductOptionSet) PersistableProductOptionSet(com.salesmanager.shop.model.catalog.product.attribute.optionset.PersistableProductOptionSet) ReadableProductOptionSet(com.salesmanager.shop.model.catalog.product.attribute.optionset.ReadableProductOptionSet) ReadableProductType(com.salesmanager.shop.model.catalog.product.type.ReadableProductType) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException)

Aggregations

Language (com.salesmanager.core.model.reference.language.Language)148 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)115 ArrayList (java.util.ArrayList)58 List (java.util.List)56 ServiceException (com.salesmanager.core.business.exception.ServiceException)55 Collectors (java.util.stream.Collectors)50 Product (com.salesmanager.core.model.catalog.product.Product)45 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)44 ServiceRuntimeException (com.salesmanager.shop.store.api.exception.ServiceRuntimeException)42 ResourceNotFoundException (com.salesmanager.shop.store.api.exception.ResourceNotFoundException)38 Autowired (org.springframework.beans.factory.annotation.Autowired)35 ConversionException (com.salesmanager.core.business.exception.ConversionException)30 Category (com.salesmanager.core.model.catalog.category.Category)30 Validate (org.apache.commons.lang3.Validate)29 Customer (com.salesmanager.core.model.customer.Customer)28 Optional (java.util.Optional)28 Inject (javax.inject.Inject)28 Service (org.springframework.stereotype.Service)28 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)27 ImageFilePath (com.salesmanager.shop.utils.ImageFilePath)25