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;
}
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;
}
Aggregations