Search in sources :

Example 1 with CategoryExcludedSearchFacet

use of org.broadleafcommerce.core.search.domain.CategoryExcludedSearchFacet in project BroadleafCommerce by BroadleafCommerce.

the class CategoryImpl method createOrRetrieveCopyInstance.

@Override
public <G extends Category> CreateResponse<G> createOrRetrieveCopyInstance(MultiTenantCopyContext context) throws CloneNotSupportedException {
    CreateResponse<G> createResponse = context.createOrRetrieveCopyInstance(this);
    if (createResponse.isAlreadyPopulated()) {
        return createResponse;
    }
    Category cloned = createResponse.getClone();
    cloned.setActiveEndDate(activeEndDate);
    cloned.setActiveStartDate(activeStartDate);
    cloned.setFulfillmentType(getFulfillmentType());
    cloned.setTaxCode(taxCode);
    cloned.setUrl(url);
    cloned.setUrlKey(urlKey);
    cloned.setOverrideGeneratedUrl(getOverrideGeneratedUrl());
    cloned.setName(name);
    cloned.setLongDescription(longDescription);
    cloned.setInventoryType(getInventoryType());
    cloned.setExternalId(externalId);
    cloned.setDisplayTemplate(displayTemplate);
    cloned.setDescription(description);
    for (CategoryXref entry : allParentCategoryXrefs) {
        CategoryXref clonedEntry = entry.createOrRetrieveCopyInstance(context).getClone();
        cloned.getAllParentCategoryXrefs().add(clonedEntry);
    }
    if (getDefaultParentCategory() != null) {
        cloned.setDefaultParentCategory(getDefaultParentCategory().createOrRetrieveCopyInstance(context).getClone());
    }
    for (CategoryXref entry : allChildCategoryXrefs) {
        CategoryXref clonedEntry = entry.createOrRetrieveCopyInstance(context).getClone();
        cloned.getAllChildCategoryXrefs().add(clonedEntry);
    }
    for (Map.Entry<String, CategoryAttribute> entry : getCategoryAttributesMap().entrySet()) {
        CategoryAttribute clonedEntry = entry.getValue().createOrRetrieveCopyInstance(context).getClone();
        cloned.getCategoryAttributesMap().put(entry.getKey(), clonedEntry);
    }
    for (CategorySearchFacet entry : searchFacets) {
        CategorySearchFacet clonedEntry = entry.createOrRetrieveCopyInstance(context).getClone();
        cloned.getSearchFacets().add(clonedEntry);
    }
    for (CategoryExcludedSearchFacet entry : excludedSearchFacets) {
        CategoryExcludedSearchFacet clonedEntry = entry.createOrRetrieveCopyInstance(context).getClone();
        cloned.getExcludedSearchFacets().add(clonedEntry);
    }
    for (Map.Entry<String, CategoryMediaXref> entry : categoryMedia.entrySet()) {
        CategoryMediaXrefImpl clonedEntry = ((CategoryMediaXrefImpl) entry.getValue()).createOrRetrieveCopyInstance(context).getClone();
        cloned.getCategoryMediaXref().put(entry.getKey(), clonedEntry);
    }
    return createResponse;
}
Also used : CategoryExcludedSearchFacet(org.broadleafcommerce.core.search.domain.CategoryExcludedSearchFacet) CategorySearchFacet(org.broadleafcommerce.core.search.domain.CategorySearchFacet) MultiValueMap(org.apache.commons.collections.map.MultiValueMap) Map(java.util.Map) HashedMap(org.apache.commons.collections.map.HashedMap) HashMap(java.util.HashMap) AdminPresentationMap(org.broadleafcommerce.common.presentation.AdminPresentationMap)

Example 2 with CategoryExcludedSearchFacet

use of org.broadleafcommerce.core.search.domain.CategoryExcludedSearchFacet in project BroadleafCommerce by BroadleafCommerce.

the class CategoryImpl method getParentFacets.

protected List<CategorySearchFacet> getParentFacets(final Collection<SearchFacet> facets) {
    List<CategorySearchFacet> parentFacets = null;
    if (getParentCategory() != null) {
        parentFacets = getParentCategory().getCumulativeSearchFacets();
        CollectionUtils.filter(parentFacets, new Predicate() {

            @Override
            public boolean evaluate(Object arg) {
                CategorySearchFacet csf = (CategorySearchFacet) arg;
                return !isExcludedSearchFacet(csf) && !facets.contains(csf.getSearchFacet());
            }

            protected boolean isExcludedSearchFacet(CategorySearchFacet csf) {
                boolean isExcludedSearchFacet = false;
                for (CategoryExcludedSearchFacet excludedSearchFacet : getExcludedSearchFacets()) {
                    if (excludedSearchFacet.getSearchFacet().equals(csf.getSearchFacet())) {
                        isExcludedSearchFacet = true;
                        break;
                    }
                }
                return isExcludedSearchFacet;
            }
        });
    }
    return parentFacets;
}
Also used : CategorySearchFacet(org.broadleafcommerce.core.search.domain.CategorySearchFacet) CategoryExcludedSearchFacet(org.broadleafcommerce.core.search.domain.CategoryExcludedSearchFacet) Predicate(org.apache.commons.collections.Predicate)

Aggregations

CategoryExcludedSearchFacet (org.broadleafcommerce.core.search.domain.CategoryExcludedSearchFacet)2 CategorySearchFacet (org.broadleafcommerce.core.search.domain.CategorySearchFacet)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Predicate (org.apache.commons.collections.Predicate)1 HashedMap (org.apache.commons.collections.map.HashedMap)1 MultiValueMap (org.apache.commons.collections.map.MultiValueMap)1 AdminPresentationMap (org.broadleafcommerce.common.presentation.AdminPresentationMap)1