Search in sources :

Example 1 with StructuredContentDTO

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);
}
Also used : Locale(org.broadleafcommerce.common.locale.domain.Locale) StructuredContentDTO(org.broadleafcommerce.common.structure.dto.StructuredContentDTO) BroadleafRequestContext(org.broadleafcommerce.common.web.BroadleafRequestContext) StructuredContent(org.broadleafcommerce.cms.structure.domain.StructuredContent)

Example 2 with StructuredContentDTO

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);
}
Also used : Locale(org.broadleafcommerce.common.locale.domain.Locale) StructuredContentDTO(org.broadleafcommerce.common.structure.dto.StructuredContentDTO) BroadleafRequestContext(org.broadleafcommerce.common.web.BroadleafRequestContext) StructuredContent(org.broadleafcommerce.cms.structure.domain.StructuredContent)

Example 3 with StructuredContentDTO

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;
}
Also used : StructuredContentItemCriteria(org.broadleafcommerce.cms.structure.domain.StructuredContentItemCriteria) StructuredContentDTO(org.broadleafcommerce.common.structure.dto.StructuredContentDTO)

Example 4 with StructuredContentDTO

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;
}
Also used : StructuredContentDTO(org.broadleafcommerce.common.structure.dto.StructuredContentDTO) ExtensionResultHolder(org.broadleafcommerce.common.extension.ExtensionResultHolder)

Example 5 with StructuredContentDTO

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;
}
Also used : StructuredContentDTO(org.broadleafcommerce.common.structure.dto.StructuredContentDTO) Element(net.sf.ehcache.Element)

Aggregations

StructuredContentDTO (org.broadleafcommerce.common.structure.dto.StructuredContentDTO)10 StructuredContent (org.broadleafcommerce.cms.structure.domain.StructuredContent)5 BroadleafRequestContext (org.broadleafcommerce.common.web.BroadleafRequestContext)5 ArrayList (java.util.ArrayList)4 Locale (org.broadleafcommerce.common.locale.domain.Locale)4 SandBox (org.broadleafcommerce.common.sandbox.domain.SandBox)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Element (net.sf.ehcache.Element)1 CompareToBuilder (org.apache.commons.lang3.builder.CompareToBuilder)1 StructuredContentItemCriteria (org.broadleafcommerce.cms.structure.domain.StructuredContentItemCriteria)1 StructuredContentType (org.broadleafcommerce.cms.structure.domain.StructuredContentType)1 ExtensionResultHolder (org.broadleafcommerce.common.extension.ExtensionResultHolder)1 DeepLink (org.broadleafcommerce.common.web.deeplink.DeepLink)1 BroadleafAssignation (org.broadleafcommerce.presentation.model.BroadleafAssignation)1 BroadleafTemplateContext (org.broadleafcommerce.presentation.model.BroadleafTemplateContext)1