Search in sources :

Example 6 with Catalog

use of com.salesmanager.core.model.catalog.catalog.Catalog in project shopizer by shopizer-ecommerce.

the class CatalogFacadeImpl method getCatalog.

@Override
public ReadableCatalog getCatalog(Long id, MerchantStore store, Language language) {
    Validate.notNull(id, "Catalog id cannot be null");
    Validate.notNull(store, "MerchantStore cannot be null");
    Catalog catalog = catalogService.getById(id, store).orElseThrow(() -> new ResourceNotFoundException("Catalog with id [" + id + "] not found"));
    return readableCatalogMapper.convert(catalog, store, language);
}
Also used : ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) ReadableCatalog(com.salesmanager.shop.model.catalog.catalog.ReadableCatalog) Catalog(com.salesmanager.core.model.catalog.catalog.Catalog) PersistableCatalog(com.salesmanager.shop.model.catalog.catalog.PersistableCatalog)

Example 7 with Catalog

use of com.salesmanager.core.model.catalog.catalog.Catalog 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);
}
Also used : PersistableCatalogCategoryEntry(com.salesmanager.shop.model.catalog.catalog.PersistableCatalogCategoryEntry) ReadableCatalogCategoryEntry(com.salesmanager.shop.model.catalog.catalog.ReadableCatalogCategoryEntry) CatalogCategoryEntry(com.salesmanager.core.model.catalog.catalog.CatalogCategoryEntry) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) ReadableCatalog(com.salesmanager.shop.model.catalog.catalog.ReadableCatalog) Catalog(com.salesmanager.core.model.catalog.catalog.Catalog) PersistableCatalog(com.salesmanager.shop.model.catalog.catalog.PersistableCatalog)

Example 8 with Catalog

use of com.salesmanager.core.model.catalog.catalog.Catalog in project shopizer by shopizer-ecommerce.

the class CatalogFacadeImpl method getCatalog.

@Override
public ReadableCatalog getCatalog(String code, MerchantStore store, Language language) {
    Validate.notNull(code, "Catalog code cannot be null");
    Validate.notNull(store, "MerchantStore cannot be null");
    Validate.notNull(language, "Language cannot be null");
    Catalog catalog = catalogService.getByCode(code, store).orElseThrow(() -> new ResourceNotFoundException("Catalog with code [" + code + "] not found"));
    return readableCatalogMapper.convert(catalog, store, language);
}
Also used : ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) ReadableCatalog(com.salesmanager.shop.model.catalog.catalog.ReadableCatalog) Catalog(com.salesmanager.core.model.catalog.catalog.Catalog) PersistableCatalog(com.salesmanager.shop.model.catalog.catalog.PersistableCatalog)

Aggregations

Catalog (com.salesmanager.core.model.catalog.catalog.Catalog)8 PersistableCatalog (com.salesmanager.shop.model.catalog.catalog.PersistableCatalog)7 ReadableCatalog (com.salesmanager.shop.model.catalog.catalog.ReadableCatalog)7 ResourceNotFoundException (com.salesmanager.shop.store.api.exception.ResourceNotFoundException)6 CatalogCategoryEntry (com.salesmanager.core.model.catalog.catalog.CatalogCategoryEntry)3 PersistableCatalogCategoryEntry (com.salesmanager.shop.model.catalog.catalog.PersistableCatalogCategoryEntry)3 ServiceException (com.salesmanager.core.business.exception.ServiceException)2 ReadableCatalogCategoryEntry (com.salesmanager.shop.model.catalog.catalog.ReadableCatalogCategoryEntry)2 OperationNotAllowedException (com.salesmanager.shop.store.api.exception.OperationNotAllowedException)2 ServiceRuntimeException (com.salesmanager.shop.store.api.exception.ServiceRuntimeException)2 CatalogEntryService (com.salesmanager.core.business.services.catalog.catalog.CatalogEntryService)1 CatalogService (com.salesmanager.core.business.services.catalog.catalog.CatalogService)1 Category (com.salesmanager.core.model.catalog.category.Category)1 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)1 Language (com.salesmanager.core.model.reference.language.Language)1 Mapper (com.salesmanager.shop.mapper.Mapper)1 PersistableCatalogMapper (com.salesmanager.shop.mapper.catalog.PersistableCatalogMapper)1 ReadableCatalogCategoryEntryMapper (com.salesmanager.shop.mapper.catalog.ReadableCatalogCategoryEntryMapper)1 ReadableCatalogMapper (com.salesmanager.shop.mapper.catalog.ReadableCatalogMapper)1 ReadableEntityList (com.salesmanager.shop.model.entity.ReadableEntityList)1