use of org.broadleafcommerce.common.structure.dto.StructuredContentDTO in project BroadleafCommerce by BroadleafCommerce.
the class StructuredContentServiceImpl method lookupStructuredContentItemsByType.
@Override
public List<StructuredContentDTO> lookupStructuredContentItemsByType(StructuredContentType contentType, Locale locale, Integer count, Map<String, Object> ruleDTOs, boolean secure) {
List<StructuredContentDTO> contentDTOList = null;
Locale languageOnlyLocale = findLanguageOnlyLocale(locale);
BroadleafRequestContext context = BroadleafRequestContext.getBroadleafRequestContext();
Long site = (context.getNonPersistentSite() != null) ? context.getNonPersistentSite().getId() : null;
String cacheKey = buildTypeKeyWithSecure(context.getSandBox(), site, languageOnlyLocale, contentType.getName(), secure);
if (context.isProductionSandBox()) {
contentDTOList = getStructuredContentListFromCache(cacheKey);
}
if (contentDTOList == null) {
List<StructuredContent> contentList = structuredContentDao.findActiveStructuredContentByType(contentType, locale, languageOnlyLocale);
contentDTOList = buildStructuredContentDTOList(contentList, secure);
if (context.isProductionSandBox()) {
addStructuredContentListToCache(cacheKey, contentDTOList);
}
}
return evaluateAndPriortizeContent(contentDTOList, count, ruleDTOs);
}
use of org.broadleafcommerce.common.structure.dto.StructuredContentDTO in project BroadleafCommerce by BroadleafCommerce.
the class StructuredContentServiceImpl method lookupStructuredContentItemsByName.
@Override
public List<StructuredContentDTO> lookupStructuredContentItemsByName(StructuredContentType contentType, String contentName, Locale locale, Integer count, Map<String, Object> ruleDTOs, boolean secure) {
List<StructuredContentDTO> contentDTOList = null;
Locale languageOnlyLocale = findLanguageOnlyLocale(locale);
BroadleafRequestContext context = BroadleafRequestContext.getBroadleafRequestContext();
Long site = (context.getNonPersistentSite() != null) ? context.getNonPersistentSite().getId() : null;
String cacheKey = buildNameKey(context.getSandBox(), site, languageOnlyLocale, contentType.getName(), contentName, secure);
if (context.isProductionSandBox()) {
contentDTOList = getStructuredContentListFromCache(cacheKey);
}
if (contentDTOList == null) {
List<StructuredContent> productionContentList = structuredContentDao.findActiveStructuredContentByNameAndType(contentType, contentName, locale, languageOnlyLocale);
contentDTOList = buildStructuredContentDTOList(productionContentList, secure);
if (context.isProductionSandBox()) {
addStructuredContentListToCache(cacheKey, contentDTOList);
}
}
return evaluateAndPriortizeContent(contentDTOList, count, ruleDTOs);
}
use of org.broadleafcommerce.common.structure.dto.StructuredContentDTO in project BroadleafCommerce by BroadleafCommerce.
the class StructuredContentServiceImpl method buildStructuredContentDTO.
/**
* Converts a StructuredContent into a StructuredContentDTO. If the item contains fields with
* broadleaf cms urls, the urls are converted to utilize the domain.
* <p/>
* The StructuredContentDTO is built via the {@link EntityConfiguration}. To override the actual type that is returned,
* include an override in an applicationContext like any other entity override.
*
* @param sc
* @param secure
* @return
*/
@Override
public StructuredContentDTO buildStructuredContentDTO(StructuredContent sc, boolean secure) {
StructuredContentDTO scDTO = entityConfiguration.createEntityInstance(StructuredContentDTO.class.getName(), StructuredContentDTO.class);
Set<StructuredContentItemCriteria> qualifyingItemCriteria = SetUtils.emptyIfNull(sc.getQualifyingItemCriteria());
scDTO.setContentName(sc.getContentName());
scDTO.setContentType(sc.getStructuredContentType().getName());
scDTO.setId(sc.getId());
scDTO.setPriority(sc.getPriority());
if (sc.getLocale() != null) {
scDTO.setLocaleCode(sc.getLocale().getLocaleCode());
}
scDTO.setRuleExpression(buildRuleExpression(sc));
buildFieldValues(sc, scDTO, secure);
if (qualifyingItemCriteria.size() > 0) {
scDTO.setItemCriteriaDTOList(buildItemCriteriaDTOList(sc));
}
return scDTO;
}
use of org.broadleafcommerce.common.structure.dto.StructuredContentDTO in project BroadleafCommerce by BroadleafCommerce.
the class StructuredContentServiceImpl method modifyStructuredContentDtoList.
protected List<StructuredContentDTO> modifyStructuredContentDtoList(List<StructuredContentDTO> structuredContentList) {
ExtensionResultHolder resultHolder = new ExtensionResultHolder();
extensionManager.getProxy().modifyStructuredContentDtoList(structuredContentList, resultHolder);
if (resultHolder.getResult() != null) {
structuredContentList = (List<StructuredContentDTO>) resultHolder.getResult();
}
return structuredContentList;
}
use of org.broadleafcommerce.common.structure.dto.StructuredContentDTO in project BroadleafCommerce by BroadleafCommerce.
the class StructuredContentServiceImpl method getSingleStructuredContentFromCache.
protected StructuredContentDTO getSingleStructuredContentFromCache(String key) {
Element scElement = getStructuredContentCache().get(key);
if (scElement != null) {
statisticsService.addCacheStat(CacheStatType.STRUCTURED_CONTENT_CACHE_HIT_RATE.toString(), true);
return (StructuredContentDTO) scElement.getValue();
}
statisticsService.addCacheStat(CacheStatType.STRUCTURED_CONTENT_CACHE_HIT_RATE.toString(), false);
return null;
}
Aggregations