use of org.broadleafcommerce.core.search.domain.IndexField 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.IndexField 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.IndexField in project BroadleafCommerce by BroadleafCommerce.
the class IndexFieldCustomPersistenceHandler method update.
@Override
public Entity update(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException {
Entity entity = persistencePackage.getEntity();
try {
PersistencePerspective persistencePerspective = persistencePackage.getPersistencePerspective();
Map<String, FieldMetadata> adminProperties = helper.getSimpleMergedProperties(IndexField.class.getName(), persistencePerspective);
Object primaryKey = helper.getPrimaryKey(entity, adminProperties);
IndexField adminInstance = (IndexField) dynamicEntityDao.retrieve(Class.forName(entity.getType()[0]), primaryKey);
return getEntity(persistencePackage, dynamicEntityDao, helper, entity, adminProperties, adminInstance);
} catch (Exception e) {
throw new ServiceException("Unable to perform update for entity: " + IndexField.class.getName(), e);
}
}
use of org.broadleafcommerce.core.search.domain.IndexField in project BroadleafCommerce by BroadleafCommerce.
the class SolrHelperServiceImpl method getSearchableIndexFields.
@Override
public List<IndexField> getSearchableIndexFields() {
List<IndexField> fields = new ArrayList<>();
ExtensionResultStatusType status = searchExtensionManager.getProxy().getSearchableIndexFields(fields);
if (ExtensionResultStatusType.NOT_HANDLED.equals(status)) {
if (useSku) {
fields = indexFieldDao.readSearchableFieldsByEntityType(FieldEntity.SKU);
} else {
fields = indexFieldDao.readSearchableFieldsByEntityType(FieldEntity.PRODUCT);
}
}
return fields;
}
use of org.broadleafcommerce.core.search.domain.IndexField in project BroadleafCommerce by BroadleafCommerce.
the class IndexFieldCustomPersistenceHandler method add.
@Override
public Entity add(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException {
Entity entity = persistencePackage.getEntity();
try {
PersistencePerspective persistencePerspective = persistencePackage.getPersistencePerspective();
IndexField adminInstance = (IndexField) Class.forName(entity.getType()[0]).newInstance();
Map<String, FieldMetadata> adminProperties = helper.getSimpleMergedProperties(IndexField.class.getName(), persistencePerspective);
return getEntity(persistencePackage, dynamicEntityDao, helper, entity, adminProperties, adminInstance);
} catch (Exception e) {
throw new ServiceException("Unable to perform add for entity: " + IndexField.class.getName(), e);
}
}
Aggregations