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;
}
Aggregations