Search in sources :

Example 1 with ProductTypeDescription

use of com.salesmanager.shop.model.catalog.product.type.ProductTypeDescription in project shopizer by shopizer-ecommerce.

the class ReadableProductPopulator method type.

private ReadableProductType type(ProductType type, Language language) {
    ReadableProductType readableType = new ReadableProductType();
    readableType.setCode(type.getCode());
    readableType.setId(type.getId());
    if (!CollectionUtils.isEmpty(type.getDescriptions())) {
        Optional<ProductTypeDescription> desc = type.getDescriptions().stream().filter(t -> t.getLanguage().getCode().equals(language.getCode())).map(d -> typeDescription(d)).findFirst();
        if (desc.isPresent()) {
            readableType.setDescription(desc.get());
        }
    }
    return readableType;
}
Also used : ProductPrice(com.salesmanager.core.model.catalog.product.price.ProductPrice) RentalOwner(com.salesmanager.shop.model.catalog.product.RentalOwner) ReadableProductOptionValueEntity(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionValueEntity) DateUtil(com.salesmanager.shop.utils.DateUtil) StringUtils(org.apache.commons.lang3.StringUtils) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) ProductOptionValueDescription(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValueDescription) Language(com.salesmanager.core.model.reference.language.Language) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ReadableProductFull(com.salesmanager.shop.model.catalog.product.ReadableProductFull) FinalPrice(com.salesmanager.core.model.catalog.product.price.FinalPrice) ReadableProductAttributeValue(com.salesmanager.shop.model.catalog.product.attribute.ReadableProductAttributeValue) ReadableImage(com.salesmanager.shop.model.catalog.product.ReadableImage) ManufacturerDescription(com.salesmanager.core.model.catalog.product.manufacturer.ManufacturerDescription) Map(java.util.Map) PricingService(com.salesmanager.core.business.services.catalog.product.PricingService) ReadableProductPrice(com.salesmanager.shop.model.catalog.product.ReadableProductPrice) ReadableProduct(com.salesmanager.shop.model.catalog.product.ReadableProduct) ProductAttribute(com.salesmanager.core.model.catalog.product.attribute.ProductAttribute) Product(com.salesmanager.core.model.catalog.product.Product) ProductPriceDescription(com.salesmanager.core.model.catalog.product.price.ProductPriceDescription) AbstractDataPopulator(com.salesmanager.core.business.utils.AbstractDataPopulator) ProductOptionValue(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue) ReadableProductType(com.salesmanager.shop.model.catalog.product.type.ReadableProductType) ProductOptionDescription(com.salesmanager.core.model.catalog.product.attribute.ProductOptionDescription) Set(java.util.Set) ImageFilePath(com.salesmanager.shop.utils.ImageFilePath) Collectors(java.util.stream.Collectors) Category(com.salesmanager.core.model.catalog.category.Category) ReadableManufacturer(com.salesmanager.shop.model.catalog.manufacturer.ReadableManufacturer) List(java.util.List) Validate(org.apache.commons.lang3.Validate) TreeMap(java.util.TreeMap) ProductImage(com.salesmanager.core.model.catalog.product.image.ProductImage) ReadableCategory(com.salesmanager.shop.model.catalog.category.ReadableCategory) Optional(java.util.Optional) ConversionException(com.salesmanager.core.business.exception.ConversionException) ProductType(com.salesmanager.core.model.catalog.product.type.ProductType) ProductSpecification(com.salesmanager.shop.model.catalog.product.ProductSpecification) ProductTypeDescription(com.salesmanager.shop.model.catalog.product.type.ProductTypeDescription) ProductAvailability(com.salesmanager.core.model.catalog.product.availability.ProductAvailability) Comparator(java.util.Comparator) ProductDescription(com.salesmanager.core.model.catalog.product.description.ProductDescription) ReadableProductPropertyValue(com.salesmanager.shop.model.catalog.product.attribute.ReadableProductPropertyValue) ReadableProductAttribute(com.salesmanager.shop.model.catalog.product.attribute.ReadableProductAttribute) ReadableProductProperty(com.salesmanager.shop.model.catalog.product.attribute.ReadableProductProperty) ReadableProductOption(com.salesmanager.shop.model.catalog.product.attribute.ReadableProductOption) ProductTypeDescription(com.salesmanager.shop.model.catalog.product.type.ProductTypeDescription) ReadableProductType(com.salesmanager.shop.model.catalog.product.type.ReadableProductType)

Example 2 with ProductTypeDescription

use of com.salesmanager.shop.model.catalog.product.type.ProductTypeDescription in project shopizer by shopizer-ecommerce.

the class ReadableProductTypeMapper method type.

private ReadableProductType type(ProductType type, Language language) {
    ReadableProductType readableType = null;
    if (language != null) {
        readableType = new ReadableProductType();
        if (!CollectionUtils.isEmpty(type.getDescriptions())) {
            Optional<ProductTypeDescription> desc = type.getDescriptions().stream().filter(t -> t.getLanguage().getCode().equals(language.getCode())).map(d -> typeDescription(d)).findFirst();
            if (desc.isPresent()) {
                readableType.setDescription(desc.get());
            }
        }
    } else {
        readableType = new ReadableProductTypeFull();
        List<ProductTypeDescription> descriptions = type.getDescriptions().stream().map(t -> this.typeDescription(t)).collect(Collectors.toList());
        ((ReadableProductTypeFull) readableType).setDescriptions(descriptions);
    }
    readableType.setCode(type.getCode());
    readableType.setId(type.getId());
    readableType.setVisible(type.getVisible() != null && type.getVisible().booleanValue() ? true : false);
    readableType.setAllowAddToCart(type.getAllowAddToCart() != null && type.getAllowAddToCart().booleanValue() ? true : false);
    return readableType;
}
Also used : Mapper(com.salesmanager.shop.mapper.Mapper) ReadableProductType(com.salesmanager.shop.model.catalog.product.type.ReadableProductType) Collectors(java.util.stream.Collectors) CollectionUtils(org.apache.commons.collections4.CollectionUtils) Language(com.salesmanager.core.model.reference.language.Language) List(java.util.List) Component(org.springframework.stereotype.Component) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ReadableProductTypeFull(com.salesmanager.shop.model.catalog.product.type.ReadableProductTypeFull) Validate(org.apache.commons.lang3.Validate) Optional(java.util.Optional) ProductType(com.salesmanager.core.model.catalog.product.type.ProductType) ProductTypeDescription(com.salesmanager.shop.model.catalog.product.type.ProductTypeDescription) ProductTypeDescription(com.salesmanager.shop.model.catalog.product.type.ProductTypeDescription) ReadableProductTypeFull(com.salesmanager.shop.model.catalog.product.type.ReadableProductTypeFull) ReadableProductType(com.salesmanager.shop.model.catalog.product.type.ReadableProductType)

Example 3 with ProductTypeDescription

use of com.salesmanager.shop.model.catalog.product.type.ProductTypeDescription in project shopizer by shopizer-ecommerce.

the class ReadableProductTypeMapper method typeDescription.

private ProductTypeDescription typeDescription(com.salesmanager.core.model.catalog.product.type.ProductTypeDescription description) {
    ProductTypeDescription desc = new ProductTypeDescription();
    desc.setId(description.getId());
    desc.setName(description.getName());
    desc.setDescription(description.getDescription());
    desc.setLanguage(description.getLanguage().getCode());
    return desc;
}
Also used : ProductTypeDescription(com.salesmanager.shop.model.catalog.product.type.ProductTypeDescription)

Example 4 with ProductTypeDescription

use of com.salesmanager.shop.model.catalog.product.type.ProductTypeDescription in project shopizer by shopizer-ecommerce.

the class ReadableProductPopulator method typeDescription.

private ProductTypeDescription typeDescription(com.salesmanager.core.model.catalog.product.type.ProductTypeDescription description) {
    ProductTypeDescription desc = new ProductTypeDescription();
    desc.setId(description.getId());
    desc.setName(description.getName());
    desc.setDescription(description.getDescription());
    desc.setLanguage(description.getLanguage().getCode());
    return desc;
}
Also used : ProductTypeDescription(com.salesmanager.shop.model.catalog.product.type.ProductTypeDescription)

Example 5 with ProductTypeDescription

use of com.salesmanager.shop.model.catalog.product.type.ProductTypeDescription in project shopizer by shopizer-ecommerce.

the class PersistableProductTypeMapper method type.

private ProductType type(PersistableProductType type, ProductType destination) throws ServiceException {
    if (destination == null) {
        destination = new ProductType();
    }
    destination.setCode(type.getCode());
    destination.setId(type.getId());
    destination.setAllowAddToCart(type.isAllowAddToCart());
    destination.setVisible(type.isVisible());
    // destination.set
    List<com.salesmanager.core.model.catalog.product.type.ProductTypeDescription> descriptions = new ArrayList<com.salesmanager.core.model.catalog.product.type.ProductTypeDescription>();
    if (!CollectionUtils.isEmpty(type.getDescriptions())) {
        for (ProductTypeDescription d : type.getDescriptions()) {
            com.salesmanager.core.model.catalog.product.type.ProductTypeDescription desc = typeDescription(d, destination, d.getLanguage());
            descriptions.add(desc);
        }
        destination.setDescriptions(new HashSet<com.salesmanager.core.model.catalog.product.type.ProductTypeDescription>(descriptions));
    }
    return destination;
}
Also used : ProductTypeDescription(com.salesmanager.shop.model.catalog.product.type.ProductTypeDescription) ProductType(com.salesmanager.core.model.catalog.product.type.ProductType) PersistableProductType(com.salesmanager.shop.model.catalog.product.type.PersistableProductType) ArrayList(java.util.ArrayList)

Aggregations

ProductTypeDescription (com.salesmanager.shop.model.catalog.product.type.ProductTypeDescription)5 ProductType (com.salesmanager.core.model.catalog.product.type.ProductType)3 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)2 Language (com.salesmanager.core.model.reference.language.Language)2 ReadableProductType (com.salesmanager.shop.model.catalog.product.type.ReadableProductType)2 List (java.util.List)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 CollectionUtils (org.apache.commons.collections4.CollectionUtils)2 Validate (org.apache.commons.lang3.Validate)2 ConversionException (com.salesmanager.core.business.exception.ConversionException)1 PricingService (com.salesmanager.core.business.services.catalog.product.PricingService)1 AbstractDataPopulator (com.salesmanager.core.business.utils.AbstractDataPopulator)1 Category (com.salesmanager.core.model.catalog.category.Category)1 Product (com.salesmanager.core.model.catalog.product.Product)1 ProductAttribute (com.salesmanager.core.model.catalog.product.attribute.ProductAttribute)1 ProductOptionDescription (com.salesmanager.core.model.catalog.product.attribute.ProductOptionDescription)1 ProductOptionValue (com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue)1 ProductOptionValueDescription (com.salesmanager.core.model.catalog.product.attribute.ProductOptionValueDescription)1 ProductAvailability (com.salesmanager.core.model.catalog.product.availability.ProductAvailability)1