use of org.broadleafcommerce.core.search.domain.SearchFacet in project BroadleafCommerce by BroadleafCommerce.
the class CategoryImpl method getCumulativeSearchFacets.
@Override
public List<CategorySearchFacet> getCumulativeSearchFacets(Set<Category> categoryHierarchy) {
categoryHierarchy.add(this);
List<CategorySearchFacet> returnCategoryFacets = new ArrayList<CategorySearchFacet>();
returnCategoryFacets.addAll(getSearchFacets());
Collections.sort(returnCategoryFacets, facetPositionComparator);
final Collection<SearchFacet> facets = CollectionUtils.collect(returnCategoryFacets, new Transformer() {
@Override
public Object transform(Object input) {
return ((CategorySearchFacet) input).getSearchFacet();
}
});
// Add in parent facets unless they are excluded
Category parentCategory = getDefaultParentCategory();
List<CategorySearchFacet> parentFacets = null;
if (parentCategory != null && !categoryHierarchy.contains(parentCategory)) {
parentFacets = parentCategory.getCumulativeSearchFacets(categoryHierarchy);
CollectionUtils.filter(parentFacets, new Predicate() {
@Override
public boolean evaluate(Object arg) {
CategorySearchFacet csf = (CategorySearchFacet) arg;
return !getExcludedSearchFacets().contains(csf.getSearchFacet()) && !facets.contains(csf.getSearchFacet());
}
});
}
if (parentFacets != null) {
returnCategoryFacets.addAll(parentFacets);
}
return returnCategoryFacets;
}
use of org.broadleafcommerce.core.search.domain.SearchFacet in project BroadleafCommerce by BroadleafCommerce.
the class SolrSearchServiceImpl method getSearchFacets.
@Override
public List<SearchFacetDTO> getSearchFacets() {
List<SearchFacet> searchFacets = new ArrayList<>();
ExtensionResultStatusType status = extensionManager.getProxy().getSearchFacets(searchFacets);
if (Objects.equals(ExtensionResultStatusType.NOT_HANDLED, status)) {
if (useSku) {
return buildSearchFacetDTOs(searchFacetDao.readAllSearchFacets(FieldEntity.SKU));
}
return buildSearchFacetDTOs(searchFacetDao.readAllSearchFacets(FieldEntity.PRODUCT));
}
return buildSearchFacetDTOs(searchFacets);
}
use of org.broadleafcommerce.core.search.domain.SearchFacet in project BroadleafCommerce by BroadleafCommerce.
the class SolrHelperServiceImpl method buildSearchFacetDTOs.
@Override
public List<SearchFacetDTO> buildSearchFacetDTOs(List<SearchFacet> searchFacets) {
List<SearchFacetDTO> facets = new ArrayList<SearchFacetDTO>();
Map<String, String[]> requestParameters = BroadleafRequestContext.getRequestParameterMap();
for (SearchFacet facet : searchFacets) {
if (isFacetAvailable(facet, requestParameters)) {
SearchFacetDTO dto = new SearchFacetDTO();
dto.setFacet(facet);
dto.setShowQuantity(true);
facets.add(dto);
}
}
return facets;
}
use of org.broadleafcommerce.core.search.domain.SearchFacet in project BroadleafCommerce by BroadleafCommerce.
the class SearchFacetCustomPersistenceHandler method getAdminInstance.
protected SearchFacet getAdminInstance(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper, Entity entity) throws ClassNotFoundException {
PersistencePerspective persistencePerspective = persistencePackage.getPersistencePerspective();
Map<String, FieldMetadata> adminProperties = helper.getSimpleMergedProperties(SearchFacetRange.class.getName(), persistencePerspective);
Object primaryKey = helper.getPrimaryKey(entity, adminProperties);
String type = entity.getType()[0];
SearchFacet adminInstance = (SearchFacet) dynamicEntityDao.retrieve(Class.forName(type), primaryKey);
return adminInstance;
}
use of org.broadleafcommerce.core.search.domain.SearchFacet in project BroadleafCommerce by BroadleafCommerce.
the class SearchFacetCustomPersistenceHandler method remove.
@Override
public void remove(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException {
Entity entity = persistencePackage.getEntity();
try {
SearchFacet adminInstance = getAdminInstance(persistencePackage, dynamicEntityDao, helper, entity);
if (Status.class.isAssignableFrom(adminInstance.getClass())) {
((Status) adminInstance).setArchived('Y');
dynamicEntityDao.merge(adminInstance);
}
} catch (Exception e) {
throw new ServiceException("Unable to remove entity for " + entity.getType()[0], e);
}
}
Aggregations