use of org.broadleafcommerce.core.search.domain.SearchFacet in project BroadleafCommerce by BroadleafCommerce.
the class DatabaseSearchServiceImpl method buildSearchFacetDtos.
/**
* Create the wrapper DTO around the SearchFacet
* @param categoryFacets
* @return the wrapper DTO
*/
protected List<SearchFacetDTO> buildSearchFacetDtos(List<SearchFacet> categoryFacets) {
List<SearchFacetDTO> facets = new ArrayList<SearchFacetDTO>();
for (SearchFacet facet : categoryFacets) {
SearchFacetDTO dto = new SearchFacetDTO();
dto.setFacet(facet);
dto.setShowQuantity(false);
dto.setFacetValues(getFacetValues(facet));
dto.setActive(false);
facets.add(dto);
}
return facets;
}
use of org.broadleafcommerce.core.search.domain.SearchFacet in project BroadleafCommerce by BroadleafCommerce.
the class DatabaseSearchServiceImpl method getCategoryFacets.
@Override
@SuppressWarnings("unchecked")
public List<SearchFacetDTO> getCategoryFacets(Category category) {
List<SearchFacetDTO> facets = null;
String cacheKey = CACHE_KEY_PREFIX + "category:" + category.getId();
Element element = cache.get(cacheKey);
if (element != null) {
facets = (List<SearchFacetDTO>) element.getValue();
}
if (facets == null) {
List<CategorySearchFacet> categorySearchFacets = category.getCumulativeSearchFacets();
List<SearchFacet> searchFacets = new ArrayList<SearchFacet>();
for (CategorySearchFacet categorySearchFacet : categorySearchFacets) {
searchFacets.add(categorySearchFacet.getSearchFacet());
}
facets = buildSearchFacetDtos(searchFacets);
element = new Element(cacheKey, facets);
cache.put(element);
}
return facets;
}
use of org.broadleafcommerce.core.search.domain.SearchFacet in project BroadleafCommerce by BroadleafCommerce.
the class SearchFacetDaoImpl method readAllSearchFacets.
@Override
public List<SearchFacet> readAllSearchFacets(FieldEntity entityType) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<SearchFacet> criteria = builder.createQuery(SearchFacet.class);
Root<SearchFacetImpl> facet = criteria.from(SearchFacetImpl.class);
criteria.select(facet);
criteria.where(builder.equal(facet.get("showOnSearch").as(Boolean.class), true), facet.join("fieldType").join("indexField").join("field").get("entityType").as(String.class).in(entityType.getAllLookupTypes()));
TypedQuery<SearchFacet> query = em.createQuery(criteria);
query.setHint(QueryHints.HINT_CACHEABLE, true);
query.setHint(QueryHints.HINT_CACHE_REGION, "query.Search");
return query.getResultList();
}
use of org.broadleafcommerce.core.search.domain.SearchFacet in project BroadleafCommerce by BroadleafCommerce.
the class SearchFacetDaoImpl method readSearchFacetForField.
@Override
public SearchFacet readSearchFacetForField(Field field) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<SearchFacet> criteria = builder.createQuery(SearchFacet.class);
Root<SearchFacetImpl> facet = criteria.from(SearchFacetImpl.class);
criteria.select(facet);
criteria.where(builder.equal(facet.join("fieldType").join("indexField").join("field").get("id").as(Long.class), field.getId()));
TypedQuery<SearchFacet> query = em.createQuery(criteria);
query.setHint(QueryHints.HINT_CACHEABLE, true);
query.setHint(QueryHints.HINT_CACHE_REGION, "query.Search");
try {
return query.getSingleResult();
} catch (NoResultException e) {
return null;
}
}
use of org.broadleafcommerce.core.search.domain.SearchFacet in project BroadleafCommerce by BroadleafCommerce.
the class SolrSearchServiceImpl method getCategoryFacets.
@Override
public List<SearchFacetDTO> getCategoryFacets(Category category) {
List<SearchFacet> searchFacets = new ArrayList<>();
ExtensionResultStatusType status = extensionManager.getProxy().getCategorySearchFacets(category, searchFacets);
if (Objects.equals(ExtensionResultStatusType.NOT_HANDLED, status)) {
List<CategorySearchFacet> categorySearchFacets = category.getCumulativeSearchFacets();
for (CategorySearchFacet categorySearchFacet : categorySearchFacets) {
searchFacets.add(categorySearchFacet.getSearchFacet());
}
}
return buildSearchFacetDTOs(searchFacets);
}
Aggregations