Search in sources :

Example 6 with ReadableEntityList

use of com.salesmanager.shop.model.entity.ReadableEntityList 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);
}
Also used : ProductService(com.salesmanager.core.business.services.catalog.product.ProductService) ReadableEntityUtil.createReadableList(com.salesmanager.shop.util.ReadableEntityUtil.createReadableList) Autowired(org.springframework.beans.factory.annotation.Autowired) ProductInventoryFacade(com.salesmanager.shop.store.controller.product.facade.ProductInventoryFacade) ServiceException(com.salesmanager.core.business.exception.ServiceException) Language(com.salesmanager.core.model.reference.language.Language) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) Service(org.springframework.stereotype.Service) MerchantStoreService(com.salesmanager.core.business.services.merchant.MerchantStoreService) Product(com.salesmanager.core.model.catalog.product.Product) PersistableInventory(com.salesmanager.shop.model.catalog.product.inventory.PersistableInventory) ReadableInventoryMapper(com.salesmanager.shop.mapper.inventory.ReadableInventoryMapper) ProductAvailabilityService(com.salesmanager.core.business.services.catalog.product.availability.ProductAvailabilityService) Page(org.springframework.data.domain.Page) Profile(org.springframework.context.annotation.Profile) Collectors(java.util.stream.Collectors) ReadableInventory(com.salesmanager.shop.model.catalog.product.inventory.ReadableInventory) Objects(java.util.Objects) List(java.util.List) Validate(org.apache.commons.lang3.Validate) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) Optional(java.util.Optional) ProductAvailability(com.salesmanager.core.model.catalog.product.availability.ProductAvailability) PersistableInventoryMapper(com.salesmanager.shop.mapper.inventory.PersistableInventoryMapper) ReadableEntityList(com.salesmanager.shop.model.entity.ReadableEntityList) ProductAvailability(com.salesmanager.core.model.catalog.product.availability.ProductAvailability) ReadableInventory(com.salesmanager.shop.model.catalog.product.inventory.ReadableInventory) Product(com.salesmanager.core.model.catalog.product.Product)

Example 7 with ReadableEntityList

use of com.salesmanager.shop.model.entity.ReadableEntityList in project shopizer by shopizer-ecommerce.

the class ContentFacadeImpl method getContentBoxes.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public ReadableEntityList<ReadableContentBox> getContentBoxes(ContentType type, MerchantStore store, Language language, int page, int count) {
    Validate.notNull(store, "MerchantStore cannot be null");
    ReadableEntityList items = new ReadableEntityList();
    Page<Content> contentBoxes;
    try {
        contentBoxes = contentService.listByType(type, store, page, count);
        items.setTotalPages(contentBoxes.getTotalPages());
        items.setNumber(contentBoxes.getContent().size());
        items.setRecordsTotal(contentBoxes.getNumberOfElements());
        List<ReadableContentBox> boxes = contentBoxes.getContent().stream().map(content -> convertContentToReadableContentBox(store, language, content)).collect(Collectors.toList());
        items.setItems(boxes);
        return items;
    } catch (ServiceException e) {
        throw new ServiceRuntimeException("Exception while getting content ", e);
    }
}
Also used : ContentDescription(com.salesmanager.core.model.content.ContentDescription) ContentFacade(com.salesmanager.shop.store.controller.content.facade.ContentFacade) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) LanguageService(com.salesmanager.core.business.services.reference.language.LanguageService) ContentDescriptionEntity(com.salesmanager.shop.model.content.ContentDescriptionEntity) ArrayList(java.util.ArrayList) ServiceException(com.salesmanager.core.business.exception.ServiceException) PersistableContentBox(com.salesmanager.shop.model.content.box.PersistableContentBox) PersistableContentPage(com.salesmanager.shop.model.content.page.PersistableContentPage) Inject(javax.inject.Inject) Language(com.salesmanager.core.model.reference.language.Language) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ContentFile(com.salesmanager.shop.model.content.ContentFile) ReadableContentPageFull(com.salesmanager.shop.model.content.page.ReadableContentPageFull) ReadableContentPage(com.salesmanager.shop.model.content.page.ReadableContentPage) ByteArrayInputStream(java.io.ByteArrayInputStream) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) Content(com.salesmanager.core.model.content.Content) ReadableContentFull(com.salesmanager.shop.model.content.ReadableContentFull) Qualifier(org.springframework.beans.factory.annotation.Qualifier) ContentType(com.salesmanager.core.model.content.ContentType) FileContentType(com.salesmanager.core.model.content.FileContentType) ReadableContentBox(com.salesmanager.shop.model.content.box.ReadableContentBox) Validate(org.jsoup.helper.Validate) OutputContentFile(com.salesmanager.core.model.content.OutputContentFile) Logger(org.slf4j.Logger) ConstraintException(com.salesmanager.shop.store.api.exception.ConstraintException) IOException(java.io.IOException) ImageFilePath(com.salesmanager.shop.utils.ImageFilePath) Page(org.springframework.data.domain.Page) InputContentFile(com.salesmanager.core.model.content.InputContentFile) Collectors(java.util.stream.Collectors) ContentService(com.salesmanager.core.business.services.content.ContentService) ContentFolder(com.salesmanager.shop.model.content.ContentFolder) ReadableContentBoxFull(com.salesmanager.shop.model.content.box.ReadableContentBoxFull) URLEncoder(java.net.URLEncoder) List(java.util.List) Component(org.springframework.stereotype.Component) ContentImage(com.salesmanager.shop.model.content.ContentImage) CollectionUtils(org.springframework.util.CollectionUtils) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) Optional(java.util.Optional) ReadableContentEntity(com.salesmanager.shop.model.content.ReadableContentEntity) FilePathUtils(com.salesmanager.shop.utils.FilePathUtils) InputStream(java.io.InputStream) ReadableEntityList(com.salesmanager.shop.model.entity.ReadableEntityList) ReadableEntityList(com.salesmanager.shop.model.entity.ReadableEntityList) ServiceException(com.salesmanager.core.business.exception.ServiceException) Content(com.salesmanager.core.model.content.Content) ReadableContentBox(com.salesmanager.shop.model.content.box.ReadableContentBox) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException)

Aggregations

ServiceException (com.salesmanager.core.business.exception.ServiceException)7 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)7 Language (com.salesmanager.core.model.reference.language.Language)7 ReadableEntityList (com.salesmanager.shop.model.entity.ReadableEntityList)7 ResourceNotFoundException (com.salesmanager.shop.store.api.exception.ResourceNotFoundException)7 ServiceRuntimeException (com.salesmanager.shop.store.api.exception.ServiceRuntimeException)7 List (java.util.List)7 Collectors (java.util.stream.Collectors)7 Optional (java.util.Optional)5 Page (org.springframework.data.domain.Page)5 Autowired (org.springframework.beans.factory.annotation.Autowired)4 ConstraintException (com.salesmanager.shop.store.api.exception.ConstraintException)3 OperationNotAllowedException (com.salesmanager.shop.store.api.exception.OperationNotAllowedException)3 Validate (org.apache.commons.lang3.Validate)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 Service (org.springframework.stereotype.Service)3 ContentService (com.salesmanager.core.business.services.content.ContentService)2 TaxClassService (com.salesmanager.core.business.services.tax.TaxClassService)2 TaxRateService (com.salesmanager.core.business.services.tax.TaxRateService)2