use of com.salesmanager.core.model.catalog.product.attribute.ProductOptionSet in project shopizer by shopizer-ecommerce.
the class ProductOptionSetFacadeImpl method exists.
@Override
public boolean exists(String code, MerchantStore store) {
Validate.notNull(store, "MerchantStore cannot be null");
Validate.notNull(code, "code cannot be null");
ProductOptionSet optionSet = productOptionSetService.getCode(store, code);
if (optionSet != null) {
return true;
}
return false;
}
use of com.salesmanager.core.model.catalog.product.attribute.ProductOptionSet in project shopizer by shopizer-ecommerce.
the class ProductOptionSetFacadeImpl method get.
@Override
public ReadableProductOptionSet get(Long id, MerchantStore store, Language language) {
Validate.notNull(store, "MerchantStore cannot be null");
Validate.notNull(language, "Language cannot be null");
ProductOptionSet optionSet = productOptionSetService.getById(store, id, language);
if (optionSet == null) {
throw new ResourceNotFoundException("ProductOptionSet not found for id [" + id + "] and store [" + store.getCode() + "]");
}
return readableProductOptionSetMapper.convert(optionSet, store, language);
}
use of com.salesmanager.core.model.catalog.product.attribute.ProductOptionSet 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());
}
use of com.salesmanager.core.model.catalog.product.attribute.ProductOptionSet in project shopizer by shopizer-ecommerce.
the class PersistableProductOptionSetMapper method merge.
@Override
public ProductOptionSet merge(PersistableProductOptionSet source, ProductOptionSet destination, MerchantStore store, Language language) {
Validate.notNull(destination, "ProductOptionSet must not be null");
destination.setId(source.getId());
destination.setCode(source.getCode());
destination.setOptionDisplayOnly(source.isReadOnly());
ProductOption option = productOptionService.getById(store, source.getOption());
destination.setOption(option);
if (!CollectionUtils.isEmpty(source.getOptionValues())) {
List<ProductOptionValue> values = source.getOptionValues().stream().map(id -> value(id, store)).collect(Collectors.toList());
destination.setValues(values);
}
if (!CollectionUtils.isEmpty(source.getProductTypes())) {
try {
List<ProductType> types = productTypeService.listProductTypes(source.getProductTypes(), store, language);
Set<ProductType> typesSet = new HashSet<ProductType>(types);
destination.setProductTypes(typesSet);
} catch (ServiceException e) {
throw new ConversionRuntimeException("Error while mpping ProductOptionSet", e);
}
}
return destination;
}
Aggregations