use of org.broadleafcommerce.core.search.domain.IndexFieldTypeImpl in project BroadleafCommerce by BroadleafCommerce.
the class IndexFieldDaoImpl method getIndexFieldTypesByAbbreviationAndEntityType.
@Override
public List<IndexFieldType> getIndexFieldTypesByAbbreviationAndEntityType(String abbreviation, FieldEntity entityType) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<IndexFieldType> criteria = builder.createQuery(IndexFieldType.class);
Root<IndexFieldTypeImpl> root = criteria.from(IndexFieldTypeImpl.class);
criteria.select(root);
if (entityType == null) {
criteria.where(builder.equal(root.get("indexField").get("field").get("abbreviation").as(String.class), abbreviation));
} else {
criteria.where(builder.and(builder.equal(root.get("indexField").get("field").get("abbreviation").as(String.class), abbreviation), builder.equal(root.get("indexField").get("field").get("entityType").as(String.class), entityType.getType())));
}
TypedQuery<IndexFieldType> 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.IndexFieldTypeImpl in project BroadleafCommerce by BroadleafCommerce.
the class IndexFieldCustomPersistenceHandler method getEntity.
protected Entity getEntity(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper, Entity entity, Map<String, FieldMetadata> adminProperties, IndexField adminInstance) throws ServiceException {
adminInstance = (IndexField) helper.createPopulatedInstance(adminInstance, entity, adminProperties, false);
adminInstance = dynamicEntityDao.merge(adminInstance);
ExtensionResultStatusType result = ExtensionResultStatusType.NOT_HANDLED;
if (extensionManager != null) {
result = extensionManager.getProxy().addtoSearchableFields(persistencePackage, adminInstance);
}
if (result.equals(ExtensionResultStatusType.NOT_HANDLED)) {
// If there is no searchable field types then we need to add a default as String
if (CollectionUtils.isEmpty(adminInstance.getFieldTypes())) {
IndexFieldType indexFieldType = new IndexFieldTypeImpl();
indexFieldType.setFieldType(FieldType.TEXT);
indexFieldType.setIndexField(adminInstance);
adminInstance.getFieldTypes().add(indexFieldType);
adminInstance = dynamicEntityDao.merge(adminInstance);
}
}
Entity adminEntity = helper.getRecord(adminProperties, adminInstance, null, null);
return adminEntity;
}
use of org.broadleafcommerce.core.search.domain.IndexFieldTypeImpl in project BroadleafCommerce by BroadleafCommerce.
the class IndexFieldDaoImpl method getIndexFieldTypes.
@Override
public List<IndexFieldType> getIndexFieldTypes(FieldType facetFieldType) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<IndexFieldType> criteria = builder.createQuery(IndexFieldType.class);
Root<IndexFieldTypeImpl> root = criteria.from(IndexFieldTypeImpl.class);
criteria.select(root);
criteria.where(builder.equal(root.get("fieldType").as(String.class), facetFieldType.getType()));
TypedQuery<IndexFieldType> 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.IndexFieldTypeImpl in project BroadleafCommerce by BroadleafCommerce.
the class IndexFieldDaoImpl method getIndexFieldTypesByAbbreviationOrPropertyName.
@Override
public List<IndexFieldType> getIndexFieldTypesByAbbreviationOrPropertyName(String name) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<IndexFieldType> criteria = builder.createQuery(IndexFieldType.class);
Root<IndexFieldTypeImpl> root = criteria.from(IndexFieldTypeImpl.class);
criteria.select(root);
List<Predicate> restrictions = new ArrayList<>();
restrictions.add(builder.or(builder.equal(root.get("indexField").get("field").get("abbreviation").as(String.class), name), builder.equal(root.get("indexField").get("field").get("propertyName").as(String.class), name)));
restrictions.add(builder.or(builder.isNull(root.get("archiveStatus").get("archived")), builder.equal(root.get("archiveStatus").get("archived"), 'N')));
criteria.where(restrictions.toArray(new Predicate[restrictions.size()]));
TypedQuery<IndexFieldType> query = em.createQuery(criteria);
query.setHint(QueryHints.HINT_CACHEABLE, true);
query.setHint(QueryHints.HINT_CACHE_REGION, "query.Catalog");
return query.getResultList();
}
Aggregations