use of com.salesmanager.shop.model.catalog.catalog.ReadableCatalogCategoryEntry in project shopizer by shopizer-ecommerce.
the class CatalogFacadeImpl method listCatalogEntry.
@Override
public ReadableEntityList<ReadableCatalogCategoryEntry> listCatalogEntry(Optional<String> product, Long id, MerchantStore store, Language language, int page, int count) {
Validate.notNull(store, "MerchantStore cannot be null");
String productCode = product.orElse(null);
Catalog catalog = catalogService.getById(id, store).orElseThrow(() -> new ResourceNotFoundException("Catalog with id [" + id + "] not found for store [" + store.getCode() + "]"));
Page<CatalogCategoryEntry> entries = catalogEntryService.list(catalog, store, language, productCode, page, count);
if (entries.isEmpty()) {
return new ReadableEntityList<>();
}
List<ReadableCatalogCategoryEntry> readableList = entries.getContent().stream().map(cat -> readableCatalogEntryMapper.convert(cat, store, language)).collect(Collectors.toList());
return createReadableList(entries, readableList);
}
use of com.salesmanager.shop.model.catalog.catalog.ReadableCatalogCategoryEntry in project shopizer by shopizer-ecommerce.
the class CatalogFacadeImpl method addCatalogEntry.
@Override
public ReadableCatalogCategoryEntry addCatalogEntry(PersistableCatalogCategoryEntry entry, MerchantStore store, Language language) {
Validate.notNull(entry, "PersistableCatalogEntry cannot be null");
Validate.notNull(entry.getCatalog(), "CatalogEntry.catalog cannot be null");
Validate.notNull(store, "MerchantStore cannot be null");
Catalog catalog = catalogService.getByCode(entry.getCatalog(), store).orElseThrow(() -> new ResourceNotFoundException("catalog [" + entry.getCatalog() + "] not found"));
CatalogCategoryEntry catalogEntryModel = persistableCatalogEntryMapper.convert(entry, store, language);
catalogEntryService.add(catalogEntryModel, catalog);
return readableCatalogEntryMapper.convert(catalogEntryModel, store, language);
}
use of com.salesmanager.shop.model.catalog.catalog.ReadableCatalogCategoryEntry in project shopizer by shopizer-ecommerce.
the class ReadableCatalogCategoryEntryMapper method merge.
@Override
public ReadableCatalogCategoryEntry merge(CatalogCategoryEntry source, ReadableCatalogCategoryEntry destination, MerchantStore store, Language language) {
ReadableCatalogCategoryEntry convertedDestination = Optional.ofNullable(destination).orElse(new ReadableCatalogCategoryEntry());
try {
// ReadableProductPopulator readableProductPopulator = new ReadableProductPopulator();
// readableProductPopulator.setimageUtils(imageUtils);
// readableProductPopulator.setPricingService(pricingService);
// ReadableProduct readableProduct = readableProductPopulator.populate(source.getProduct(), store, language);
ReadableCategory readableCategory = readableCategoryMapper.convert(source.getCategory(), store, language);
convertedDestination.setCatalog(source.getCatalog().getCode());
convertedDestination.setId(source.getId());
convertedDestination.setVisible(source.isVisible());
convertedDestination.setCategory(readableCategory);
// destination.setProduct(readableProduct);
return convertedDestination;
} catch (Exception e) {
throw new ConversionRuntimeException("Error while creating ReadableCatalogEntry", e);
}
}
Aggregations