use of org.broadleafcommerce.cms.file.domain.StaticAssetImpl in project BroadleafCommerce by BroadleafCommerce.
the class StaticAssetDaoImpl method readStaticAssetByFullUrl.
@Override
public StaticAsset readStaticAssetByFullUrl(String fullUrl) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<StaticAsset> criteria = builder.createQuery(StaticAsset.class);
Root<StaticAssetImpl> handler = criteria.from(StaticAssetImpl.class);
criteria.select(handler);
List<Predicate> restrictions = new ArrayList<Predicate>();
List<Order> sorts = new ArrayList<Order>();
restrictions.add(builder.equal(handler.get("fullUrl"), fullUrl));
try {
if (queryExtensionManager != null) {
queryExtensionManager.getProxy().setup(StaticAssetImpl.class, null);
queryExtensionManager.getProxy().refineRetrieve(StaticAssetImpl.class, null, builder, criteria, handler, restrictions);
queryExtensionManager.getProxy().refineOrder(StaticAssetImpl.class, null, builder, criteria, handler, sorts);
}
criteria.where(restrictions.toArray(new Predicate[restrictions.size()]));
if (!org.apache.commons.collections.CollectionUtils.isEmpty(sorts)) {
criteria.orderBy(sorts);
}
TypedQuery<StaticAsset> query = em.createQuery(criteria);
query.setHint(QueryHints.HINT_CACHEABLE, true);
List<StaticAsset> response = query.getResultList();
if (response.size() > 0) {
return response.get(0);
}
return null;
} finally {
if (queryExtensionManager != null) {
queryExtensionManager.getProxy().breakdown(StaticAssetImpl.class, null);
}
}
}
use of org.broadleafcommerce.cms.file.domain.StaticAssetImpl in project BroadleafCommerce by BroadleafCommerce.
the class StaticAssetDaoImpl method readStaticAssetById.
@Override
public StaticAsset readStaticAssetById(Long id) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<StaticAsset> criteria = builder.createQuery(StaticAsset.class);
Root<StaticAssetImpl> handler = criteria.from(StaticAssetImpl.class);
criteria.select(handler);
List<Predicate> restrictions = new ArrayList<Predicate>();
restrictions.add(builder.equal(handler.get("id"), id));
if (queryExtensionManager != null) {
queryExtensionManager.getProxy().setup(StaticAssetImpl.class, null);
queryExtensionManager.getProxy().refineRetrieve(StaticAssetImpl.class, null, builder, criteria, handler, restrictions);
}
criteria.where(restrictions.toArray(new Predicate[restrictions.size()]));
TypedQuery<StaticAsset> query = em.createQuery(criteria);
query.setHint(QueryHints.HINT_CACHEABLE, true);
List<StaticAsset> response = query.getResultList();
if (response.size() > 0) {
return response.get(0);
}
return null;
}
use of org.broadleafcommerce.cms.file.domain.StaticAssetImpl in project BroadleafCommerce by BroadleafCommerce.
the class StaticAssetDaoImpl method readAllStaticAssets.
public List<StaticAsset> readAllStaticAssets() {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<StaticAsset> criteria = builder.createQuery(StaticAsset.class);
Root<StaticAssetImpl> handler = criteria.from(StaticAssetImpl.class);
criteria.select(handler);
List<Predicate> restrictions = new ArrayList<Predicate>();
List<Order> sorts = new ArrayList<Order>();
try {
if (queryExtensionManager != null) {
queryExtensionManager.getProxy().setup(StaticAssetImpl.class, null);
queryExtensionManager.getProxy().refineRetrieve(StaticAssetImpl.class, null, builder, criteria, handler, restrictions);
queryExtensionManager.getProxy().refineOrder(StaticAssetImpl.class, null, builder, criteria, handler, sorts);
}
criteria.where(restrictions.toArray(new Predicate[restrictions.size()]));
return em.createQuery(criteria).getResultList();
} catch (NoResultException e) {
return new ArrayList<StaticAsset>();
}
}
Aggregations