use of com.salesmanager.core.model.content.ContentDescription in project shopizer by shopizer-ecommerce.
the class ContentFacadeImpl method contentDescriptionToReadableContent.
private ReadableContentPage contentDescriptionToReadableContent(MerchantStore store, Content content, ContentDescription contentDescription) {
ReadableContentPage page = new ReadableContentPage();
ContentDescription desc = new ContentDescription();
desc.setName(contentDescription.getName());
desc.setDescription(contentDescription.getDescription());
page.setId(content.getId());
desc.setSeUrl(contentDescription.getSeUrl());
page.setLinkToMenu(content.isLinkToMenu());
desc.setTitle(contentDescription.getTitle());
desc.setMetatagDescription(contentDescription.getMetatagDescription());
page.setContentType(ContentType.PAGE.name());
page.setCode(content.getCode());
page.setPath(fileUtils.buildStaticFilePath(store.getCode(), contentDescription.getSeUrl()));
return page;
}
use of com.salesmanager.core.model.content.ContentDescription in project shopizer by shopizer-ecommerce.
the class ContentFacadeImpl method getContentBox.
@Override
public ReadableContentBox getContentBox(String code, MerchantStore store, Language language) {
Validate.notNull(code, "Content code cannot be null");
Validate.notNull(store, "MerchantStore cannot be null");
try {
Content content = null;
ReadableContentBox box = new ReadableContentBox();
if (language != null) {
content = Optional.ofNullable(contentService.getByCode(code, store, language)).orElseThrow(() -> new ResourceNotFoundException("Resource not found [" + code + "] for store [" + store.getCode() + "]"));
Optional<ContentDescription> contentDescription = findAppropriateContentDescription(content.getDescriptions(), language);
if (contentDescription.isPresent()) {
com.salesmanager.shop.model.content.common.ContentDescription desc = this.contentDescription(// return cdata description
contentDescription.get());
desc.setDescription(this.fixContentDescription(desc.getDescription()));
box.setDescription(desc);
}
return box;
} else {
content = Optional.ofNullable(contentService.getByCode(code, store)).orElseThrow(() -> new ResourceNotFoundException("Resource not found [" + code + "] for store [" + store.getCode() + "]"));
// all languages
ReadableContentBoxFull full = new ReadableContentBoxFull();
List<com.salesmanager.shop.model.content.common.ContentDescription> descriptions = content.getDescriptions().stream().map(d -> this.contentDescription(d)).collect(Collectors.toList());
/**
* Optional<ContentDescription> contentDescription = findAppropriateContentDescription(
* content.getDescriptions(), store.getDefaultLanguage());
*
* if(contentDescription.isPresent()) {
* com.salesmanager.shop.model.content.common.ContentDescription desc = this
* .contentDescription(contentDescription.get());
* full.setDescription(desc);
* }
*/
full.setDescriptions(descriptions);
full.setCode(content.getCode());
full.setId(content.getId());
full.setVisible(content.isVisible());
return full;
}
} catch (ServiceException e) {
throw new ServiceRuntimeException(e);
}
}
use of com.salesmanager.core.model.content.ContentDescription in project shopizer by shopizer-ecommerce.
the class ContentFacadeImpl method getContentPageByName.
@Override
public ReadableContentPage getContentPageByName(String name, MerchantStore store, Language language) {
Validate.notNull(name, "Content name cannot be null");
Validate.notNull(store, "MerchantStore cannot be null");
Validate.notNull(language, "Language cannot be null");
try {
ContentDescription contentDescription = Optional.ofNullable(contentService.getBySeUrl(store, name)).orElseThrow(() -> new ResourceNotFoundException("No page found : " + name));
return this.contentDescriptionToReadableContent(store, contentDescription.getContent(), contentDescription);
} catch (Exception e) {
throw new ServiceRuntimeException("Error while getting page " + e.getMessage(), e);
}
}
use of com.salesmanager.core.model.content.ContentDescription in project shopizer by shopizer-ecommerce.
the class ContentFacadeImpl method createContentDescriptionEntitys.
/*
* private Content convertContentPageToContent(MerchantStore store, Language
* language, Content content, PersistableContentEntity contentPage) throws
* ServiceException {
*
* ContentType contentType =
* ContentType.valueOf(contentPage.getContentType()); if (contentType ==
* null) { throw new
* ServiceRuntimeException("Invalid specified contentType [" +
* contentPage.getContentType() + "]"); }
*
* List<ContentDescription> descriptions = createContentDescription(store,
* content, contentPage); descriptions.stream().forEach(c ->
* c.setContent(content));
*
* content.setDescriptions(descriptions);
*
* // ContentDescription contentDescription = //
* createContentDescription(store, contentPage, language); //
* setContentDescriptionToContentModel(content,contentDescription,language);
*
* // contentDescription.setContent(content);
*
* if (contentPage.getId() != null && contentPage.getId().longValue() > 0) {
* content.setId(contentPage.getId()); }
* content.setVisible(contentPage.isVisible());
* content.setLinkToMenu(contentPage.isDisplayedInMenu());
* content.setContentType(ContentType.valueOf(contentPage.getContentType()))
* ; content.setMerchantStore(store);
*
* return content; }
*/
@Deprecated
private List<ContentDescriptionEntity> createContentDescriptionEntitys(MerchantStore store, Content contentModel, Language language) throws ServiceException {
List<ContentDescriptionEntity> descriptions = new ArrayList<ContentDescriptionEntity>();
if (!CollectionUtils.isEmpty(contentModel.getDescriptions())) {
for (ContentDescription description : contentModel.getDescriptions()) {
if (language != null && !language.getId().equals(description.getLanguage().getId())) {
continue;
}
ContentDescriptionEntity contentDescription = create(description);
descriptions.add(contentDescription);
}
}
return descriptions;
}
use of com.salesmanager.core.model.content.ContentDescription in project shopizer by shopizer-ecommerce.
the class ContentFacadeImpl method convertContentPageToContent.
private Content convertContentPageToContent(MerchantStore store, Content model, PersistableContentPage content) throws Exception {
Content contentModel = new Content();
if (model != null) {
contentModel = model;
}
List<ContentDescription> descriptions = buildDescriptions(contentModel, content.getDescriptions());
contentModel.setCode(content.getCode());
contentModel.setContentType(ContentType.PAGE);
contentModel.setMerchantStore(store);
contentModel.setLinkToMenu(content.isLinkToMenu());
contentModel.setVisible(content.isVisible());
contentModel.setDescriptions(descriptions);
contentModel.setId(content.getId());
return contentModel;
}
Aggregations