Search in sources :

Example 1 with ReadableContentPageFull

use of com.salesmanager.shop.model.content.page.ReadableContentPageFull in project shopizer by shopizer-ecommerce.

the class ContentFacadeImpl method convertContentToReadableContentPage.

private ReadableContentPage convertContentToReadableContentPage(MerchantStore store, Language language, Content content) {
    if (language != null) {
        ReadableContentPage page = new ReadableContentPage();
        Optional<ContentDescription> contentDescription = findAppropriateContentDescription(content.getDescriptions(), language);
        if (contentDescription.isPresent()) {
            com.salesmanager.shop.model.content.common.ContentDescription desc = this.contentDescription(contentDescription.get());
            page.setDescription(desc);
        }
        page.setCode(content.getCode());
        page.setId(content.getId());
        page.setVisible(content.isVisible());
        return page;
    } else {
        ReadableContentPageFull page = new ReadableContentPageFull();
        List<com.salesmanager.shop.model.content.common.ContentDescription> descriptions = content.getDescriptions().stream().map(d -> this.contentDescription(d)).collect(Collectors.toList());
        page.setDescriptions(descriptions);
        page.setCode(content.getCode());
        page.setId(content.getId());
        page.setVisible(content.isVisible());
        return page;
    }
}
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) ReadableContentPageFull(com.salesmanager.shop.model.content.page.ReadableContentPageFull) ReadableContentPage(com.salesmanager.shop.model.content.page.ReadableContentPage) ContentDescription(com.salesmanager.core.model.content.ContentDescription)

Aggregations

ServiceException (com.salesmanager.core.business.exception.ServiceException)1 ContentService (com.salesmanager.core.business.services.content.ContentService)1 LanguageService (com.salesmanager.core.business.services.reference.language.LanguageService)1 Content (com.salesmanager.core.model.content.Content)1 ContentDescription (com.salesmanager.core.model.content.ContentDescription)1 ContentType (com.salesmanager.core.model.content.ContentType)1 FileContentType (com.salesmanager.core.model.content.FileContentType)1 InputContentFile (com.salesmanager.core.model.content.InputContentFile)1 OutputContentFile (com.salesmanager.core.model.content.OutputContentFile)1 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)1 Language (com.salesmanager.core.model.reference.language.Language)1 ContentDescriptionEntity (com.salesmanager.shop.model.content.ContentDescriptionEntity)1 ContentFile (com.salesmanager.shop.model.content.ContentFile)1 ContentFolder (com.salesmanager.shop.model.content.ContentFolder)1 ContentImage (com.salesmanager.shop.model.content.ContentImage)1 ReadableContentEntity (com.salesmanager.shop.model.content.ReadableContentEntity)1 ReadableContentFull (com.salesmanager.shop.model.content.ReadableContentFull)1 PersistableContentBox (com.salesmanager.shop.model.content.box.PersistableContentBox)1 ReadableContentBox (com.salesmanager.shop.model.content.box.ReadableContentBox)1 ReadableContentBoxFull (com.salesmanager.shop.model.content.box.ReadableContentBoxFull)1