Search in sources :

Example 1 with ReadableProductOptionValueFull

use of com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionValueFull in project shopizer by shopizer-ecommerce.

the class ReadableProductOptionValueMapper method merge.

@Override
public ReadableProductOptionValueEntity merge(ProductOptionValue source, ReadableProductOptionValueEntity destination, MerchantStore store, Language language) {
    ReadableProductOptionValueEntity readableProductOptionValue = new ReadableProductOptionValueEntity();
    if (language == null) {
        readableProductOptionValue = new ReadableProductOptionValueFull();
        List<com.salesmanager.shop.model.catalog.product.attribute.ProductOptionValueDescription> descriptions = new ArrayList<com.salesmanager.shop.model.catalog.product.attribute.ProductOptionValueDescription>();
        for (ProductOptionValueDescription desc : source.getDescriptions()) {
            com.salesmanager.shop.model.catalog.product.attribute.ProductOptionValueDescription d = this.description(desc);
            descriptions.add(d);
        }
        ((ReadableProductOptionValueFull) readableProductOptionValue).setDescriptions(descriptions);
    } else {
        readableProductOptionValue = new ReadableProductOptionValueEntity();
        if (!CollectionUtils.isEmpty(source.getDescriptions())) {
            for (ProductOptionValueDescription desc : source.getDescriptions()) {
                if (desc != null && desc.getLanguage() != null && desc.getLanguage().getId() == language.getId()) {
                    com.salesmanager.shop.model.catalog.product.attribute.ProductOptionValueDescription d = this.description(desc);
                    readableProductOptionValue.setDescription(d);
                }
            }
        }
    }
    readableProductOptionValue.setCode(source.getCode());
    if (source.getId() != null) {
        readableProductOptionValue.setId(source.getId().longValue());
    }
    if (source.getProductOptionValueSortOrder() != null) {
        readableProductOptionValue.setOrder(source.getProductOptionValueSortOrder().intValue());
    }
    if (!StringUtils.isBlank(source.getProductOptionValueImage())) {
        readableProductOptionValue.setImage(imageUtils.buildProductPropertyImageUtils(store, source.getProductOptionValueImage()));
    }
    return readableProductOptionValue;
}
Also used : ArrayList(java.util.ArrayList) ReadableProductOptionValueEntity(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionValueEntity) ReadableProductOptionValueFull(com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionValueFull) ProductOptionValueDescription(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValueDescription)

Aggregations

ProductOptionValueDescription (com.salesmanager.core.model.catalog.product.attribute.ProductOptionValueDescription)1 ReadableProductOptionValueEntity (com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionValueEntity)1 ReadableProductOptionValueFull (com.salesmanager.shop.model.catalog.product.attribute.api.ReadableProductOptionValueFull)1 ArrayList (java.util.ArrayList)1