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