use of com.salesmanager.core.model.content.Content 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;
}
use of com.salesmanager.core.model.content.Content in project shopizer by shopizer-ecommerce.
the class ContentRepositoryImpl method listNameByType.
@Override
public List<ContentDescription> listNameByType(List<ContentType> contentType, MerchantStore store, Language language) {
StringBuilder qs = new StringBuilder();
qs.append("select c from Content c ");
qs.append("left join fetch c.descriptions cd join fetch c.merchantStore cm ");
qs.append("where c.contentType in (:ct) ");
qs.append("and cm.id =:cm ");
qs.append("and cd.language.id =:cl ");
qs.append("and c.visible=true ");
qs.append("order by c.sortOrder");
String hql = qs.toString();
Query q = this.em.createQuery(hql);
q.setParameter("ct", contentType);
q.setParameter("cm", store.getId());
q.setParameter("cl", language.getId());
@SuppressWarnings("unchecked") List<Content> contents = q.getResultList();
List<ContentDescription> descriptions = new ArrayList<ContentDescription>();
for (Content c : contents) {
String name = c.getDescription().getName();
String url = c.getDescription().getSeUrl();
ContentDescription contentDescription = new ContentDescription();
contentDescription.setName(name);
contentDescription.setSeUrl(url);
contentDescription.setContent(c);
descriptions.add(contentDescription);
}
return descriptions;
}
use of com.salesmanager.core.model.content.Content in project shopizer by shopizer-ecommerce.
the class ContentServiceImpl method delete.
@Override
public void delete(Content content) throws ServiceException {
Content c = this.getById(content.getId());
super.delete(c);
}
use of com.salesmanager.core.model.content.Content in project shopizer by shopizer-ecommerce.
the class ContentFacadeImpl method saveContentBox.
@Override
public Long saveContentBox(PersistableContentBox box, MerchantStore merchantStore, Language language) {
Validate.notNull(box);
Validate.notNull(box.getCode(), "Content box must not be null");
Validate.notNull(merchantStore);
try {
Content content = null;
content = contentService.getByCode(box.getCode(), merchantStore);
if (content != null) {
throw new ConstraintException("Content box with code [" + box.getCode() + "] already exist for store [" + merchantStore.getCode() + "]");
}
content = convertContentBoxToContent(merchantStore, content, box);
contentService.saveOrUpdate(content);
return content.getId();
} catch (Exception e) {
throw new ServiceRuntimeException(e);
}
}
use of com.salesmanager.core.model.content.Content in project shopizer by shopizer-ecommerce.
the class ContentFacadeImpl method convertContentToReadableContentBox.
private ReadableContentBox convertContentToReadableContentBox(MerchantStore store, Language language, Content content) {
if (language != null) {
ReadableContentBox box = new ReadableContentBox();
this.setDescription(content, box, language);
box.setCode(content.getCode());
box.setId(content.getId());
box.setVisible(content.isVisible());
return box;
} else {
ReadableContentBoxFull box = new ReadableContentBoxFull();
List<com.salesmanager.shop.model.content.common.ContentDescription> descriptions = content.getDescriptions().stream().map(d -> this.contentDescription(d)).collect(Collectors.toList());
this.setDescription(content, box, store.getDefaultLanguage());
box.setDescriptions(descriptions);
box.setCode(content.getCode());
box.setId(content.getId());
box.setVisible(content.isVisible());
return box;
}
// TODO revise this
// String staticImageFilePath = imageUtils.buildStaticImageUtils(store,
// content.getCode() + ".jpg");
// box.setImage(staticImageFilePath);
}
Aggregations