Search in sources :

Example 1 with StructuredContentItemCriteria

use of org.broadleafcommerce.cms.structure.domain.StructuredContentItemCriteria 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 2 with StructuredContentItemCriteria

use of org.broadleafcommerce.cms.structure.domain.StructuredContentItemCriteria in project BroadleafCommerce by BroadleafCommerce.

the class StructuredContentServiceImpl method buildItemCriteriaDTOList.

protected List<ItemCriteriaDTO> buildItemCriteriaDTOList(StructuredContent sc) {
    List<ItemCriteriaDTO> itemCriteriaDTOList = new ArrayList<>();
    Set<StructuredContentItemCriteria> qualifyingItemCriteria = SetUtils.emptyIfNull(sc.getQualifyingItemCriteria());
    for (StructuredContentItemCriteria criteria : qualifyingItemCriteria) {
        ItemCriteriaDTO criteriaDTO = entityConfiguration.createEntityInstance(ItemCriteriaDTO.class.getName(), ItemCriteriaDTO.class);
        criteriaDTO.setMatchRule(criteria.getMatchRule());
        criteriaDTO.setQty(criteria.getQuantity());
        itemCriteriaDTOList.add(criteriaDTO);
    }
    return itemCriteriaDTOList;
}
Also used : StructuredContentItemCriteria(org.broadleafcommerce.cms.structure.domain.StructuredContentItemCriteria) ArrayList(java.util.ArrayList) ItemCriteriaDTO(org.broadleafcommerce.common.structure.dto.ItemCriteriaDTO)

Aggregations

StructuredContentItemCriteria (org.broadleafcommerce.cms.structure.domain.StructuredContentItemCriteria)2 ArrayList (java.util.ArrayList)1 ItemCriteriaDTO (org.broadleafcommerce.common.structure.dto.ItemCriteriaDTO)1 StructuredContentDTO (org.broadleafcommerce.common.structure.dto.StructuredContentDTO)1