use of org.broadleafcommerce.core.search.domain.IndexFieldImpl in project BroadleafCommerce by BroadleafCommerce.
the class IndexFieldDaoImpl method readIndexFieldByAbbreviationAndEntityType.
@Override
public IndexField readIndexFieldByAbbreviationAndEntityType(String abbreviation, FieldEntity entityType) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<IndexField> criteria = builder.createQuery(IndexField.class);
Root<IndexFieldImpl> root = criteria.from(IndexFieldImpl.class);
criteria.select(root);
if (entityType == null) {
criteria.where(builder.equal(root.get("field").get("abbreviation").as(String.class), abbreviation));
} else {
criteria.where(builder.and(builder.equal(root.get("field").get("abbreviation").as(String.class), abbreviation), builder.equal(root.get("field").get("entityType").as(String.class), entityType.getType())));
}
TypedQuery<IndexField> query = em.createQuery(criteria);
query.setHint(QueryHints.HINT_CACHEABLE, true);
query.setHint(QueryHints.HINT_CACHE_REGION, "query.Search");
List<IndexField> resultList = query.getResultList();
return CollectionUtils.isNotEmpty(resultList) ? resultList.get(0) : null;
}
use of org.broadleafcommerce.core.search.domain.IndexFieldImpl in project BroadleafCommerce by BroadleafCommerce.
the class IndexFieldDaoImpl method readFieldsByEntityType.
@Override
public List<IndexField> readFieldsByEntityType(FieldEntity entityType) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<IndexField> criteria = builder.createQuery(IndexField.class);
Root<IndexFieldImpl> root = criteria.from(IndexFieldImpl.class);
criteria.select(root);
criteria.where(root.get("field").get("entityType").as(String.class).in(entityType.getAllLookupTypes()));
TypedQuery<IndexField> 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.IndexFieldImpl in project BroadleafCommerce by BroadleafCommerce.
the class IndexFieldDaoImpl method readSearchableFieldsByEntityType.
@Override
public List<IndexField> readSearchableFieldsByEntityType(FieldEntity entityType) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<IndexField> criteria = builder.createQuery(IndexField.class);
Root<IndexFieldImpl> root = criteria.from(IndexFieldImpl.class);
criteria.select(root);
criteria.where(builder.equal(root.get("searchable").as(Boolean.class), Boolean.TRUE), root.get("field").get("entityType").as(String.class).in(entityType.getAllLookupTypes()));
TypedQuery<IndexField> 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.IndexFieldImpl in project BroadleafCommerce by BroadleafCommerce.
the class IndexFieldDaoImpl method readIndexFieldByFieldId.
@Override
public IndexField readIndexFieldByFieldId(Long fieldId) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<IndexField> criteria = builder.createQuery(IndexField.class);
Root<IndexFieldImpl> search = criteria.from(IndexFieldImpl.class);
criteria.select(search);
criteria.where(builder.equal(search.join("field").get("id").as(Long.class), fieldId));
TypedQuery<IndexField> 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;
}
}
Aggregations